diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..a011c936 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: castano diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..d1064a7b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: build + +on: [push, pull_request] + +jobs: + vs2017: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - uses: microsoft/setup-msbuild@v1.0.0 + - name: Build Debug/x64 + run: msbuild .\project\vc2017\nvtt.sln /property:Configuration=Debug /property:Platform=x64 + - name: Build Debug/Win32 + run: msbuild .\project\vc2017\nvtt.sln /property:Configuration=Debug /property:Platform=Win32 + - name: Build Release/x64 + run: msbuild .\project\vc2017\nvtt.sln /property:Configuration=Release /property:Platform=x64 + - name: Build Release/Win32 + run: msbuild .\project\vc2017\nvtt.sln /property:Configuration=Release /property:Platform=Win32 + + unix: + strategy: + matrix: + os: [ubuntu, macos] + name: ${{matrix.os}} + runs-on: ${{matrix.os}}-latest + steps: + - uses: actions/checkout@v2 + - name: make + run: | + ./configure --debug + make VERBOSE=1 + ./configure --release + make VERBOSE=1 diff --git a/.gitignore b/.gitignore index 9542f421..637a69c4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,12 @@ **/Debug-CUDA/ **/Release-CUDA/ *.vcxproj.user +*.csproj.user *.opensdf *.sdf *.suo +build +.vs +project/nvtt.sublime-workspace +project/vc12/packages/**/* + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..fe9ed10f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +# NOTE: We use TeamCity for official builds. + +language: csharp +os: + - osx +compiler: + - clang + - gcc +script: +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd build ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DNVTT_SHARED="TRUE" .. ; fi +- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make ; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e4bab96..8c14a88e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,30 +5,18 @@ ENABLE_TESTING() SET(NV_CMAKE_DIR "${NV_SOURCE_DIR}/cmake") SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${NV_CMAKE_DIR}") -# GCC check (needs -std:c++11 flag) -#if(CMAKE_COMPILER_IS_GNUCC) -# ADD_DEFINITIONS("-std=c++11") -#ENDIF(CMAKE_COMPILER_IS_GNUCC) -set (CMAKE_CXX_STANDARD 11) - -IF(WIN32) - # gnuwin32 paths: - SET(GNUWIN32_PATH "${NV_SOURCE_DIR}/extern/gnuwin32") - SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${GNUWIN32_PATH}/include") - SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${GNUWIN32_PATH}/lib") - - # Set GLUT path: - SET(GLUT_ROOT_DIR "${NV_SOURCE_DIR}/extern/glut") - - # Set FreeImage path: - SET(FREEIMAGE_ROOT_DIR "${NV_SOURCE_DIR}/extern/FreeImage") - -ENDIF(WIN32) +# Compiler check (needs -std:c++11 flag) +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) +if(COMPILER_SUPPORTS_CXX17) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +else() + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") +endif() INCLUDE(${NV_CMAKE_DIR}/OptimalOptions.cmake) -MESSAGE(STATUS "Setting optimal options") -MESSAGE(STATUS " Processor: ${NV_SYSTEM_PROCESSOR}") -MESSAGE(STATUS " Compiler Flags: ${CMAKE_CXX_FLAGS}") IF(CMAKE_BUILD_TYPE MATCHES "debug") SET(CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "Postfix for debug build libraries.") @@ -36,12 +24,6 @@ IF(CMAKE_BUILD_TYPE MATCHES "debug") ENDIF() -IF(NVTT_SHARED) - SET(NVCORE_SHARED TRUE) - SET(NVMATH_SHARED TRUE) - SET(NVIMAGE_SHARED TRUE) -ENDIF(NVTT_SHARED) - ADD_SUBDIRECTORY(extern) ADD_SUBDIRECTORY(src) @@ -62,10 +44,9 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") SET(CPACK_PACKAGE_NAME "nvidia-texture-tools") SET(CPACK_PACKAGE_VERSION_MAJOR "2") SET(CPACK_PACKAGE_VERSION_MINOR "1") -SET(CPACK_PACKAGE_VERSION_PATCH "0") -SET(CPACK_PACKAGE_VERSION "2.1.0") -SET(CPACK_PACKAGE_CONTACT "Ignacio Castaño ") -#SET(CPACK_PACKAGE_VENDOR "NVIDIA Corporation") +SET(CPACK_PACKAGE_VERSION_PATCH "2") +SET(CPACK_PACKAGE_VERSION "2.1.2") +SET(CPACK_PACKAGE_CONTACT "Ignacio Casta�o ") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Texture processing tools with support for Direct3D 10 and 11 formats.") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${NV_SOURCE_DIR}/README.md") @@ -75,7 +56,7 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${NV_SOURCE_DIR}/LICENSE") IF(WIN32) SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_VENDOR}\\\\NVIDIA Texture Tools 2.1") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}\\\\NVIDIA Texture Tools 2.1") - SET(CPACK_PACKAGE_ICON "${NV_SOURCE_DIR}\\\\project\\\\vc8\\\\nvcompress\\\\nvidia.ico") + SET(CPACK_PACKAGE_ICON "${NV_SOURCE_DIR}\\\\project\\\\vc2017\\\\nvcompress\\\\nvidia.ico") ENDIF(WIN32) INCLUDE(CPack) diff --git a/ChangeLog b/ChangeLog index 20e269fa..7662240b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +NVIDIA Texture Tools version 2.1.2 + * Use ICBC as the main BC1 compressor. + * Various fixes. + NVIDIA Texture Tools version 2.1.1 * Various fixes. diff --git a/LICENSE b/LICENSE index c1bfebc5..35d671ff 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ NVIDIA Texture Tools is licensed under the MIT license. -Copyright (c) 2009-2017 Ignacio Castaño +Copyright (c) 2009-2020 Ignacio Castaño Copyright (c) 2007-2009 NVIDIA Corporation Permission is hereby granted, free of charge, to any person diff --git a/README.md b/README.md index 6b14411d..f686d1b4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,44 @@ -NVIDIA Texture Tools -==================== +# NVTT is discontinued + +After more than 14 years maintaining and updating this library on my spare time, I've decided to officially discontinue it and focus my energy on other projects. + +When I released NVTT there was very little public information about compression for GPU texture formats. Existing codecs were closed-source, encumbered by patents, and not particularly efficient or high quality. A lot has changed since then. NVTT doesn't support the latest formats anymore, some of its codecs are outdated, and it's source code has aged. Today most IHVs maintain their own open source codecs and several companies develop high quality commercial products around texture compression. + +If you are looking for alternative texture compression tools and processing algorithms I recommend you check these out: + +## Open Source Encoders + +* I still maintain [A High Quality SIMD BC1 Encoder](https://github.com/castano/icbc). +* [rgbcx](https://github.com/richgel999/bc7enc/blob/master/rgbcx.h) is another high-performance (but scalar) BC1-5 encoder. +* [stb_dxt](https://github.com/nothings/stb/blob/master/stb_dxt.h) is a single header library that provides low quality, but fast BC1-5 encoders. +* [Binomial](https://www.binomial.info/) is an image and texture compression company that develops [Basis a universal texture codec](https://github.com/BinomialLLC/basis_universal) and also has [other open source codecs](https://github.com/BinomialLLC). +* [Intel ISPC Texture Compressor](https://github.com/GameTechDev/ISPCTextureCompressor) is a set of set of open source SIMD texture encoders that are very fast, but low quality. +* [AMD Compressonator](https://gpuopen.com/compressonator/) offers various open source encoders that also run on the GPU. +* [Betsy](https://github.com/darksylinc/betsy/) is a compressor for various GPU formats using compute shaders. +* For ETC encoders see Google's [Etc2Comp](https://github.com/google/etc2comp), Bartosz Taudul's [etcpak](https://github.com/wolfpld/etcpak) and Rich Geldreich's [rg-etc1](https://github.com/richgel999/rg-etc1). +* [ARM ASTC Encoder](https://github.com/ARM-software/astc-encoder) is an excellent ASTC encoder. +* This is [a good overview of the state of texture encoders in 2020](https://aras-p.info/blog/2020/12/08/Texture-Compression-in-2020/). + +## Image Processing and IO + +* [stb_image_resize](https://github.com/nothings/stb/blob/master/stb_image_resize.h) provides polyphase image resize filters that are similar to what NVTT supports. +* [Dario Manesku's cube map filtering tool](https://github.com/dariomanesku/cmft) seems like a good alternative for the cube map filtering functions in NVTT. +* [CubeMapGen](https://gpuopen.com/archived/cubemapgen/) is another source of information for cubemap filtering algorithms, but is now unsupported as well. +* Deano Calver supports [three tiny libraries](https://deanoc.com/2019/09/tiny) that provide support for DDS and KTX file formats, and pixel format conversion. +* [stb_image](https://github.com/nothings/stb/blob/master/stb_image.h) and [stb_image_write](https://github.com/nothings/stb/blob/master/stb_image_write.h) are two handy single header libraries to read and write images in various formats. +* https://github.com/syoyo/tinyexr +* https://lodev.org/lodepng/ +* [texturec](https://bkaradzic.github.io/bgfx/tools.html#texture-compiler-texturec) is a handy command line tool similar to `nvcompress`, built on top of [bimg](https://github.com/bkaradzic/bimg). +* The venerable [ImageMagick](https://imagemagick.org/) still provides many valuable tools and utilities. + +## Commercial Libraries + +* [Oodle Texture](http://www.radgametools.com/oodletexture.htm) is a suite of commercial RDO texture codecs. +* [NVIDIA Texture Tools exporter](https://developer.nvidia.com/nvidia-texture-tools-exporter) is based on a private fork of this project and offers additional GPU accelerated codecs, but it's not open source. + +------------------------------- + +# NVIDIA Texture Tools [![Actions Status](https://github.com/castano/nvidia-texture-tools/workflows/build/badge.svg)](https://github.com/castano/nvidia-texture-tools/actions) ![MIT](https://img.shields.io/badge/license-MIT-blue.svg) [![GitHub](https://img.shields.io/badge/repo-github-green.svg)](https://github.com/castano/nvidia-texture-tools) The NVIDIA Texture Tools is a collection of image processing and texture manipulation tools, designed to be integrated in game tools and asset @@ -11,9 +50,7 @@ conversion, and DXT compression. ### How to build (Windows) -Open `project/vc12/thekla.sln` using Visual Studio. - -Solutions for previous versions are also available, but they may not be up to date. +Use the provided Visual Studio 2017 solution `project/vc2017/thekla.sln`. ### How to build (Linux/OSX) @@ -32,13 +69,13 @@ $ sudo make install To use the NVIDIA Texture Tools in your own applications you just have to include the following header file: -src/nvtt/nvtt.h +[src/nvtt/nvtt.h](https://github.com/castano/nvidia-texture-tools/blob/master/src/nvtt/nvtt.h) And include the nvtt library in your projects. The following file contains a simple example that shows how to use the library: -src/nvtt/tools/compress.cpp +[src/nvtt/tools/compress.cpp](https://github.com/castano/nvidia-texture-tools/blob/master/src/nvtt/tools/compress.cpp) Detailed documentation of the API can be found at: diff --git a/VERSION b/VERSION index 3e3c2f1e..eca07e4c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.1 +2.1.2 diff --git a/buildpkg b/buildpkg deleted file mode 100755 index 140833d4..00000000 --- a/buildpkg +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -tar zcvf nvidia-texture-tools-`cat VERSION`.tar.gz \ - --exclude '.*' --exclude debian --exclude '*~' --exclude buildpkg \ - --exclude 'build-*' --exclude data --exclude tags --exclude Makefile \ - --exclude 'doc' --exclude 'nvidia-texture-tools-*.tar.gz' \ - --exclude 'extern/skylight' --exclude 'extern/FreeImage' \ - --exclude 'extern/atitc' --exclude 'extern/glew' \ - --exclude 'extern/gnuwin32' \ - --exclude '*.user' -s ',^,nvidia-texture-tools/,' * -# --exclude '*.user' --transform 's,^,nvidia-texture-tools/,' * -# --exclude '*.user' * - diff --git a/cmake/DetermineProcessor.cmake b/cmake/DetermineProcessor.cmake deleted file mode 100644 index 7db7a95b..00000000 --- a/cmake/DetermineProcessor.cmake +++ /dev/null @@ -1,72 +0,0 @@ - -# Assume i586 by default. -SET(NV_SYSTEM_PROCESSOR "i586") - -IF(UNIX) - FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) - IF(CMAKE_UNAME) - #EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE NV_SYSTEM_PROCESSOR RETURN_VALUE val) - - #IF("${val}" GREATER 0 OR NV_SYSTEM_PROCESSOR STREQUAL "unknown") - EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE NV_SYSTEM_PROCESSOR RETURN_VALUE val) - #ENDIF("${val}" GREATER 0 OR NV_SYSTEM_PROCESSOR STREQUAL "unknown") - - IF(NV_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") - SET(NV_SYSTEM_PROCESSOR "powerpc") - ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") - - # processor may have double quote in the name, and that needs to be removed - STRING(REGEX REPLACE "\"" "" NV_SYSTEM_PROCESSOR "${NV_SYSTEM_PROCESSOR}") - STRING(REGEX REPLACE "/" "_" NV_SYSTEM_PROCESSOR "${NV_SYSTEM_PROCESSOR}") - ENDIF(CMAKE_UNAME) - -#~ # Get extended processor information from /proc/cpuinfo -#~ IF(EXISTS "/proc/cpuinfo") - -#~ FILE(READ /proc/cpuinfo PROC_CPUINFO) - -#~ SET(VENDOR_ID_RX "vendor_id[ \t]*:[ \t]*([a-zA-Z]+)\n") -#~ STRING(REGEX MATCH "${VENDOR_ID_RX}" VENDOR_ID "${PROC_CPUINFO}") -#~ STRING(REGEX REPLACE "${VENDOR_ID_RX}" "\\1" VENDOR_ID "${VENDOR_ID}") - -#~ SET(CPU_FAMILY_RX "cpu family[ \t]*:[ \t]*([0-9]+)") -#~ STRING(REGEX MATCH "${CPU_FAMILY_RX}" CPU_FAMILY "${PROC_CPUINFO}") -#~ STRING(REGEX REPLACE "${CPU_FAMILY_RX}" "\\1" CPU_FAMILY "${CPU_FAMILY}") - -#~ SET(MODEL_RX "model[ \t]*:[ \t]*([0-9]+)") -#~ STRING(REGEX MATCH "${MODEL_RX}" MODEL "${PROC_CPUINFO}") -#~ STRING(REGEX REPLACE "${MODEL_RX}" "\\1" MODEL "${MODEL}") - -#~ SET(FLAGS_RX "flags[ \t]*:[ \t]*([a-zA-Z0-9 _]+)\n") -#~ STRING(REGEX MATCH "${FLAGS_RX}" FLAGS "${PROC_CPUINFO}") -#~ STRING(REGEX REPLACE "${FLAGS_RX}" "\\1" FLAGS "${FLAGS}") - -#~ # Debug output. -#~ IF(LINUX_CPUINFO) -#~ MESSAGE(STATUS "LinuxCPUInfo.cmake:") -#~ MESSAGE(STATUS "VENDOR_ID : ${VENDOR_ID}") -#~ MESSAGE(STATUS "CPU_FAMILY : ${CPU_FAMILY}") -#~ MESSAGE(STATUS "MODEL : ${MODEL}") -#~ MESSAGE(STATUS "FLAGS : ${FLAGS}") -#~ ENDIF(LINUX_CPUINFO) - -#~ ENDIF(EXISTS "/proc/cpuinfo") - -#~ # Information on how to decode CPU_FAMILY and MODEL: -#~ # http://balusc.xs4all.nl/srv/har-cpu-int-pm.php - -ELSE(UNIX) - - IF(WIN32) - # It's not OK to trust $ENV{PROCESSOR_ARCHITECTURE}: its value depends on the type of executable being run, - # so a 32-bit cmake (the default binary distribution) will always say "x86" regardless of the actual target. - IF (CMAKE_SIZEOF_VOID_P EQUAL 8) - SET (NV_SYSTEM_PROCESSOR "x86_64") - ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET (NV_SYSTEM_PROCESSOR "x86") - ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) - ENDIF(WIN32) - -ENDIF(UNIX) - - diff --git a/cmake/FindCg.cmake b/cmake/FindCg.cmake deleted file mode 100644 index 085bb6b4..00000000 --- a/cmake/FindCg.cmake +++ /dev/null @@ -1,172 +0,0 @@ -# -# Try to find NVIDIA's Cg compiler, runtime libraries, and include path. -# Once done this will define -# -# CG_FOUND =system has NVIDIA Cg and it can be used. -# CG_INCLUDE_DIR = directory where cg.h resides -# CG_LIBRARY = full path to libCg.so (Cg.DLL on win32) -# CG_GL_LIBRARY = full path to libCgGL.so (CgGL.dll on win32) -# CG_COMPILER = full path to cgc (cgc.exe on win32) -# - -# On OSX default to using the framework version of Cg. -IF (APPLE) - INCLUDE(${CMAKE_ROOT}/Modules/CMakeFindFrameworks.cmake) - SET(CG_FRAMEWORK_INCLUDES) - CMAKE_FIND_FRAMEWORKS(Cg) - IF (Cg_FRAMEWORKS) - FOREACH(dir ${Cg_FRAMEWORKS}) - SET(CG_FRAMEWORK_INCLUDES ${CG_FRAMEWORK_INCLUDES} - ${dir}/Headers ${dir}/PrivateHeaders) - ENDFOREACH(dir) - - # Find the include dir - FIND_PATH(CG_INCLUDE_DIR cg.h - ${CG_FRAMEWORK_INCLUDES} - ) - - # Since we are using Cg framework, we must link to it. - # Note, we use weak linking, so that it works even when Cg is not available. - SET(CG_LIBRARY "-weak_framework Cg" CACHE STRING "Cg library") - SET(CG_GL_LIBRARY "-weak_framework Cg" CACHE STRING "Cg GL library") - ENDIF (Cg_FRAMEWORKS) - FIND_PROGRAM(CG_COMPILER cgc - /usr/bin - /usr/local/bin - DOC "The Cg compiler" - ) -ELSE (APPLE) - IF (WIN32) - - # When compiling 64-bit programs, the binaries and libs are in bin.x64 and lib.x64 directories, - - # This will have only effect for 64bit versions of cmake, when running the default 32bit version - # both ProgramFiles and ProgramFiles(x86) point to the same place in Win64 - SET(PFx86_VARNAME "ProgramFiles(x86)") - SET(PFx86 $ENV{${PFx86_VARNAME}}) - - # Let's play safe in case we are cross compiling to 64 bit: for cgc it doesn't really matter - FIND_PROGRAM( CG_COMPILER cgc - $ENV{CG_BIN64_PATH} - $ENV{CG_BIN_PATH} - $ENV{PROGRAMFILES}/NVIDIA\ Corporation/Cg/bin - $ENV{PFx86}/NVIDIA\ Corporation/Cg/bin - $ENV{PROGRAMFILES}/Cg - ${PROJECT_SOURCE_DIR}/../Cg - DOC "The Cg Compiler" - ) - - IF (CG_COMPILER) - GET_FILENAME_COMPONENT(CG_COMPILER_DIR ${CG_COMPILER} PATH) - GET_FILENAME_COMPONENT(CG_COMPILER_SUPER_DIR ${CG_COMPILER_DIR} PATH) - ELSE (CG_COMPILER) - SET (CG_COMPILER_DIR .) - SET (CG_COMPILER_SUPER_DIR ..) - ENDIF (CG_COMPILER) - FIND_PATH( CG_INCLUDE_DIR Cg/cg.h - $ENV{CG_INC_PATH} - $ENV{PROGRAMFILES}/NVIDIA\ Corporation/Cg/include - $ENV{PROGRAMFILES}/Cg - ${PROJECT_SOURCE_DIR}/../Cg - ${CG_COMPILER_SUPER_DIR}/include - ${CG_COMPILER_DIR} - DOC "The directory where Cg/cg.h resides" - ) - - IF (NV_SYSTEM_PROCESSOR STREQUAL "x86_64") - FIND_LIBRARY( CG_LIBRARY - NAMES Cg - PATHS - $ENV{CG_LIB64_PATH} - $ENV{PROGRAMFILES}/NVIDIA\ Corporation/Cg/lib.x64 - $ENV{PFx86}/NVIDIA\ Corporation/Cg/lib.x64 - $ENV{PROGRAMFILES}/Cg - $ENV{PFx86}/Cg - ${PROJECT_SOURCE_DIR}/../Cg - ${CG_COMPILER_SUPER_DIR}/lib.x64 - ${CG_COMPILER_DIR} - DOC "The Cg runtime library (64-bit)" - ) - FIND_LIBRARY( CG_GL_LIBRARY - NAMES CgGL - PATHS - $ENV{CG_LIB64_PATH} - $ENV{PROGRAMFILES}/NVIDIA\ Corporation/Cg/lib.x64 - $ENV{PFx86}/NVIDIA\ Corporation/Cg/lib.x64 - $ENV{PROGRAMFILES}/Cg - $ENV{PFx86}/Cg - ${PROJECT_SOURCE_DIR}/../Cg - ${CG_COMPILER_SUPER_DIR}/lib.x64 - ${CG_COMPILER_DIR} - DOC "The Cg GL runtime library (64-bit)" - ) - ELSE(NV_SYSTEM_PROCESSOR STREQUAL "x86_64") - FIND_LIBRARY( CG_LIBRARY - NAMES Cg - PATHS - $ENV{CG_LIB_PATH} - $ENV{PROGRAMFILES}/NVIDIA\ Corporation/Cg/lib - $ENV{PROGRAMFILES}/Cg - ${PROJECT_SOURCE_DIR}/../Cg - ${CG_COMPILER_SUPER_DIR}/lib - ${CG_COMPILER_DIR} - DOC "The Cg runtime library" - ) - FIND_LIBRARY( CG_GL_LIBRARY - NAMES CgGL - PATHS - $ENV{CG_LIB_PATH} - $ENV{PROGRAMFILES}/NVIDIA\ Corporation/Cg/lib - $ENV{PROGRAMFILES}/Cg - ${PROJECT_SOURCE_DIR}/../Cg - ${CG_COMPILER_SUPER_DIR}/lib - ${CG_COMPILER_DIR} - DOC "The Cg GL runtime library" - ) - ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "x86_64") - - ELSE (WIN32) - FIND_PROGRAM( CG_COMPILER cgc - /usr/bin - /usr/local/bin - DOC "The Cg Compiler" - ) - GET_FILENAME_COMPONENT(CG_COMPILER_DIR "${CG_COMPILER}" PATH) - GET_FILENAME_COMPONENT(CG_COMPILER_SUPER_DIR "${CG_COMPILER_DIR}" PATH) - FIND_PATH( CG_INCLUDE_DIR Cg/cg.h - /usr/include - /usr/local/include - ${CG_COMPILER_SUPER_DIR}/include - DOC "The directory where Cg/cg.h resides" - ) - FIND_LIBRARY( CG_LIBRARY Cg - PATHS - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - ${CG_COMPILER_SUPER_DIR}/lib64 - ${CG_COMPILER_SUPER_DIR}/lib - DOC "The Cg runtime library" - ) - SET(CG_LIBRARY ${CG_LIBRARY} -lpthread) - FIND_LIBRARY( CG_GL_LIBRARY CgGL - PATHS - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - ${CG_COMPILER_SUPER_DIR}/lib64 - ${CG_COMPILER_SUPER_DIR}/lib - DOC "The Cg runtime library" - ) - ENDIF (WIN32) -ENDIF (APPLE) - -IF (CG_INCLUDE_DIR) - SET( CG_FOUND 1 CACHE STRING "Set to 1 if CG is found, 0 otherwise") -ELSE (CG_INCLUDE_DIR) - SET( CG_FOUND 0 CACHE STRING "Set to 1 if CG is found, 0 otherwise") -ENDIF (CG_INCLUDE_DIR) - -MARK_AS_ADVANCED( CG_FOUND ) diff --git a/cmake/FindDirectX.cmake b/cmake/FindDirectX.cmake deleted file mode 100644 index 0177240e..00000000 --- a/cmake/FindDirectX.cmake +++ /dev/null @@ -1,38 +0,0 @@ - -IF (WIN32) - - FIND_PATH(DX9_INCLUDE_PATH d3d9.h - PATHS - "$ENV{DXSDK_DIR}/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK/Include" - DOC "The directory where D3D9.h resides") - - FIND_PATH(DX10_INCLUDE_PATH D3D10.h - PATHS - "$ENV{DXSDK_DIR}/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK/Include" - DOC "The directory where D3D10.h resides") - - FIND_LIBRARY(D3D10_LIBRARY d3d10.lib - PATHS - "$ENV{DXSDK_DIR}/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK/Lib/x86" - DOC "The directory where d3d10.lib resides") - - FIND_LIBRARY(D3DX10_LIBRARY d3dx10.lib - PATHS - "$ENV{DXSDK_DIR}/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK/Lib/x86" - DOC "The directory where d3dx10.lib resides") - - SET(DX10_LIBRARIES ${D3D10_LIBRARY} ${D3DX10_LIBRARY}) - -ENDIF (WIN32) - -IF (DX10_INCLUDE_PATH) - SET( DX10_FOUND 1 CACHE STRING "Set to 1 if CG is found, 0 otherwise") -ELSE (DX10_INCLUDE_PATH) - SET( DX10_FOUND 0 CACHE STRING "Set to 1 if CG is found, 0 otherwise") -ENDIF (DX10_INCLUDE_PATH) - -MARK_AS_ADVANCED( DX10_FOUND ) diff --git a/cmake/FindFreeImage.cmake b/cmake/FindFreeImage.cmake deleted file mode 100644 index 2e995085..00000000 --- a/cmake/FindFreeImage.cmake +++ /dev/null @@ -1,53 +0,0 @@ -# -# Try to find the FreeImage library and include path. -# Once done this will define -# -# FREEIMAGE_FOUND -# FREEIMAGE_INCLUDE_PATH -# FREEIMAGE_LIBRARY -# - -IF (WIN32) - FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h - ${FREEIMAGE_ROOT_DIR}/include - ${FREEIMAGE_ROOT_DIR} - DOC "The directory where FreeImage.h resides") - FIND_LIBRARY( FREEIMAGE_LIBRARY - NAMES FreeImage freeimage - PATHS - ${FREEIMAGE_ROOT_DIR}/lib - ${FREEIMAGE_ROOT_DIR} - DOC "The FreeImage library") -ELSE (WIN32) - FIND_PATH( FREEIMAGE_INCLUDE_PATH FreeImage.h - /usr/include - /usr/local/include - /sw/include - /opt/local/include - DOC "The directory where FreeImage.h resides") - FIND_LIBRARY( FREEIMAGE_LIBRARY - NAMES FreeImage freeimage - PATHS - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - DOC "The FreeImage library") -ENDIF (WIN32) - -SET(FREEIMAGE_LIBRARIES ${FREEIMAGE_LIBRARY}) - -IF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY) - SET( FREEIMAGE_FOUND TRUE CACHE BOOL "Set to TRUE if FreeImage is found, FALSE otherwise") -ELSE (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY) - SET( FREEIMAGE_FOUND FALSE CACHE BOOL "Set to TRUE if FreeImage is found, FALSE otherwise") -ENDIF (FREEIMAGE_INCLUDE_PATH AND FREEIMAGE_LIBRARY) - -MARK_AS_ADVANCED( - FREEIMAGE_FOUND - FREEIMAGE_LIBRARY - FREEIMAGE_LIBRARIES - FREEIMAGE_INCLUDE_PATH) - diff --git a/cmake/FindGLEW.cmake b/cmake/FindGLEW.cmake deleted file mode 100644 index 540911fd..00000000 --- a/cmake/FindGLEW.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# -# Try to find GLEW library and include path. -# Once done this will define -# -# GLEW_FOUND -# GLEW_INCLUDE_PATH -# GLEW_LIBRARY -# - -IF (WIN32) - FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h - $ENV{PROGRAMFILES}/GLEW/include - ${GLEW_ROOT_DIR}/include - DOC "The directory where GL/glew.h resides") - - FIND_LIBRARY( GLEW_LIBRARY - NAMES glew GLEW glew32 glew32s - PATHS - $ENV{PROGRAMFILES}/GLEW/lib - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib - DOC "The GLEW library") -ELSE (WIN32) - FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h - /usr/include - /usr/local/include - /sw/include - /opt/local/include - ${GLEW_ROOT_DIR}/include - DOC "The directory where GL/glew.h resides") - - # Prefer the static library. - FIND_LIBRARY( GLEW_LIBRARY - NAMES libGLEW.a GLEW - PATHS - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - ${GLEW_ROOT_DIR}/lib - DOC "The GLEW library") -ENDIF (WIN32) - -SET(GLEW_FOUND "NO") -IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY) - SET(GLEW_LIBRARIES ${GLEW_LIBRARY}) - SET(GLEW_FOUND "YES") -ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY) diff --git a/cmake/FindMaya.cmake b/cmake/FindMaya.cmake deleted file mode 100644 index 3599329e..00000000 --- a/cmake/FindMaya.cmake +++ /dev/null @@ -1,67 +0,0 @@ - - - -IF (WIN32) - - # Maya plugins can only be compiled with msvc - IF (MSVC) - - FIND_PATH(MAYA_INCLUDE_PATH maya/MTypes.h - PATHS - "$ENV{PROGRAMFILES}/Autodesk/Maya8.5/include" - "$ENV{MAYA_LOCATION}/include" - DOC "The directory where MTypes.h resides") - - # Find maya version! - - FIND_LIBRARY(MAYA_FOUNDATION_LIBRARY Foundation - PATHS - "$ENV{PROGRAMFILES}/Autodesk/Maya8.5/lib" - "$ENV{MAYA_LOCATION}/lib" - DOC "The directory where Foundation.lib resides") - - FIND_LIBRARY(MAYA_OPENMAYA_LIBRARY OpenMaya - PATHS - "$ENV{PROGRAMFILES}/Autodesk/Maya8.5/lib" - "$ENV{MAYA_LOCATION}/lib" - DOC "The directory where OpenMaya.lib resides") - - FIND_LIBRARY(MAYA_OPENMAYAANIM_LIBRARY OpenMayaAnim - PATHS - "$ENV{PROGRAMFILES}/Autodesk/Maya8.5/lib" - "$ENV{MAYA_LOCATION}/lib" - DOC "The directory where OpenMayaAnim.lib resides") - - SET(MAYA_LIBRARIES - ${MAYA_FOUNDATION_LIBRARY} - ${MAYA_OPENMAYA_LIBRARY} - ${MAYA_OPENMAYAANIM_LIBRARY}) - - SET(MAYA_EXTENSION ".mll") - - ENDIF (MSVC) -ELSE (WIN32) - - # On linux, check gcc version. - - # OSX and Linux - - FIND_PATH(MAYA_INCLUDE_PATH maya/MTypes.h - PATHS - /usr/autodesk/maya/include - $ENV{MAYA_LOCATION}/include - DOC "The directory where MTypes.h resides") - -# TODO - -ENDIF (WIN32) - - - -IF (MAYA_INCLUDE_PATH) - SET( MAYA_FOUND 1 CACHE STRING "Set to 1 if Maya is found, 0 otherwise") -ELSE (MAYA_INCLUDE_PATH) - SET( MAYA_FOUND 0 CACHE STRING "Set to 1 if Maya is found, 0 otherwise") -ENDIF (MAYA_INCLUDE_PATH) - -MARK_AS_ADVANCED( MAYA_FOUND ) diff --git a/cmake/FindOpenEXR.cmake b/cmake/FindOpenEXR.cmake deleted file mode 100644 index 776810c0..00000000 --- a/cmake/FindOpenEXR.cmake +++ /dev/null @@ -1,75 +0,0 @@ -# -# Try to find OpenEXR's libraries, and include path. -# Once done this will define: -# -# OPENEXR_FOUND = OpenEXR found. -# OPENEXR_INCLUDE_PATHS = OpenEXR include directories. -# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR. -# - -INCLUDE(FindZLIB) - - -IF(ZLIB_FOUND) - - SET(LIBRARY_PATHS - /usr/lib - /usr/local/lib - /sw/lib - /opt/local/lib - $ENV{PROGRAM_FILES}/OpenEXR/lib/static) - - FIND_PATH(OPENEXR_INCLUDE_PATH ImfRgbaFile.h - PATH_SUFFIXES OpenEXR - /usr/include - /usr/local/include - /sw/include - /opt/local/include) - - FIND_LIBRARY(OPENEXR_HALF_LIBRARY - NAMES Half - PATHS ${LIBRARY_PATHS}) - - FIND_LIBRARY(OPENEXR_IEX_LIBRARY - NAMES Iex - PATHS ${LIBRARY_PATHS}) - - FIND_LIBRARY(OPENEXR_IMATH_LIBRARY - NAMES Imath - PATHS ${LIBRARY_PATHS}) - - FIND_LIBRARY(OPENEXR_ILMIMF_LIBRARY - NAMES IlmImf - PATHS ${LIBRARY_PATHS}) - - FIND_LIBRARY(OPENEXR_ILMTHREAD_LIBRARY - NAMES IlmThread - PATHS ${LIBRARY_PATHS}) - -ENDIF(ZLIB_FOUND) - -#MESSAGE(STATUS ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ZLIB_LIBRARY}) - -IF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) - SET(OPENEXR_FOUND TRUE) - SET(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATH} CACHE STRING "The include paths needed to use OpenEXR") - SET(OPENEXR_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_ILMIMF_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ZLIB_LIBRARY} CACHE STRING "The libraries needed to use OpenEXR") -ENDIF (OPENEXR_INCLUDE_PATH AND OPENEXR_IMATH_LIBRARY AND OPENEXR_ILMIMF_LIBRARY AND OPENEXR_IEX_LIBRARY AND OPENEXR_HALF_LIBRARY) - -IF(OPENEXR_FOUND) - IF(NOT OPENEXR_FIND_QUIETLY) - MESSAGE(STATUS "Found OpenEXR: ${OPENEXR_ILMIMF_LIBRARY}") - ENDIF(NOT OPENEXR_FIND_QUIETLY) -ELSE(OPENEXR_FOUND) - IF(OPENEXR_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find OpenEXR library") - ENDIF(OPENEXR_FIND_REQUIRED) -ENDIF(OPENEXR_FOUND) - -MARK_AS_ADVANCED( - OPENEXR_INCLUDE_PATHS - OPENEXR_LIBRARIES - OPENEXR_ILMIMF_LIBRARY - OPENEXR_IMATH_LIBRARY - OPENEXR_IEX_LIBRARY - OPENEXR_HALF_LIBRARY) diff --git a/cmake/OptimalOptions.cmake b/cmake/OptimalOptions.cmake index ac450c99..c2358380 100644 --- a/cmake/OptimalOptions.cmake +++ b/cmake/OptimalOptions.cmake @@ -1,54 +1,13 @@ -INCLUDE(${NV_CMAKE_DIR}/DetermineProcessor.cmake) - # Set optimal options for gcc: -IF(CMAKE_COMPILER_IS_GNUCXX) - - IF(NV_SYSTEM_PROCESSOR STREQUAL "i586") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i586") - ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "i586") - - IF(NV_SYSTEM_PROCESSOR STREQUAL "i686") - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686") - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse -mtune=i686 -msse3") - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=pentium4") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=prescott") - ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "i686") - - IF(NV_SYSTEM_PROCESSOR STREQUAL "x86_64") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=athlon64") - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=athlon64 -msse3") - ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "x86_64") - - IF(NV_SYSTEM_PROCESSOR STREQUAL "powerpc") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=powerpc -faltivec -maltivec -mabi=altivec -mpowerpc-gfxopt") - - # ibook G4: - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=7450 -mtune=7450 -faltivec -maltivec -mabi=altivec -mpowerpc-gfxopt") - - # G5 - #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=G5 -faltivec -maltivec -mabi=altivec -mpowerpc-gfxopt") - - ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "powerpc") - -# IF(DARWIN) -# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk") -# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk") -# ENDIF(DARWIN) - IF(APPLE) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i586 -arch x86_64 -msse3 -mmacosx-version-min=10.5") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i586 -arch x86_64 -msse3 -mmacosx-version-min=10.5") - ENDIF(APPLE) - - IF(CMAKE_BUILD_TYPE STREQUAL "debug") - ADD_DEFINITIONS(-D_DEBUG) - ENDIF(CMAKE_BUILD_TYPE STREQUAL "debug") - +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if (NOT APPLE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + endif () SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -ENDIF(CMAKE_COMPILER_IS_GNUCXX) +ENDIF() IF(MSVC) - # @@ Some of these might only be available in VC8. # Code generation flags. # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2 /fp:fast") # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2 /fp:fast") diff --git a/configure b/configure index b16c4ece..7f774a27 100755 --- a/configure +++ b/configure @@ -52,7 +52,7 @@ echo "-- Configuring nvidia-texture-tools "`cat VERSION` mkdir -p ./build-$build cd ./build-$build -$CMAKE .. -DNVTT_SHARED=0 -DCMAKE_BUILD_TYPE=$build -DCMAKE_INSTALL_PREFIX=$prefix -G "Unix Makefiles" || exit 1 +$CMAKE .. -DNVTT_SHARED=1 -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DCMAKE_BUILD_TYPE=$build -DCMAKE_INSTALL_PREFIX=$prefix -G "Unix Makefiles" || exit 1 cd .. echo "" diff --git a/data/testsuite/waterloo/baboon.png b/data/testsuite/waterloo/baboon.png new file mode 100644 index 00000000..2b1499a5 Binary files /dev/null and b/data/testsuite/waterloo/baboon.png differ diff --git a/doc/release_todo b/doc/release_todo index f5ea7726..e13c2bfd 100644 --- a/doc/release_todo +++ b/doc/release_todo @@ -1,4 +1,5 @@ +Update version number in nvtt/nvtt.h Update version number in nvimage/DirectDrawSurface.cpp Update version number in CMakeLists.txt Update version number in VERSION -Update version number in NVIDIA_Texture_Tools_README.txt +Update version number in project/vc2017/nvtt/nvtt.rc diff --git a/extern/CMP_Core/CMP_Core.def b/extern/CMP_Core/CMP_Core.def new file mode 100644 index 00000000..baa5bc1b --- /dev/null +++ b/extern/CMP_Core/CMP_Core.def @@ -0,0 +1,56 @@ +; Core def : Declares the module parameters for the DLL. + +EXPORTS +CreateOptionsBC1 +CreateOptionsBC2 +CreateOptionsBC3 +CreateOptionsBC4 +CreateOptionsBC5 +CreateOptionsBC6 +CreateOptionsBC7 + +DestroyOptionsBC1 +DestroyOptionsBC2 +DestroyOptionsBC3 +DestroyOptionsBC4 +DestroyOptionsBC5 +DestroyOptionsBC6 +DestroyOptionsBC7 + +SetDecodeChannelMapping + +SetChannelWeightsBC1 +SetChannelWeightsBC2 +SetChannelWeightsBC3 + +SetQualityBC1 +SetQualityBC2 +SetQualityBC3 +SetQualityBC4 +SetQualityBC5 +SetQualityBC6 +SetQualityBC7 + +SetAlphaThresholdBC1 + +SetMaskBC6 +SetMaskBC7 + +SetErrorThresholdBC7 +SetAlphaOptionsBC7 + +CompressBlockBC1 +CompressBlockBC2 +CompressBlockBC3 +CompressBlockBC4 +CompressBlockBC5 +CompressBlockBC6 +CompressBlockBC7 + +DecompressBlockBC1 +DecompressBlockBC2 +DecompressBlockBC3 +DecompressBlockBC4 +DecompressBlockBC5 +DecompressBlockBC6 +DecompressBlockBC7 diff --git a/extern/CMP_Core/CMakeLists.txt b/extern/CMP_Core/CMakeLists.txt new file mode 100644 index 00000000..e89ea3d8 --- /dev/null +++ b/extern/CMP_Core/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.10) + +add_library(CMP_Core STATIC "") + +target_sources(CMP_Core + PRIVATE + shaders/BC1_Encode_kernel.h + shaders/BC1_Encode_kernel.cpp + shaders/BC2_Encode_kernel.h + shaders/BC2_Encode_kernel.cpp + shaders/BC3_Encode_kernel.h + shaders/BC3_Encode_kernel.cpp + shaders/BC4_Encode_kernel.h + shaders/BC4_Encode_kernel.cpp + shaders/BC5_Encode_kernel.h + shaders/BC5_Encode_kernel.cpp + shaders/BC6_Encode_kernel.h + shaders/BC6_Encode_kernel.cpp + shaders/BC7_Encode_Kernel.h + shaders/BC7_Encode_Kernel.cpp + shaders/BCn_Common_Kernel.h + shaders/Common_Def.h + ) + +target_include_directories(CMP_Core + PRIVATE + shaders + source) +#add_subdirectory(test) + +if (UNIX) +target_compile_definitions(CMP_Core PRIVATE _LINUX ASPM_GPU) +endif() diff --git a/extern/CMP_Core/shaders/BC1_Encode_kernel.cpp b/extern/CMP_Core/shaders/BC1_Encode_kernel.cpp new file mode 100644 index 00000000..43d831cf --- /dev/null +++ b/extern/CMP_Core/shaders/BC1_Encode_kernel.cpp @@ -0,0 +1,305 @@ +//============================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//=============================================================================== + +// Heat Mapping +// This is code that compares quality of two similar or equal codecs with varying quality settings +// A resulting compressed codec data block is colored according to three colors conditions +// The base codec, lowest quality is colored green and the varying quality code is colored red. +// If the quality of the base matches that of the varying codec then the color is set to blue +// Base codecs can be local to CMP_Core or imported using a external set of files, the base codec + +#ifndef TEST_HEATMAP +//#define TEST_HEATMAP // Enable this to run heat map tests on BC1 codec +#endif + +#include "BC1_Encode_kernel.h" + +#ifdef TEST_HEATMAP +#include "ExternCodec.h" // Use external codec for testing +#endif +//============================================== BC1 INTERFACES ======================================================= + +#ifndef ASPM_HLSL + +void CompressBlockBC1_Internal( + const CMP_Vec4uc srcBlockTemp[16], + CMP_GLOBAL CGU_UINT32 compressedBlock[2], + CMP_GLOBAL CMP_BC15Options *BC15options) +{ + CGU_UINT8 srcindex = 0; + CGU_FLOAT BlockA[16]; + CGU_Vec3f rgbBlockUV[16]; + for ( CGU_INT32 j = 0; j < 4; j++) { + for ( CGU_INT32 i = 0; i < 4; i++) { + rgbBlockUV[srcindex].x = (CGU_FLOAT)(srcBlockTemp[srcindex].x & 0xFF)/ 255.0f; // R + rgbBlockUV[srcindex].y = (CGU_FLOAT)(srcBlockTemp[srcindex].y & 0xFF)/ 255.0f; // G + rgbBlockUV[srcindex].z = (CGU_FLOAT)(srcBlockTemp[srcindex].z & 0xFF)/ 255.0f; // B + srcindex++; + } + } + + CMP_BC15Options internalOptions = *BC15options; + internalOptions = CalculateColourWeightings3f(rgbBlockUV,internalOptions); + CGU_Vec3f channelWeights = {internalOptions.m_fChannelWeights[0],internalOptions.m_fChannelWeights[1],internalOptions.m_fChannelWeights[2]}; + CGU_BOOL isSRGB = internalOptions.m_bIsSRGB; // feature not supported in this section of code until v4.1 + CGU_Vec2ui cmpBlock = 0; + +//#define CMP_PRINTRESULTS +#ifdef TEST_HEATMAP + + #ifdef CMP_PRINTRESULTS + static int q1= 0,q2= 0,same = 0; + static int testnum = 0; + printf("%4d ",testnum); + #endif + { + + // Heatmap test: See BCn_Common_Kernel for details + CGU_Vec2ui red = {0xf800f800,0}; + CGU_Vec2ui green = {0x07e007e0,0}; + CGU_Vec2ui blue = {0x001f001f,0}; + + CGU_Vec2ui comp1; + CGU_Vec2ui comp2; + float err ; + + comp1 = (BC15options->m_fquality < 0.3)?CompressBC1Block_SRGB(rgbBlockUV):CompressBC1Block(rgbBlockUV); + comp2 = CompressBlockBC1_UNORM(rgbBlockUV, BC15options->m_fquality,BC15options->m_fquality < 0.3?true:false); + + if ((comp1.x == comp2.x)&&(comp1.y == comp2.y)) err = 0.0f; + else { + float err1 = CMP_RGBBlockError(rgbBlockUV,comp1,(BC15options->m_fquality < 0.3)?true:false); + float err2 = CMP_RGBBlockError(rgbBlockUV,comp2,(BC15options->m_fquality < 0.3)?true:false); + err = err1-err2; + } + + if (err > 0.0f) + { + cmpBlock = red; + } + else if (err < 0.0f) { + cmpBlock = green; + } + else { + cmpBlock = blue; + } + } + #ifdef CMP_PRINTRESULTS + printf("Q1 [%4X:%4X] %.3f, ",cmpBlockQ1.x,cmpBlockQ1.y,err1); + printf("Q2 [%4X:%4X] %.3f, ",cmpBlock.x,cmpBlock.y ,err2); + testnum++; + #endif +#else + + // printf("q = %f\n",internalOptions.m_fquality); + cmpBlock = CompressBlockBC1_RGBA_Internal( + rgbBlockUV, + BlockA, + channelWeights, + 0, //internalOptions.m_nAlphaThreshold, bug to investigate in debug is ok release has issue! + 1, + internalOptions.m_fquality, + isSRGB + ); +#endif + compressedBlock[0] = cmpBlock.x; + compressedBlock[1] = cmpBlock.y; + + +} +#endif + +//============================================== CPU USER INTERFACES ======================================================== +#ifndef ASPM_GPU +int CMP_CDECL CreateOptionsBC1(void **options) +{ + CMP_BC15Options *BC15optionsDefault = new CMP_BC15Options; + if (BC15optionsDefault) { + SetDefaultBC15Options(BC15optionsDefault); + (*options) = BC15optionsDefault; + } + else { + (*options) = NULL; + return CGU_CORE_ERR_NEWMEM; + } + return CGU_CORE_OK; +} + +int CMP_CDECL DestroyOptionsBC1(void *options) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BCOptions = reinterpret_cast (options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC1(void *options, + CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_NEWMEM; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC15optionsDefault->m_fquality = fquality; + return CGU_CORE_OK; +} + + +int CMP_CDECL SetAlphaThresholdBC1(void *options, + CGU_UINT8 alphaThreshold) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + BC15optionsDefault->m_nAlphaThreshold = alphaThreshold; + return CGU_CORE_OK; +} + +int CMP_CDECL SetDecodeChannelMapping(void *options, + CGU_BOOL mapRGBA) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + BC15optionsDefault->m_mapDecodeRGBA = mapRGBA; + return CGU_CORE_OK; +} + +int CMP_CDECL SetChannelWeightsBC1(void *options, + CGU_FLOAT WeightRed, + CGU_FLOAT WeightGreen, + CGU_FLOAT WeightBlue) { + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = (CMP_BC15Options *)options; + + if ((WeightRed < 0.0f) || (WeightRed > 1.0f)) return CGU_CORE_ERR_RANGERED; + if ((WeightGreen < 0.0f) || (WeightGreen > 1.0f)) return CGU_CORE_ERR_RANGEGREEN; + if ((WeightBlue < 0.0f) || (WeightBlue > 1.0f)) return CGU_CORE_ERR_RANGEBLUE; + + BC15optionsDefault->m_bUseChannelWeighting = true; + BC15optionsDefault->m_fChannelWeights[0] = WeightRed; + BC15optionsDefault->m_fChannelWeights[1] = WeightGreen; + BC15optionsDefault->m_fChannelWeights[2] = WeightBlue; + return CGU_CORE_OK; +} + +int CMP_CDECL CompressBlockBC1(const unsigned char *srcBlock, + unsigned int srcStrideInBytes, + CMP_GLOBAL unsigned char cmpBlock[8], + const void *options = NULL) { + CMP_Vec4uc inBlock[16]; + + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row=0; row < 4; row++) + { + srcpos = row * srcStrideInBytes; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlock[dstptr].x = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].y = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].z = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].w = CGU_UINT8(srcBlock[srcpos++]); + dstptr++; + } + } + + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + + CompressBlockBC1_Internal(inBlock, (CMP_GLOBAL CGU_UINT32 *)cmpBlock, BC15options); + return CGU_CORE_OK; +} + +int CMP_CDECL DecompressBlockBC1(const unsigned char cmpBlock[8], + CMP_GLOBAL unsigned char srcBlock[64], + const void *options = NULL) { + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + + CGU_Vec2ui compBlock; + + compBlock.x = (CGU_UINT32)cmpBlock[3] << 24 | + (CGU_UINT32)cmpBlock[2] << 16 | + (CGU_UINT32)cmpBlock[1] << 8 | + (CGU_UINT32)cmpBlock[0]; + + compBlock.y = (CGU_UINT32)cmpBlock[7] << 24 | + (CGU_UINT32)cmpBlock[6] << 16 | + (CGU_UINT32)cmpBlock[5] << 8 | + (CGU_UINT32)cmpBlock[4]; + + cmp_decompressDXTRGBA_Internal(srcBlock, compBlock, BC15options->m_mapDecodeRGBA); + + return CGU_CORE_OK; +} +#endif + +//============================================== OpenCL USER INTERFACE ======================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder( + CMP_GLOBAL const CMP_Vec4uc* ImageSource, + CMP_GLOBAL CGU_UINT8* ImageDestination, + CMP_GLOBAL Source_Info* SourceInfo, + CMP_GLOBAL CMP_BC15Options* BC15options +) +{ + CGU_UINT32 xID; + CGU_UINT32 yID; + + //printf("SourceInfo: (H:%d,W:%d) Quality %1.2f \n", SourceInfo->m_src_height, SourceInfo->m_src_width, SourceInfo->m_fquality); + xID = get_global_id(0); + yID = get_global_id(1); + + + if (xID >= (SourceInfo->m_src_width / BlockX)) return; + if (yID >= (SourceInfo->m_src_height / BlockX)) return; + int srcWidth = SourceInfo->m_src_width; + + CGU_UINT32 destI = (xID*BC1CompBlockSize) + (yID*(srcWidth / BlockX)*BC1CompBlockSize); + int srcindex = 4 * (yID * srcWidth + xID); + int blkindex = 0; + CMP_Vec4uc srcData[16]; + srcWidth = srcWidth - 4; + + for ( CGU_INT32 j = 0; j < 4; j++) { + for ( CGU_INT32 i = 0; i < 4; i++) { + srcData[blkindex++] = ImageSource[srcindex++]; + } + srcindex += srcWidth; + } + CompressBlockBC1_Internal(srcData, (CMP_GLOBAL CGU_UINT32 *)&ImageDestination[destI], BC15options); +} +#endif diff --git a/extern/CMP_Core/shaders/BC1_Encode_kernel.h b/extern/CMP_Core/shaders/BC1_Encode_kernel.h new file mode 100644 index 00000000..ac1f5d03 --- /dev/null +++ b/extern/CMP_Core/shaders/BC1_Encode_kernel.h @@ -0,0 +1,30 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef BC1_ENCODE_KERNEL_H +#define BC1_ENCODE_KERNEL_H + +#include "Common_Def.h" +#include "BCn_Common_Kernel.h" + + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BC1_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC1_Encode_kernel.hlsl new file mode 100644 index 00000000..46b1b6b2 --- /dev/null +++ b/extern/CMP_Core/shaders/BC1_Encode_kernel.hlsl @@ -0,0 +1,99 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// File: BC1_Encode_kernel.hlsl +//-------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +#include "BCn_Common_Kernel.h" + +// Source Data +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +// Compressed Output Data +RWStructuredBuffer g_OutBuff : register( u0 ); + +// Processing multiple blocks at a time +#define MAX_USED_THREAD 16 // pixels in a BC (block compressed) block +#define BLOCK_IN_GROUP 4 // the number of BC blocks a thread group processes = 64 / 16 = 4 +#define THREAD_GROUP_SIZE 64 // 4 blocks where a block is (BLOCK_SIZE_X x BLOCK_SIZE_Y) +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 + +groupshared float4 shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + // we process 4 BC blocks per thread group + uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on + uint pixelBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group + uint pixelInBlock = GI - pixelBase; // id of the pixel in this BC block + + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + + // Load up the pixels + if (pixelInBlock < 16) + { + // load pixels (0..1) + shared_temp[GI] = float4(g_Input.Load( uint3( base_x + pixelInBlock % 4, base_y + pixelInBlock / 4, 0 ) )); + } + + GroupMemoryBarrierWithGroupSync(); + + // Process and save s + if (pixelInBlock == 0) + { + float3 block[16]; + for (int i = 0; i < 16; i++ ) + { + block[i].x = shared_temp[pixelBase + i].x; + block[i].y = shared_temp[pixelBase + i].y; + block[i].z = shared_temp[pixelBase + i].z; + } + + g_OutBuff[blockID] = CompressBlockBC1_UNORM(block,g_quality,false); + } +} diff --git a/extern/CMP_Core/shaders/BC2_Encode_kernel.cpp b/extern/CMP_Core/shaders/BC2_Encode_kernel.cpp new file mode 100644 index 00000000..a1a26d03 --- /dev/null +++ b/extern/CMP_Core/shaders/BC2_Encode_kernel.cpp @@ -0,0 +1,250 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== + +#include "BC2_Encode_kernel.h" + +//============================================== BC2 INTERFACES ======================================================= + +void CompressBlockBC2_Internal(const CMP_Vec4uc srcBlockTemp[16], + CMP_GLOBAL CGU_UINT32 compressedBlock[4], + CMP_GLOBAL const CMP_BC15Options *BC15options) +{ + + CGU_Vec2ui cmpBlock; + CGU_Vec3f rgbBlock[16]; + CGU_FLOAT BlockA[16]; + + for (CGU_INT32 i = 0; i < 16; i++) { + rgbBlock[i].x = (CGU_FLOAT)(srcBlockTemp[i].x & 0xFF)/255.0f; // R + rgbBlock[i].y = (CGU_FLOAT)(srcBlockTemp[i].y & 0xFF)/255.0f; // G + rgbBlock[i].z = (CGU_FLOAT)(srcBlockTemp[i].z & 0xFF)/255.0f; // B + BlockA[i] = (CGU_FLOAT)(srcBlockTemp[i].w & 0xFF)/255.0f; // A + } + + cmpBlock = cmp_compressExplicitAlphaBlock(BlockA); + compressedBlock[DXTC_OFFSET_ALPHA ] = cmpBlock.x; + compressedBlock[DXTC_OFFSET_ALPHA+1] = cmpBlock.y; + + // Need a copy, as CalculateColourWeightings sets variables in the BC15options + CMP_BC15Options internalOptions = *BC15options; + internalOptions = CalculateColourWeightings3f(rgbBlock, internalOptions); + internalOptions.m_bUseAlpha = false; + CGU_Vec3f channelWeights = {internalOptions.m_fChannelWeights[0],internalOptions.m_fChannelWeights[1],internalOptions.m_fChannelWeights[2]}; + CGU_Vec3f MinColor = {0,0,0}, MaxColor={0,0,0}; + + cmpBlock = CompressBlockBC1_RGBA_Internal( + rgbBlock, + BlockA, + channelWeights, + 0,//internalOptions.m_nAlphaThreshold, + 1, //internalOptions.m_nRefinementSteps + internalOptions.m_fquality, + FALSE); + + compressedBlock[DXTC_OFFSET_RGB] = cmpBlock.x; + compressedBlock[DXTC_OFFSET_RGB+1] = cmpBlock.y; + +} + +//============================================== USER INTERFACES ======================================================== +#ifndef ASPM_GPU + +int CMP_CDECL CreateOptionsBC2(void **options) +{ + CMP_BC15Options *BC15optionsDefault = new CMP_BC15Options; + if (BC15optionsDefault) { + SetDefaultBC15Options(BC15optionsDefault); + (*options) = BC15optionsDefault; + } + else { + (*options) = NULL; + return CGU_CORE_ERR_NEWMEM; + } + return CGU_CORE_OK; +} + +int CMP_CDECL DestroyOptionsBC2(void *options) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BCOptions = reinterpret_cast (options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC2(void *options, + CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC15optionsDefault->m_fquality = fquality; + return CGU_CORE_OK; +} + +int CMP_CDECL SetChannelWeightsBC2(void *options, + CGU_FLOAT WeightRed, + CGU_FLOAT WeightGreen, + CGU_FLOAT WeightBlue) { + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = (CMP_BC15Options *)options; + + if ((WeightRed < 0.0f) || (WeightRed > 1.0f)) return CGU_CORE_ERR_RANGERED; + if ((WeightGreen < 0.0f) || (WeightGreen > 1.0f)) return CGU_CORE_ERR_RANGEGREEN; + if ((WeightBlue < 0.0f) || (WeightBlue > 1.0f)) return CGU_CORE_ERR_RANGEBLUE; + + BC15optionsDefault->m_bUseChannelWeighting = true; + BC15optionsDefault->m_fChannelWeights[0] = WeightRed; + BC15optionsDefault->m_fChannelWeights[1] = WeightGreen; + BC15optionsDefault->m_fChannelWeights[2] = WeightBlue; + return CGU_CORE_OK; +} + +#define EXPLICIT_ALPHA_PIXEL_MASK 0xf +#define EXPLICIT_ALPHA_PIXEL_BPP 4 + +// Decompresses an explicit alpha block (DXT3) +void DecompressExplicitAlphaBlock(CGU_UINT8 alphaBlock[BLOCK_SIZE_4X4], + const CGU_UINT32 compressedBlock[2]) +{ + for (int i = 0; i < 16; i++) + { + int nBlock = i < 8 ? 0 : 1; + CGU_UINT8 cAlpha = (CGU_UINT8)((compressedBlock[nBlock] >> ((i % 8) * EXPLICIT_ALPHA_PIXEL_BPP)) & EXPLICIT_ALPHA_PIXEL_MASK); + alphaBlock[i] = (CGU_UINT8)((cAlpha << EXPLICIT_ALPHA_PIXEL_BPP) | cAlpha); + } +} + +void DecompressBC2_Internal(CMP_GLOBAL CGU_UINT8 rgbaBlock[BLOCK_SIZE_4X4X4], + const CGU_UINT32 compressedBlock[4], + const CMP_BC15Options *BC15options) +{ + CGU_UINT8 alphaBlock[BLOCK_SIZE_4X4]; + + DecompressExplicitAlphaBlock(alphaBlock, &compressedBlock[DXTC_OFFSET_ALPHA]); + + + CGU_Vec2ui compBlock; + compBlock.x = compressedBlock[DXTC_OFFSET_RGB]; + compBlock.y = compressedBlock[DXTC_OFFSET_RGB+1]; + + cmp_decompressDXTRGBA_Internal(rgbaBlock, compBlock,BC15options->m_mapDecodeRGBA); + + for (CGU_UINT32 i = 0; i < 16; i++) + ((CMP_GLOBAL CGU_UINT32*)rgbaBlock)[i] = (alphaBlock[i] << RGBA8888_OFFSET_A) | (((CMP_GLOBAL CGU_UINT32*)rgbaBlock)[i] & ~(BYTE_MASK << RGBA8888_OFFSET_A)); +} + +int CMP_CDECL CompressBlockBC2(const unsigned char *srcBlock, + unsigned int srcStrideInBytes, + CMP_GLOBAL unsigned char cmpBlock[16], + CMP_GLOBAL const void *options = NULL) { + + CMP_Vec4uc inBlock[16]; + + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInBytes; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlock[dstptr].x = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].y = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].z = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].w = CGU_UINT8(srcBlock[srcpos++]); + dstptr++; + } + } + + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + CompressBlockBC2_Internal(inBlock, (CMP_GLOBAL CGU_UINT32 *)cmpBlock, BC15options); + return CGU_CORE_OK; +} + +int CMP_CDECL DecompressBlockBC2(const unsigned char cmpBlock[16], + CMP_GLOBAL unsigned char srcBlock[64], + const void *options = NULL) { + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + DecompressBC2_Internal(srcBlock, (CGU_UINT32 *)cmpBlock,BC15options); + + return CGU_CORE_OK; +} +#endif + +//============================================== OpenCL USER INTERFACE ======================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder( + CMP_GLOBAL const CMP_Vec4uc* ImageSource, + CMP_GLOBAL CGU_UINT8* ImageDestination, + CMP_GLOBAL Source_Info* SourceInfo, + CMP_GLOBAL CMP_BC15Options* BC15options +) +{ + CGU_UINT32 xID; + CGU_UINT32 yID; + +#ifdef ASPM_GPU + xID = get_global_id(0); + yID = get_global_id(1); +#else + xID = 0; + yID = 0; +#endif + + if (xID >= (SourceInfo->m_src_width / BlockX)) return; + if (yID >= (SourceInfo->m_src_height / BlockX)) return; + int srcWidth = SourceInfo->m_src_width; + + CGU_UINT32 destI = (xID*BC2CompBlockSize) + (yID*(srcWidth / BlockX)*BC2CompBlockSize); + int srcindex = 4 * (yID * srcWidth + xID); + int blkindex = 0; + CMP_Vec4uc srcData[16]; + srcWidth = srcWidth - 4; + + for ( CGU_INT32 j = 0; j < 4; j++) { + for ( CGU_INT32 i = 0; i < 4; i++) { + srcData[blkindex++] = ImageSource[srcindex++]; + } + srcindex += srcWidth; + } + + CompressBlockBC2_Internal(srcData,(CMP_GLOBAL CGU_UINT32 *)&ImageDestination[destI], BC15options); +} +#endif + diff --git a/extern/CMP_Core/shaders/BC2_Encode_kernel.h b/extern/CMP_Core/shaders/BC2_Encode_kernel.h new file mode 100644 index 00000000..4b1487d5 --- /dev/null +++ b/extern/CMP_Core/shaders/BC2_Encode_kernel.h @@ -0,0 +1,34 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef BC2_ENCODE_KERNEL_H +#define BC2_ENCODE_KERNEL_H + +#include "Common_Def.h" +#include "BCn_Common_Kernel.h" + +#define BC2CompBlockSize 16 +#define NUM_CHANNELS 4 +#define NUM_ENDPOINTS 2 + + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BC2_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC2_Encode_kernel.hlsl new file mode 100644 index 00000000..0af9bf1c --- /dev/null +++ b/extern/CMP_Core/shaders/BC2_Encode_kernel.hlsl @@ -0,0 +1,101 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// File: BC1Encode.hlsl +//-------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +#include "BCn_Common_Kernel.h" + +// Source Data +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +// Compressed Output Data +RWStructuredBuffer g_OutBuff : register( u0 ); + +// Processing multiple blocks at a time +#define MAX_USED_THREAD 16 // pixels in a BC (block compressed) block +#define BLOCK_IN_GROUP 4 // the number of BC blocks a thread group processes = 64 / 16 = 4 +#define THREAD_GROUP_SIZE 64 // 4 blocks where a block is (BLOCK_SIZE_X x BLOCK_SIZE_Y) +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 + +groupshared float4 shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + // we process 4 BC blocks per thread group + uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on + uint pixelBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group + uint pixelInBlock = GI - pixelBase; // id of the pixel in this BC block + + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + + // Load up the pixels + if (pixelInBlock < 16) + { + // load pixels (0..1) + shared_temp[GI] = float4(g_Input.Load( uint3( base_x + pixelInBlock % 4, base_y + pixelInBlock / 4, 0 ) )); + } + + GroupMemoryBarrierWithGroupSync(); + + // Process and save s + if (pixelInBlock == 0) + { + float3 blockRGB[16]; + float blockA[16]; + for (int i = 0; i < 16; i++ ) + { + blockRGB[i].x = shared_temp[pixelBase + i].x; + blockRGB[i].y = shared_temp[pixelBase + i].y; + blockRGB[i].z = shared_temp[pixelBase + i].z; + blockA[i] = shared_temp[pixelBase + i].w; + } + g_OutBuff[blockID] = CompressBlockBC2_UNORM(blockRGB,blockA,g_quality,false); + } +} diff --git a/extern/CMP_Core/shaders/BC3_Encode_kernel.cpp b/extern/CMP_Core/shaders/BC3_Encode_kernel.cpp new file mode 100644 index 00000000..69b57dd3 --- /dev/null +++ b/extern/CMP_Core/shaders/BC3_Encode_kernel.cpp @@ -0,0 +1,235 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#include "BC3_Encode_kernel.h" + +//============================================== BC3 INTERFACES ======================================================= +#ifndef ASPM_HLSL + +void CompressBlockBC3_Internal(const CMP_Vec4uc srcBlockTemp[16], + CMP_GLOBAL CGU_UINT32 compressedBlock[4], + CMP_GLOBAL CMP_BC15Options *BC15options) { + CGU_Vec3f rgbBlock[16]; + CGU_FLOAT alphaBlock[BLOCK_SIZE_4X4]; + + for (CGU_INT32 i = 0; i < 16; i++) { + rgbBlock[i].x = (CGU_FLOAT)(srcBlockTemp[i].x & 0xFF)/255; // R + rgbBlock[i].y = (CGU_FLOAT)(srcBlockTemp[i].y & 0xFF)/255; // G + rgbBlock[i].z = (CGU_FLOAT)(srcBlockTemp[i].z & 0xFF)/255; // B + alphaBlock[i] = (CGU_FLOAT)(srcBlockTemp[i].w) / 255.0f; + } + + CMP_BC15Options internalOptions = *BC15options; + + CGU_Vec2ui cmpBlock; + + cmpBlock = cmp_compressAlphaBlock(alphaBlock,internalOptions.m_fquality); + compressedBlock[0] = cmpBlock.x; + compressedBlock[1] = cmpBlock.y; + + for (CGU_INT32 i = 0; i < 16; i++) { + alphaBlock[i] = (CGU_FLOAT)(srcBlockTemp[i].w); + } + + internalOptions = CalculateColourWeightings3f(rgbBlock, internalOptions); + CGU_Vec3f channelWeights = {internalOptions.m_fChannelWeights[0],internalOptions.m_fChannelWeights[1],internalOptions.m_fChannelWeights[2]}; + + cmpBlock = CompressBlockBC1_RGBA_Internal( + rgbBlock, + alphaBlock, + channelWeights, + 0, // internalOptions.m_nAlphaThreshold, + 1, // internalOptions.m_nRefinementSteps + internalOptions.m_fquality, + FALSE); + + + compressedBlock[2] = cmpBlock.x; + compressedBlock[3] = cmpBlock.y; +} +#endif + +//============================================== USER INTERFACES ======================================================== +#ifndef ASPM_GPU + +int CMP_CDECL CreateOptionsBC3(void **options) +{ + CMP_BC15Options *BC15optionsDefault = new CMP_BC15Options; + if (BC15optionsDefault) { + SetDefaultBC15Options(BC15optionsDefault); + (*options) = BC15optionsDefault; + } + else { + (*options) = NULL; + return CGU_CORE_ERR_NEWMEM; + } + return CGU_CORE_OK; +} + + +int CMP_CDECL DestroyOptionsBC3(void *options) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BCOptions = reinterpret_cast (options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC3(void *options, + CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC15optionsDefault->m_fquality = fquality; + return CGU_CORE_OK; +} + +int CMP_CDECL SetChannelWeightsBC3(void *options, + CGU_FLOAT WeightRed, + CGU_FLOAT WeightGreen, + CGU_FLOAT WeightBlue) { + if (!options) return 1; + CMP_BC15Options *BC15optionsDefault = (CMP_BC15Options *)options; + + if ((WeightRed < 0.0f) || (WeightRed > 1.0f)) return CGU_CORE_ERR_RANGERED; + if ((WeightGreen < 0.0f) || (WeightGreen > 1.0f)) return CGU_CORE_ERR_RANGEGREEN; + if ((WeightBlue < 0.0f) || (WeightBlue > 1.0f)) return CGU_CORE_ERR_RANGEBLUE; + + BC15optionsDefault->m_bUseChannelWeighting = true; + BC15optionsDefault->m_fChannelWeights[0] = WeightRed; + BC15optionsDefault->m_fChannelWeights[1] = WeightGreen; + BC15optionsDefault->m_fChannelWeights[2] = WeightBlue; + return CGU_CORE_OK; +} + + +void DecompressBC3_Internal(CMP_GLOBAL CGU_UINT8 rgbaBlock[64], + const CGU_UINT32 compressedBlock[4], + const CMP_BC15Options *BC15options) { + CGU_UINT8 alphaBlock[BLOCK_SIZE_4X4]; + + cmp_decompressAlphaBlock(alphaBlock, &compressedBlock[DXTC_OFFSET_ALPHA]); + + CGU_Vec2ui compBlock; + compBlock.x = compressedBlock[DXTC_OFFSET_RGB]; + compBlock.y = compressedBlock[DXTC_OFFSET_RGB+1]; + cmp_decompressDXTRGBA_Internal(rgbaBlock, compBlock,BC15options->m_mapDecodeRGBA); + + for (CGU_UINT32 i = 0; i < 16; i++) + ((CMP_GLOBAL CGU_UINT32 *)rgbaBlock)[i] = + (alphaBlock[i] << RGBA8888_OFFSET_A) | + (((CMP_GLOBAL CGU_UINT32 *)rgbaBlock)[i] & + ~(BYTE_MASK << RGBA8888_OFFSET_A)); +} + +int CMP_CDECL CompressBlockBC3( const unsigned char *srcBlock, + unsigned int srcStrideInBytes, + CMP_GLOBAL unsigned char cmpBlock[16], + const void *options = NULL) { + CMP_Vec4uc inBlock[16]; + + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInBytes; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlock[dstptr].x = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].y = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].z = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].w = CGU_UINT8(srcBlock[srcpos++]); + dstptr++; + } + } + + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + + CompressBlockBC3_Internal(inBlock,(CMP_GLOBAL CGU_UINT32 *)cmpBlock, BC15options); + return CGU_CORE_OK; +} + +int CMP_CDECL DecompressBlockBC3(const unsigned char cmpBlock[16], + CMP_GLOBAL unsigned char srcBlock[64], + const void *options = NULL) { + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + DecompressBC3_Internal(srcBlock, (CGU_UINT32 *)cmpBlock,BC15options); + return CGU_CORE_OK; +} +#endif + +//============================================== OpenCL USER INTERFACE ==================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder( + CMP_GLOBAL const CMP_Vec4uc *ImageSource, + CMP_GLOBAL CGU_UINT8 *ImageDestination, CMP_GLOBAL Source_Info *SourceInfo, + CMP_GLOBAL CMP_BC15Options *BC15options) { + CGU_UINT32 xID; + CGU_UINT32 yID; + +#ifdef ASPM_GPU + xID = get_global_id(0); + yID = get_global_id(1); +#else + xID = 0; + yID = 0; +#endif + + if (xID >= (SourceInfo->m_src_width / BlockX)) return; + if (yID >= (SourceInfo->m_src_height / BlockX)) return; + int srcWidth = SourceInfo->m_src_width; + + CGU_UINT32 destI = + (xID * BC3CompBlockSize) + (yID * (srcWidth / BlockX) * BC3CompBlockSize); + int srcindex = 4 * (yID * srcWidth + xID); + int blkindex = 0; + CMP_Vec4uc srcData[16]; + srcWidth = srcWidth - 4; + + for (CGU_INT32 j = 0; j < 4; j++) { + for (CGU_INT32 i = 0; i < 4; i++) { + srcData[blkindex++] = ImageSource[srcindex++]; + } + srcindex += srcWidth; + } + + CompressBlockBC3_Internal( + srcData, (CMP_GLOBAL CGU_UINT32 *)&ImageDestination[destI], BC15options); +} +#endif diff --git a/extern/CMP_Core/shaders/BC3_Encode_kernel.h b/extern/CMP_Core/shaders/BC3_Encode_kernel.h new file mode 100644 index 00000000..0deb0cf5 --- /dev/null +++ b/extern/CMP_Core/shaders/BC3_Encode_kernel.h @@ -0,0 +1,31 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef BC3_ENCODE_KERNEL_H +#define BC3_ENCODE_KERNEL_H + +#include "Common_Def.h" +#include "BCn_Common_Kernel.h" + +#define BC3CompBlockSize 16 + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BC3_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC3_Encode_kernel.hlsl new file mode 100644 index 00000000..03f1cff3 --- /dev/null +++ b/extern/CMP_Core/shaders/BC3_Encode_kernel.hlsl @@ -0,0 +1,101 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// File: BC1Encode.hlsl +//-------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +#include "BCn_Common_Kernel.h" + +// Source Data +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +// Compressed Output Data +RWStructuredBuffer g_OutBuff : register( u0 ); + +// Processing multiple blocks at a time +#define MAX_USED_THREAD 16 // pixels in a BC (block compressed) block +#define BLOCK_IN_GROUP 4 // the number of BC blocks a thread group processes = 64 / 16 = 4 +#define THREAD_GROUP_SIZE 64 // 4 blocks where a block is (BLOCK_SIZE_X x BLOCK_SIZE_Y) +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 + +groupshared float4 shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + // we process 4 BC blocks per thread group + uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on + uint pixelBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group + uint pixelInBlock = GI - pixelBase; // id of the pixel in this BC block + + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + + // Load up the pixels + if (pixelInBlock < 16) + { + // load pixels (0..1) + shared_temp[GI] = float4(g_Input.Load( uint3( base_x + pixelInBlock % 4, base_y + pixelInBlock / 4, 0 ) )); + } + + GroupMemoryBarrierWithGroupSync(); + + // Process and save s + if (pixelInBlock == 0) + { + float3 blockRGB[16]; + float blockA[16]; + for (int i = 0; i < 16; i++ ) + { + blockRGB[i].x = shared_temp[pixelBase + i].x; + blockRGB[i].y = shared_temp[pixelBase + i].y; + blockRGB[i].z = shared_temp[pixelBase + i].z; + blockA[i] = shared_temp[pixelBase + i].w; + } + + g_OutBuff[blockID] = CompressBlockBC3_UNORM(blockRGB,blockA, g_quality,false); + } +} diff --git a/extern/CMP_Core/shaders/BC4_Encode_kernel.cpp b/extern/CMP_Core/shaders/BC4_Encode_kernel.cpp new file mode 100644 index 00000000..accb374f --- /dev/null +++ b/extern/CMP_Core/shaders/BC4_Encode_kernel.cpp @@ -0,0 +1,213 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#include "BC4_Encode_kernel.h" + +//============================================== BC4 INTERFACES ======================================================= + +void CompressBlockBC4_Internal(const CMP_Vec4uc srcBlockTemp[16], + CMP_GLOBAL CGU_UINT32 compressedBlock[2], + CMP_GLOBAL const CMP_BC15Options *BC15options) { + if (BC15options->m_fquality) { + // Reserved! + } + CGU_UINT8 blkindex = 0; + CGU_UINT8 srcindex = 0; + CGU_FLOAT alphaBlock[16]; + for (CGU_INT32 j = 0; j < 4; j++) { + for (CGU_INT32 i = 0; i < 4; i++) { + alphaBlock[blkindex++] = srcBlockTemp[srcindex].x / 255.0f; // Red channel + srcindex++; + } + } + + CGU_Vec2ui cmpBlock; + + cmpBlock = cmp_compressAlphaBlock(alphaBlock,BC15options->m_fquality); + compressedBlock[0] = cmpBlock.x; + compressedBlock[1] = cmpBlock.y; +} + +void DecompressBC4_Internal(CMP_GLOBAL CGU_UINT8 rgbaBlock[64], + const CGU_UINT32 compressedBlock[2], + const CMP_BC15Options *BC15options) { + if (BC15options) {} + CGU_UINT8 alphaBlock[BLOCK_SIZE_4X4]; + cmp_decompressAlphaBlock(alphaBlock, compressedBlock); + + CGU_UINT8 blkindex = 0; + CGU_UINT8 srcindex = 0; + for (CGU_INT32 j = 0; j < 4; j++) { + for (CGU_INT32 i = 0; i < 4; i++) { + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlock[srcindex]; // R + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlock[srcindex]; // G + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlock[srcindex]; // B + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlock[srcindex]; // A + srcindex++; + } + } +} + +void CompressBlockBC4_SingleChannel(const CGU_UINT8 srcBlockTemp[BLOCK_SIZE_4X4], + CMP_GLOBAL CGU_UINT32 compressedBlock[2], + CMP_GLOBAL const CMP_BC15Options *BC15options) { + if (BC15options) {} + CGU_FLOAT alphaBlock[BLOCK_SIZE_4X4]; + + for (CGU_INT32 i = 0; i < BLOCK_SIZE_4X4; i++) alphaBlock[i] = (srcBlockTemp[i] / 255.0f); + + CGU_Vec2ui cmpBlock; + cmpBlock = cmp_compressAlphaBlock(alphaBlock,BC15options->m_fquality); + compressedBlock[0] = cmpBlock.x; + compressedBlock[1] = cmpBlock.y; + + +} + +void DecompressBlockBC4_SingleChannel(CGU_UINT8 srcBlockTemp[16], + const CGU_UINT32 compressedBlock[2], + const CMP_BC15Options *BC15options) { + if (BC15options) {} + cmp_decompressAlphaBlock(srcBlockTemp, compressedBlock); +} + +//============================================== USER INTERFACES ======================================================== +#ifndef ASPM_GPU + +int CMP_CDECL CreateOptionsBC4(void **options) +{ + CMP_BC15Options *BC15optionsDefault = new CMP_BC15Options; + if (BC15optionsDefault) { + SetDefaultBC15Options(BC15optionsDefault); + (*options) = BC15optionsDefault; + } + else { + (*options) = NULL; + return CGU_CORE_ERR_NEWMEM; + } + return CGU_CORE_OK; +} + +int CMP_CDECL DestroyOptionsBC4(void *options) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BCOptions = reinterpret_cast (options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC4(void *options, + CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC15optionsDefault->m_fquality = fquality; + return CGU_CORE_OK; +} + +int CMP_CDECL CompressBlockBC4(const unsigned char *srcBlock, + unsigned int srcStrideInBytes, + CMP_GLOBAL unsigned char cmpBlock[8], + const void *options = NULL) { + + unsigned char inBlock[16]; + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInBytes; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlock[dstptr++] = CGU_UINT8(srcBlock[srcpos++]); + } + } + + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + if (BC15options == NULL) { + CMP_BC15Options BC15optionsDefault; + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + + CompressBlockBC4_SingleChannel(inBlock,(CMP_GLOBAL CGU_UINT32 *)cmpBlock, BC15options); + return CGU_CORE_OK; +} + +int CMP_CDECL DecompressBlockBC4(const unsigned char cmpBlock[8], + CMP_GLOBAL unsigned char srcBlock[16], + const void *options = NULL) { + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + DecompressBlockBC4_SingleChannel(srcBlock, (CGU_UINT32 *)cmpBlock,BC15options); + return CGU_CORE_OK; +} +#endif + +//============================================== OpenCL USER INTERFACE ==================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder( + CMP_GLOBAL const CMP_Vec4uc *ImageSource, + CMP_GLOBAL CGU_UINT8 *ImageDestination, CMP_GLOBAL Source_Info *SourceInfo, + CMP_GLOBAL CMP_BC15Options *BC15options) { + CGU_UINT32 xID; + CGU_UINT32 yID; + +#ifdef ASPM_GPU + xID = get_global_id(0); + yID = get_global_id(1); +#else + xID = 0; + yID = 0; +#endif + + if (xID >= (SourceInfo->m_src_width / BlockX)) return; + if (yID >= (SourceInfo->m_src_height / BlockX)) return; + int srcWidth = SourceInfo->m_src_width; + + CGU_UINT32 destI = + (xID * BC4CompBlockSize) + (yID * (srcWidth / BlockX) * BC4CompBlockSize); + int srcindex = 4 * (yID * srcWidth + xID); + int blkindex = 0; + CMP_Vec4uc srcData[16]; + srcWidth = srcWidth - 4; + + for (CGU_INT32 j = 0; j < 4; j++) { + for (CGU_INT32 i = 0; i < 4; i++) { + srcData[blkindex++] = ImageSource[srcindex++]; + } + srcindex += srcWidth; + } + + CompressBlockBC4_Internal(srcData, (CMP_GLOBAL CGU_UINT32 *)&ImageDestination[destI], BC15options); +} +#endif diff --git a/extern/CMP_Core/shaders/BC4_Encode_kernel.h b/extern/CMP_Core/shaders/BC4_Encode_kernel.h new file mode 100644 index 00000000..62648cff --- /dev/null +++ b/extern/CMP_Core/shaders/BC4_Encode_kernel.h @@ -0,0 +1,31 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef BC4_ENCODE_KERNEL_H +#define BC4_ENCODE_KERNEL_H + +#include "Common_Def.h" +#include "BCn_Common_Kernel.h" + +#define BC4CompBlockSize 8 + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BC4_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC4_Encode_kernel.hlsl new file mode 100644 index 00000000..4f40ce11 --- /dev/null +++ b/extern/CMP_Core/shaders/BC4_Encode_kernel.hlsl @@ -0,0 +1,97 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// File: BC4Encode.hlsl +//-------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +#include "BCn_Common_Kernel.h" + +// Source Data +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +// Compressed Output Data +RWStructuredBuffer g_OutBuff : register( u0 ); + +// Processing multiple blocks at a time +#define MAX_USED_THREAD 16 // pixels in a BC (block compressed) block +#define BLOCK_IN_GROUP 4 // the number of BC blocks a thread group processes = 64 / 16 = 4 +#define THREAD_GROUP_SIZE 64 // 4 blocks where a block is (BLOCK_SIZE_X x BLOCK_SIZE_Y) +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 + +groupshared float4 shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + // we process 4 BC blocks per thread group + uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on + uint pixelBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group + uint pixelInBlock = GI - pixelBase; // id of the pixel in this BC block + + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + + // Load up the pixels + if (pixelInBlock < 16) + { + // load pixels (0..1) + shared_temp[GI] = float4(g_Input.Load( uint3( base_x + pixelInBlock % 4, base_y + pixelInBlock / 4, 0 ) )); + } + + GroupMemoryBarrierWithGroupSync(); + + // Process and save s + if (pixelInBlock == 0) + { + float block[16]; + // covert back to UV for processing!! + for ( uint i = 0; i < 16; i ++ ) + { + block[i].x = shared_temp[pixelBase + i].x; + } + g_OutBuff[blockID] = CompressBlockBC4_UNORM(block, g_quality); + } +} diff --git a/extern/CMP_Core/shaders/BC5_Encode_kernel.cpp b/extern/CMP_Core/shaders/BC5_Encode_kernel.cpp new file mode 100644 index 00000000..5862478c --- /dev/null +++ b/extern/CMP_Core/shaders/BC5_Encode_kernel.cpp @@ -0,0 +1,287 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#include "BC5_Encode_kernel.h" + +//============================================== BC5 INTERFACES ======================================================= + +CGU_Vec4ui CompressBC5Block_Internal(CMP_IN CGU_FLOAT aBlockU[16], CMP_IN CGU_FLOAT aBlockV[16], CMP_IN CGU_FLOAT fquality) +{ + CGU_Vec4ui compBlock; + CGU_Vec2ui cmpBlock; + + cmpBlock = cmp_compressAlphaBlock(aBlockU,fquality); + compBlock.x = cmpBlock.x; + compBlock.y = cmpBlock.y; + + cmpBlock = cmp_compressAlphaBlock(aBlockV,fquality); + compBlock.z = cmpBlock.x; + compBlock.w = cmpBlock.y; + return compBlock; +} + +#ifndef ASPM_HLSL +void CompressBlockBC5_Internal(CMP_Vec4uc srcBlockTemp[16], // range 0 to 255 + CMP_GLOBAL CGU_UINT32 compressedBlock[4], + CMP_GLOBAL CMP_BC15Options *BC15options) +{ + CGU_Vec4ui cmpBlock; + CGU_FLOAT alphaBlockU[16]; + CGU_FLOAT alphaBlockV[16]; + CGU_UINT32 i; + + for (i = 0; i < 16; i++) { + alphaBlockU[i] = srcBlockTemp[i].x / 255.0f; + alphaBlockV[i] = srcBlockTemp[i].y / 255.0f; + } + + cmpBlock = CompressBC5Block_Internal(alphaBlockU, alphaBlockV,BC15options->m_fquality); + compressedBlock[0] = cmpBlock.x; + compressedBlock[1] = cmpBlock.y; + compressedBlock[2] = cmpBlock.z; + compressedBlock[3] = cmpBlock.w; +} +#endif + +#ifndef ASPM_GPU +void DecompressBC5_Internal(CMP_GLOBAL CGU_UINT8 rgbaBlock[64], + CGU_UINT32 compressedBlock[4], + CMP_BC15Options *BC15options) +{ + CGU_UINT8 alphaBlockR[BLOCK_SIZE_4X4]; + CGU_UINT8 alphaBlockG[BLOCK_SIZE_4X4]; + + cmp_decompressAlphaBlock(alphaBlockR, &compressedBlock[0]); + cmp_decompressAlphaBlock(alphaBlockG, &compressedBlock[2]); + + CGU_UINT8 blkindex = 0; + CGU_UINT8 srcindex = 0; + + if (BC15options->m_mapDecodeRGBA) + { + for (CGU_INT32 j = 0; j < 4; j++) { + for (CGU_INT32 i = 0; i < 4; i++) { + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlockR[srcindex]; + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlockG[srcindex]; + rgbaBlock[blkindex++] = 0; + rgbaBlock[blkindex++] = 255; + srcindex++; + } + } + } + else + { + for (CGU_INT32 j = 0; j < 4; j++) { + for (CGU_INT32 i = 0; i < 4; i++) { + rgbaBlock[blkindex++] = 0; + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlockG[srcindex]; + rgbaBlock[blkindex++] = (CGU_UINT8)alphaBlockR[srcindex]; + rgbaBlock[blkindex++] = 255; + srcindex++; + } + } + } + +} + +void CompressBlockBC5_DualChannel_Internal(const CGU_UINT8 srcBlockR[16], + const CGU_UINT8 srcBlockG[16], + CMP_GLOBAL CGU_UINT32 compressedBlock[4], + CMP_GLOBAL const CMP_BC15Options *BC15options) +{ + if (BC15options) {} + CGU_Vec2ui cmpBlock; + CGU_FLOAT srcAlphaRF[16]; + CGU_FLOAT srcAlphaGF[16]; + + for (CGU_INT i =0; i< 16; i++) + { + srcAlphaRF[i] = srcBlockR[i]; + srcAlphaGF[i] = srcBlockG[i]; + } + + cmpBlock = cmp_compressAlphaBlock(srcAlphaRF,BC15options->m_fquality); + compressedBlock[0] = cmpBlock.x; + compressedBlock[1] = cmpBlock.y; + + cmpBlock = cmp_compressAlphaBlock(srcAlphaGF,BC15options->m_fquality); + compressedBlock[2] = cmpBlock.x; + compressedBlock[3] = cmpBlock.y; +} + +void DecompressBC5_DualChannel_Internal(CMP_GLOBAL CGU_UINT8 srcBlockR[16], + CMP_GLOBAL CGU_UINT8 srcBlockG[16], + const CGU_UINT32 compressedBlock[4], + const CMP_BC15Options *BC15options) +{ + if (BC15options) {} + cmp_decompressAlphaBlock(srcBlockR, &compressedBlock[0]); + cmp_decompressAlphaBlock(srcBlockG, &compressedBlock[2]); +} +#endif + +//============================================== USER INTERFACES ======================================================== +#ifndef ASPM_GPU + +int CMP_CDECL CreateOptionsBC5(void **options) +{ + CMP_BC15Options *BC15optionsDefault = new CMP_BC15Options; + if (BC15optionsDefault) { + SetDefaultBC15Options(BC15optionsDefault); + (*options) = BC15optionsDefault; + } + else { + (*options) = NULL; + return CGU_CORE_ERR_NEWMEM; + } + return CGU_CORE_OK; +} + +int CMP_CDECL DestroyOptionsBC5(void *options) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BCOptions = reinterpret_cast (options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC5(void *options, + CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + CMP_BC15Options *BC15optionsDefault = reinterpret_cast (options); + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC15optionsDefault->m_fquality = fquality; + return CGU_CORE_OK; +} + + +int CMP_CDECL CompressBlockBC5(const CGU_UINT8 *srcBlockR, + unsigned int srcStrideInBytes1, + const CGU_UINT8 *srcBlockG, + unsigned int srcStrideInBytes2, + CMP_GLOBAL CGU_UINT8 cmpBlock[16], + const void *options = NULL) { + CGU_UINT8 inBlockR[16]; + + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInBytes1; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlockR[dstptr++] = CGU_UINT8(srcBlockR[srcpos++]); + } + } + + + CGU_UINT8 inBlockG[16]; + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + srcpos = 0; + dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInBytes2; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlockG[dstptr++] = CGU_UINT8(srcBlockG[srcpos++]); + } + } + + + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + + CompressBlockBC5_DualChannel_Internal(inBlockR,inBlockG, (CMP_GLOBAL CGU_UINT32 *)cmpBlock, BC15options); + return CGU_CORE_OK; +} + +int CMP_CDECL DecompressBlockBC5(const CGU_UINT8 cmpBlock[16], + CMP_GLOBAL CGU_UINT8 srcBlockR[16], + CMP_GLOBAL CGU_UINT8 srcBlockG[16], + const void *options = NULL) { + CMP_BC15Options *BC15options = (CMP_BC15Options *)options; + CMP_BC15Options BC15optionsDefault; + if (BC15options == NULL) + { + BC15options = &BC15optionsDefault; + SetDefaultBC15Options(BC15options); + } + DecompressBC5_DualChannel_Internal(srcBlockR,srcBlockG,(CGU_UINT32 *)cmpBlock,BC15options); + + return CGU_CORE_OK; +} + +#endif + +//============================================== OpenCL USER INTERFACE ==================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder(CMP_GLOBAL const CMP_Vec4uc* ImageSource, + CMP_GLOBAL CGU_UINT8* ImageDestination, + CMP_GLOBAL Source_Info* SourceInfo, + CMP_GLOBAL CMP_BC15Options* BC15options +) +{ + CGU_UINT32 xID; + CGU_UINT32 yID; + +#ifdef ASPM_GPU + xID = get_global_id(0); + yID = get_global_id(1); +#else + xID = 0; + yID = 0; +#endif + + if (xID >= (SourceInfo->m_src_width / BlockX)) return; + if (yID >= (SourceInfo->m_src_height / BlockX)) return; + int srcWidth = SourceInfo->m_src_width; + + CGU_UINT32 destI = (xID*BC5CompBlockSize) + (yID*(srcWidth / BlockX)*BC5CompBlockSize); + int srcindex = 4 * (yID * srcWidth + xID); + int blkindex = 0; + CMP_Vec4uc srcData[16]; + srcWidth = srcWidth - 4; + + for ( CGU_INT32 j = 0; j < 4; j++) { + for ( CGU_INT32 i = 0; i < 4; i++) { + srcData[blkindex++] = ImageSource[srcindex++]; + } + srcindex += srcWidth; + } + + CompressBlockBC5_Internal(srcData, (CMP_GLOBAL CGU_UINT32 *)&ImageDestination[destI], BC15options); +} +#endif diff --git a/extern/CMP_Core/shaders/BC5_Encode_kernel.h b/extern/CMP_Core/shaders/BC5_Encode_kernel.h new file mode 100644 index 00000000..6c604a58 --- /dev/null +++ b/extern/CMP_Core/shaders/BC5_Encode_kernel.h @@ -0,0 +1,31 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef BC5_ENCODE_KERNEL_H +#define BC5_ENCODE_KERNEL_H + +#include "Common_Def.h" +#include "BCn_Common_Kernel.h" + +#define BC5CompBlockSize 16 + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BC5_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC5_Encode_kernel.hlsl new file mode 100644 index 00000000..0719e7ca --- /dev/null +++ b/extern/CMP_Core/shaders/BC5_Encode_kernel.hlsl @@ -0,0 +1,98 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// File: BC1Encode.hlsl +//-------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +#include "BCn_Common_Kernel.h" + +// Source Data +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +// Compressed Output Data +RWStructuredBuffer g_OutBuff : register( u0 ); + +// Processing multiple blocks at a time +#define MAX_USED_THREAD 16 // pixels in a BC (block compressed) block +#define BLOCK_IN_GROUP 4 // the number of BC blocks a thread group processes = 64 / 16 = 4 +#define THREAD_GROUP_SIZE 64 // 4 blocks where a block is (BLOCK_SIZE_X x BLOCK_SIZE_Y) +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 + +groupshared float4 shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + // we process 4 BC blocks per thread group + uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on + uint pixelBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group + uint pixelInBlock = GI - pixelBase; // id of the pixel in this BC block + + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + + // Load up the pixels + if (pixelInBlock < 16) + { + // load pixels (0..1) + shared_temp[GI] = float4(g_Input.Load( uint3( base_x + pixelInBlock % 4, base_y + pixelInBlock / 4, 0 ) )); + } + + GroupMemoryBarrierWithGroupSync(); + + // Process and save s + if (pixelInBlock == 0) + { + float blockU[16]; + float blockV[16]; + for ( uint i = 0; i < 16; i ++ ) + { + blockU[i] = shared_temp[pixelBase + i].x; + blockV[i] = shared_temp[pixelBase + i].y; + } + g_OutBuff[blockID] = CompressBlockBC5_UNORM(blockU,blockV,g_quality); + } +} diff --git a/extern/CMP_Core/shaders/BC6_Encode_kernel.cpp b/extern/CMP_Core/shaders/BC6_Encode_kernel.cpp new file mode 100644 index 00000000..6b3ea728 --- /dev/null +++ b/extern/CMP_Core/shaders/BC6_Encode_kernel.cpp @@ -0,0 +1,3990 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#include "BC6_Encode_kernel.h" + +#ifdef ASPM_GPU +void memset(CGU_UINT8 *srcdata, CGU_UINT8 value, CGU_INT size) +{ + for (CGU_INT i = 0; i < size; i++) + *srcdata++ = value; +} + +void memcpy(CGU_UINT8 *dstdata, CGU_UINT8 *srcdata, CGU_INT size) +{ + for (CGU_INT i = 0; i < size; i++) + { + *dstdata = *srcdata; + srcdata++; + dstdata++; + } +} + +void swap(CGU_INT A, CGU_INT B) +{ + CGU_INT hold = A; + A = B; + B = hold; +} + +#define abs fabs +#define floorf floor +#define sqrtf sqrt +#define logf log +#define ceilf ceil + +#endif + +__constant CGU_UINT8 BC6_PARTITIONS[MAX_BC6H_PARTITIONS][MAX_SUBSET_SIZE] = { + { // 0 + 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1 + }, + + { // 1 + 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1 + }, + + { // 2 + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1 + }, + + { // 3 + 0,0,0,1,0,0,1,1,0,0,1,1,0,1,1,1 + }, + + { // 4 + 0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,1 + }, + + { // 5 + 0,0,1,1,0,1,1,1, 0,1,1,1,1,1,1,1 + }, + + { // 6 + 0,0,0,1,0,0,1,1,0,1,1,1,1,1,1,1 + }, + + { // 7 + 0,0,0,0,0,0,0,1,0,0,1,1,0,1,1,1 + }, + + { // 8 + 0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1 + }, + + { // 9 + 0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1 + }, + + { // 10 + 0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1 + }, + + { // 11 + 0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1 + }, + + { // 12 + 0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1 + }, + + { // 13 + 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1 + }, + + { // 14 + 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1 + }, + + { // 15 + 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1 + }, + + { // 16 + 0,0,0,0,1,0,0,0,1,1,1,0,1,1,1,1 + }, + + { // 17 + 0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0 + }, + + { // 18 + 0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0 + }, + + { // 19 + 0,1,1,1,0,0,1,1,0,0,0,1,0,0,0,0 + }, + + { // 20 + 0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0 + }, + + { // 21 + 0,0,0,0,1,0,0,0,1,1,0,0,1,1,1,0 + }, + + { // 22 + 0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0 + }, + + { // 23 + 0,1,1,1,0,0,1,1,0,0,1,1,0,0,0,1 + }, + + { // 24 + 0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0 + }, + + { // 25 + 0,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0 + }, + + { // 26 + 0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0 + }, + + { // 27 + 0,0,1,1,0,1,1,0,0,1,1,0,1,1,0,0 + }, + + { // 28 + 0,0,0,1,0,1,1,1,1,1,1,0,1,0,0,0 + }, + + { // 29 + 0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0 + }, + + { // 30 + 0,1,1,1,0,0,0,1,1,0,0,0,1,1,1,0 + }, + + { // 31 + 0,0,1,1,1,0,0,1,1,0,0,1,1,1,0,0 + }, +}; + +CGU_DWORD get_partition_subset(CGU_INT subset, CGU_INT partI, CGU_INT index) +{ + if (subset) + return BC6_PARTITIONS[partI][index]; + else + return 0; +} + +void Partition(CGU_INT shape, + CGU_FLOAT in[][MAX_DIMENSION_BIG], + CGU_FLOAT subsets[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG], //[3][16][4] + CGU_INT count[MAX_SUBSETS], + CGU_INT8 ShapeTableToUse, + CGU_INT dimension) +{ + int i, j; + int insubset = -1, inpart = 0; + + // Dont use memset: this is better for now + for (i = 0; i < MAX_SUBSETS; i++) count[i] = 0; + + switch (ShapeTableToUse) + { + case 0: + case 1: + insubset = 0; + inpart = 0; + break; + case 2: + insubset = 1; + inpart = shape; + break; + default: + break; + } + + // Nothing to do!!: Must indicate an error to user + if (insubset == -1) return; // Nothing to do!! + + for (i = 0; i < MAX_SUBSET_SIZE; i++) + { + int subset = get_partition_subset(insubset, inpart, i); + for (j = 0; j < dimension; j++) + { + subsets[subset][count[subset]][j] = in[i][j]; + } + if (dimension < MAX_DIMENSION_BIG) + { + subsets[subset][count[subset]][j] = 0.0; + } + count[subset]++; + } + +} + +void GetEndPoints(CGU_FLOAT EndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_FLOAT outB[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG], CGU_INT max_subsets, int entryCount[MAX_SUBSETS]) +{ + // Should have some sort of error notification! + if (max_subsets > MAX_SUBSETS) return; + + // Save Min and Max OutB points as EndPoints + for (int subset = 0; subset < max_subsets; subset++) + { + // We now have points on direction vector(s) + // find the min and max points + CGU_FLOAT min = CMP_HALF_MAX; + CGU_FLOAT max = 0; + CGU_FLOAT val; + int mini = 0; + int maxi = 0; + + + for (int i = 0; i < entryCount[subset]; i++) + { + val = outB[subset][i][0] + outB[subset][i][1] + outB[subset][i][2]; + if (val < min) + { + min = val; + mini = i; + } + if (val > max) + { + max = val; + maxi = i; + } + } + + // Is round best for this ! + for (int c = 0; c < MAX_DIMENSION_BIG; c++) + { + EndPoints[subset][0][c] = outB[subset][mini][c]; + } + + for (int c = 0; c < MAX_DIMENSION_BIG; c++) + { + EndPoints[subset][1][c] = outB[subset][maxi][c]; + } + } +} + +void covariance_d(CGU_FLOAT data[][MAX_DIMENSION_BIG], CGU_INT numEntries, CGU_FLOAT cov[MAX_DIMENSION_BIG][MAX_DIMENSION_BIG], CGU_INT dimension) +{ +#ifdef USE_DBGTRACE + DbgTrace(()); +#endif + int i, j, k; + + for (i = 0; i < dimension; i++) + for (j = 0; j <= i; j++) + { + cov[i][j] = 0; + for (k = 0; k < numEntries; k++) + cov[i][j] += data[k][i] * data[k][j]; + } + + for (i = 0; i < dimension; i++) + for (j = i + 1; j < dimension; j++) + cov[i][j] = cov[j][i]; +} + +void centerInPlace_d(CGU_FLOAT data[][MAX_DIMENSION_BIG], int numEntries, CGU_FLOAT mean[MAX_DIMENSION_BIG], CGU_INT dimension) +{ +#ifdef USE_DBGTRACE + DbgTrace(()); +#endif + int i, k; + + for (i = 0; i < dimension; i++) + { + mean[i] = 0; + for (k = 0; k < numEntries; k++) + mean[i] += data[k][i]; + } + + if (!numEntries) + return; + + for (i = 0; i < dimension; i++) + { + mean[i] /= numEntries; + for (k = 0; k < numEntries; k++) + data[k][i] -= mean[i]; + } +} + +void eigenVector_d(CGU_FLOAT cov[MAX_DIMENSION_BIG][MAX_DIMENSION_BIG], CGU_FLOAT vector[MAX_DIMENSION_BIG], CGU_INT dimension) +{ +#ifdef USE_DBGTRACE + DbgTrace(()); +#endif + // calculate an eigenvecto corresponding to a biggest eigenvalue + // will work for non-zero non-negative matricies only + +#define EV_ITERATION_NUMBER 20 +#define EV_SLACK 2 /* additive for exp base 2)*/ + + + CGU_INT i, j, k, l, m, n, p, q; + CGU_FLOAT c[2][MAX_DIMENSION_BIG][MAX_DIMENSION_BIG]; + CGU_FLOAT maxDiag; + + for (i = 0; i < dimension; i++) + for (j = 0; j < dimension; j++) + c[0][i][j] = cov[i][j]; + + p = (int)floorf(log((FLT_MAX_EXP - EV_SLACK) / ceilf(logf((CGU_FLOAT)dimension) / logf(2.0f))) / logf(2.0f)); + + //assert(p>0); + + p = p > 0 ? p : 1; + + q = (EV_ITERATION_NUMBER + p - 1) / p; + + l = 0; + + for (n = 0; n < q; n++) + { + maxDiag = 0; + + for (i = 0; i < dimension; i++) + maxDiag = c[l][i][i] > maxDiag ? c[l][i][i] : maxDiag; + + if (maxDiag <= 0) + { + return; + } + + //assert(maxDiag >0); + + for (i = 0; i < dimension; i++) + for (j = 0; j < dimension; j++) + c[l][i][j] /= maxDiag; + + for (m = 0; m < p; m++) { + for (i = 0; i < dimension; i++) + for (j = 0; j < dimension; j++) { + CGU_FLOAT temp = 0; + for (k = 0; k < dimension; k++) + { + // Notes: + // This is the most consuming portion of the code and needs optimizing for perfromance + temp += c[l][i][k] * c[l][k][j]; + } + c[1 - l][i][j] = temp; + } + l = 1 - l; + } + } + + maxDiag = 0; + k = 0; + + for (i = 0; i < dimension; i++) + { + k = c[l][i][i] > maxDiag ? i : k; + maxDiag = c[l][i][i] > maxDiag ? c[l][i][i] : maxDiag; + } + CGU_FLOAT t; + t = 0; + for (i = 0; i < dimension; i++) + { + t += c[l][k][i] * c[l][k][i]; + vector[i] = c[l][k][i]; + } + // normalization is really optional + t = sqrtf(t); + //assert(t>0); + + if (t <= 0) + { + return; + } + for (i = 0; i < dimension; i++) + vector[i] /= t; +} + +void project_d(CGU_FLOAT data[][MAX_DIMENSION_BIG], CGU_INT numEntries, CGU_FLOAT vector[MAX_DIMENSION_BIG], CGU_FLOAT projection[MAX_ENTRIES], CGU_INT dimension) +{ +#ifdef USE_DBGTRACE + DbgTrace(()); +#endif + // assume that vector is normalized already + int i, k; + + for (k = 0; k < numEntries; k++) + { + projection[k] = 0; + for (i = 0; i < dimension; i++) + { + projection[k] += data[k][i] * vector[i]; + } + } +} + +typedef struct { + CGU_FLOAT d; + int i; +} a; + +inline CGU_INT a_compare(const void *arg1, const void *arg2) +{ + if (((a*)arg1)->d - ((a*)arg2)->d > 0) return 1; + if (((a*)arg1)->d - ((a*)arg2)->d < 0) return -1; + return 0; +}; + +void sortProjection(CGU_FLOAT projection[MAX_ENTRIES], CGU_INT order[MAX_ENTRIES], CGU_INT numEntries) +{ + int i; + a what[MAX_ENTRIES + MAX_PARTITIONS_TABLE]; + + for (i = 0; i < numEntries; i++) + what[what[i].i = i].d = projection[i]; + +#ifdef USE_QSORT + qsort((void*)&what, numEntries, sizeof(a), a_compare); +#else + { + int j; + int tmp; + CGU_FLOAT tmp_d; + for (i = 1; i < numEntries; i++) + { + for (j = i; j > 0; j--) + { + if (what[j - 1].d > what[j].d) + { + tmp = what[j].i; + tmp_d = what[j].d; + what[j].i = what[j - 1].i; + what[j].d = what[j - 1].d; + what[j - 1].i = tmp; + what[j - 1].d = tmp_d; + } + } + } + } +#endif + + + for (i = 0; i < numEntries; i++) + order[i] = what[i].i; +}; + +CGU_FLOAT totalError_d(CGU_FLOAT data[MAX_ENTRIES][MAX_DIMENSION_BIG], CGU_FLOAT data2[MAX_ENTRIES][MAX_DIMENSION_BIG], CGU_INT numEntries, CGU_INT dimension) +{ + int i, j; + CGU_FLOAT t = 0; + for (i = 0; i < numEntries; i++) + for (j = 0; j < dimension; j++) + t += (data[i][j] - data2[i][j])*(data[i][j] - data2[i][j]); + + return t; +}; + +// input: +// +// v_ points, might be uncentered +// k - number of points in the ramp +// n - number of points in v_ +// +// output: +// index, uncentered, in the range 0..k-1 +// + +void quant_AnD_Shell(CGU_FLOAT* v_, CGU_INT k, CGU_INT n, CGU_INT idx[MAX_ENTRIES]) +{ +#define MAX_BLOCK MAX_ENTRIES + CGU_INT i, j; + CGU_FLOAT v[MAX_BLOCK]; + CGU_FLOAT z[MAX_BLOCK]; + a d[MAX_BLOCK]; + CGU_FLOAT l; + CGU_FLOAT mm; + CGU_FLOAT r = 0; + CGU_INT mi; + + CGU_FLOAT m, M, s, dm = 0.; + m = M = v_[0]; + + for (i = 1; i < n; i++) { + m = m < v_[i] ? m : v_[i]; + M = M > v_[i] ? M : v_[i]; + } + if (M == m) { + for (i = 0; i < n; i++) + idx[i] = 0; + return; + } + + //assert(M - m >0); + s = (k - 1) / (M - m); + for (i = 0; i < n; i++) { + v[i] = v_[i] * s; + + idx[i] = (int)(z[i] = (v[i] + 0.5f /* stabilizer*/ - m * s)); //floorf(v[i] + 0.5f /* stabilizer*/ - m *s)); + + d[i].d = v[i] - z[i] - m * s; + d[i].i = i; + dm += d[i].d; + r += d[i].d*d[i].d; + } + if (n*r - dm * dm >= (CGU_FLOAT)(n - 1) / 4 /*slack*/ / 2) { + + dm /= (CGU_FLOAT)n; + + for (i = 0; i < n; i++) + d[i].d -= dm; + + + //!!! Need an OpenCL version of qsort +#ifdef USE_QSORT + qsort((void*)&d, n, sizeof(a), a_compare); +#else + { + CGU_INT tmp; + CGU_FLOAT tmp_d; + for (i = 1; i < n; i++) { + for (j = i; j > 0; j--) + { + if (d[j - 1].d > d[j].d) + { + tmp = d[j].i; + tmp_d = d[j].d; + d[j].i = d[j - 1].i; + d[j].d = d[j - 1].d; + d[j - 1].i = tmp; + d[j - 1].d = tmp_d; + } + } + } + } +#endif + // got into fundamental simplex + // move coordinate system origin to its center + for (i = 0; i < n; i++) + d[i].d -= (2.0f*(CGU_FLOAT)i + 1.0f - (CGU_FLOAT)n) / 2.0f / (CGU_FLOAT)n; + + mm = l = 0.; + j = -1; + for (i = 0; i < n; i++) { + l += d[i].d; + if (l < mm) { + mm = l; + j = i; + } + } + + // position which should be in 0 + j = j + 1; + j = j % n; + + for (i = j; i < n; i++) + idx[d[i].i]++; + } + // get rid of an offset in idx + mi = idx[0]; + for (i = 1; i < n; i++) + mi = mi < idx[i] ? mi : idx[i]; + + for (i = 0; i < n; i++) + idx[i] -= mi; +} + +CGU_FLOAT optQuantAnD_d(CGU_FLOAT data[MAX_ENTRIES][MAX_DIMENSION_BIG], + CGU_INT numEntries, + CGU_INT numClusters, + CGU_INT index[MAX_ENTRIES], + CGU_FLOAT out[MAX_ENTRIES][MAX_DIMENSION_BIG], + CGU_FLOAT direction[MAX_DIMENSION_BIG], CGU_FLOAT *step, + CGU_INT dimension, + CGU_FLOAT quality) +{ + CGU_INT index_[MAX_ENTRIES]; + + CGU_INT maxTry = (int)(MAX_TRY * quality); + CGU_INT try_two = 50; + + CGU_INT i, j, k; + CGU_FLOAT t, s; + + CGU_FLOAT centered[MAX_ENTRIES][MAX_DIMENSION_BIG]; + + CGU_FLOAT mean[MAX_DIMENSION_BIG]; + + CGU_FLOAT cov[MAX_DIMENSION_BIG][MAX_DIMENSION_BIG]; + + CGU_FLOAT projected[MAX_ENTRIES]; + + CGU_INT order_[MAX_ENTRIES]; + + + for (i = 0; i < numEntries; i++) + for (j = 0; j < dimension; j++) + centered[i][j] = data[i][j]; + + centerInPlace_d(centered, numEntries, mean, dimension); + covariance_d(centered, numEntries, cov, dimension); + + // check if they all are the same + + t = 0; + for (j = 0; j < dimension; j++) + t += cov[j][j]; + + if (numEntries == 0) { + for (i = 0; i < numEntries; i++) { + index[i] = 0; + for (j = 0; j < dimension; j++) + out[i][j] = mean[j]; + } + return 0.0f; + } + + eigenVector_d(cov, direction, dimension); + project_d(centered, numEntries, direction, projected, dimension); + + for (i = 0; i < maxTry; i++) + { + CGU_INT done = 0; + + if (i) + { + do + { + CGU_FLOAT q; + q = s = t = 0; + + for (k = 0; k < numEntries; k++) + { + s += index[k]; + t += index[k] * index[k]; + } + + for (j = 0; j < dimension; j++) + { + direction[j] = 0; + for (k = 0; k < numEntries; k++) + direction[j] += centered[k][j] * index[k]; + q += direction[j] * direction[j]; + + } + + s /= (CGU_FLOAT)numEntries; + t = t - s * s * (CGU_FLOAT)numEntries; + //assert(t != 0); + t = (t == 0.0f ? 0.0f : 1.0f / t); + // We need to requantize + + q = sqrtf(q); + t *= q; + + if (q != 0) + for (j = 0; j < dimension; j++) + direction[j] /= q; + + // direction normalized + + project_d(centered, numEntries, direction, projected, dimension); + sortProjection(projected, order_, numEntries); + + CGU_INT index__[MAX_ENTRIES]; + + // it's projected and centered; cluster centers are (index[i]-s)*t (*dir) + k = 0; + for (j = 0; j < numEntries; j++) + { + while (projected[order_[j]] > (k + 0.5 - s)*t && k < numClusters - 1) + k++; + index__[order_[j]] = k; + } + done = 1; + for (j = 0; j < numEntries; j++) + { + done = (done && (index__[j] == index[j])); + index[j] = index__[j]; + } + } while (!done && try_two--); + + if (i == 1) + for (j = 0; j < numEntries; j++) + index_[j] = index[j]; + else + { + done = 1; + for (j = 0; j < numEntries; j++) + { + done = (done && (index_[j] == index[j])); + index_[j] = index_[j]; + } + if (done) + break; + + } + } + + quant_AnD_Shell(projected, numClusters, numEntries, index); + } + s = t = 0; + + CGU_FLOAT q = 0; + + for (k = 0; k < numEntries; k++) + { + s += index[k]; + t += index[k] * index[k]; + } + + for (j = 0; j < dimension; j++) + { + direction[j] = 0; + for (k = 0; k < numEntries; k++) + direction[j] += centered[k][j] * index[k]; + q += direction[j] * direction[j]; + } + + s /= (CGU_FLOAT)numEntries; + + t = t - s * s * (CGU_FLOAT)numEntries; + + //assert(t != 0); + + t = (t == 0.0 ? 0.0f : 1.0f / t); + + for (i = 0; i < numEntries; i++) + for (j = 0; j < dimension; j++) + out[i][j] = mean[j] + direction[j] * t*(index[i] - s); + + // normalize direction for output + + q = sqrtf(q); + *step = t * q; + for (j = 0; j < dimension; j++) + direction[j] /= q; + + return totalError_d(data, out, numEntries, dimension); +} + +void clampF16Max(CGU_FLOAT EndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_BOOL isSigned) +{ + for (CGU_INT region = 0; region < 2; region++) + for (CGU_INT ab = 0; ab < 2; ab++) + for (CGU_INT rgb = 0; rgb < 3; rgb++) + { + if (isSigned) + { + if (EndPoints[region][ab][rgb] < -FLT16_MAX) EndPoints[region][ab][rgb] = -FLT16_MAX; + else if (EndPoints[region][ab][rgb] > FLT16_MAX) EndPoints[region][ab][rgb] = FLT16_MAX; + } + else + { + if (EndPoints[region][ab][rgb] < 0.0) EndPoints[region][ab][rgb] = 0.0; + else if (EndPoints[region][ab][rgb] > FLT16_MAX) EndPoints[region][ab][rgb] = FLT16_MAX; + } + // Zero region + // if ((EndPoints[region][ab][rgb] > -0.01) && ((EndPoints[region][ab][rgb] < 0.01))) EndPoints[region][ab][rgb] = 0.0; + } +} + +//===================================================================================================================== +#define LOG_CL_BASE 2 +#define BIT_BASE 5 +#define LOG_CL_RANGE 5 +#define BIT_RANGE 9 +#define MAX_CLUSTERS_BIG 16 +#define BTT(bits) (bits-BIT_BASE) +#define CLT(cl) (cl-LOG_CL_BASE) + +#ifdef USE_BC6RAMPS + +int spidx(int in_data, int in_clogs, int in_bits, int in_p2, int in_o1, int in_o2, int in_i) +{ + // use BC7 sp_idx + return 0; +} + +float sperr(int in_data, int clogs, int bits, int p2, int o1, int o2) +{ + // use BC7 sp_err + return 0,0f; +} +#endif + +__constant CGU_FLOAT rampLerpWeightsBC6[5][16] = +{ + { 0.0 }, // 0 bit index + { 0.0, 1.0 }, // 1 bit index + { 0.0, 21.0 / 64.0, 43.0 / 64.0, 1.0 }, // 2 bit index + { 0.0, 9.0 / 64.0, 18.0 / 64.0, 27.0 / 64.0, 37.0 / 64.0, 46.0 / 64.0, 55.0 / 64.0, 1.0 }, // 3 bit index + { 0.0, 4.0 / 64.0, 9.0 / 64.0, 13.0 / 64.0, 17.0 / 64.0, 21.0 / 64.0, 26.0 / 64.0, 30.0 / 64.0, + 34.0 / 64.0, 38.0 / 64.0, 43.0 / 64.0, 47.0 / 64.0, 51.0 / 64.0, 55.0 / 64.0, 60.0 / 64.0, 1.0 } // 4 bit index +}; + + +CGU_FLOAT rampf(CGU_INT clogs, CGU_FLOAT p1, CGU_FLOAT p2, CGU_INT indexPos) +{ + // (clogs+ LOG_CL_BASE) starts from 2 to 4 + return (CGU_FLOAT)p1 + rampLerpWeightsBC6[clogs + LOG_CL_BASE][indexPos] * (p2 - p1); +} + +CGU_INT all_same_d(CGU_FLOAT d[][MAX_DIMENSION_BIG], CGU_INT n, CGU_INT dimension) +{ + CGU_INT i, j; + CGU_INT same = 1; + for (i = 1; i < n; i++) + for (j = 0; j < dimension; j++) + same = same && (d[0][j] == d[i][j]); + + return(same); +} + +// return the max index from a set of indexes +CGU_INT max_index(CGU_INT a[], CGU_INT n) +{ + CGU_INT i, m = a[0]; + for (i = 0; i < n; i++) + m = m > a[i] ? m : a[i]; + return (m); +} + +CGU_INT cluster_mean_d_d(CGU_FLOAT d[MAX_ENTRIES][MAX_DIMENSION_BIG], CGU_FLOAT mean[MAX_ENTRIES][MAX_DIMENSION_BIG], CGU_INT index[], CGU_INT i_comp[], CGU_INT i_cnt[], CGU_INT n, CGU_INT dimension) +{ + // unused index values are underfined + CGU_INT i, j, k; + //assert(n!=0); + + for (i = 0; i < n; i++) + for (j = 0; j < dimension; j++) { + // assert(index[i] index[k] ? Mi : index[k]; + } + D = 1; + for (d = 2; d <= Mi - mi; d++) { + + for (k = 0; k < numEntries; k++) + if ((index[k] - mi) % d != 0) + break; + if (k >= numEntries) + D = d; + } + for (k = 0; k < numEntries; k++) + index[k] = (index[k] - mi) / D; +} + +CGU_INT max_int(CGU_INT a[], CGU_INT n) +{ + CGU_INT i, m = a[0]; + for (i = 0; i < n; i++) + m = m > a[i] ? m : a[i]; + return (m); +} + +__constant CGU_INT npv_nd[2][2 * MAX_DIMENSION_BIG] = +{ + { 1,2,4,8,16,32,0,0 }, //dimension = 3 + { 1,2,4,0,0,0,0,0 } //dimension = 4 +}; + +__constant short par_vectors_nd[2][8][128][2][MAX_DIMENSION_BIG] = +{ + { // Dimension = 3 + { + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 0,0,0,0 },{ 0,0,0,0 } } + }, + + // 3*n+1 BCC 3*n+1 Cartesian 3*n //same parity + { // SAME_PAR + { { 0,0,0 },{ 0,0,0 } }, + { { 1,1,1 },{ 1,1,1 } } + }, + // 3*n+2 BCC 3*n+1 BCC 3*n+1 + { // BCC + { { 0,0,0 },{ 0,0,0 } }, + { { 0,0,0 },{ 1,1,1 } }, + { { 1,1,1 },{ 0,0,0 } }, + { { 1,1,1 },{ 1,1,1 } } + }, + // 3*n+3 FCC ??? // ?????? + // BCC with FCC same or inverted, symmetric + { // BCC_SAME_FCC + { { 0,0,0 },{ 0,0,0 } }, + { { 1,1,0 },{ 1,1,0 } }, + { { 1,0,1 },{ 1,0,1 } }, + { { 0,1,1 },{ 0,1,1 } }, + + { { 0,0,0 },{ 1,1,1 } }, + { { 1,1,1 },{ 0,0,0 } }, + { { 0,1,0 },{ 0,1,0 } }, // ?? + { { 1,1,1 },{ 1,1,1 } }, + + }, + // 3*n+4 FCC 3*n+2 FCC 3*n+2 + { + + { { 0,0,0 },{ 0,0,0 } }, + { { 1,1,0 },{ 0,0,0 } }, + { { 1,0,1 },{ 0,0,0 } }, + { { 0,1,1 },{ 0,0,0 } }, + + { { 0,0,0 },{ 1,1,0 } }, + { { 1,1,0 },{ 1,1,0 } }, + { { 1,0,1 },{ 1,1,0 } }, + { { 0,1,1 },{ 1,1,0 } }, + + { { 0,0,0 },{ 1,0,1 } }, + { { 1,1,0 },{ 1,0,1 } }, + { { 1,0,1 },{ 1,0,1 } }, + { { 0,1,1 },{ 1,0,1 } }, + + { { 0,0,0 },{ 0,1,1 } }, + { { 1,1,0 },{ 0,1,1 } }, + { { 1,0,1 },{ 0,1,1 } }, + { { 0,1,1 },{ 0,1,1 } } + }, + + + // 3*n+5 Cartesian 3*n+3 FCC 3*n+2 //D^*[6] + { + + { { 0,0,0 },{ 0,0,0 } }, + { { 1,1,0 },{ 0,0,0 } }, + { { 1,0,1 },{ 0,0,0 } }, + { { 0,1,1 },{ 0,0,0 } }, + + { { 0,0,0 },{ 1,1,0 } }, + { { 1,1,0 },{ 1,1,0 } }, + { { 1,0,1 },{ 1,1,0 } }, + { { 0,1,1 },{ 1,1,0 } }, + + { { 0,0,0 },{ 1,0,1 } }, + { { 1,1,0 },{ 1,0,1 } }, + { { 1,0,1 },{ 1,0,1 } }, + { { 0,1,1 },{ 1,0,1 } }, + + { { 0,0,0 },{ 0,1,1 } }, + { { 1,1,0 },{ 0,1,1 } }, + { { 1,0,1 },{ 0,1,1 } }, + { { 0,1,1 },{ 0,1,1 } }, + + + { { 1,0,0 },{ 1,1,1 } }, + { { 0,1,0 },{ 1,1,1 } }, + { { 0,0,1 },{ 1,1,1 } }, + { { 1,1,1 },{ 1,1,1 } }, + + { { 1,0,0 },{ 0,0,1 } }, + { { 0,1,0 },{ 0,0,1 } }, + { { 0,0,1 },{ 0,0,1 } }, + { { 1,1,1 },{ 0,0,1 } }, + + { { 1,0,0 },{ 1,0,0 } }, + { { 0,1,0 },{ 1,0,0 } }, + { { 0,0,1 },{ 1,0,0 } }, + { { 1,1,1 },{ 1,0,0 } }, + + { { 1,0,0 },{ 0,1,0 } }, + { { 0,1,0 },{ 0,1,0 } }, + { { 0,0,1 },{ 0,1,0 } }, + { { 1,1,1 },{ 0,1,0 } } + } + },// Dimension = 3 + { // Dimension = 4 + { + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 0,0,0,0 },{ 0,0,0,0 } } + }, + + // 3*n+1 BCC 3*n+1 Cartesian 3*n //same parity + { // SAME_PAR + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 1,1,1,1 },{ 1,1,1,1 } } + }, + // 3*n+2 BCC 3*n+1 BCC 3*n+1 + { // BCC + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 0,0,0,0 },{ 1,1,1,1 } }, + { { 1,1,1,1 },{ 0,0,0,0 } }, + { { 1,1,1,1 },{ 1,1,1,1 } } + }, + // 3 PBIT + { + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 0,0,0,0 },{ 0,1,1,1 } }, + { { 0,1,1,1 },{ 0,0,0,0 } }, + { { 0,1,1,1 },{ 0,1,1,1 } }, + + { { 1,0,0,0 },{ 1,0,0,0 } }, + { { 1,0,0,0 },{ 1,1,1,1 } }, + { { 1,1,1,1 },{ 1,0,0,0 } }, + { { 1,1,1,1 },{ 1,1,1,1 } } + }, + + // 4 PBIT + { + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 0,0,0,0 },{ 0,1,1,1 } }, + { { 0,1,1,1 },{ 0,0,0,0 } }, + { { 0,1,1,1 },{ 0,1,1,1 } }, + + { { 1,0,0,0 },{ 1,0,0,0 } }, + { { 1,0,0,0 },{ 1,1,1,1 } }, + { { 1,1,1,1 },{ 1,0,0,0 } }, + { { 1,1,1,1 },{ 1,1,1,1 } }, + + { { 0,0,0,0 },{ 0,0,0,0 } }, + { { 0,0,0,0 },{ 0,0,1,1 } }, + { { 0,0,1,1 },{ 0,0,0,0 } }, + { { 0,1,0,1 },{ 0,1,0,1 } }, + + { { 1,0,0,0 },{ 1,0,0,0 } }, + { { 1,0,0,0 },{ 1,0,1,1 } }, + { { 1,0,1,1 },{ 1,0,0,0 } }, + { { 1,1,0,1 },{ 1,1,0,1 } }, + + }, + + } // Dimension = 4 + +}; + +CGU_INT get_par_vector(CGU_INT dim1, CGU_INT dim2, CGU_INT dim3, CGU_INT dim4, CGU_INT dim5) +{ + return par_vectors_nd[dim1][dim2][dim3][dim4][dim5]; +} + +CGU_FLOAT quant_single_point_d(CGU_FLOAT data[MAX_ENTRIES][MAX_DIMENSION_BIG], + CGU_INT numEntries, CGU_INT index[MAX_ENTRIES], + CGU_FLOAT out[MAX_ENTRIES][MAX_DIMENSION_BIG], + CGU_INT epo_1[2][MAX_DIMENSION_BIG], + CGU_INT Mi_, // last cluster + CGU_INT type, + CGU_INT dimension) +{ + if (dimension < 3) return CMP_FLOAT_MAX; + + CGU_INT i, j; + + CGU_FLOAT err_0 = CMP_FLOAT_MAX; + CGU_FLOAT err_1 = CMP_FLOAT_MAX; + + CGU_INT idx = 0; + CGU_INT idx_1 = 0; + + CGU_INT epo_0[2][MAX_DIMENSION_BIG]; + + CGU_INT use_par = (type != 0); + + CGU_INT clogs = 0; + i = Mi_ + 1; + while (i >>= 1) + clogs++; + + // assert((1< sperr(tc, CLT(clogs), BTT(bits[j]), t1, t2, i)) + dr[j] = tc; + else if (sperr(tf, CLT(clogs), BTT(bits[j]), t1, t2, i) < sperr(tc, CLT(clogs), BTT(bits[j]), t1, t2, i)) + dr[j] = tf; + else +#endif + dr[j] = (int)floorf(data[0][j] + 0.5f); + +#ifdef USE_BC6RAMPS + tr = sperr(dr[j], CLT(clogs), BTT(bits[j]), t1, t2, i) + 2.0f * sqrtf(sperr(dr[j], CLT(clogs), BTT(bits[j]), t1, t2, i)) * fabsf((float)dr[j] - data[0][j]) + + (dr[j] - data[0][j])* (dr[j] - data[0][j]); + if (tr < t_) + { + t_ = tr; +#else + t_ = 0; +#endif + + t1o[j] = t1; + t2o[j] = t2; + dr_0[j] = dr[j]; +#ifdef USE_BC6RAMPS + if ((dr_0[j] < 0) || (dr_0[j] > 255)) + { + dr_0[j] = 0; // Error! + } + } +#endif + } // B + } //C + + t += t_; + } // D + + + if (t < err_0) + { + + idx = i; + + for (j = 0; j < dimension; j++) + { +#ifdef USE_BC6RAMPS + CGU_INT p1 = CLT(clogs); // < 3 + CGU_INT p2 = BTT(bits[j]); // < 4 + CGU_INT in_data = dr_0[j]; // < SP_ERRIDX_MAX + CGU_INT p4 = t1o[j]; // < 2 + CGU_INT p5 = t2o[j]; // < 2 + CGU_INT p6 = i; // < 16 + + // New spidx + epo_0[0][j] = spidx(in_data, p1, p2, p4, p5, p6, 0); + epo_0[1][j] = spidx(in_data, p1, p2, p4, p5, p6, 1); + + if (epo_0[1][j] >= SP_ERRIDX_MAX) + { + epo_0[1][j] = 0; // Error!! + } +#else + epo_0[0][j] = 0; + epo_0[1][j] = 0; +#endif + } + err_0 = t; + } + if (err_0 == 0) + break; + } // E + + if (err_0 < err_1) + { + idx_1 = idx; + for (j = 0; j < dimension; j++) + { + epo_1[0][j] = epo_0[0][j]; + epo_1[1][j] = epo_0[1][j]; + } + err_1 = err_0; + } + + if (err_1 == 0) + break; + } //1 + +for (i = 0; i < numEntries; i++) +{ + index[i] = idx_1; + for (j = 0; j < dimension; j++) + { + CGU_INT p1 = CLT(clogs); // < 3 + CGU_INT p3 = epo_1[0][j]; // < SP_ERRIDX_MAX + CGU_INT p4 = epo_1[1][j]; // < SP_ERRIDX_MAX + CGU_INT p5 = idx_1; // < 16 +#pragma warning( push ) +#pragma warning(disable:4244) + out[i][j] = (int)rampf(p1, p3, p4, p5); +#pragma warning( pop ) + } +} +return err_1 * numEntries; +} + +//======================================================================================================================== + +CGU_FLOAT ep_shaker_HD(CGU_FLOAT data[MAX_ENTRIES][MAX_DIMENSION_BIG], + CGU_INT numEntries, + CGU_INT index_[MAX_ENTRIES], + CGU_FLOAT out[MAX_ENTRIES][MAX_DIMENSION_BIG], + CGU_INT epo_code_out[2][MAX_DIMENSION_BIG], + CGU_INT Mi_, // last cluster + CGU_INT bits[3], // including parity + CGU_INT channels3or4 +) +{ + CGU_INT i, j, k; + CGU_INT use_par = 0; + CGU_INT clogs = 0; + + i = Mi_ + 1; + while (i >>= 1) + clogs++; + + CGU_FLOAT mean[MAX_DIMENSION_BIG]; + CGU_INT index[MAX_ENTRIES]; + CGU_INT Mi; + + CGU_INT maxTry = 1; + + for (k = 0; k < numEntries; k++) + { + index[k] = index_[k]; + } + + CGU_INT done; + CGU_INT change; + + CGU_INT better; + + CGU_FLOAT err_o = CMP_FLOAT_MAX; + CGU_FLOAT out_2[MAX_ENTRIES][MAX_DIMENSION_BIG]; + CGU_INT idx_2[MAX_ENTRIES]; + CGU_INT epo_2[2][MAX_DIMENSION_BIG]; + + CGU_INT max_bits[MAX_DIMENSION_BIG]; + CGU_INT type = bits[0] % (2 * channels3or4); + + for (j = 0; j < channels3or4; j++) + max_bits[j] = (bits[0] + 2 * channels3or4 - 1) / (2 * channels3or4); + + + // handled below automatically + CGU_INT alls = all_same_d(data, numEntries, channels3or4); + + mean_d_d(data, mean, numEntries, channels3or4); + + do { + index_collapse_kernel(index, numEntries); + + Mi = max_index(index, numEntries); // index can be from requantizer + + CGU_INT p, q; + CGU_INT p0 = -1, q0 = -1; + + CGU_FLOAT err_2 = CMP_FLOAT_MAX; + + if (Mi == 0) { + CGU_FLOAT t; + CGU_INT epo_0[2][MAX_DIMENSION_BIG]; + // either sinle point from the beginning or collapsed index + if (alls) { + t = quant_single_point_d(data, numEntries, index, out_2, epo_0, Mi_, type, channels3or4); + } + else + { + quant_single_point_d(&mean, numEntries, index, out_2, epo_0, Mi_, type, channels3or4); + t = totalError_d(data, out_2, numEntries, channels3or4); + } + + if (t < err_o) { + for (k = 0; k < numEntries; k++) { + index_[k] = index[k]; + for (j = 0; j < channels3or4; j++) { + out[k][j] = out_2[k][j]; + epo_code_out[0][j] = epo_0[0][j]; + epo_code_out[1][j] = epo_0[1][j]; + } + }; + err_o = t; + } + return err_o; + } + + //=============================== + // We have ramp colors to process + //=============================== + + for (q = 1; Mi != 0 && q*Mi <= Mi_; q++) // does not work for single point collapsed index!!! + { + for (p = 0; p <= Mi_ - q * Mi; p++) + { + + //------------------------------------- + // set a new index data to try + //------------------------------------- + CGU_INT cidx[MAX_ENTRIES]; + + for (k = 0; k < numEntries; k++) + { + cidx[k] = index[k] * q + p; + } + + CGU_FLOAT epa[2][MAX_DIMENSION_BIG]; + + // + // solve RMS problem for center + // + + CGU_FLOAT im[2][2] = { { 0,0 },{ 0,0 } }; // matrix /inverse matrix + CGU_FLOAT rp[2][MAX_DIMENSION_BIG]; // right part for RMS fit problem + + // get ideal clustr centers + CGU_FLOAT cc[MAX_CLUSTERS_BIG][MAX_DIMENSION_BIG]; + CGU_INT index_cnt[MAX_CLUSTERS_BIG]; // count of index entries + CGU_INT index_comp[MAX_CLUSTERS_BIG]; // compacted index + CGU_INT index_ncl; // number of unique indexes + + index_ncl = cluster_mean_d_d(data, cc, cidx, index_comp, index_cnt, numEntries, channels3or4); // unrounded + + for (i = 0; i < index_ncl; i++) + for (j = 0; j < channels3or4; j++) + cc[index_comp[i]][j] = (CGU_FLOAT)floorf(cc[index_comp[i]][j] + 0.5f); // more or less ideal location + + for (j = 0; j < channels3or4; j++) + { + rp[0][j] = rp[1][j] = 0; + } + + // weight with cnt if runnning on compacted index + for (k = 0; k < numEntries; k++) + { + im[0][0] += (Mi_ - cidx[k])* (Mi_ - cidx[k]); + im[0][1] += cidx[k] * (Mi_ - cidx[k]); // im is symmetric + im[1][1] += cidx[k] * cidx[k]; + + for (j = 0; j < channels3or4; j++) + { + rp[0][j] += (Mi_ - cidx[k]) * cc[cidx[k]][j]; + rp[1][j] += cidx[k] * cc[cidx[k]][j]; + } + } + + CGU_FLOAT dd = im[0][0] * im[1][1] - im[0][1] * im[0][1]; + + //assert(dd !=0); + + // dd=0 means that cidx[k] and (Mi_-cidx[k]) collinear which implies only one active index; + // taken care of separately + + im[1][0] = im[0][0]; + im[0][0] = im[1][1] / dd; + im[1][1] = im[1][0] / dd; + im[1][0] = im[0][1] = -im[0][1] / dd; + + for (j = 0; j < channels3or4; j++) { + epa[0][j] = (im[0][0] * rp[0][j] + im[0][1] * rp[1][j])*Mi_; + epa[1][j] = (im[1][0] * rp[0][j] + im[1][1] * rp[1][j])*Mi_; + } + + CGU_FLOAT err_1 = CMP_FLOAT_MAX; + CGU_FLOAT out_1[MAX_ENTRIES][MAX_DIMENSION_BIG]; + CGU_INT idx_1[MAX_ENTRIES]; + CGU_INT epo_1[2][MAX_DIMENSION_BIG]; + CGU_INT s1 = 0; + CGU_FLOAT epd[2][MAX_DIMENSION_BIG][2]; // first second, coord, begin range end range + + for (j = 0; j < channels3or4; j++) + { + for (i = 0; i < 2; i++) + { // set range + epd[i][j][0] = epd[i][j][1] = epa[i][j]; + epd[i][j][1] += ((1 << bits[j]) - 1 - (int)epd[i][j][1] < (1 << use_par) ? + (1 << bits[j]) - 1 - (int)epd[i][j][1] : (1 << use_par)) & (~use_par); + } + } + + CGU_FLOAT ce[MAX_ENTRIES][MAX_CLUSTERS_BIG][MAX_DIMENSION_BIG]; + CGU_FLOAT err_0 = 0; + CGU_FLOAT out_0[MAX_ENTRIES][MAX_DIMENSION_BIG]; + CGU_INT idx_0[MAX_ENTRIES]; + + for (i = 0; i < numEntries; i++) + { + CGU_FLOAT d[4]; + d[0] = data[i][0]; + d[1] = data[i][1]; + d[2] = data[i][2]; + d[3] = data[i][3]; + for (j = 0; j < (1 << clogs); j++) + for (k = 0; k < channels3or4; k++) + { + ce[i][j][k] = (rampf(CLT(clogs), epd[0][k][0], epd[1][k][0], j) - d[k])* + (rampf(CLT(clogs), epd[0][k][0], epd[1][k][0], j) - d[k]); + } + } + + CGU_INT s = 0, p1, g; + CGU_INT ei0 = 0, ei1 = 0; + + for (p1 = 0; p1 < 64; p1++) + { + CGU_INT j0 = 0; + + // Gray code increment + g = p1 & (-p1); + + err_0 = 0; + + for (j = 0; j < channels3or4; j++) + { + if (((g >> (2 * j)) & 0x3) != 0) + { + j0 = j; + // new cords + ei0 = (((s^g) >> (2 * j)) & 0x1); + ei1 = (((s^g) >> (2 * j + 1)) & 0x1); + } + } + s = s ^ g; + err_0 = 0; + + for (i = 0; i < numEntries; i++) + { + CGU_FLOAT d[4]; + d[0] = data[i][0]; + d[1] = data[i][1]; + d[2] = data[i][2]; + d[3] = data[i][3]; + CGU_INT ci = 0; + CGU_FLOAT cmin = CMP_FLOAT_MAX; + + for (j = 0; j < (1 << clogs); j++) + { + float t_ = 0.; + ce[i][j][j0] = (rampf(CLT(clogs), epd[0][j0][ei0], epd[1][j0][ei1], j) - d[j0])* + (rampf(CLT(clogs), epd[0][j0][ei0], epd[1][j0][ei1], j) - d[j0]); + for (k = 0; k < channels3or4; k++) + { + t_ += ce[i][j][k]; + } + + if (t_ < cmin) + { + cmin = t_; + ci = j; + } + } + + idx_0[i] = ci; + for (k = 0; k < channels3or4; k++) + { + out_0[i][k] = rampf(CLT(clogs), epd[0][k][ei0], epd[1][k][ei1], ci); + } + err_0 += cmin; + } + + if (err_0 < err_1) + { + // best in the curent ep cube run + for (i = 0; i < numEntries; i++) + { + idx_1[i] = idx_0[i]; + for (j = 0; j < channels3or4; j++) + out_1[i][j] = out_0[i][j]; + } + err_1 = err_0; + + s1 = s; // epo coding + } + } + + // reconstruct epo + for (j = 0; j < channels3or4; j++) + { + { + // new cords + ei0 = ((s1 >> (2 * j)) & 0x1); + ei1 = ((s1 >> (2 * j + 1)) & 0x1); + epo_1[0][j] = (int)epd[0][j][ei0]; + epo_1[1][j] = (int)epd[1][j][ei1]; + } + } + + if (err_1 < err_2) + { + // best in the curent ep cube run + for (i = 0; i < numEntries; i++) + { + idx_2[i] = idx_1[i]; + for (j = 0; j < channels3or4; j++) + out_2[i][j] = out_1[i][j]; + } + err_2 = err_1; + for (j = 0; j < channels3or4; j++) + { + epo_2[0][j] = epo_1[0][j]; + epo_2[1][j] = epo_1[1][j]; + } + p0 = p; + q0 = q; + } + } + } + + // change/better + change = 0; + for (k = 0; k < numEntries; k++) + change = change || (index[k] * q0 + p0 != idx_2[k]); + + better = err_2 < err_o; + + if (better) + { + for (k = 0; k < numEntries; k++) + { + index_[k] = index[k] = idx_2[k]; + for (j = 0; j < channels3or4; j++) + { + out[k][j] = out_2[k][j]; + epo_code_out[0][j] = epo_2[0][j]; + epo_code_out[1][j] = epo_2[1][j]; + } + } + err_o = err_2; + } + + done = !(change && better); + + if (maxTry > 0) maxTry--; + else maxTry = 0; + + } while (!done && maxTry); + + return err_o; +} + + +#ifndef ASPM_GPU +static CGU_INT g_aWeights3[] = { 0, 9, 18, 27, 37, 46, 55, 64 }; // 3 bit color Indices +static CGU_INT g_aWeights4[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 }; // 4 bit color indices + +CGU_FLOAT lerpf(CGU_FLOAT a, CGU_FLOAT b, CGU_INT i, CGU_INT denom) +{ + assert(denom == 3 || denom == 7 || denom == 15); + assert(i >= 0 && i <= denom); + + CGU_INT *weights = NULL; + + switch (denom) + { + case 3: denom *= 5; i *= 5; // fall through to case 15 + case 7: weights = g_aWeights3; break; + case 15: weights = g_aWeights4; break; + default: assert(0); + } + return (a*weights[denom - i] + b * weights[i]) / 64.0f; +} +#else + +CGU_FLOAT lerpf(CGU_FLOAT a, CGU_FLOAT b, CGU_INT i, CGU_INT denom) +{ + CGU_INT g_aWeights3[] = { 0, 9, 18, 27, 37, 46, 55, 64 }; // 3 bit color Indices + CGU_INT g_aWeights4[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 }; // 4 bit color indices + switch (denom) + { + case 7: return ((a*g_aWeights3[denom - i] + b * g_aWeights3[i]) / 64.0f); break; + case 15: return ((a*g_aWeights4[denom - i] + b * g_aWeights4[i]) / 64.0f); break; + default: + case 3:// fall through to case 15 + denom *= 5; + i *= 5; + return ((a*g_aWeights3[denom - i] + b * g_aWeights3[i]) / 64.0f); break; + } +} +#endif + +void palitizeEndPointsF(BC6H_Encode_local *BC6H_data, CGU_FLOAT fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]) +{ + // scale endpoints + CGU_FLOAT Ar, Ag, Ab, Br, Bg, Bb; + + + // Compose index colors from end points + if (BC6H_data->region == 1) + { + Ar = fEndPoints[0][0][0]; + Ag = fEndPoints[0][0][1]; + Ab = fEndPoints[0][0][2]; + Br = fEndPoints[0][1][0]; + Bg = fEndPoints[0][1][1]; + Bb = fEndPoints[0][1][2]; + + for (CGU_INT i = 0; i < 16; i++) + { + + // Red + BC6H_data->Paletef[0][i].x = lerpf(Ar, Br, i, 15); + // Green + BC6H_data->Paletef[0][i].y = lerpf(Ag, Bg, i, 15); + // Blue + BC6H_data->Paletef[0][i].z = lerpf(Ab, Bb, i, 15); + } + + } + else //mode.type == BC6_TWO + { + for (CGU_INT region = 0; region < 2; region++) + { + Ar = fEndPoints[region][0][0]; + Ag = fEndPoints[region][0][1]; + Ab = fEndPoints[region][0][2]; + Br = fEndPoints[region][1][0]; + Bg = fEndPoints[region][1][1]; + Bb = fEndPoints[region][1][2]; + for (CGU_INT i = 0; i < 8; i++) + { + // Red + BC6H_data->Paletef[region][i].x = lerpf(Ar, Br, i, 7); + // Greed + BC6H_data->Paletef[region][i].y = lerpf(Ag, Bg, i, 7); + // Blue + BC6H_data->Paletef[region][i].z = lerpf(Ab, Bb, i, 7); + } + + } + } +} + +CGU_FLOAT CalcShapeError(BC6H_Encode_local *BC6H_data, CGU_FLOAT fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_BOOL SkipPallet) +{ + CGU_INT maxPallet; + CGU_INT subset = 0; + CGU_FLOAT totalError = 0.0f; + CGU_INT region = (BC6H_data->region - 1); + + if (region == 0) + maxPallet = 16; + else + maxPallet = 8; + + if (!SkipPallet) + palitizeEndPointsF(BC6H_data, fEndPoints); + + for (CGU_INT i = 0; i < MAX_SUBSET_SIZE; i++) + { + CGU_FLOAT error = 0.0f; + CGU_FLOAT bestError = 0.0f; + + if (region == 0) + { + subset = 0; + } + else + { + // get the shape subset 0 or 1 + subset = BC6_PARTITIONS[BC6H_data->d_shape_index][i]; + } + + // initialize bestError to the difference for first data + bestError = abs(BC6H_data->din[i][0] - BC6H_data->Paletef[subset][0].x) + + abs(BC6H_data->din[i][1] - BC6H_data->Paletef[subset][0].y) + + abs(BC6H_data->din[i][2] - BC6H_data->Paletef[subset][0].z); + + // loop through the rest of the data until find the best error + for (CGU_INT j = 1; j < maxPallet && bestError > 0; j++) + { + error = abs(BC6H_data->din[i][0] - BC6H_data->Paletef[subset][j].x) + + abs(BC6H_data->din[i][1] - BC6H_data->Paletef[subset][j].y) + + abs(BC6H_data->din[i][2] - BC6H_data->Paletef[subset][j].z); + + if (error <= bestError) + bestError = error; + else + break; + } + totalError += bestError; + } + + return totalError; +} + +CGU_FLOAT FindBestPattern(BC6H_Encode_local * BC6H_data, CGU_BOOL TwoRegionShapes, CGU_INT8 shape_pattern, CGU_FLOAT quality) +{ + // Index bit size for the patterns been used. + // All two zone shapes have 3 bits per color, max index value < 8 + // All one zone shapes gave 4 bits per color, max index value < 16 + CGU_INT8 Index_BitSize = TwoRegionShapes ? 8 : 16; + CGU_INT8 max_subsets = TwoRegionShapes ? 2 : 1; + CGU_FLOAT direction[NCHANNELS]; + CGU_FLOAT step; + + BC6H_data->region = max_subsets; + BC6H_data->index = 0; + BC6H_data->d_shape_index = shape_pattern; + memset((CGU_UINT8 *)BC6H_data->partition, 0, sizeof(BC6H_data->partition)); + memset((CGU_UINT8 *)BC6H_data->shape_indices, 0, sizeof(BC6H_data->shape_indices)); + + // Get the pattern to encode with + Partition(shape_pattern, // Shape pattern we want to get + BC6H_data->din, // Input data + BC6H_data->partition, // Returns the patterned shape data + BC6H_data->entryCount, // counts the number of pixel used in each subset region num of 0's amd 1's + max_subsets, // Table Shapes to use eithe one regions 1 or two regions 2 + 3); // rgb no alpha always = 3 + + CGU_FLOAT error[MAX_SUBSETS] = { 0.0, CMP_FLOAT_MAX,CMP_FLOAT_MAX }; + CGU_INT BestOutB = 0; + CGU_FLOAT BestError; //the lowest error from vector direction quantization + CGU_FLOAT BestError_endpts; //the lowest error from endpoints extracted from the vector direction quantization + + CGU_FLOAT outB[2][2][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; + CGU_INT shape_indicesB[2][MAX_SUBSETS][MAX_SUBSET_SIZE]; + + for (CGU_INT subset = 0; subset < max_subsets; subset++) + { + error[0] += optQuantAnD_d( + BC6H_data->partition[subset], // input data + BC6H_data->entryCount[subset], // number of input points above (not clear about 1, better to avoid) + Index_BitSize, // number of clusters on the ramp, 8 or 16 + shape_indicesB[0][subset], // output index, if not all points of the ramp used, 0 may not be assigned + outB[0][subset], // resulting quantization + direction, // direction vector of the ramp (check normalization) + &step, // step size (check normalization) + 3, // number of channels (always 3 = RGB for BC6H) + quality // Quality set number of retry to get good end points + // Max retries = MAX_TRY = 4000 when Quality is 1.0 + // Min = 0 and default with quality 0.05 is 200 times + ); + } + + BestError = error[0]; + BestOutB = 0; + + // The following code is almost complete - runs very slow and not sure if % of improvement is justified.. +#ifdef USE_SHAKERHD + // Valid only for 2 region shapes + if ((max_subsets > 1) && (quality > 0.80)) + { + CGU_INT tempIndices[MAX_SUBSET_SIZE]; + // CGU_INT temp_epo_code[2][2][MAX_DIMENSION_BIG]; + CGU_INT bits[3] = { 8,8,8 }; // Channel index bit size + + // CGU_FLOAT epo[2][MAX_DIMENSION_BIG]; + CGU_INT epo_code[MAX_SUBSETS][2][MAX_DIMENSION_BIG]; + // CGU_INT shakeSize = 8; + + error[1] = 0.0; + for (CGU_INT subset = 0; subset < max_subsets; subset++) + { + for (CGU_INT k = 0; k < BC6H_data->entryCount[subset]; k++) + { + tempIndices[k] = shape_indicesB[0][subset][k]; + } + + error[1] += ep_shaker_HD( + BC6H_data->partition[subset], + BC6H_data->entryCount[subset], + tempIndices, // output index, if not all points of the ramp used, 0 may not be assigned + outB[1][subset], // resulting quantization + epo_code[subset], + BC6H_data->entryCount[subset] - 1, + bits, + 3 + ); + + // error[1] += ep_shaker_2_d( + // BC6H_data.partition[subset], + // BC6H_data.entryCount[subset], + // tempIndices, // output index, if not all points of the ramp used, 0 may not be assigned + // outB[1][subset], // resulting quantization + // epo_code[subset], + // shakeSize, + // BC6H_data.entryCount[subset] - 1, + // bits[0], + // 3, + // epo + // ); + + + for (CGU_INT k = 0; k < BC6H_data->entryCount[subset]; k++) + { + shape_indicesB[1][subset][k] = tempIndices[k]; + } + + } // subsets + + if (BestError > error[1]) + { + BestError = error[1]; + BestOutB = 1; + for (CGU_INT subset = 0; subset < max_subsets; subset++) + { + for (CGU_INT k = 0; k < MAX_DIMENSION_BIG; k++) + { + BC6H_data->fEndPoints[subset][0][k] = (CGU_FLOAT)epo_code[subset][0][k]; + BC6H_data->fEndPoints[subset][1][k] = (CGU_FLOAT)epo_code[subset][1][k]; + } + } + } + + } +#endif + + // Save the best for BC6H data processing later + if (BestOutB == 0) + GetEndPoints(BC6H_data->fEndPoints, outB[BestOutB], max_subsets, BC6H_data->entryCount); + + memcpy((CGU_UINT8 *)BC6H_data->shape_indices, (CGU_UINT8 *)shape_indicesB[BestOutB], sizeof(BC6H_data->shape_indices)); + clampF16Max(BC6H_data->fEndPoints, BC6H_data->issigned); + + BestError_endpts = CalcShapeError(BC6H_data, BC6H_data->fEndPoints, false); + return BestError_endpts; +} + +#ifndef ASPM_GPU +void SaveDataBlock(BC6H_Encode_local *bc6h_format, CMP_GLOBAL CGU_UINT8 cmpout[COMPRESSED_BLOCK_SIZE]) +{ + BitHeader header(NULL, COMPRESSED_BLOCK_SIZE); + + // Save the RGB end point values + switch (bc6h_format->m_mode) + { + case 1: //0x00 + header.setvalue(0, 2, 0x00); + header.setvalue(2, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(3, 1, bc6h_format->by, 4); // by[4] + header.setvalue(4, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(5, 10, bc6h_format->rw); // 10: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 10: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 10: bw[9:0] + header.setvalue(35, 5, bc6h_format->rx); // 5: rx[4:0] + header.setvalue(40, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(41, 4, bc6h_format->gy); // 5: gy[3:0] + header.setvalue(45, 5, bc6h_format->gx); // 5: gx[4:0] + header.setvalue(50, 1, bc6h_format->bz); // 5: bz[0] + header.setvalue(51, 4, bc6h_format->gz); // 5: gz[3:0] + header.setvalue(55, 5, bc6h_format->bx); // 5: bx[4:0] + header.setvalue(60, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(61, 4, bc6h_format->by); // 5: by[3:0] + header.setvalue(65, 5, bc6h_format->ry); // 5: ry[4:0] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 5, bc6h_format->rz); // 5: rz[4:0] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 2: // 0x01 + header.setvalue(0, 2, 0x01); + header.setvalue(2, 1, bc6h_format->gy, 5); // gy[5] + header.setvalue(3, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(4, 1, bc6h_format->gz, 5); // gz[5] + header.setvalue(5, 7, bc6h_format->rw); // rw[6:0] + header.setvalue(12, 1, bc6h_format->bz); // bz[0] + header.setvalue(13, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(14, 1, bc6h_format->by, 4); // by[4] + header.setvalue(15, 7, bc6h_format->gw); // gw[6:0] + header.setvalue(22, 1, bc6h_format->by, 5); // by[5] + header.setvalue(23, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(24, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(25, 7, bc6h_format->bw); // 7: bw[6:0] + header.setvalue(32, 1, bc6h_format->bz, 3); // bz[3] + header.setvalue(33, 1, bc6h_format->bz, 5); // bz[5] + header.setvalue(34, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(35, 6, bc6h_format->rx); // 6: rx[5:0] + header.setvalue(41, 4, bc6h_format->gy); // 6: gy[3:0] + header.setvalue(45, 6, bc6h_format->gx); // 6: gx[5:0] + header.setvalue(51, 4, bc6h_format->gz); // 6: gz[3:0] + header.setvalue(55, 6, bc6h_format->bx); // 6: bx[5:0] + header.setvalue(61, 4, bc6h_format->by); // 6: by[3:0] + header.setvalue(65, 6, bc6h_format->ry); // 6: ry[5:0] + header.setvalue(71, 6, bc6h_format->rz); // 6: rz[5:0] + break; + case 3: // 0x02 + header.setvalue(0, 5, 0x02); + header.setvalue(5, 10, bc6h_format->rw); // 11: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 11: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 11: bw[9:0] + header.setvalue(35, 5, bc6h_format->rx); // 5: rx[4:0] + header.setvalue(40, 1, bc6h_format->rw, 10); // rw[10] + header.setvalue(41, 4, bc6h_format->gy); // 4: gy[3:0] + header.setvalue(45, 4, bc6h_format->gx); // 4: gx[3:0] + header.setvalue(49, 1, bc6h_format->gw, 10); // gw[10] + header.setvalue(50, 1, bc6h_format->bz); // 4: bz[0] + header.setvalue(51, 4, bc6h_format->gz); // 4: gz[3:0] + header.setvalue(55, 4, bc6h_format->bx); // 4: bx[3:0] + header.setvalue(59, 1, bc6h_format->bw, 10); // bw[10] + header.setvalue(60, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(61, 4, bc6h_format->by); // 4: by[3:0] + header.setvalue(65, 5, bc6h_format->ry); // 5: ry[4:0] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 5, bc6h_format->rz); // 5: rz[4:0] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 4: // 0x06 + header.setvalue(0, 5, 0x06); + header.setvalue(5, 10, bc6h_format->rw); // 11: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 11: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 11: bw[9:0] + header.setvalue(35, 4, bc6h_format->rx); // rx[3:0] + header.setvalue(39, 1, bc6h_format->rw, 10); // rw[10] + header.setvalue(40, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(41, 4, bc6h_format->gy); // 5: gy[3:0] + header.setvalue(45, 5, bc6h_format->gx); // gx[4:0] + header.setvalue(50, 1, bc6h_format->gw, 10); // 5: gw[10] + header.setvalue(51, 4, bc6h_format->gz); // 5: gz[3:0] + header.setvalue(55, 4, bc6h_format->bx); // 4: bx[3:0] + header.setvalue(59, 1, bc6h_format->bw, 10); // bw[10] + header.setvalue(60, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(61, 4, bc6h_format->by); // 4: by[3:0] + header.setvalue(65, 4, bc6h_format->ry); // 4: ry[3:0] + header.setvalue(69, 1, bc6h_format->bz); // 4: bz[0] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 4, bc6h_format->rz); // 4: rz[3:0] + header.setvalue(75, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 5: // 0x0A + header.setvalue(0, 5, 0x0A); + header.setvalue(5, 10, bc6h_format->rw); // 11: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 11: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 11: bw[9:0] + header.setvalue(35, 4, bc6h_format->rx); // 4: rx[3:0] + header.setvalue(39, 1, bc6h_format->rw, 10); // rw[10] + header.setvalue(40, 1, bc6h_format->by, 4); // by[4] + header.setvalue(41, 4, bc6h_format->gy); // 4: gy[3:0] + header.setvalue(45, 4, bc6h_format->gx); // 4: gx[3:0] + header.setvalue(49, 1, bc6h_format->gw, 10); // gw[10] + header.setvalue(50, 1, bc6h_format->bz); // 5: bz[0] + header.setvalue(51, 4, bc6h_format->gz); // 4: gz[3:0] + header.setvalue(55, 5, bc6h_format->bx); // 5: bx[4:0] + header.setvalue(60, 1, bc6h_format->bw, 10); // bw[10] + header.setvalue(61, 4, bc6h_format->by); // 5: by[3:0] + header.setvalue(65, 4, bc6h_format->ry); // 4: ry[3:0] + header.setvalue(69, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 4, bc6h_format->rz); // 4: rz[3:0] + header.setvalue(75, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 6: // 0x0E + header.setvalue(0, 5, 0x0E); + header.setvalue(5, 9, bc6h_format->rw); // 9: rw[8:0] + header.setvalue(14, 1, bc6h_format->by, 4); // by[4] + header.setvalue(15, 9, bc6h_format->gw); // 9: gw[8:0] + header.setvalue(24, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(25, 9, bc6h_format->bw); // 9: bw[8:0] + header.setvalue(34, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(35, 5, bc6h_format->rx); // 5: rx[4:0] + header.setvalue(40, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(41, 4, bc6h_format->gy); // 5: gy[3:0] + header.setvalue(45, 5, bc6h_format->gx); // 5: gx[4:0] + header.setvalue(50, 1, bc6h_format->bz); // 5: bz[0] + header.setvalue(51, 4, bc6h_format->gz); // 5: gz[3:0] + header.setvalue(55, 5, bc6h_format->bx); // 5: bx[4:0] + header.setvalue(60, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(61, 4, bc6h_format->by); // 5: by[3:0] + header.setvalue(65, 5, bc6h_format->ry); // 5: ry[4:0] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 5, bc6h_format->rz); // 5: rz[4:0] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 7: // 0x12 + header.setvalue(0, 5, 0x12); + header.setvalue(5, 8, bc6h_format->rw); // 8: rw[7:0] + header.setvalue(13, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(14, 1, bc6h_format->by, 4); // by[4] + header.setvalue(15, 8, bc6h_format->gw); // 8: gw[7:0] + header.setvalue(23, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(24, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(25, 8, bc6h_format->bw); // 8: bw[7:0] + header.setvalue(33, 1, bc6h_format->bz, 3); // bz[3] + header.setvalue(34, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(35, 6, bc6h_format->rx); // 6: rx[5:0] + header.setvalue(41, 4, bc6h_format->gy); // 5: gy[3:0] + header.setvalue(45, 5, bc6h_format->gx); // 5: gx[4:0] + header.setvalue(50, 1, bc6h_format->bz); // 5: bz[0] + header.setvalue(51, 4, bc6h_format->gz); // 5: gz[3:0] + header.setvalue(55, 5, bc6h_format->bx); // 5: bx[4:0] + header.setvalue(60, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(61, 4, bc6h_format->by); // 5: by[3:0] + header.setvalue(65, 6, bc6h_format->ry); // 6: ry[5:0] + header.setvalue(71, 6, bc6h_format->rz); // 6: rz[5:0] + break; + case 8: // 0x16 + header.setvalue(0, 5, 0x16); + header.setvalue(5, 8, bc6h_format->rw); // 8: rw[7:0] + header.setvalue(13, 1, bc6h_format->bz); // 5: bz[0] + header.setvalue(14, 1, bc6h_format->by, 4); // by[4] + header.setvalue(15, 8, bc6h_format->gw); // 8: gw[7:0] + header.setvalue(23, 1, bc6h_format->gy, 5); // gy[5] + header.setvalue(24, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(25, 8, bc6h_format->bw); // 8: bw[7:0] + header.setvalue(33, 1, bc6h_format->gz, 5); // gz[5] + header.setvalue(34, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(35, 5, bc6h_format->rx); // 5: rx[4:0] + header.setvalue(40, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(41, 4, bc6h_format->gy); // 6: gy[3:0] + header.setvalue(45, 6, bc6h_format->gx); // 6: gx[5:0] + header.setvalue(51, 4, bc6h_format->gz); // 6: gz[3:0] + header.setvalue(55, 5, bc6h_format->bx); // 5: bx[4:0] + header.setvalue(60, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(61, 4, bc6h_format->by); // 5: by[3:0] + header.setvalue(65, 5, bc6h_format->ry); // 5: ry[4:0] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 5, bc6h_format->rz); // 5: rz[4:0] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 9: // 0x1A + header.setvalue(0, 5, 0x1A); + header.setvalue(5, 8, bc6h_format->rw); // 8: rw[7:0] + header.setvalue(13, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(14, 1, bc6h_format->by, 4); // by[4] + header.setvalue(15, 8, bc6h_format->gw); // 8: gw[7:0] + header.setvalue(23, 1, bc6h_format->by, 5); // by[5] + header.setvalue(24, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(25, 8, bc6h_format->bw); // 8: bw[7:0] + header.setvalue(33, 1, bc6h_format->bz, 5); // bz[5] + header.setvalue(34, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(35, 5, bc6h_format->rx); // 5: rx[4:0] + header.setvalue(40, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(41, 4, bc6h_format->gy); // 5: gy[3:0] + header.setvalue(45, 5, bc6h_format->gx); // 5: gx[4:0] + header.setvalue(50, 1, bc6h_format->bz); // 6: bz[0] + header.setvalue(51, 4, bc6h_format->gz); // 5: gz[3:0] + header.setvalue(55, 6, bc6h_format->bx); // 6: bx[5:0] + header.setvalue(61, 4, bc6h_format->by); // 6: by[3:0] + header.setvalue(65, 5, bc6h_format->ry); // 5: ry[4:0] + header.setvalue(70, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(71, 5, bc6h_format->rz); // 5: rz[4:0] + header.setvalue(76, 1, bc6h_format->bz, 3); // bz[3] + break; + case 10: // 0x1E + header.setvalue(0, 5, 0x1E); + header.setvalue(5, 6, bc6h_format->rw); // 6: rw[5:0] + header.setvalue(11, 1, bc6h_format->gz, 4); // gz[4] + header.setvalue(12, 1, bc6h_format->bz); // 6: bz[0] + header.setvalue(13, 1, bc6h_format->bz, 1); // bz[1] + header.setvalue(14, 1, bc6h_format->by, 4); // by[4] + header.setvalue(15, 6, bc6h_format->gw); // 6: gw[5:0] + header.setvalue(21, 1, bc6h_format->gy, 5); // gy[5] + header.setvalue(22, 1, bc6h_format->by, 5); // by[5] + header.setvalue(23, 1, bc6h_format->bz, 2); // bz[2] + header.setvalue(24, 1, bc6h_format->gy, 4); // gy[4] + header.setvalue(25, 6, bc6h_format->bw); // 6: bw[5:0] + header.setvalue(31, 1, bc6h_format->gz, 5); // gz[5] + header.setvalue(32, 1, bc6h_format->bz, 3); // bz[3] + header.setvalue(33, 1, bc6h_format->bz, 5); // bz[5] + header.setvalue(34, 1, bc6h_format->bz, 4); // bz[4] + header.setvalue(35, 6, bc6h_format->rx); // 6: rx[5:0] + header.setvalue(41, 4, bc6h_format->gy); // 6: gy[3:0] + header.setvalue(45, 6, bc6h_format->gx); // 6: gx[5:0] + header.setvalue(51, 4, bc6h_format->gz); // 6: gz[3:0] + header.setvalue(55, 6, bc6h_format->bx); // 6: bx[5:0] + header.setvalue(61, 4, bc6h_format->by); // 6: by[3:0] + header.setvalue(65, 6, bc6h_format->ry); // 6: ry[5:0] + header.setvalue(71, 6, bc6h_format->rz); // 6: rz[5:0] + break; + + // Single regions Modes + case 11: // 0x03 + header.setvalue(0, 5, 0x03); + header.setvalue(5, 10, bc6h_format->rw); // 10: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 10: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 10: bw[9:0] + header.setvalue(35, 10, bc6h_format->rx); // 10: rx[9:0] + header.setvalue(45, 10, bc6h_format->gx); // 10: gx[9:0] + header.setvalue(55, 10, bc6h_format->bx); // 10: bx[9:0] + break; + case 12: // 0x07 + header.setvalue(0, 5, 0x07); + header.setvalue(5, 10, bc6h_format->rw); // 11: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 11: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 11: bw[9:0] + header.setvalue(35, 9, bc6h_format->rx); // 9: rx[8:0] + header.setvalue(44, 1, bc6h_format->rw, 10); // rw[10] + header.setvalue(45, 9, bc6h_format->gx); // 9: gx[8:0] + header.setvalue(54, 1, bc6h_format->gw, 10); // gw[10] + header.setvalue(55, 9, bc6h_format->bx); // 9: bx[8:0] + header.setvalue(64, 1, bc6h_format->bw, 10); // bw[10] + break; + case 13: // 0x0B + header.setvalue(0, 5, 0x0B); + header.setvalue(5, 10, bc6h_format->rw); // 12: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 12: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 12: bw[9:0] + header.setvalue(35, 8, bc6h_format->rx); // 8: rx[7:0] + header.setvalue(43, 1, bc6h_format->rw, 11); // rw[11] + header.setvalue(44, 1, bc6h_format->rw, 10); // rw[10] + header.setvalue(45, 8, bc6h_format->gx); // 8: gx[7:0] + header.setvalue(53, 1, bc6h_format->gw, 11); // gw[11] + header.setvalue(54, 1, bc6h_format->gw, 10); // gw[10] + header.setvalue(55, 8, bc6h_format->bx); // 8: bx[7:0] + header.setvalue(63, 1, bc6h_format->bw, 11); // bw[11] + header.setvalue(64, 1, bc6h_format->bw, 10); // bw[10] + break; + case 14: // 0x0F + header.setvalue(0, 5, 0x0F); + header.setvalue(5, 10, bc6h_format->rw); // 16: rw[9:0] + header.setvalue(15, 10, bc6h_format->gw); // 16: gw[9:0] + header.setvalue(25, 10, bc6h_format->bw); // 16: bw[9:0] + header.setvalue(35, 4, bc6h_format->rx); // 4: rx[3:0] + header.setvalue(39, 6, bc6h_format->rw, 10); // rw[15:10] + header.setvalue(45, 4, bc6h_format->gx); // 4: gx[3:0] + header.setvalue(49, 6, bc6h_format->gw, 10); // gw[15:10] + header.setvalue(55, 4, bc6h_format->bx); // 4: bx[3:0] + header.setvalue(59, 6, bc6h_format->bw, 10); // bw[15:10] + break; + default: // Need to indicate error! + return; + } + + // Each format in the mode table can be uniquely identified by the mode bits. + // The first ten modes are used for two-region tiles, and the mode bit field + // can be either two or five bits long. These blocks also have fields for + // the compressed color endpoints (72 or 75 bits), the partition (5 bits), + // and the partition indices (46 bits). + + if (bc6h_format->m_mode >= MIN_MODE_FOR_ONE_REGION) + { + CGU_INT startbit = ONE_REGION_INDEX_OFFSET; + header.setvalue(startbit, 3, bc6h_format->indices16[0]); + startbit += 3; + for (CGU_INT i = 1; i < 16; i++) + { + header.setvalue(startbit, 4, bc6h_format->indices16[i]); + startbit += 4; + } + } + else + { + header.setvalue(77, 5, bc6h_format->d_shape_index); // Shape Index + CGU_INT startbit = TWO_REGION_INDEX_OFFSET, + nbits = 2; + header.setvalue(startbit, nbits, bc6h_format->indices16[0]); + for (CGU_INT i = 1; i < 16; i++) + { + startbit += nbits; // offset start bit for next index using prior nbits used + nbits = g_indexfixups[bc6h_format->d_shape_index] == i ? 2 : 3; // get new number of bit to save index with + header.setvalue(startbit, nbits, bc6h_format->indices16[i]); + } + } + + // save to output buffer our new bit values + // this can be optimized if header is part of bc6h_format struct + header.transferbits(cmpout, 16); +} +#else +void SaveDataBlock(BC6H_Encode_local *bc6h_format, CMP_GLOBAL CGU_UINT8 out[COMPRESSED_BLOCK_SIZE]) +{ + // ToDo +} +#endif + +void SwapIndices(CGU_INT32 iEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT32 iIndices[3][MAX_SUBSET_SIZE], CGU_INT entryCount[MAX_SUBSETS], CGU_INT max_subsets, CGU_INT mode, CGU_INT shape_pattern) +{ + + CGU_UINT32 uNumIndices = 1 << ModePartition[mode].IndexPrec; + CGU_UINT32 uHighIndexBit = uNumIndices >> 1; + + for (CGU_INT subset = 0; subset < max_subsets; ++subset) + { + // region 0 (subset = 0) The fix-up index for this subset is allways index 0 + // region 1 (subset = 1) The fix-up index for this subset varies based on the shape + size_t i = subset ? g_Region2FixUp[shape_pattern] : 0; + + if (iIndices[subset][i] & uHighIndexBit) + { + // high bit is set, swap the aEndPts and indices for this region + swap(iEndPoints[subset][0][0], iEndPoints[subset][1][0]); + swap(iEndPoints[subset][0][1], iEndPoints[subset][1][1]); + swap(iEndPoints[subset][0][2], iEndPoints[subset][1][2]); + + for (size_t j = 0; j < (size_t)entryCount[subset]; ++j) + { + iIndices[subset][j] = uNumIndices - 1 - iIndices[subset][j]; + } + } + + } +} + +// helper function to check transform overflow +// todo: check overflow by checking against sign +CGU_BOOL isOverflow(CGU_INT endpoint, CGU_INT nbit) +{ + CGU_INT maxRange = (int)pow(2.0f, (CGU_FLOAT)nbit - 1.0f) - 1; + CGU_INT minRange = (int)-(pow(2.0f, (CGU_FLOAT)nbit - 1.0f)); + + //no overflow + if ((endpoint >= minRange) && (endpoint <= maxRange)) + return false; + else //overflow + return true; +} + +CGU_BOOL TransformEndPoints(BC6H_Encode_local *BC6H_data, CGU_INT iEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT oEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT max_subsets, CGU_INT mode) +{ + CGU_INT Mask; + if (ModePartition[mode].transformed) + { + BC6H_data->istransformed = true; + for (CGU_INT i = 0; i < 3; ++i) + { + Mask = MASK(ModePartition[mode].nbits); + oEndPoints[0][0][i] = iEndPoints[0][0][i] & Mask; // [0][A] + + Mask = MASK(ModePartition[mode].prec[i]); + oEndPoints[0][1][i] = iEndPoints[0][1][i] - iEndPoints[0][0][i]; // [0][B] - [0][A] + + if (isOverflow(oEndPoints[0][1][i], ModePartition[mode].prec[i])) + return false; + + oEndPoints[0][1][i] = (oEndPoints[0][1][i] & Mask); + + //redo the check for sign overflow for one region case + if (max_subsets <= 1) + { + if (isOverflow(oEndPoints[0][1][i], ModePartition[mode].prec[i])) + return false; + } + + if (max_subsets > 1) + { + oEndPoints[1][0][i] = iEndPoints[1][0][i] - iEndPoints[0][0][i]; // [1][A] - [0][A] + if (isOverflow(oEndPoints[1][0][i], ModePartition[mode].prec[i])) + return false; + + oEndPoints[1][0][i] = (oEndPoints[1][0][i] & Mask); + + oEndPoints[1][1][i] = iEndPoints[1][1][i] - iEndPoints[0][0][i]; // [1][B] - [0][A] + if (isOverflow(oEndPoints[1][1][i], ModePartition[mode].prec[i])) + return false; + + oEndPoints[1][1][i] = (oEndPoints[1][1][i] & Mask); + } + } + } + else + { + BC6H_data->istransformed = false; + for (CGU_INT i = 0; i < 3; ++i) + { + Mask = MASK(ModePartition[mode].nbits); + oEndPoints[0][0][i] = iEndPoints[0][0][i] & Mask; + + Mask = MASK(ModePartition[mode].prec[i]); + oEndPoints[0][1][i] = iEndPoints[0][1][i] & Mask; + + if (max_subsets > 1) + { + oEndPoints[1][0][i] = iEndPoints[1][0][i] & Mask; + oEndPoints[1][1][i] = iEndPoints[1][1][i] & Mask; + } + } + } + + return true; +} + +void SaveCompressedBlockData(BC6H_Encode_local *BC6H_data, + CGU_INT oEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], + CGU_INT iIndices[2][MAX_SUBSET_SIZE], + CGU_INT8 max_subsets, + CGU_INT8 mode) +{ + BC6H_data->m_mode = mode; + BC6H_data->index++; + + // Save the data to output + BC6H_data->rw = oEndPoints[0][0][0]; // rw + BC6H_data->gw = oEndPoints[0][0][1]; // gw + BC6H_data->bw = oEndPoints[0][0][2]; // bw + BC6H_data->rx = oEndPoints[0][1][0]; // rx + BC6H_data->gx = oEndPoints[0][1][1]; // gx + BC6H_data->bx = oEndPoints[0][1][2]; // bx + + if (max_subsets > 1) + { + // Save the data to output + BC6H_data->ry = oEndPoints[1][0][0]; // ry + BC6H_data->gy = oEndPoints[1][0][1]; // gy + BC6H_data->by = oEndPoints[1][0][2]; // by + BC6H_data->rz = oEndPoints[1][1][0]; // rz + BC6H_data->gz = oEndPoints[1][1][1]; // gz + BC6H_data->bz = oEndPoints[1][1][2]; // bz + } + + // Map our two subset Indices for the shape to output 4x4 block + CGU_INT pos[2] = { 0,0 }; + CGU_INT asubset; + for (CGU_INT i = 0; i < MAX_SUBSET_SIZE; i++) + { + if (max_subsets > 1) + asubset = BC6_PARTITIONS[BC6H_data->d_shape_index][i]; // Two region shapes + else + asubset = 0; // One region shapes + BC6H_data->indices16[i] = (CGU_UINT8)iIndices[asubset][pos[asubset]]; + pos[asubset]++; + } + +} + +CGU_FLOAT CalcOneRegionEndPtsError(BC6H_Encode_local *BC6H_data, CGU_FLOAT fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]) +{ + CGU_FLOAT error = 0; + + for (CGU_INT i = 0; i < MAX_SUBSET_SIZE; i++) + { + for (CGU_INT m = 0; m < MAX_END_POINTS; m++) + { + for (CGU_INT n = 0; n < NCHANNELS; n++) + { + CGU_FLOAT calencpts = fEndPoints[0][m][n] + (abs(fEndPoints[0][m][n] - fEndPoints[0][m][n]) * (shape_indices[0][i] / 15)); + error += abs(BC6H_data->din[i][n] - calencpts); + } + } + } + + return error; +} + +void ReIndexShapef(BC6H_Encode_local *BC6H_data, CGU_INT shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]) +{ + CGU_FLOAT error = 0; + CGU_FLOAT bestError; + CGU_INT bestIndex = 0; + CGU_INT sub0index = 0; + CGU_INT sub1index = 0; + CGU_INT MaxPallet; + CGU_INT region = (BC6H_data->region - 1); + + if (region == 0) + MaxPallet = 16; + else + MaxPallet = 8; + + CGU_UINT8 isSet = 0; + for (CGU_INT i = 0; i < MAX_SUBSET_SIZE; i++) + { + // subset 0 or subset 1 + if (region) + isSet = BC6_PARTITIONS[BC6H_data->d_shape_index][i]; + + if (isSet) + { + bestError = CMP_HALF_MAX; + bestIndex = 0; + + // For two shape regions max Pallet is 8 + for (CGU_INT j = 0; j < MaxPallet; j++) + { + // Calculate error from original + error = abs(BC6H_data->din[i][0] - BC6H_data->Paletef[1][j].x) + + abs(BC6H_data->din[i][1] - BC6H_data->Paletef[1][j].y) + + abs(BC6H_data->din[i][2] - BC6H_data->Paletef[1][j].z); + if (error < bestError) + { + bestError = error; + bestIndex = j; + } + } + + shape_indices[1][sub1index] = bestIndex; + sub1index++; + } + else + { + // This is shared for one or two shape regions max Pallet either 16 or 8 + bestError = CMP_FLOAT_MAX; + bestIndex = 0; + + for (CGU_INT j = 0; j < MaxPallet; j++) + { + // Calculate error from original + error = abs(BC6H_data->din[i][0] - BC6H_data->Paletef[0][j].x) + + abs(BC6H_data->din[i][1] - BC6H_data->Paletef[0][j].y) + + abs(BC6H_data->din[i][2] - BC6H_data->Paletef[0][j].z); + if (error < bestError) + { + bestError = error; + bestIndex = j; + } + } + + shape_indices[0][sub0index] = bestIndex; + sub0index++; + } + } + +} + +CGU_INT Unquantize(CGU_INT comp, unsigned char uBitsPerComp, CGU_BOOL bSigned) +{ + CGU_INT unq = 0, s = 0; + if (bSigned) + { + if (uBitsPerComp >= 16) + { + unq = comp; + } + else + { + if (comp < 0) + { + s = 1; + comp = -comp; + } + + if (comp == 0) unq = 0; + else if (comp >= ((1 << (uBitsPerComp - 1)) - 1)) unq = 0x7FFF; + else unq = ((comp << 15) + 0x4000) >> (uBitsPerComp - 1); + + if (s) unq = -unq; + } + } + else + { + if (uBitsPerComp >= 15) unq = comp; + else if (comp == 0) unq = 0; + else if (comp == ((1 << uBitsPerComp) - 1)) unq = 0xFFFF; + else unq = ((comp << 16) + 0x8000) >> uBitsPerComp; + } + + return unq; +} + +CGU_INT finish_unquantizef16(CGU_INT q, CGU_BOOL isSigned) +{ + // Is it F16 Signed else F16 Unsigned + if (isSigned) + return (q < 0) ? -(((-q) * 31) >> 5) : (q * 31) >> 5; // scale the magnitude by 31/32 + else + return (q * 31) >> 6; // scale the magnitude by 31/64 + + // Note for Undefined we should return q as is +} + +// decompress endpoints +void decompress_endpoints1(BC6H_Encode_local * bc6h_format, CGU_INT oEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_FLOAT outf[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT mode) +{ + CGU_INT i; + CGU_INT t; + CGU_FLOAT out[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + + if (bc6h_format->issigned) + { + if (bc6h_format->istransformed) + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[0][0][i], ModePartition[mode].nbits); + + t = SIGN_EXTEND_TYPELESS(oEndPoints[0][1][i], ModePartition[mode].prec[i]); //C_RED + t = (t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits); + out[0][1][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits); + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + } + } + else + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[0][0][i], ModePartition[mode].nbits); + out[0][1][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[0][1][i], ModePartition[mode].prec[i]); + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + } + } + + } + else + { + if (bc6h_format->istransformed) + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)oEndPoints[0][0][i]; + t = SIGN_EXTEND_TYPELESS(oEndPoints[0][1][i], ModePartition[mode].prec[i]); + out[0][1][i] = (CGU_FLOAT)((t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits)); + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + } + } + else + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)oEndPoints[0][0][i]; + out[0][1][i] = (CGU_FLOAT)oEndPoints[0][1][i]; + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + } + } + } +} + +void decompress_endpoints2(BC6H_Encode_local * bc6h_format, CGU_INT oEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_FLOAT outf[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT mode) +{ + CGU_INT i; + CGU_INT t; + CGU_FLOAT out[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + + if (bc6h_format->issigned) + { + if (bc6h_format->istransformed) + { + for (i = 0; i < NCHANNELS; i++) + { + // get the quantized values + out[0][0][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[0][0][i], ModePartition[mode].nbits); + + t = SIGN_EXTEND_TYPELESS(oEndPoints[0][1][i], ModePartition[mode].prec[i]); + t = (t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits); + out[0][1][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits); + + t = SIGN_EXTEND_TYPELESS(oEndPoints[1][0][i], ModePartition[mode].prec[i]); + t = (t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits); + out[1][0][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits); + + t = SIGN_EXTEND_TYPELESS(oEndPoints[1][1][i], ModePartition[mode].prec[i]); + t = (t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits); + out[1][1][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits); + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, true); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, true); + out[1][0][i] = (CGU_FLOAT)Unquantize((int)out[1][0][i], (unsigned char)ModePartition[mode].nbits, true); + out[1][1][i] = (CGU_FLOAT)Unquantize((int)out[1][1][i], (unsigned char)ModePartition[mode].nbits, true); + + // F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], true); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], true); + outf[1][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][0][i], true); + outf[1][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][1][i], true); + + } + } + else + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[0][0][i], ModePartition[mode].nbits); + out[0][1][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[0][1][i], ModePartition[mode].prec[i]); + out[1][0][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[1][0][i], ModePartition[mode].prec[i]); + out[1][1][i] = (CGU_FLOAT)SIGN_EXTEND_TYPELESS(oEndPoints[1][1][i], ModePartition[mode].prec[i]); + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + out[1][0][i] = (CGU_FLOAT)Unquantize((int)out[1][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[1][1][i] = (CGU_FLOAT)Unquantize((int)out[1][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // nbits to F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + outf[1][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][0][i], false); + outf[1][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][1][i], false); + } + } + + } + else + { + if (bc6h_format->istransformed) + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)oEndPoints[0][0][i]; + t = SIGN_EXTEND_TYPELESS(oEndPoints[0][1][i], ModePartition[mode].prec[i]); + out[0][1][i] = (CGU_FLOAT)((t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits)); + + t = SIGN_EXTEND_TYPELESS(oEndPoints[1][0][i], ModePartition[mode].prec[i]); + out[1][0][i] = (CGU_FLOAT)((t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits)); + + t = SIGN_EXTEND_TYPELESS(oEndPoints[1][1][i], ModePartition[mode].prec[i]); + out[1][1][i] = (CGU_FLOAT)((t + oEndPoints[0][0][i]) & MASK(ModePartition[mode].nbits)); + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + out[1][0][i] = (CGU_FLOAT)Unquantize((int)out[1][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[1][1][i] = (CGU_FLOAT)Unquantize((int)out[1][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // nbits to F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + outf[1][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][0][i], false); + outf[1][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][1][i], false); + + } + } + else + { + for (i = 0; i < NCHANNELS; i++) + { + out[0][0][i] = (CGU_FLOAT)oEndPoints[0][0][i]; + out[0][1][i] = (CGU_FLOAT)oEndPoints[0][1][i]; + out[1][0][i] = (CGU_FLOAT)oEndPoints[1][0][i]; + out[1][1][i] = (CGU_FLOAT)oEndPoints[1][1][i]; + + // Unquantize all points to nbits + out[0][0][i] = (CGU_FLOAT)Unquantize((int)out[0][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[0][1][i] = (CGU_FLOAT)Unquantize((int)out[0][1][i], (unsigned char)ModePartition[mode].nbits, false); + out[1][0][i] = (CGU_FLOAT)Unquantize((int)out[1][0][i], (unsigned char)ModePartition[mode].nbits, false); + out[1][1][i] = (CGU_FLOAT)Unquantize((int)out[1][1][i], (unsigned char)ModePartition[mode].nbits, false); + + // nbits to F16 format + outf[0][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][0][i], false); + outf[0][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[0][1][i], false); + outf[1][0][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][0][i], false); + outf[1][1][i] = (CGU_FLOAT)finish_unquantizef16((int)out[1][1][i], false); + } + } + } +} + +// decompress endpoints +static void decompress_endpts(const CGU_INT in[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT out[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], const CGU_INT mode, CGU_BOOL issigned) +{ + + if (ModePartition[mode].transformed) + { + for (CGU_INT i = 0; i < 3; ++i) + { + R_0(out) = issigned ? SIGN_EXTEND_TYPELESS(R_0(in), ModePartition[mode].IndexPrec) : R_0(in); + CGU_INT t; + t = SIGN_EXTEND_TYPELESS(R_1(in), ModePartition[mode].prec[i]); + t = (t + R_0(in)) & MASK(ModePartition[mode].nbits); + R_1(out) = issigned ? SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits) : t; + + t = SIGN_EXTEND_TYPELESS(R_2(in), ModePartition[mode].prec[i]); + t = (t + R_0(in)) & MASK(ModePartition[mode].nbits); + R_2(out) = issigned ? SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits) : t; + + t = SIGN_EXTEND_TYPELESS(R_3(in), ModePartition[mode].prec[i]); + t = (t + R_0(in)) & MASK(ModePartition[mode].nbits); + R_3(out) = issigned ? SIGN_EXTEND_TYPELESS(t, ModePartition[mode].nbits) : t; + } + } + else + { + for (CGU_INT i = 0; i < 3; ++i) + { + R_0(out) = issigned ? SIGN_EXTEND_TYPELESS(R_0(in), ModePartition[mode].nbits) : R_0(in); + R_1(out) = issigned ? SIGN_EXTEND_TYPELESS(R_1(in), ModePartition[mode].prec[i]) : R_1(in); + R_2(out) = issigned ? SIGN_EXTEND_TYPELESS(R_2(in), ModePartition[mode].prec[i]) : R_2(in); + R_3(out) = issigned ? SIGN_EXTEND_TYPELESS(R_3(in), ModePartition[mode].prec[i]) : R_3(in); + } + } +} + +// endpoints fit only if the compression was lossless +static CGU_BOOL endpts_fit(const CGU_INT orig[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], const CGU_INT compressed[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], const CGU_INT mode, CGU_INT max_subsets, CGU_BOOL issigned) +{ + CGU_INT uncompressed[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + + decompress_endpts(compressed, uncompressed, mode, issigned); + + for (CGU_INT j = 0; j < max_subsets; ++j) + for (CGU_INT i = 0; i < 3; ++i) + { + if (orig[j][0][i] != uncompressed[j][0][i]) return false; + if (orig[j][1][i] != uncompressed[j][1][i]) return false; + } + + return true; +} + +//todo: check overflow +CGU_INT QuantizeToInt(short value, CGU_INT prec, CGU_BOOL signedfloat16) +{ + + if (prec <= 1) return 0; + CGU_BOOL negvalue = false; + + // move data to use extra bits for processing + CGU_INT ivalue = value; + + if (signedfloat16) + { + if (value < 0) + { + negvalue = true; + value = -value; + } + prec--; + } + else + { + // clamp -ve + if (value < 0) + value = 0; + } + + CGU_INT iQuantized; + CGU_INT bias = (prec > 10 && prec != 16) ? ((1 << (prec - 11)) - 1) : 0; + bias = (prec == 16) ? 15 : bias; + + iQuantized = ((ivalue << prec) + bias) / (FLT16_MAX + 1); + + return (negvalue ? -iQuantized : iQuantized); +} + +//todo: checkoverflow +void QuantizeEndPointToF16Prec(CGU_FLOAT EndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT iEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG], CGU_INT max_subsets, CGU_INT prec, CGU_BOOL isSigned) +{ + + for (CGU_INT subset = 0; subset < max_subsets; ++subset) + { + iEndPoints[subset][0][0] = QuantizeToInt((short)EndPoints[subset][0][0], prec, isSigned); // A.Red + iEndPoints[subset][0][1] = QuantizeToInt((short)EndPoints[subset][0][1], prec, isSigned); // A.Green + iEndPoints[subset][0][2] = QuantizeToInt((short)EndPoints[subset][0][2], prec, isSigned); // A.Blue + iEndPoints[subset][1][0] = QuantizeToInt((short)EndPoints[subset][1][0], prec, isSigned); // B.Red + iEndPoints[subset][1][1] = QuantizeToInt((short)EndPoints[subset][1][1], prec, isSigned); // B.Green + iEndPoints[subset][1][2] = QuantizeToInt((short)EndPoints[subset][1][2], prec, isSigned); // B.Blue + } +} + +CGU_FLOAT EncodePattern(BC6H_Encode_local *BC6H_data, CGU_FLOAT error) +{ + CGU_INT8 max_subsets = BC6H_data->region; + + // now we have input colors (in), output colors (outB) mapped to a line of ends (EndPoints) + // and a set of colors on the line equally spaced (indexedcolors) + // Lets assign indices + + //CGU_FLOAT SrcEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // temp endpoints used during calculations + + // Quantize the EndPoints + CGU_INT F16EndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // temp endpoints used during calculations + CGU_INT quantEndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; // endpoints to save for a given mode + + // ModePartition[] starts from 1 to 14 + // If we have a shape pattern set the loop to check modes from 1 to 10 else from 11 to 14 + // of the ModePartition table + CGU_INT min_mode = (BC6H_data->region == 2) ? 1 : 11; + CGU_INT max_mode = (BC6H_data->region == 2) ? MAX_TWOREGION_MODES : MAX_BC6H_MODES; + + CGU_BOOL fits[15]; + memset((CGU_UINT8 *)fits, 0, sizeof(fits)); + + CGU_INT bestFit = 0; + CGU_INT bestEndpointMode = 0; + CGU_FLOAT bestError = CMP_FLOAT_MAX; + CGU_FLOAT bestEndpointsErr = CMP_FLOAT_MAX; + CGU_FLOAT endPointErr = 0; + + // Try Optimization for the Mode + CGU_FLOAT best_EndPoints[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + CGU_INT best_Indices[MAX_BC6H_MODES + 1][MAX_SUBSETS][MAX_SUBSET_SIZE]; + CGU_FLOAT opt_toterr[MAX_BC6H_MODES + 1] = { 0 }; + + memset((CGU_UINT8 *)opt_toterr, 0, sizeof(opt_toterr)); + + CGU_INT numfits = 0; + // + // Notes; Only the endpoints are varying; the indices stay fixed in values! + // so to optimize which mode we need only check the endpoints error against our original to pick the mode to save + // + for (CGU_INT modes = min_mode; modes <= max_mode; ++modes) + { + memcpy((CGU_UINT8 *)best_EndPoints[modes], (CGU_UINT8 *)BC6H_data->fEndPoints, sizeof(BC6H_data->fEndPoints)); + memcpy((CGU_UINT8 *)best_Indices[modes] , (CGU_UINT8 *)BC6H_data->shape_indices, sizeof(BC6H_data->shape_indices)); + + { + QuantizeEndPointToF16Prec(best_EndPoints[modes], F16EndPoints[modes], max_subsets, ModePartition[ModeFitOrder[modes]].nbits, BC6H_data->issigned); + } + + // Indices data to save for given mode + SwapIndices(F16EndPoints[modes], best_Indices[modes], BC6H_data->entryCount, max_subsets, ModeFitOrder[modes], BC6H_data->d_shape_index); + CGU_BOOL transformfit = TransformEndPoints(BC6H_data, F16EndPoints[modes], quantEndPoints[modes], max_subsets, ModeFitOrder[modes]); + fits[modes] = endpts_fit(F16EndPoints[modes], quantEndPoints[modes], ModeFitOrder[modes], max_subsets, BC6H_data->issigned); + + if (fits[modes] && transformfit) + { + numfits++; + + // The new compressed end points fit the mode + // recalculate the error for this mode with a new set of indices + // since we have shifted the end points from what we origially calc + // from the find_bestpattern + CGU_FLOAT uncompressed[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + if (BC6H_data->region == 1) + decompress_endpoints1(BC6H_data, quantEndPoints[modes], uncompressed, ModeFitOrder[modes]); + else + decompress_endpoints2(BC6H_data, quantEndPoints[modes], uncompressed, ModeFitOrder[modes]); + // Takes the end points and creates a pallet of colors + // based on preset weights along a vector formed by the two end points + palitizeEndPointsF(BC6H_data, uncompressed); + + // Once we have the pallet - recalculate the optimal indices using the pallet + // and the original image data stored in BC6H_data.din[] + if (!BC6H_data->issigned) + ReIndexShapef(BC6H_data, best_Indices[modes]); + + // Calculate the error of the new tile vs the old tile data + opt_toterr[modes] = CalcShapeError(BC6H_data, uncompressed, true); + if (BC6H_data->region == 1) + { + endPointErr = CalcOneRegionEndPtsError(BC6H_data, uncompressed, best_Indices[modes]); + if (endPointErr < bestEndpointsErr) + { + bestEndpointsErr = endPointErr; + bestEndpointMode = modes; + } + } + + CGU_BOOL transformFit = true; + // Save hold this mode fit data if its better than the last one checked. + if (opt_toterr[modes] < bestError) + { + if (!BC6H_data->issigned) + { + QuantizeEndPointToF16Prec(uncompressed, F16EndPoints[modes], max_subsets, ModePartition[ModeFitOrder[modes]].nbits, BC6H_data->issigned); + SwapIndices(F16EndPoints[modes], best_Indices[modes], BC6H_data->entryCount, max_subsets, ModeFitOrder[modes], BC6H_data->d_shape_index); + transformFit = TransformEndPoints(BC6H_data, F16EndPoints[modes], quantEndPoints[modes], max_subsets, ModeFitOrder[modes]); + } + if (transformFit) + { + if (BC6H_data->region == 1) + { + bestFit = (modes == bestEndpointMode) ? modes : ((modes < bestEndpointMode) ? modes : bestEndpointMode); + } + else + { + bestFit = modes; + } + bestError = opt_toterr[bestFit]; + error = bestError; + } + } + + } + } + + if (numfits > 0) + { + SaveCompressedBlockData(BC6H_data, quantEndPoints[bestFit], best_Indices[bestFit], max_subsets, ModeFitOrder[bestFit]); + return error; + } + + // Should not get here! + return error; +} + +void CompressBlockBC6_Internal(CMP_GLOBAL unsigned char*outdata, + CGU_UINT32 destIdx, + BC6H_Encode_local * BC6HEncode_local, + CMP_GLOBAL const BC6H_Encode *BC6HEncode) +{ + //printf("---SRC---\n"); + //CGU_UINT8 blkindex = 0; + //CGU_UINT8 srcindex = 0; + //for ( CGU_INT32 j = 0; j < 16; j++) { + // printf("%5.0f,",BC6HEncode_local->din[j][0]);// R + // printf("%5.0f,",BC6HEncode_local->din[j][1]);// G + // printf("%5.0f,",BC6HEncode_local->din[j][2]);// B + // printf("%5.0f\n,",BC6HEncode_local->din[j][3]);// No Alpha + //} + + CGU_UINT8 Cmp_Red_Block[16] = { 0xc2,0x7b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00 }; + + CGU_FLOAT bestError = CMP_FLOAT_MAX; + CGU_FLOAT error = CMP_FLOAT_MAX; + CGU_INT8 bestShape = 0; + CGU_FLOAT quality = BC6HEncode->m_quality; + BC6HEncode_local->issigned = BC6HEncode->m_isSigned; + // run through no partition first + error = FindBestPattern(BC6HEncode_local, false, 0, quality); + if (error < bestError) + { + bestError = error; + bestShape = -1; + + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_shape_indices,(CGU_UINT8 *) BC6HEncode_local->shape_indices, sizeof(BC6HEncode_local->shape_indices)); + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_partition ,(CGU_UINT8 *) BC6HEncode_local->partition, sizeof(BC6HEncode_local->partition)); + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_fEndPoints ,(CGU_UINT8 *) BC6HEncode_local->fEndPoints, sizeof(BC6HEncode_local->fEndPoints)); + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_entryCount ,(CGU_UINT8 *) BC6HEncode_local->entryCount, sizeof(BC6HEncode_local->entryCount)); + BC6HEncode_local->d_shape_index = bestShape; + } + + + // run through 32 possible partition set + for (CGU_INT8 shape = 0; shape < MAX_BC6H_PARTITIONS; shape++) + { + error = FindBestPattern(BC6HEncode_local, true, shape, quality); + if (error < bestError) + { + bestError = error; + bestShape = shape; + + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_shape_indices, (CGU_UINT8 *)BC6HEncode_local->shape_indices, sizeof(BC6HEncode_local->shape_indices)); + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_partition , (CGU_UINT8 *)BC6HEncode_local->partition, sizeof(BC6HEncode_local->partition)); + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_fEndPoints , (CGU_UINT8 *)BC6HEncode_local->fEndPoints, sizeof(BC6HEncode_local->fEndPoints)); + memcpy((CGU_UINT8 *)BC6HEncode_local->cur_best_entryCount , (CGU_UINT8 *)BC6HEncode_local->entryCount, sizeof(BC6HEncode_local->entryCount)); + BC6HEncode_local->d_shape_index = bestShape; + } + else + { + if (bestShape != -1) + { + BC6HEncode_local->d_shape_index = bestShape; + memcpy((CGU_UINT8 *)BC6HEncode_local->shape_indices, (CGU_UINT8 *)BC6HEncode_local->cur_best_shape_indices, sizeof(BC6HEncode_local->shape_indices)); + memcpy((CGU_UINT8 *)BC6HEncode_local->partition , (CGU_UINT8 *)BC6HEncode_local->cur_best_partition, sizeof(BC6HEncode_local->partition)); + memcpy((CGU_UINT8 *)BC6HEncode_local->fEndPoints , (CGU_UINT8 *)BC6HEncode_local->cur_best_fEndPoints, sizeof(BC6HEncode_local->fEndPoints)); + memcpy((CGU_UINT8 *)BC6HEncode_local->entryCount , (CGU_UINT8 *)BC6HEncode_local->cur_best_entryCount, sizeof(BC6HEncode_local->entryCount)); + } + } + } + + bestError = EncodePattern(BC6HEncode_local, bestError); + + + // used for debugging modes, set the value you want to debug with + if (BC6HEncode_local->m_mode != 0) + { + // do final encoding and save to output block + SaveDataBlock(BC6HEncode_local, &outdata[destIdx]); + } + else + { + for (CGU_INT i = 0; i < 16; i++) + outdata[destIdx + i] = Cmp_Red_Block[i]; + } +} + +//============================================== USER INTERFACES ======================================================== + +#ifndef ASPM_GPU +#ifndef ASPM +//======================= DECOMPRESS ========================================= +using namespace std; + +static AMD_BC6H_Format extract_format(const CGU_UINT8 in[COMPRESSED_BLOCK_SIZE]) +{ + AMD_BC6H_Format bc6h_format; + unsigned short decvalue; + CGU_UINT8 iData[COMPRESSED_BLOCK_SIZE]; + memcpy(iData,in,COMPRESSED_BLOCK_SIZE); + + memset(&bc6h_format,0,sizeof(AMD_BC6H_Format)); + + // 2 bit mode has Mode bit:2 = 0 and mode bits:1 = 0 or 1 + // 5 bit mode has Mode bit:2 = 1 + if ((in[0]&0x02) > 0) + { + decvalue = (in[0]&0x1F); // first five bits + } + else + { + decvalue = (in[0]&0x01); // first two bits + } + + BitHeader header(in,16); + + switch (decvalue) + { + case 0x00: + bc6h_format.m_mode = 1; // 10:5:5:5 + bc6h_format.wBits = 10; + bc6h_format.tBits[C_RED] = 5; + bc6h_format.tBits[C_GREEN] = 5; + bc6h_format.tBits[C_BLUE] = 5; + bc6h_format.rw = header.getvalue(5 ,10); // 10: rw[9:0] + bc6h_format.rx = header.getvalue(35,5); // 5: rx[4:0] + bc6h_format.ry = header.getvalue(65,5); // 5: ry[4:0] + bc6h_format.rz = header.getvalue(71,5); // 5: rz[4:0] + bc6h_format.gw = header.getvalue(15,10); // 10: gw[9:0] + bc6h_format.gx = header.getvalue(45,5); // 5: gx[4:0] + bc6h_format.gy = header.getvalue(41,4) | // 5: gy[3:0] + (header.getvalue(2,1) << 4); // gy[4] + bc6h_format.gz = header.getvalue(51,4) | // 5: gz[3:0] + (header.getvalue(40,1) << 4); // gz[4] + bc6h_format.bw = header.getvalue(25,10); // 10: bw[9:0] + bc6h_format.bx = header.getvalue(55,5); // 5: bx[4:0] + bc6h_format.by = header.getvalue(61,4) | // 5: by[3:0] + (header.getvalue(3,1) << 4); // by[4] + bc6h_format.bz = header.getvalue(50,1) | // 5: bz[0] + (header.getvalue(60,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3) | // bz[3] + (header.getvalue(4 ,1) << 4); // bz[4] + break; + case 0x01: + bc6h_format.m_mode = 2; // 7:6:6:6 + bc6h_format.wBits = 7; + bc6h_format.tBits[C_RED] = 6; + bc6h_format.tBits[C_GREEN] = 6; + bc6h_format.tBits[C_BLUE] = 6; + bc6h_format.rw = header.getvalue(5,7); // 7: rw[6:0] + bc6h_format.rx = header.getvalue(35,6); // 6: rx[5:0] + bc6h_format.ry = header.getvalue(65,6); // 6: ry[5:0] + bc6h_format.rz = header.getvalue(71,6); // 6: rz[5:0] + bc6h_format.gw = header.getvalue(15,7); // 7: gw[6:0] + bc6h_format.gx = header.getvalue(45,6); // 6: gx[5:0] + bc6h_format.gy = header.getvalue(41,4) | // 6: gy[3:0] + (header.getvalue(24,1) << 4) | // gy[4] + (header.getvalue(2,1) << 5); // gy[5] + bc6h_format.gz = header.getvalue(51,4) | // 6: gz[3:0] + (header.getvalue(3,1) << 4) | // gz[4] + (header.getvalue(4,1) << 5); // gz[5] + bc6h_format.bw = header.getvalue(25,7); // 7: bw[6:0] + bc6h_format.bx = header.getvalue(55,6); // 6: bx[5:0] + bc6h_format.by = header.getvalue(61,4) | // 6: by[3:0] + (header.getvalue(14,1) << 4) | // by[4] + (header.getvalue(22,1) << 5); // by[5] + bc6h_format.bz = header.getvalue(12,1) | // 6: bz[0] + (header.getvalue(13,1) << 1) | // bz[1] + (header.getvalue(23,1) << 2) | // bz[2] + (header.getvalue(32,1) << 3) | // bz[3] + (header.getvalue(34,1) << 4) | // bz[4] + (header.getvalue(33,1) << 5); // bz[5] + break; + case 0x02: + bc6h_format.m_mode = 3; // 11:5:4:4 + bc6h_format.wBits = 11; + bc6h_format.tBits[C_RED] = 5; + bc6h_format.tBits[C_GREEN] = 4; + bc6h_format.tBits[C_BLUE] = 4; + bc6h_format.rw = header.getvalue(5,10) | //11: rw[9:0] + (header.getvalue(40,1) << 10); // rw[10] + bc6h_format.rx = header.getvalue(35,5); // 5: rx[4:0] + bc6h_format.ry = header.getvalue(65,5); // 5: ry[4:0] + bc6h_format.rz = header.getvalue(71,5); // 5: rz[4:0] + bc6h_format.gw = header.getvalue(15,10) | //11: gw[9:0] + (header.getvalue(49,1) << 10); // gw[10] + bc6h_format.gx = header.getvalue(45,4); //4: gx[3:0] + bc6h_format.gy = header.getvalue(41,4); //4: gy[3:0] + bc6h_format.gz = header.getvalue(51,4); //4: gz[3:0] + bc6h_format.bw = header.getvalue(25,10) | //11: bw[9:0] + (header.getvalue(59,1) << 10); // bw[10] + bc6h_format.bx = header.getvalue(55,4); //4: bx[3:0] + bc6h_format.by = header.getvalue(61,4); //4: by[3:0] + bc6h_format.bz = header.getvalue(50,1) | //4: bz[0] + (header.getvalue(60,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3); // bz[3] + break; + case 0x06: + bc6h_format.m_mode = 4; // 11:4:5:4 + bc6h_format.wBits = 11; + bc6h_format.tBits[C_RED] = 4; + bc6h_format.tBits[C_GREEN] = 5; + bc6h_format.tBits[C_BLUE] = 4; + bc6h_format.rw = header.getvalue(5,10) | //11: rw[9:0] + (header.getvalue(39,1) << 10); // rw[10] + bc6h_format.rx = header.getvalue(35,4); //4: rx[3:0] + bc6h_format.ry = header.getvalue(65,4); //4: ry[3:0] + bc6h_format.rz = header.getvalue(71,4); //4: rz[3:0] + bc6h_format.gw = header.getvalue(15,10) | //11: gw[9:0] + (header.getvalue(50,1) << 10); // gw[10] + bc6h_format.gx = header.getvalue(45,5); //5: gx[4:0] + bc6h_format.gy = header.getvalue(41,4) | //5: gy[3:0] + (header.getvalue(75,1) << 4); // gy[4] + bc6h_format.gz = header.getvalue(51,4) | //5: gz[3:0] + (header.getvalue(40,1) << 4); // gz[4] + bc6h_format.bw = header.getvalue(25,10) | //11: bw[9:0] + (header.getvalue(59,1) << 10); // bw[10] + bc6h_format.bx = header.getvalue(55,4); //4: bx[3:0] + bc6h_format.by = header.getvalue(61,4); //4: by[3:0] + bc6h_format.bz = header.getvalue(69,1) | //4: bz[0] + (header.getvalue(60,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3); // bz[3] + break; + case 0x0A: + bc6h_format.m_mode = 5; // 11:4:4:5 + bc6h_format.wBits = 11; + bc6h_format.tBits[C_RED] = 4; + bc6h_format.tBits[C_GREEN] = 4; + bc6h_format.tBits[C_BLUE] = 5; + bc6h_format.rw = header.getvalue(5,10) | //11: rw[9:0] + (header.getvalue(39,1) << 10); // rw[10] + bc6h_format.rx = header.getvalue(35,4); //4: rx[3:0] + bc6h_format.ry = header.getvalue(65,4); //4: ry[3:0] + bc6h_format.rz = header.getvalue(71,4); //4: rz[3:0] + bc6h_format.gw = header.getvalue(15,10) | //11: gw[9:0] + (header.getvalue(49,1) << 10); // gw[10] + bc6h_format.gx = header.getvalue(45,4); //4: gx[3:0] + bc6h_format.gy = header.getvalue(41,4); //4: gy[3:0] + bc6h_format.gz = header.getvalue(51,4); //4: gz[3:0] + bc6h_format.bw = header.getvalue(25,10) | //11: bw[9:0] + (header.getvalue(60,1) << 10); // bw[10] + bc6h_format.bx = header.getvalue(55,5); //5: bx[4:0] + bc6h_format.by = header.getvalue(61,4); //5: by[3:0] + (header.getvalue(40,1) << 4); // by[4] + bc6h_format.bz = header.getvalue(50,1) | //5: bz[0] + (header.getvalue(69,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3) | // bz[3] + (header.getvalue(75,1) << 4); // bz[4] + break; + case 0x0E: + bc6h_format.m_mode = 6; // 9:5:5:5 + bc6h_format.wBits = 9; + bc6h_format.tBits[C_RED] = 5; + bc6h_format.tBits[C_GREEN] = 5; + bc6h_format.tBits[C_BLUE] = 5; + bc6h_format.rw = header.getvalue(5,9); //9: rw[8:0] + bc6h_format.gw = header.getvalue(15,9); //9: gw[8:0] + bc6h_format.bw = header.getvalue(25,9); //9: bw[8:0] + bc6h_format.rx = header.getvalue(35,5); //5: rx[4:0] + bc6h_format.gx = header.getvalue(45,5); //5: gx[4:0] + bc6h_format.bx = header.getvalue(55,5); //5: bx[4:0] + bc6h_format.ry = header.getvalue(65,5); //5: ry[4:0] + bc6h_format.gy = header.getvalue(41,4) | //5: gy[3:0] + (header.getvalue(24,1) << 4); // gy[4] + bc6h_format.by = header.getvalue(61,4) | //5: by[3:0] + (header.getvalue(14,1) << 4); // by[4] + bc6h_format.rz = header.getvalue(71,5); //5: rz[4:0] + bc6h_format.gz = header.getvalue(51,4) | //5: gz[3:0] + (header.getvalue(40,1) << 4); // gz[4] + bc6h_format.bz = header.getvalue(50,1) | //5: bz[0] + (header.getvalue(60,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3) | // bz[3] + (header.getvalue(34,1) << 4); // bz[4] + break; + case 0x12: + bc6h_format.m_mode = 7; // 8:6:5:5 + bc6h_format.wBits = 8; + bc6h_format.tBits[C_RED] = 6; + bc6h_format.tBits[C_GREEN] = 5; + bc6h_format.tBits[C_BLUE] = 5; + bc6h_format.rw = header.getvalue(5,8); //8: rw[7:0] + bc6h_format.gw = header.getvalue(15,8); //8: gw[7:0] + bc6h_format.bw = header.getvalue(25,8); //8: bw[7:0] + bc6h_format.rx = header.getvalue(35,6); //6: rx[5:0] + bc6h_format.gx = header.getvalue(45,5); //5: gx[4:0] + bc6h_format.bx = header.getvalue(55,5); //5: bx[4:0] + bc6h_format.ry = header.getvalue(65,6); //6: ry[5:0] + bc6h_format.gy = header.getvalue(41,4) | //5: gy[3:0] + (header.getvalue(24,1) << 4); // gy[4] + bc6h_format.by = header.getvalue(61,4) | //5: by[3:0] + (header.getvalue(14,1) << 4); // by[4] + bc6h_format.rz = header.getvalue(71,6); //6: rz[5:0] + bc6h_format.gz = header.getvalue(51,4) | //5: gz[3:0] + (header.getvalue(13,1) << 4); // gz[4] + bc6h_format.bz = header.getvalue(50,1) | //5: bz[0] + (header.getvalue(60,1) << 1) | // bz[1] + (header.getvalue(23,1) << 2) | // bz[2] + (header.getvalue(33,1) << 3) | // bz[3] + (header.getvalue(34,1) << 4); // bz[4] + break; + case 0x16: + bc6h_format.m_mode = 8; // 8:5:6:5 + bc6h_format.wBits = 8; + bc6h_format.tBits[C_RED] = 5; + bc6h_format.tBits[C_GREEN] = 6; + bc6h_format.tBits[C_BLUE] = 5; + bc6h_format.rw = header.getvalue(5,8); //8: rw[7:0] + bc6h_format.gw = header.getvalue(15,8); //8: gw[7:0] + bc6h_format.bw = header.getvalue(25,8); //8: bw[7:0] + bc6h_format.rx = header.getvalue(35,5); //5: rx[4:0] + bc6h_format.gx = header.getvalue(45,6); //6: gx[5:0] + bc6h_format.bx = header.getvalue(55,5); //5: bx[4:0] + bc6h_format.ry = header.getvalue(65,5); //5: ry[4:0] + bc6h_format.gy = header.getvalue(41,4) | //6: gy[3:0] + (header.getvalue(24,1) << 4) | // gy[4] + (header.getvalue(23,1) << 5); // gy[5] + bc6h_format.by = header.getvalue(61,4) | //5: by[3:0] + (header.getvalue(14,1) << 4); // by[4] + bc6h_format.rz = header.getvalue(71,5); //5: rz[4:0] + bc6h_format.gz = header.getvalue(51,4) | //6: gz[3:0] + (header.getvalue(40,1) << 4) | // gz[4] + (header.getvalue(33,1) << 5); // gz[5] + bc6h_format.bz = header.getvalue(13,1) | //5: bz[0] + (header.getvalue(60,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3) | // bz[3] + (header.getvalue(34,1) << 4); // bz[4] + break; + case 0x1A: + bc6h_format.m_mode = 9; // 8:5:5:6 + bc6h_format.wBits = 8; + bc6h_format.tBits[C_RED] = 5; + bc6h_format.tBits[C_GREEN] = 5; + bc6h_format.tBits[C_BLUE] = 6; + bc6h_format.rw = header.getvalue(5,8); //8: rw[7:0] + bc6h_format.gw = header.getvalue(15,8); //8: gw[7:0] + bc6h_format.bw = header.getvalue(25,8); //8: bw[7:0] + bc6h_format.rx = header.getvalue(35,5); //5: rx[4:0] + bc6h_format.gx = header.getvalue(45,5); //5: gx[4:0] + bc6h_format.bx = header.getvalue(55,6); //6: bx[5:0] + bc6h_format.ry = header.getvalue(65,5); //5: ry[4:0] + bc6h_format.gy = header.getvalue(41,4) | //5: gy[3:0] + (header.getvalue(24,1) << 4); // gy[4] + bc6h_format.by = header.getvalue(61,4) | //6: by[3:0] + (header.getvalue(14,1) << 4) | // by[4] + (header.getvalue(23,1) << 5); // by[5] + bc6h_format.rz = header.getvalue(71,5); //5: rz[4:0] + bc6h_format.gz = header.getvalue(51,4) | //5: gz[3:0] + (header.getvalue(40,1) << 4); // gz[4] + bc6h_format.bz = header.getvalue(50,1) | //6: bz[0] + (header.getvalue(13,1) << 1) | // bz[1] + (header.getvalue(70,1) << 2) | // bz[2] + (header.getvalue(76,1) << 3) | // bz[3] + (header.getvalue(34,1) << 4) | // bz[4] + (header.getvalue(33,1) << 5); // bz[5] + break; + case 0x1E: + bc6h_format.m_mode = 10; // 6:6:6:6 + bc6h_format.istransformed = FALSE; + bc6h_format.wBits = 6; + bc6h_format.tBits[C_RED] = 6; + bc6h_format.tBits[C_GREEN] = 6; + bc6h_format.tBits[C_BLUE] = 6; + bc6h_format.rw = header.getvalue(5,6); //6: rw[5:0] + bc6h_format.gw = header.getvalue(15,6); //6: gw[5:0] + bc6h_format.bw = header.getvalue(25,6); //6: bw[5:0] + bc6h_format.rx = header.getvalue(35,6); //6: rx[5:0] + bc6h_format.gx = header.getvalue(45,6); //6: gx[5:0] + bc6h_format.bx = header.getvalue(55,6); //6: bx[5:0] + bc6h_format.ry = header.getvalue(65,6); //6: ry[5:0] + bc6h_format.gy = header.getvalue(41,4) | //6: gy[3:0] + (header.getvalue(24,1) << 4) | // gy[4] + (header.getvalue(21,1) << 5); // gy[5] + bc6h_format.by = header.getvalue(61,4) | //6: by[3:0] + (header.getvalue(14,1) << 4) | // by[4] + (header.getvalue(22,1) << 5); // by[5] + bc6h_format.rz = header.getvalue(71,6); //6: rz[5:0] + bc6h_format.gz = header.getvalue(51,4) | //6: gz[3:0] + (header.getvalue(11,1) << 4) | // gz[4] + (header.getvalue(31,1) << 5); // gz[5] + bc6h_format.bz = header.getvalue(12,1) | //6: bz[0] + (header.getvalue(13,1) << 1) | // bz[1] + (header.getvalue(23,1) << 2) | // bz[2] + (header.getvalue(32,1) << 3) | // bz[3] + (header.getvalue(34,1) << 4) | // bz[4] + (header.getvalue(33,1) << 5); // bz[5] + break; + + // Single region modes + case 0x03: + bc6h_format.m_mode = 11; // 10:10 + bc6h_format.wBits = 10; + bc6h_format.tBits[C_RED] = 10; + bc6h_format.tBits[C_GREEN] = 10; + bc6h_format.tBits[C_BLUE] = 10; + bc6h_format.rw = header.getvalue(5,10); // 10: rw[9:0] + bc6h_format.gw = header.getvalue(15,10); // 10: gw[9:0] + bc6h_format.bw = header.getvalue(25,10); // 10: bw[9:0] + bc6h_format.rx = header.getvalue(35,10); // 10: rx[9:0] + bc6h_format.gx = header.getvalue(45,10); // 10: gx[9:0] + bc6h_format.bx = header.getvalue(55,10); // 10: bx[9:0] + break; + case 0x07: + bc6h_format.m_mode = 12; // 11:9 + bc6h_format.wBits = 11; + bc6h_format.tBits[C_RED] = 9; + bc6h_format.tBits[C_GREEN] = 9; + bc6h_format.tBits[C_BLUE] = 9; + bc6h_format.rw = header.getvalue(5,10) | // 10: rw[9:0] + (header.getvalue(44,1) << 10); // rw[10] + bc6h_format.gw = header.getvalue(15,10) | // 10: gw[9:0] + (header.getvalue(54,1) << 10); // gw[10] + bc6h_format.bw = header.getvalue(25,10) | // 10: bw[9:0] + (header.getvalue(64,1) << 10); // bw[10] + bc6h_format.rx = header.getvalue(35,9); // 9: rx[8:0] + bc6h_format.gx = header.getvalue(45,9); // 9: gx[8:0] + bc6h_format.bx = header.getvalue(55,9); // 9: bx[8:0] + break; + case 0x0B: + bc6h_format.m_mode = 13; // 12:8 + bc6h_format.wBits = 12; + bc6h_format.tBits[C_RED] = 8; + bc6h_format.tBits[C_GREEN] = 8; + bc6h_format.tBits[C_BLUE] = 8; + bc6h_format.rw = header.getvalue(5, 10) | // 12: rw[9:0] + (header.getvalue(43, 1) << 11) | // rw[11] + (header.getvalue(44, 1) << 10); // rw[10] + bc6h_format.gw = header.getvalue(15, 10) | // 12: gw[9:0] + (header.getvalue(53, 1) << 11) | // gw[11] + (header.getvalue(54, 1) << 10); // gw[10] + bc6h_format.bw = header.getvalue(25,10) | // 12: bw[9:0] + (header.getvalue(63, 1) << 11) | // bw[11] + (header.getvalue(64,1) << 10); // bw[10] + bc6h_format.rx = header.getvalue(35,8); // 8: rx[7:0] + bc6h_format.gx = header.getvalue(45,8); // 8: gx[7:0] + bc6h_format.bx = header.getvalue(55,8); // 8: bx[7:0] + break; + case 0x0F: + bc6h_format.m_mode = 14; // 16:4 + bc6h_format.wBits = 16; + bc6h_format.tBits[C_RED] = 4; + bc6h_format.tBits[C_GREEN] = 4; + bc6h_format.tBits[C_BLUE] = 4; + bc6h_format.rw = header.getvalue(5,10) | // 16: rw[9:0] + (header.getvalue(39, 1) << 15) | // rw[15] + (header.getvalue(40, 1) << 14) | // rw[14] + (header.getvalue(41, 1) << 13) | // rw[13] + (header.getvalue(42, 1) << 12) | // rw[12] + (header.getvalue(43, 1) << 11) | // rw[11] + (header.getvalue(44, 1) << 10); // rw[10] + bc6h_format.gw = header.getvalue(15,10) | // 16: gw[9:0] + (header.getvalue(49, 1) << 15) | // gw[15] + (header.getvalue(50, 1) << 14) | // gw[14] + (header.getvalue(51, 1) << 13) | // gw[13] + (header.getvalue(52, 1) << 12) | // gw[12] + (header.getvalue(53, 1) << 11) | // gw[11] + (header.getvalue(54, 1) << 10); // gw[10] + bc6h_format.bw = header.getvalue(25,10) | // 16: bw[9:0] + (header.getvalue(59, 1) << 15) | // bw[15] + (header.getvalue(60, 1) << 14) | // bw[14] + (header.getvalue(61, 1) << 13) | // bw[13] + (header.getvalue(62, 1) << 12) | // bw[12] + (header.getvalue(63, 1) << 11) | // bw[11] + (header.getvalue(64, 1) << 10); // bw[10] + bc6h_format.rx = header.getvalue(35,4); // 4: rx[3:0] + bc6h_format.gx = header.getvalue(45,4); // 4: gx[3:0] + bc6h_format.bx = header.getvalue(55,4); // 4: bx[3:0] + break; + default: + bc6h_format.m_mode = 0; + return bc6h_format; + } + + // Each format in the mode table can be uniquely identified by the mode bits. + // The first ten modes are used for two-region tiles, and the mode bit field + // can be either two or five bits long. These blocks also have fields for + // the compressed color endpoints (72 or 75 bits), the partition (5 bits), + // and the partition indices (46 bits). + + if (bc6h_format.m_mode <= 10) + { + bc6h_format.region = BC6_TWO; + // Get the shape index bits 77 to 81 + bc6h_format.d_shape_index = (unsigned short) header.getvalue(77,5); + bc6h_format.istransformed = (bc6h_format.m_mode < 10) ? TRUE : FALSE; + } + else + { + bc6h_format.region = BC6_ONE; + bc6h_format.d_shape_index = 0; + bc6h_format.istransformed = (bc6h_format.m_mode > 11) ? TRUE : FALSE; + } + + // Save the points in a form easy to compute with + bc6h_format.EC[0].A[0] = (CGU_FLOAT)bc6h_format.rw; + bc6h_format.EC[0].B[0] = (CGU_FLOAT)bc6h_format.rx; + bc6h_format.EC[1].A[0] = (CGU_FLOAT)bc6h_format.ry; + bc6h_format.EC[1].B[0] = (CGU_FLOAT)bc6h_format.rz; + bc6h_format.EC[0].A[1] = (CGU_FLOAT)bc6h_format.gw; + bc6h_format.EC[0].B[1] = (CGU_FLOAT)bc6h_format.gx; + bc6h_format.EC[1].A[1] = (CGU_FLOAT)bc6h_format.gy; + bc6h_format.EC[1].B[1] = (CGU_FLOAT)bc6h_format.gz; + bc6h_format.EC[0].A[2] = (CGU_FLOAT)bc6h_format.bw; + bc6h_format.EC[0].B[2] = (CGU_FLOAT)bc6h_format.bx; + bc6h_format.EC[1].A[2] = (CGU_FLOAT)bc6h_format.by; + bc6h_format.EC[1].B[2] = (CGU_FLOAT)bc6h_format.bz; + + if (bc6h_format.region == BC6_ONE) + { + int startbits = ONE_REGION_INDEX_OFFSET; + bc6h_format.indices16[0] = (CGU_UINT8) header.getvalue(startbits,3); + startbits+=3; + for (int i=1; i<16; i++) + { + bc6h_format.indices16[i] = (CGU_UINT8)header.getvalue(startbits,4); + startbits+=4; + } + } + else + { + int startbit = TWO_REGION_INDEX_OFFSET, + nbits = 2; + bc6h_format.indices16[0 ] = (CGU_UINT8)header.getvalue(startbit,2); + for (int i= 1; i<16; i++) + { + startbit += nbits; // offset start bit for next index using prior nbits used + nbits = g_indexfixups[bc6h_format.d_shape_index] == i?2:3; // get new number of bit to save index with + bc6h_format.indices16[i] = (CGU_UINT8)header.getvalue(startbit,nbits); + } + + } + + return bc6h_format; +} + +static void extract_compressed_endpoints(AMD_BC6H_Format& bc6h_format) +{ + int i; + int t; + + if (bc6h_format.issigned) + { + if (bc6h_format.istransformed) + { + for (i=0; i= 15) + unq = q; + else if (q == 0) + unq = 0; + else if (q == ((1<> prec; + break; + + // here, let's stick with S16 (no apparent quality benefit from going to S17) + // range is (-7c00..7c00)/(-8000..8000) = 31/32 + case SIGNED_F16: + // don't remove this test even though it appears equivalent to the code below + // as it isn't -- the code below can overflow for prec = 16 + if (prec >= 16) + unq = q; + else + { + if (q < 0) { s = 1; q = -q; } else s = 0; + + if (q == 0) + unq = 0; + else if (q >= ((1<<(prec-1))-1)) + unq = s ? -S16MAX : S16MAX; + else + { + unq = (q * (S16MAX+1) + (S16MAX+1)/2) >> (prec-1); + if (s) + unq = -unq; + } + } + break; + } + return unq; +} + +static int lerp(int a, int b, int i, int denom) +{ + assert (denom == 3 || denom == 7 || denom == 15); + assert (i >= 0 && i <= denom); + + int shift = 6, *weights = NULL; + + switch(denom) + { + case 3: denom *= 5; i *= 5; // fall through to case 15 + case 15: weights = g_aWeights4; break; + case 7: weights = g_aWeights3; break; + default: assert(0); + } + + #pragma warning(disable:4244) + // no need to round these as this is an exact division + return (int)(a*weights[denom-i] +b*weights[i]) / float(1 << shift); +} + +static int finish_unquantize(AMD_BC6H_Format bc6h_format, int q) +{ + if (bc6h_format.format == UNSIGNED_F16) + return (q * 31) >> 6; // scale the magnitude by 31/64 + else if (bc6h_format.format == SIGNED_F16) + return (q < 0) ? -(((-q) * 31) >> 5) : (q * 31) >> 5; // scale the magnitude by 31/32 + else + return q; +} + +static void generate_palette_quantized(int max, AMD_BC6H_Format& bc6h_format, int region) +{ + // scale endpoints + int a, b, c; // really need a IntVec3... + + a = unquantize(bc6h_format, bc6h_format.E[region].A[0], bc6h_format.wBits); + b = unquantize(bc6h_format, bc6h_format.E[region].B[0], bc6h_format.wBits); + + // interpolate : This part of code is used for debuging data + for (int i = 0; i < max; i++) + { + c = finish_unquantize(bc6h_format, lerp(a, b, i, max-1)); + bc6h_format.Palete[region][i].x = c; + } + + a = unquantize(bc6h_format, bc6h_format.E[region].A[1], bc6h_format.wBits); + b = unquantize(bc6h_format, bc6h_format.E[region].B[1], bc6h_format.wBits); + + // interpolate + for (int i = 0; i < max; i++) + bc6h_format.Palete[region][i].y = finish_unquantize(bc6h_format, lerp(a, b, i, max-1)); + + a = unquantize(bc6h_format,bc6h_format.E[region].A[2], bc6h_format.wBits); + b = unquantize(bc6h_format,bc6h_format.E[region].B[2], bc6h_format.wBits); + + // interpolate + for (int i = 0; i < max; i++) + bc6h_format.Palete[region][i].z = finish_unquantize(bc6h_format, lerp(a, b, i, max-1)); +} + +// NV code : used with modifications +static void extract_compressed_endpoints2(AMD_BC6H_Format& bc6h_format) +{ + int i; + int t; + + if (bc6h_format.issigned) + { + if (bc6h_format.istransformed) + { + for (i=0; i(options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC6(void *options, CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + BC6H_Encode *BC6optionsDefault = (BC6H_Encode *)options; + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC6optionsDefault->m_quality = fquality; + BC6optionsDefault->m_partitionSearchSize = (BC6optionsDefault->m_quality*2.0F) / qFAST_THRESHOLD; + if (BC6optionsDefault->m_partitionSearchSize < (1.0F / 16.0F)) + BC6optionsDefault->m_partitionSearchSize = (1.0F / 16.0F); + return CGU_CORE_OK; +} + +int CMP_CDECL SetMaskBC6(void *options, CGU_UINT32 mask) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + BC6H_Encode *BC6options = (BC6H_Encode *)options; + BC6options->m_validModeMask = mask; + return CGU_CORE_OK; +} + +int CMP_CDECL CompressBlockBC6(const CGU_UINT16 *srcBlock, + unsigned int srcStrideInShorts, + CMP_GLOBAL CGU_UINT8 cmpBlock[16], + const CMP_GLOBAL void *options = NULL) +{ + + CGU_UINT16 inBlock[48]; + + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInShorts; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlock[dstptr++] = CGU_UINT16(srcBlock[srcpos++]); + inBlock[dstptr++] = CGU_UINT16(srcBlock[srcpos++]); + inBlock[dstptr++] = CGU_UINT16(srcBlock[srcpos++]); + } + } + + + BC6H_Encode *BC6HEncode = (BC6H_Encode *)options; + BC6H_Encode BC6HEncodeDefault; + + if (BC6HEncode == NULL) + { + BC6HEncode = &BC6HEncodeDefault; + SetDefaultBC6Options(BC6HEncode); + } + + BC6H_Encode_local BC6HEncode_local; + memset((CGU_UINT8 *)&BC6HEncode_local, 0, sizeof(BC6H_Encode_local)); + CGU_UINT8 blkindex = 0; + for ( CGU_INT32 j = 0; j < 16; j++) { + BC6HEncode_local.din[j][0] = inBlock[blkindex++]; // R + BC6HEncode_local.din[j][1] = inBlock[blkindex++]; // G + BC6HEncode_local.din[j][2] = inBlock[blkindex++]; // B + BC6HEncode_local.din[j][3] = 0; // A + } + + CompressBlockBC6_Internal(cmpBlock, 0, &BC6HEncode_local,BC6HEncode); + + return CGU_CORE_OK; +} + +int CMP_CDECL DecompressBlockBC6(const unsigned char cmpBlock[16], + CGU_UINT16 srcBlock[48], + const void *options = NULL) { + BC6H_Encode *BC6HEncode = (BC6H_Encode *)options; + BC6H_Encode BC6HEncodeDefault; + + if (BC6HEncode == NULL) + { + BC6HEncode = &BC6HEncodeDefault; + SetDefaultBC6Options(BC6HEncode); + } + DecompressBC6_Internal(srcBlock, cmpBlock,BC6HEncode); + + return CGU_CORE_OK; +} + +#endif // !ASPM +#endif // !ASPM_GPU + +//============================================== OpenCL USER INTERFACE ==================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder( + CMP_GLOBAL CGU_UINT8* p_source_pixels, + CMP_GLOBAL CGU_UINT8* p_encoded_blocks, + CMP_GLOBAL Source_Info* SourceInfo, + CMP_GLOBAL BC6H_Encode * BC6HEncode +) +{ + CGU_UINT32 x = get_global_id(0); + CGU_UINT32 y = get_global_id(1); + + if (x >= (SourceInfo->m_src_width / BYTEPP)) return; + if (y >= (SourceInfo->m_src_height / BYTEPP)) return; + + BC6H_Encode_local BC6HEncode_local; + memset((CGU_UINT8 *)&BC6HEncode_local, 0, sizeof(BC6H_Encode_local)); + + + CGU_UINT32 stride = SourceInfo->m_src_width * BYTEPP; + CGU_UINT32 srcOffset = (x*BlockX*BYTEPP) + (y*stride*BYTEPP); + CGU_UINT32 destI = (x*COMPRESSED_BLOCK_SIZE) + (y*(SourceInfo->m_src_width / BlockX)*COMPRESSED_BLOCK_SIZE); + CGU_UINT32 srcidx; + + //CGU_FLOAT block4x4[16][4]; + + for (CGU_INT i = 0; i < BlockX; i++) + { + srcidx = i * stride; + for (CGU_INT j = 0; j < BlockY; j++) + { + BC6HEncode_local.din[i*BlockX + j][0] = (CGU_UINT16)(p_source_pixels[srcOffset + srcidx++]); + if (BC6HEncode_local.din[i*BlockX + j][0] < 0.00001 || isnan(BC6HEncode_local.din[i*BlockX + j][0])) + { + if (BC6HEncode->m_isSigned) + { + BC6HEncode_local.din[i*BlockX + j][0] = (isnan(BC6HEncode_local.din[i*BlockX + j][0])) ? F16NEGPREC_LIMIT_VAL : -BC6HEncode_local.din[i*BlockX + j][0]; + if (BC6HEncode_local.din[i*BlockX + j][0] < F16NEGPREC_LIMIT_VAL) { + BC6HEncode_local.din[i*BlockX + j][0] = F16NEGPREC_LIMIT_VAL; + } + } + else + BC6HEncode_local.din[i*BlockX + j][0] = 0.0; + } + + BC6HEncode_local.din[i*BlockX + j][1] = (CGU_UINT16)(p_source_pixels[srcOffset + srcidx++]); + + if (BC6HEncode_local.din[i*BlockX + j][1] < 0.00001 || isnan(BC6HEncode_local.din[i*BlockX + j][1])) + { + if (BC6HEncode->m_isSigned) + { + BC6HEncode_local.din[i*BlockX + j][1] = (isnan(BC6HEncode_local.din[i*BlockX + j][1])) ? F16NEGPREC_LIMIT_VAL : -BC6HEncode_local.din[i*BlockX + j][1]; + if (BC6HEncode_local.din[i*BlockX + j][1] < F16NEGPREC_LIMIT_VAL) { + BC6HEncode_local.din[i*BlockX + j][1] = F16NEGPREC_LIMIT_VAL; + } + } + else + BC6HEncode_local.din[i*BlockX + j][1] = 0.0; + } + + BC6HEncode_local.din[i*BlockX + j][2] = (CGU_UINT16)(p_source_pixels[srcOffset + srcidx++]); + if (BC6HEncode_local.din[i*BlockX + j][2] < 0.00001 || isnan(BC6HEncode_local.din[i*BlockX + j][2])) + { + if (BC6HEncode->m_isSigned) + { + BC6HEncode_local.din[i*BlockX + j][2] = (isnan(BC6HEncode_local.din[i*BlockX + j][2])) ? F16NEGPREC_LIMIT_VAL : -BC6HEncode_local.din[i*BlockX + j][2]; + if (BC6HEncode_local.din[i*BlockX + j][2] < F16NEGPREC_LIMIT_VAL) { + BC6HEncode_local.din[i*BlockX + j][2] = F16NEGPREC_LIMIT_VAL; + } + } + else + BC6HEncode_local.din[i*BlockX + j][2] = 0.0; + } + + BC6HEncode_local.din[i*BlockX + j][3] = 0.0f; + //printf("Ori---src image %d, --%02x", x, (p_source_pixels[srcOffset + srcidx++]) & 0x0000ff); //for debug + } + } + + // printf(" X %3d Y %3d Quality %2.2f", x, y, BC6HEncode->m_quality); + CompressBlockBC6_Internal(p_encoded_blocks, destI, &BC6HEncode_local, BC6HEncode); +} +#endif diff --git a/extern/CMP_Core/shaders/BC6_Encode_kernel.h b/extern/CMP_Core/shaders/BC6_Encode_kernel.h new file mode 100644 index 00000000..435993d6 --- /dev/null +++ b/extern/CMP_Core/shaders/BC6_Encode_kernel.h @@ -0,0 +1,482 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef BC6_ENCODE_KERNEL_H +#define BC6_ENCODE_KERNEL_H + +#pragma warning(disable:4505) // disable warnings on unreferenced local function has been removed + +#include "Common_Def.h" + +#define MAX_TRACE 10 +#define MAX_ENTRIES_QUANT_TRACE 16 +#define BlockX 4 +#define BlockY 4 +#define BYTEPP 4 +#define COMPRESSED_BLOCK_SIZE 16 // Size of a compressed block in bytes +#define MAX_DIMENSION_BIG 4 +#define MAX_SUBSET_SIZE 16 // Largest possible size for an individual subset +#define NUM_BLOCK_TYPES 8 // Number of block types in the format +#define MAX_SUBSETS 3 // Maximum number of possible subsets +#define MAX_PARTITIONS 64 // Maximum number of partition types +#define MAX_ENTRIES 64 +#define MAX_TRY 20 + +#define MAX_PARTITIONS_TABLE (1+64+64) +#define DIMENSION 4 +#define MAX_CLUSTERS_BIG 16 +#define EPSILON 0.000001 +#define MAX_CLUSTERS_QUANT_TRACE 8 + +//# Image Quality will increase as this number gets larger and end-to-end performance time will reduce +#define MAX_INDEX_BITS 4 +#define HIGHQULITY_THRESHOLD 0.7F +#define qFAST_THRESHOLD 0.5F + +#define F16NEGPREC_LIMIT_VAL -2048.0f //f16 negative precision limit value + +#define LOG_CL_RANGE 5 +#define LOG_CL_BASE 2 +#define BIT_BASE 5 +#define BIT_RANGE 9 +#define MAX_CLUSTERS 8 +#define BTT(bits) (bits-BIT_BASE) +#define CLT(cl) (cl-LOG_CL_BASE) +#define MASK(n) ((1<<(n))-1) +#define SIGN_EXTEND_TYPELESS(x,nb) ((((x)&(1<<((nb)-1)))?((~0)<<(nb)):0)|(x)) +#define CMP_HALF_MAX 65504.0f // positive half max + +#ifndef ASPM_GPU +#include +#include +//typedef uint8_t byte; +#else +//typedef bitset uint8_t; +//typedef uint8 byte; +#endif + +#define BC6CompBlockSize 16 +#define BC6BlockX 4 +#define BC6BlockY 4 + +typedef struct +{ + CGU_INT k; + CGU_FLOAT d; +} BC6H_TRACE; + +#define NCHANNELS 3 +#define MAX_END_POINTS 2 +#define MAX_BC6H_MODES 14 +#define MAX_BC6H_PARTITIONS 32 +#define MAX_TWOREGION_MODES 10 +#define COMPRESSED_BLOCK_SIZE 16 // Size of a compressed block in bytes +#define ONE_REGION_INDEX_OFFSET 65 // bit location to start saving color index values for single region shape +#define TWO_REGION_INDEX_OFFSET 82 // bit location to start saving color index values for two region shapes +#define MIN_MODE_FOR_ONE_REGION 11 // Two regions shapes use modes 1..9 and single use 11..14 +#define R_0(ep) (ep)[0][0][i] +#define R_1(ep) (ep)[0][1][i] +#define R_2(ep) (ep)[1][0][i] +#define R_3(ep) (ep)[1][1][i] +#define FLT16_MAX 0x7bff + +#ifndef ASPM_GPU +#define USE_SHAKERHD +#endif + +#define USE_NEWRAMP + +typedef struct +{ + CGU_FLOAT A[NCHANNELS]; + CGU_FLOAT B[NCHANNELS]; +} END_Points; + +typedef struct +{ + CGU_FLOAT x, y, z; +} BC6H_Vec3f; + +typedef struct +{ + CGU_INT nbits; // Number of bits + CGU_INT prec[3]; // precission of the Qunatized RGB endpoints + CGU_INT transformed; // if 0, deltas are unsigned and no transform; otherwise, signed and transformed + CGU_INT modebits; // number of mode bits + CGU_INT IndexPrec; // Index Precision + CGU_INT mode; // Mode value to save + CGU_INT lowestPrec; // Step size of each precesion incriment +} ModePartitions; + +__constant ModePartitions ModePartition[MAX_BC6H_MODES + 1] = +{ + {0, {0,0,0}, 0, 0, 0, 0, 0}, // Mode = Invaild + + // Two region Partition + { 10, {5,5,5}, 1, 2, 3, 0x00, 31 }, // Mode = 1 + { 7, {6,6,6}, 1, 2, 3, 0x01, 248}, // Mode = 2 + { 11, {5,4,4}, 1, 5, 3, 0x02, 15 }, // Mode = 3 + { 11, {4,5,4}, 1, 5, 3, 0x06, 15 }, // Mode = 4 + { 11, {4,4,5}, 1, 5, 3, 0x0a, 15 }, // Mode = 5 + { 9, {5,5,5}, 1, 5, 3, 0x0e, 62 }, // Mode = 6 + { 8, {6,5,5}, 1, 5, 3, 0x12, 124}, // Mode = 7 + { 8, {5,6,5}, 1, 5, 3, 0x16, 124}, // Mode = 8 + { 8, {5,5,6}, 1, 5, 3, 0x1a, 124}, // Mode = 9 + { 6, {6,6,6}, 0, 5, 3, 0x1e, 496}, // Mode = 10 + + // One region Partition + {10, {10,10,10}, 0, 5, 4, 0x03, 31}, // Mode = 11 + {11, {9,9,9 }, 1, 5, 4, 0x07, 15}, // Mode = 12 + {12, {8,8,8 }, 1, 5, 4, 0x0b, 7 }, // Mode = 13 + {16, {4,4,4 }, 1, 5, 4, 0x0f, 1 } // Mode = 14 +}; + +//================================================ +// Mode Pathern order to try on endpoints +// The order can be rearranged to set which modes gets processed first +// for now it is set in order. +//================================================ +__constant CGU_INT8 ModeFitOrder[MAX_BC6H_MODES + 1] = +{ + 0, //0: N/A + // ---- 2 region lower bits --- + 1, // 10 5 5 5 + 2, // 7 6 6 6 + 3, // 11 5 4 5 + 4, // 11 4 5 4 + 5, // 11 4 4 5 + 6, // 9 5 5 5 + 7, // 8 6 5 5 + 8, // 8 5 6 5 + 9, // 8 5 5 6 + 10, // 6 6 6 6 + //------ 1 region high bits --- + 11, // 10 10 10 10 + 12, // 11 9 9 9 + 13, // 12 8 8 8 + 14 // 16 4 4 4 +}; + +// The Region2FixUps are for our index[subset = 2][16][3] locations +// indexed by shape region 2 +__constant CGU_INT g_Region2FixUp[32] = +{ + 7 , 3 , 11, 7, + 3 , 11, 9 , 5, + 2 , 12, 7 , 3, + 11, 7 , 11, 3, + 7 , 1 , 0 , 1, + 0 , 1 , 0 , 7, + 0 , 1 , 1 , 0, + 4 , 4 , 1 , 0, +}; + +// Indexed by all shape regions +// Partition Set Fixups for region 1 note region 0 is always at 0 +// that means normally we use 3 bits to define an index value +// if its at the fix up location then its one bit less +__constant CGU_INT g_indexfixups[32] = +{ + 15,15,15,15, + 15,15,15,15, + 15,15,15,15, + 15,15,15,15, + 15, 2, 8, 2, + 2, 8, 8,15, + 2, 8, 2, 2, + 8, 8, 2, 2, +}; + +typedef struct +{ + CGU_INT8 region; // one or two + CGU_INT8 m_mode; // m + CGU_INT8 d_shape_index; // d + CGU_INT rw; // endpt[0].A[0] + CGU_INT rx; // endpt[0].B[0] + CGU_INT ry; // endpt[1].A[0] + CGU_INT rz; // endpt[1].B[0] + CGU_INT gw; // endpt[0].A[1] + CGU_INT gx; // endpt[0].B[1] + CGU_INT gy; // endpt[1].A[1] + CGU_INT gz; // endpt[1].B[1] + CGU_INT bw; // endpt[0].A[2] + CGU_INT bx; // endpt[0].B[2] + CGU_INT by; // endpt[1].A[2] + CGU_INT bz; // endpt[1].B[2] + + union + { + CGU_UINT8 indices[4][4]; // Indices data after header block + CGU_UINT8 indices16[16]; + }; + + union + { + CGU_FLOAT din[MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; // Original data input as floats + unsigned char cdin[256]; // as uchar to match float + }; + + END_Points EC[MAX_END_POINTS]; // compressed endpoints expressed as endpt[0].A[] and endpt[1].B[] + END_Points E[MAX_END_POINTS]; // decompressed endpoints + CGU_BOOL issigned; // Format is 16 bit signed floating point + CGU_BOOL istransformed; // region two: all modes = true except mode=10 + short wBits; // number of bits for the root endpoint + short tBits[NCHANNELS]; // number of bits used for the transformed endpoints + CGU_INT format; // floating point format are we using for decompression + BC6H_Vec3f Paletef[2][16]; + + CGU_INT index; // for debugging + CGU_FLOAT fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + CGU_FLOAT cur_best_fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + CGU_INT shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]; + CGU_INT cur_best_shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]; + CGU_INT entryCount[MAX_SUBSETS]; + CGU_INT cur_best_entryCount[MAX_SUBSETS]; + CGU_FLOAT partition[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; + CGU_FLOAT cur_best_partition[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; + CGU_BOOL optimized; // were end points optimized during final encoding + +} BC6H_Encode_local; + +#ifndef ASPM_GPU +using namespace std; +class BitHeader +{ +public: + BitHeader(const CGU_UINT8 in[], CGU_INT sizeinbytes) + { + m_bits.reset(); + m_sizeinbytes = sizeinbytes; + + if ((in != NULL) && (sizeinbytes <= 16)) + { + // Init bits set with given data + CGU_INT bitpos = 0; + for (CGU_INT i = 0; i < sizeinbytes; i++) + { + CGU_INT bit = 1; + for (CGU_INT j = 0; j < 8; j++) + { + m_bits[bitpos] = in[i] & bit ? 1 : 0; + bit = bit << 1; + bitpos++; + } + } + } + } + + ~BitHeader() + { + } + + void transferbits(CGU_UINT8 in[], CGU_INT sizeinbytes) + { + if ((sizeinbytes <= m_sizeinbytes) && (in != NULL)) + { + // Init bits set with given data + memset(in, 0, sizeinbytes); + CGU_INT bitpos = 0; + for (CGU_INT i = 0; i < sizeinbytes; i++) + { + CGU_INT bit = 1; + for (CGU_INT j = 0; j < 8; j++) + { + if (m_bits[bitpos]) in[i] |= bit; + bit = bit << 1; + bitpos++; + } + } + } + } + + CGU_INT getvalue(CGU_INT start, CGU_INT bitsize) + { + CGU_INT value = 0; + CGU_INT end = start + bitsize - 1; + for (; end >= start; end--) + { + value |= m_bits[end] ? 1 : 0; + if (end > start) value <<= 1; + } + + return value; + } + + void setvalue(CGU_INT start, CGU_INT bitsize, CGU_INT value, CGU_INT maskshift = 0) + { + CGU_INT end = start + bitsize - 1; + CGU_INT mask = 0x1 << maskshift; + for (; start <= end; start++) + { + m_bits[start] = (value&mask) ? 1 : 0; + mask <<= 1; + } + } + + bitset<128> m_bits; // 16 bytes max + CGU_INT m_sizeinbytes; +}; + +//==================== DECODER CODE ====================== +#define MAXENDPOINTS 2 +#define U16MAX 0xffff +#define S16MAX 0x7fff +#define SIGN_EXTEND(w,tbits) ((((signed(w))&(1<<((tbits)-1)))?((~0)<<(tbits)):0)|(signed(w))) + +enum +{ + UNSIGNED_F16 = 1, + SIGNED_F16 = 2 +}; + +enum +{ + BC6_ONE = 0, + BC6_TWO +}; + +enum +{ + C_RED = 0, + C_GREEN, + C_BLUE +}; + +struct BC6H_Vec3 +{ + int x,y,z; +}; + +struct AMD_BC6H_Format +{ + unsigned short region; // one or two + unsigned short m_mode; // m + int d_shape_index; // d + int rw; // endpt[0].A[0] + int rx; // endpt[0].B[0] + int ry; // endpt[1].A[0] + int rz; // endpt[1].B[0] + int gw; // endpt[0].A[1] + int gx; // endpt[0].B[1] + int gy; // endpt[1].A[1] + int gz; // endpt[1].B[1] + int bw; // endpt[0].A[2] + int bx; // endpt[0].B[2] + int by; // endpt[1].A[2] + int bz; // endpt[1].B[2] + + union + { + CGU_UINT8 indices[4][4]; // Indices data after header block + CGU_UINT8 indices16[16]; + }; + + float din[MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; // Original data input + END_Points EC[MAXENDPOINTS]; // compressed endpoints expressed as endpt[0].A[] and endpt[1].B[] + END_Points E[MAXENDPOINTS]; // decompressed endpoints + bool issigned; // Format is 16 bit signed floating point + bool istransformed; // region two: all modes = true except mode=10 + short wBits; // number of bits for the root endpoint + short tBits[NCHANNELS]; // number of bits used for the transformed endpoints + int format; // floating point format are we using for decompression + BC6H_Vec3 Palete[2][16]; + BC6H_Vec3f Paletef[2][16]; + + int index; // for debugging + float fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + float cur_best_fEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG]; + int shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]; + int cur_best_shape_indices[MAX_SUBSETS][MAX_SUBSET_SIZE]; + int entryCount[MAX_SUBSETS]; + int cur_best_entryCount[MAX_SUBSETS]; + float partition[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; + float cur_best_partition[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_DIMENSION_BIG]; + bool optimized; // were end points optimized during final encoding +}; + +// =================================== END OF DECODER CODE ======================================================== +#endif + +//------------------------------------------------- +// Set by Host : Read only in kernel +//------------------------------------------------- +typedef struct +{ + // Setup at initialization time + CGU_FLOAT m_quality; + CGU_FLOAT m_performance; + CGU_FLOAT m_errorThreshold; + CGU_DWORD m_validModeMask; + CGU_BOOL m_imageNeedsAlpha; + CGU_BOOL m_colourRestrict; + CGU_BOOL m_alphaRestrict; + CGU_BOOL m_isSigned; +} CMP_BC6HOptions; + +typedef struct +{ + // These are quality parameters used to select when to use the high precision quantizer + // and shaker paths + CGU_FLOAT m_quantizerRangeThreshold; + CGU_FLOAT m_shakerRangeThreshold; + CGU_FLOAT m_partitionSearchSize; + + // Setup at initialization time + CGU_FLOAT m_quality; + CGU_FLOAT m_performance; + CGU_FLOAT m_errorThreshold; + CGU_DWORD m_validModeMask; + CGU_BOOL m_imageNeedsAlpha; + CGU_BOOL m_colourRestrict; + CGU_BOOL m_alphaRestrict; + CGU_BOOL m_isSigned; + + // Source image info : must be set prior to use in kernel + CGU_UINT32 m_src_width; + CGU_UINT32 m_src_height; + CGU_UINT32 m_src_stride; + +} BC6H_Encode; + +CMP_STATIC void SetDefaultBC6Options(BC6H_Encode *BC6Encode) +{ + if (BC6Encode) + { + BC6Encode->m_quality = 1.0f; + BC6Encode->m_quantizerRangeThreshold = 0.0f; + BC6Encode->m_shakerRangeThreshold = 0.0f; + BC6Encode->m_partitionSearchSize = 0.20f; + BC6Encode->m_performance = 0.0f; + BC6Encode->m_errorThreshold = 0.0f; + BC6Encode->m_validModeMask = 0; + BC6Encode->m_imageNeedsAlpha = 0; + BC6Encode->m_colourRestrict = 0; + BC6Encode->m_alphaRestrict = 0; + BC6Encode->m_isSigned = 0; + BC6Encode->m_src_width = 4; + BC6Encode->m_src_height = 4; + BC6Encode->m_src_stride = 0; + } +} + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BC6_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC6_Encode_kernel.hlsl new file mode 100644 index 00000000..07d4117d --- /dev/null +++ b/extern/CMP_Core/shaders/BC6_Encode_kernel.hlsl @@ -0,0 +1,2572 @@ +//-------------------------------------------------------------------------------------- +// File: BC6HEncode.hlsl +// +// The Compute Shader for BC6H Encoder +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- + +#define REF_DEVICE +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + +#define UINTLENGTH 32 +#define NCHANNELS 3 +#define SIGNED_F16 96 +#define UNSIGNED_F16 95 +#define MAX_FLOAT asfloat(0x7F7FFFFF) +#define MIN_FLOAT asfloat(0xFF7FFFFF) +#define MAX_INT asint(0x7FFFFFFF) +#define MIN_INT asint(0x80000000) + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; //either SIGNED_F16 for DXGI_FORMAT_BC6H_SF16 or UNSIGNED_F16 for DXGI_FORMAT_BC6H_UF16 + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +static const uint candidateModeMemory[14] = { 0x00, 0x01, 0x02, 0x06, 0x0A, 0x0E, 0x12, 0x16, 0x1A, 0x1E, 0x03, 0x07, 0x0B, 0x0F }; +static const uint candidateModeFlag[14] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; +static const bool candidateModeTransformed[14] = { true, true, true, true, true, true, true, true, true, false, false, true, true, true }; +static const uint4 candidateModePrec[14] = { uint4(10,5,5,5), uint4(7,6,6,6), + uint4(11,5,4,4), uint4(11,4,5,4), uint4(11,4,4,5), uint4(9,5,5,5), + uint4(8,6,5,5), uint4(8,5,6,5), uint4(8,5,5,6), uint4(6,6,6,6), + uint4(10,10,10,10), uint4(11,9,9,9), uint4(12,8,8,8), uint4(16,4,4,4) }; + +/*static const uint4x4 candidateSection[32] = +{ + {0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1}, {0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1}, {0,1,1,1, 0,1,1,1, 0,1,1,1, 0,1,1,1}, {0,0,0,1, 0,0,1,1, 0,0,1,1, 0,1,1,1}, + {0,0,0,0, 0,0,0,1, 0,0,0,1, 0,0,1,1}, {0,0,1,1, 0,1,1,1, 0,1,1,1, 1,1,1,1}, {0,0,0,1, 0,0,1,1, 0,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,1, 0,0,1,1, 0,1,1,1}, + {0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,1,1}, {0,0,1,1, 0,1,1,1, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,1, 0,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,0, 0,0,0,1, 0,1,1,1}, + {0,0,0,1, 0,1,1,1, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1}, + {0,0,0,0, 1,0,0,0, 1,1,1,0, 1,1,1,1}, {0,1,1,1, 0,0,0,1, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 1,0,0,0, 1,1,1,0}, {0,1,1,1, 0,0,1,1, 0,0,0,1, 0,0,0,0}, + {0,0,1,1, 0,0,0,1, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 1,0,0,0, 1,1,0,0, 1,1,1,0}, {0,0,0,0, 0,0,0,0, 1,0,0,0, 1,1,0,0}, {0,1,1,1, 0,0,1,1, 0,0,1,1, 0,0,0,1}, + {0,0,1,1, 0,0,0,1, 0,0,0,1, 0,0,0,0}, {0,0,0,0, 1,0,0,0, 1,0,0,0, 1,1,0,0}, {0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0}, {0,0,1,1, 0,1,1,0, 0,1,1,0, 1,1,0,0}, + {0,0,0,1, 0,1,1,1, 1,1,1,0, 1,0,0,0}, {0,0,0,0, 1,1,1,1, 1,1,1,1, 0,0,0,0}, {0,1,1,1, 0,0,0,1, 1,0,0,0, 1,1,1,0}, {0,0,1,1, 1,0,0,1, 1,0,0,1, 1,1,0,0} +};*/ + +static const uint candidateSectionBit[32] = +{ + 0xCCCC, 0x8888, 0xEEEE, 0xECC8, + 0xC880, 0xFEEC, 0xFEC8, 0xEC80, + 0xC800, 0xFFEC, 0xFE80, 0xE800, + 0xFFE8, 0xFF00, 0xFFF0, 0xF000, + 0xF710, 0x008E, 0x7100, 0x08CE, + 0x008C, 0x7310, 0x3100, 0x8CCE, + 0x088C, 0x3110, 0x6666, 0x366C, + 0x17E8, 0x0FF0, 0x718E, 0x399C +}; + +static const uint candidateFixUpIndex1D[32] = +{ + 15,15,15,15, + 15,15,15,15, + 15,15,15,15, + 15,15,15,15, + 15, 2, 8, 2, + 2, 8, 8,15, + 2, 8, 2, 2, + 8, 8, 2, 2 +}; + +//0, 9, 18, 27, 37, 46, 55, 64 +static const uint aStep1[64] = {0,0,0,0,0,1,1,1, + 1,1,1,1,1,1,2,2, + 2,2,2,2,2,2,2,3, + 3,3,3,3,3,3,3,3, + 3,4,4,4,4,4,4,4, + 4,4,5,5,5,5,5,5, + 5,5,5,6,6,6,6,6, + 6,6,6,6,7,7,7,7}; + +//0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 +static const uint aStep2[64] = { 0, 0, 0, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 4, 4, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 7, 7, 7, + 7, 8, 8, 8, 8, 9, 9, 9, + 9,10,10,10,10,10,11,11, + 11,11,12,12,12,12,13,13, + 13,13,14,14,14,14,15,15}; + +static const float3 RGB2LUM = float3(0.2126f, 0.7152f, 0.0722f); + +#define THREAD_GROUP_SIZE 64 +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 +#define BLOCK_SIZE (BLOCK_SIZE_Y * BLOCK_SIZE_X) + + +//Forward declaration +uint3 float2half( float3 pixel_f ); +int3 start_quantize( uint3 pixel_h ); +void quantize( inout int2x3 endPoint, uint prec ); +void finish_quantize_0( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed ); +void finish_quantize_1( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed ); +void finish_quantize( out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed ); + +void start_unquantize( inout int2x3 endPoint[2], uint4 prec, bool transformed ); +void start_unquantize( inout int2x3 endPoint, uint4 prec, bool transformed ); +void unquantize( inout int2x3 color, uint prec ); +uint3 finish_unquantize( int3 color ); +void generate_palette_unquantized8( out uint3 palette, int3 low, int3 high, int i ); +void generate_palette_unquantized16( out uint3 palette, int3 low, int3 high, int i ); +float3 half2float(uint3 color_h ); + +void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index ); +void block_package( inout uint4 block, int2x3 endPoint, uint mode_type ); + +void swap(inout int3 lhs, inout int3 rhs) +{ + int3 tmp = lhs; + lhs = rhs; + rhs = tmp; +} + +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +RWStructuredBuffer g_OutBuff : register( u0 ); + +struct SharedData +{ + float3 pixel; + int3 pixel_ph; + float3 pixel_hr; + float pixel_lum; + float error; + uint best_mode; + uint best_partition; + int3 endPoint_low; + int3 endPoint_high; + float endPoint_lum_low; + float endPoint_lum_high; +}; + +groupshared SharedData shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void TryModeG10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID ) +{ + const uint MAX_USED_THREAD = 16; + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; + uint blockInGroup = GI / MAX_USED_THREAD; + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; + uint threadBase = blockInGroup * MAX_USED_THREAD; + uint threadInBlock = GI - threadBase; + +#ifndef REF_DEVICE + if (blockID >= g_num_total_blocks) + { + return; + } +#endif + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + if (threadInBlock < 16) + { + shared_temp[GI].pixel = g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ).rgb; + uint3 pixel_h = float2half( shared_temp[GI].pixel ); + shared_temp[GI].pixel_hr = half2float(pixel_h); + shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel_hr, RGB2LUM); + shared_temp[GI].pixel_ph = start_quantize( pixel_h ); + + shared_temp[GI].endPoint_low = shared_temp[GI].pixel_ph; + shared_temp[GI].endPoint_high = shared_temp[GI].pixel_ph; + shared_temp[GI].endPoint_lum_low = shared_temp[GI].pixel_lum; + shared_temp[GI].endPoint_lum_high = shared_temp[GI].pixel_lum; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 8) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 8].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 8].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 8].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 8].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 8].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 8].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 4].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 4].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 4].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 4].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 4].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 4].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 2].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 2].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 2].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 2].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 2].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 2].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 1].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 1].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 1].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 1].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 1].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 1].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + //ergod mode_type 11:14 + if ( threadInBlock == 0 ) + { + int2x3 endPoint; + // find_axis + endPoint[0] = shared_temp[threadBase + 0].endPoint_low; + endPoint[1] = shared_temp[threadBase + 0].endPoint_high; + + //compute_index + float3 span = endPoint[1] - endPoint[0];// fixed a bug in v0.2 + float span_norm_sqr = dot( span, span );// fixed a bug in v0.2 + float dotProduct = dot( span, shared_temp[threadBase + 0].pixel_ph - endPoint[0] );// fixed a bug in v0.2 + if ( span_norm_sqr > 0 && dotProduct >= 0 && uint( dotProduct * 63.49999 / span_norm_sqr ) > 32 ) + { + swap(endPoint[0], endPoint[1]); + + shared_temp[GI].endPoint_low = endPoint[0]; + shared_temp[GI].endPoint_high = endPoint[1]; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 4) + { + int2x3 endPoint; + endPoint[0] = shared_temp[threadBase + 0].endPoint_low; + endPoint[1] = shared_temp[threadBase + 0].endPoint_high; + + float3 span = endPoint[1] - endPoint[0]; + float span_norm_sqr = dot( span, span ); + + uint4 prec = candidateModePrec[threadInBlock + 10]; + int2x3 endPoint_q = endPoint; + quantize( endPoint_q, prec.x ); + + bool transformed = candidateModeTransformed[threadInBlock + 10]; + if (transformed) + { + endPoint_q[1] -= endPoint_q[0]; + } + + bool bBadQuantize; + finish_quantize( bBadQuantize, endPoint_q, prec, transformed ); + + start_unquantize( endPoint_q, prec, transformed ); + + unquantize( endPoint_q, prec.x ); + + float error = 0; + [loop]for ( uint j = 0; j < 16; j ++ ) + { + float dotProduct = dot( span, shared_temp[threadBase + j].pixel_ph - endPoint[0] );// fixed a bug in v0.2 + uint index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr ) ? aStep2[ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep2[63] ); + + uint3 pixel_rh; + generate_palette_unquantized16( pixel_rh, endPoint_q[0], endPoint_q[1], index ); + float3 pixel_r = half2float( pixel_rh ); + pixel_r -= shared_temp[threadBase + j].pixel_hr; + error += dot(pixel_r, pixel_r); + } + if ( bBadQuantize ) + error = 1e20f; + + shared_temp[GI].error = error; + shared_temp[GI].best_mode = candidateModeFlag[threadInBlock + 10]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 2) + { + if ( shared_temp[GI].error > shared_temp[GI + 2].error ) + { + shared_temp[GI].error = shared_temp[GI + 2].error; + shared_temp[GI].best_mode = shared_temp[GI + 2].best_mode; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + if ( shared_temp[GI].error > shared_temp[GI + 1].error ) + { + shared_temp[GI].error = shared_temp[GI + 1].error; + shared_temp[GI].best_mode = shared_temp[GI + 1].best_mode; + } + + g_OutBuff[blockID] = uint4(asuint(shared_temp[GI].error), shared_temp[GI].best_mode, 0, 0); + } +} + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void TryModeLE10CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID ) +{ + const uint MAX_USED_THREAD = 32; + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; + uint blockInGroup = GI / MAX_USED_THREAD; + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; + uint threadBase = blockInGroup * MAX_USED_THREAD; + uint threadInBlock = GI - threadBase; + +#ifndef REF_DEVICE + if (blockID >= g_num_total_blocks) + { + return; + } + + if (asfloat(g_InBuff[blockID].x) < 1e-6f) + { + g_OutBuff[blockID] = g_InBuff[blockID]; + return; + } +#endif + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + if (threadInBlock < 16) + { + shared_temp[GI].pixel = g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ).rgb; + uint3 pixel_h = float2half( shared_temp[GI].pixel ); + shared_temp[GI].pixel_hr = half2float(pixel_h); + shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel_hr, RGB2LUM); + shared_temp[GI].pixel_ph = start_quantize( pixel_h ); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + //ergod mode_type 1:10 + if (threadInBlock < 32) + { + // find_axis + int2x3 endPoint[2]; + endPoint[0][0] = MAX_INT; + endPoint[0][1] = MIN_INT; + endPoint[1][0] = MAX_INT; + endPoint[1][1] = MIN_INT; + + float2 endPoint_lum[2]; + endPoint_lum[0][0] = MAX_FLOAT; + endPoint_lum[0][1] = MIN_FLOAT; + endPoint_lum[1][0] = MAX_FLOAT; + endPoint_lum[1][1] = MIN_FLOAT; + + uint bit = candidateSectionBit[threadInBlock]; + for ( uint i = 0; i < 16; i ++ ) + { + int3 pixel_ph = shared_temp[threadBase + i].pixel_ph; + float pixel_lum = shared_temp[threadBase + i].pixel_lum; + if ( (bit >> i) & 1 ) //It gets error when using "candidateSection" as "endPoint_ph" index + { + if (endPoint_lum[1][0] > pixel_lum) + { + endPoint[1][0] = pixel_ph; + endPoint_lum[1][0] = pixel_lum; + } + if (endPoint_lum[1][1] < pixel_lum) + { + endPoint[1][1] = pixel_ph; + endPoint_lum[1][1] = pixel_lum; + } + } + else + { + if (endPoint_lum[0][0] > pixel_lum) + { + endPoint[0][0] = pixel_ph; + endPoint_lum[0][0] = pixel_lum; + } + if (endPoint_lum[0][1] < pixel_lum) + { + endPoint[0][1] = pixel_ph; + endPoint_lum[0][1] = pixel_lum; + } + } + } + + //compute_index + float3 span[2];// fixed a bug in v0.2 + float span_norm_sqr[2];// fixed a bug in v0.2 + [unroll] + for (uint p = 0; p < 2; ++ p) + { + span[p] = endPoint[p][1] - endPoint[p][0]; + span_norm_sqr[p] = dot( span[p], span[p] ); + + float dotProduct = dot( span[p], shared_temp[threadBase + (0 == p ? 0 : candidateFixUpIndex1D[threadInBlock])].pixel_ph - endPoint[p][0] );// fixed a bug in v0.2 + if ( span_norm_sqr[p] > 0 && dotProduct >= 0 && uint( dotProduct * 63.49999 / span_norm_sqr[p] ) > 32 ) + { + span[p] = -span[p]; + swap(endPoint[p][0], endPoint[p][1]); + } + } + + uint4 prec = candidateModePrec[g_mode_id]; + int2x3 endPoint_q[2] = endPoint; + quantize( endPoint_q[0], prec.x ); + quantize( endPoint_q[1], prec.x ); + + bool transformed = candidateModeTransformed[g_mode_id]; + if (transformed) + { + endPoint_q[0][1] -= endPoint_q[0][0]; + endPoint_q[1][0] -= endPoint_q[0][0]; + endPoint_q[1][1] -= endPoint_q[0][0]; + } + + int bBadQuantize = 0; + finish_quantize_0( bBadQuantize, endPoint_q[0], prec, transformed ); + finish_quantize_1( bBadQuantize, endPoint_q[1], prec, transformed ); + + start_unquantize( endPoint_q, prec, transformed ); + + unquantize( endPoint_q[0], prec.x ); + unquantize( endPoint_q[1], prec.x ); + + float error = 0; + for ( uint j = 0; j < 16; j ++ ) + { + uint3 pixel_rh; + if ((bit >> j) & 1) + { + float dotProduct = dot( span[1], shared_temp[threadBase + j].pixel_ph - endPoint[1][0] );// fixed a bug in v0.2 + uint index = ( span_norm_sqr[1] <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr[1] ) ? aStep1[ uint( dotProduct * 63.49999 / span_norm_sqr[1] ) ] : aStep1[63] ); + generate_palette_unquantized8( pixel_rh, endPoint_q[1][0], endPoint_q[1][1], index ); + } + else + { + float dotProduct = dot( span[0], shared_temp[threadBase + j].pixel_ph - endPoint[0][0] );// fixed a bug in v0.2 + uint index = ( span_norm_sqr[0] <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr[0] ) ? aStep1[ uint( dotProduct * 63.49999 / span_norm_sqr[0] ) ] : aStep1[63] ); + generate_palette_unquantized8( pixel_rh, endPoint_q[0][0], endPoint_q[0][1], index ); + } + + float3 pixel_r = half2float( pixel_rh ); + pixel_r -= shared_temp[threadBase + j].pixel_hr; + error += dot(pixel_r, pixel_r); + } + if ( bBadQuantize ) + error = 1e20f; + + shared_temp[GI].error = error; + shared_temp[GI].best_mode = candidateModeFlag[g_mode_id]; + shared_temp[GI].best_partition = threadInBlock; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 16) + { + if ( shared_temp[GI].error > shared_temp[GI + 16].error ) + { + shared_temp[GI].error = shared_temp[GI + 16].error; + shared_temp[GI].best_mode = shared_temp[GI + 16].best_mode; + shared_temp[GI].best_partition = shared_temp[GI + 16].best_partition; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 8) + { + if ( shared_temp[GI].error > shared_temp[GI + 8].error ) + { + shared_temp[GI].error = shared_temp[GI + 8].error; + shared_temp[GI].best_mode = shared_temp[GI + 8].best_mode; + shared_temp[GI].best_partition = shared_temp[GI + 8].best_partition; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + if ( shared_temp[GI].error > shared_temp[GI + 4].error ) + { + shared_temp[GI].error = shared_temp[GI + 4].error; + shared_temp[GI].best_mode = shared_temp[GI + 4].best_mode; + shared_temp[GI].best_partition = shared_temp[GI + 4].best_partition; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + if ( shared_temp[GI].error > shared_temp[GI + 2].error ) + { + shared_temp[GI].error = shared_temp[GI + 2].error; + shared_temp[GI].best_mode = shared_temp[GI + 2].best_mode; + shared_temp[GI].best_partition = shared_temp[GI + 2].best_partition; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + if ( shared_temp[GI].error > shared_temp[GI + 1].error ) + { + shared_temp[GI].error = shared_temp[GI + 1].error; + shared_temp[GI].best_mode = shared_temp[GI + 1].best_mode; + shared_temp[GI].best_partition = shared_temp[GI + 1].best_partition; + } + + if (asfloat(g_InBuff[blockID].x) > shared_temp[GI].error) + { + g_OutBuff[blockID] = uint4(asuint(shared_temp[GI].error), shared_temp[GI].best_mode, shared_temp[GI].best_partition, 0); + } + else + { + g_OutBuff[blockID] = g_InBuff[blockID]; + } + } +} + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + const uint MAX_USED_THREAD = 32; + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; + uint blockInGroup = GI / MAX_USED_THREAD; + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; + uint threadBase = blockInGroup * MAX_USED_THREAD; + uint threadInBlock = GI - threadBase; + +#ifndef REF_DEVICE + if (blockID >= g_num_total_blocks) + { + return; + } +#endif + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + if (threadInBlock < 16) + { + shared_temp[GI].pixel = g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ).rgb; + shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel, RGB2LUM); + uint3 pixel_h = float2half( shared_temp[GI].pixel ); + shared_temp[GI].pixel_ph = start_quantize( pixel_h ); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + uint best_mode = g_InBuff[blockID].y; + uint best_partition = g_InBuff[blockID].z; + + uint4 block = 0; + + if (threadInBlock < 32) + { + int2x3 endPoint; + endPoint[0] = MAX_INT; + endPoint[1] = MIN_INT; + + float2 endPoint_lum; + endPoint_lum[0] = MAX_FLOAT; + endPoint_lum[1] = MIN_FLOAT; + + int2 endPoint_lum_index; + endPoint_lum_index[0] = -1; + endPoint_lum_index[1] = -1; + + int3 pixel_ph = shared_temp[threadBase + (threadInBlock & 0xF)].pixel_ph; + float pixel_lum = shared_temp[threadBase + (threadInBlock & 0xF)].pixel_lum; + if (threadInBlock < 16) + { + if (best_mode > 10) + { + endPoint[0] = endPoint[1] = pixel_ph; + endPoint_lum[0] = endPoint_lum[1] = pixel_lum; + } + else + { + uint bits = candidateSectionBit[best_partition]; + if (0 == ((bits >> threadInBlock) & 1)) + { + endPoint[0] = endPoint[1] = pixel_ph; + endPoint_lum[0] = endPoint_lum[1] = pixel_lum; + } + } + } + else + { + if (best_mode <= 10) + { + uint bits = candidateSectionBit[best_partition]; + if (1 == ((bits >> (threadInBlock & 0xF)) & 1)) + { + endPoint[0] = endPoint[1] = pixel_ph; + endPoint_lum[0] = endPoint_lum[1] = pixel_lum; + } + } + } + + shared_temp[GI].endPoint_low = endPoint[0]; + shared_temp[GI].endPoint_high = endPoint[1]; + + shared_temp[GI].endPoint_lum_low = endPoint_lum[0]; + shared_temp[GI].endPoint_lum_high = endPoint_lum[1]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if ((threadInBlock & 0xF) < 8) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 8].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 8].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 8].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 8].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 8].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 8].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if ((threadInBlock & 0xF) < 4) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 4].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 4].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 4].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 4].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 4].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 4].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if ((threadInBlock & 0xF) < 2) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 2].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 2].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 2].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 2].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 2].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 2].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if ((threadInBlock & 0xF) < 1) + { + if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 1].endPoint_lum_low) + { + shared_temp[GI].endPoint_low = shared_temp[GI + 1].endPoint_low; + shared_temp[GI].endPoint_lum_low = shared_temp[GI + 1].endPoint_lum_low; + } + if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 1].endPoint_lum_high) + { + shared_temp[GI].endPoint_high = shared_temp[GI + 1].endPoint_high; + shared_temp[GI].endPoint_lum_high = shared_temp[GI + 1].endPoint_lum_high; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 2) + { + // find_axis + int2x3 endPoint; + endPoint[0] = shared_temp[threadBase + threadInBlock * 16].endPoint_low; + endPoint[1] = shared_temp[threadBase + threadInBlock * 16].endPoint_high; + + uint fixup = 0; + if ((1 == threadInBlock) && (best_mode <= 10)) + { + fixup = candidateFixUpIndex1D[best_partition]; + } + + float3 span = endPoint[1] - endPoint[0]; + float span_norm_sqr = dot( span, span ); + float dotProduct = dot( span, shared_temp[threadBase + fixup].pixel_ph - endPoint[0] ); + if ( span_norm_sqr > 0 && dotProduct >= 0 && uint( dotProduct * 63.49999 / span_norm_sqr ) > 32 ) + { + swap(endPoint[0], endPoint[1]); + } + + shared_temp[GI].endPoint_low = endPoint[0]; + shared_temp[GI].endPoint_high = endPoint[1]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 16) + { + uint bits; + if (best_mode > 10) + { + bits = 0; + } + else + { + bits = candidateSectionBit[best_partition]; + } + + float3 span; + float dotProduct; + if ((bits >> threadInBlock) & 1) + { + span = shared_temp[threadBase + 1].endPoint_high - shared_temp[threadBase + 1].endPoint_low; + dotProduct = dot( span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 1].endPoint_low ); + } + else + { + span = shared_temp[threadBase + 0].endPoint_high - shared_temp[threadBase + 0].endPoint_low; + dotProduct = dot( span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 0].endPoint_low ); + } + float span_norm_sqr = dot( span, span ); + + if (best_mode > 10) + { + uint index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr ) ? aStep2[ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep2[63] ); + if (threadInBlock == 0) + { + block.z |= index << 1; + } + else if (threadInBlock < 8) + { + block.z |= index << (threadInBlock * 4); + } + else + { + block.w |= index << ((threadInBlock - 8) * 4); + } + } + else + { + uint index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr ) ? aStep1[ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep1[63] ); + + uint fixup = candidateFixUpIndex1D[best_partition]; + int2 offset = int2((fixup != 2), (fixup == 15)); + + if (threadInBlock == 0) + { + block.z |= index << 18; + } + else if (threadInBlock < 3) + { + block.z |= index << (20 + (threadInBlock - 1) * 3); + } + else if (threadInBlock < 5) + { + block.z |= index << (25 + (threadInBlock - 3) * 3 + offset.x); + } + else if (threadInBlock == 5) + { + block.w |= index >> !offset.x; + if (!offset.x) + { + block.z |= index << 31; + } + } + else if (threadInBlock < 9) + { + block.w |= index << (2 + (threadInBlock - 6) * 3 + offset.x); + } + else + { + block.w |= index << (11 + (threadInBlock - 9) * 3 + offset.y); + } + } + + shared_temp[GI].pixel_hr.xy = asfloat(block.zw); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 8) + { + shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 8].pixel_hr.xy)); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 4].pixel_hr.xy)); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 2].pixel_hr.xy)); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 1].pixel_hr.xy)); + + block.zw = asuint(shared_temp[GI].pixel_hr.xy); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + bool transformed = candidateModeTransformed[best_mode - 1]; + uint4 prec = candidateModePrec[best_mode - 1]; + if (threadInBlock == 2) + { + int2x3 endPoint_q; + endPoint_q[0] = shared_temp[threadBase + 0].endPoint_low; + endPoint_q[1] = shared_temp[threadBase + 0].endPoint_high; + + quantize( endPoint_q, prec.x ); + if (transformed) + { + endPoint_q[1] -= endPoint_q[0]; + } + + shared_temp[GI].endPoint_low = endPoint_q[0]; + shared_temp[GI].endPoint_high = endPoint_q[1]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock == 3) + { + int3 ep0 = shared_temp[threadBase + 2].endPoint_low; + int2x3 endPoint_q; + endPoint_q[0] = shared_temp[threadBase + 1].endPoint_low; + endPoint_q[1] = shared_temp[threadBase + 1].endPoint_high; + + if (best_mode <= 10) + { + quantize( endPoint_q, prec.x ); + if (transformed) + { + endPoint_q[0] -= ep0; + endPoint_q[1] -= ep0; + } + + shared_temp[GI].endPoint_low = endPoint_q[0]; + shared_temp[GI].endPoint_high = endPoint_q[1]; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 2) + { + int2x3 endPoint_q; + endPoint_q[0] = shared_temp[threadBase + threadInBlock + 2].endPoint_low; + endPoint_q[1] = shared_temp[threadBase + threadInBlock + 2].endPoint_high; + + int bBadQuantize = 0; + if (threadInBlock == 0) + { + if (best_mode > 10) + { + finish_quantize( bBadQuantize, endPoint_q, prec, transformed ); + } + else + { + finish_quantize_0( bBadQuantize, endPoint_q, prec, transformed ); + } + } + else // if (threadInBlock == 1) + { + if (best_mode <= 10) + { + finish_quantize_1( bBadQuantize, endPoint_q, prec, transformed ); + } + } + + shared_temp[GI].endPoint_low = endPoint_q[0]; + shared_temp[GI].endPoint_high = endPoint_q[1]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if ( threadInBlock == 0 ) + { + int2x3 endPoint_q[2]; + endPoint_q[0][0] = shared_temp[threadBase + 0].endPoint_low; + endPoint_q[0][1] = shared_temp[threadBase + 0].endPoint_high; + endPoint_q[1][0] = shared_temp[threadBase + 1].endPoint_low; + endPoint_q[1][1] = shared_temp[threadBase + 1].endPoint_high; + + if ( best_mode > 10 ) + { + block_package( block, endPoint_q[0], best_mode ); + } + else + { + block_package( block, endPoint_q, best_mode, best_partition ); + } + + g_OutBuff[blockID] = block; + } +} + +uint float2half1( float f ) +{ + uint Result; + + uint IValue = asuint(f); + uint Sign = (IValue & 0x80000000U) >> 16U; + IValue = IValue & 0x7FFFFFFFU; + + if (IValue > 0x47FFEFFFU) + { + // The number is too large to be represented as a half. Saturate to infinity. + Result = 0x7FFFU; + } + else + { + if (IValue < 0x38800000U) + { + // The number is too small to be represented as a normalized half. + // Convert it to a denormalized value. + uint Shift = 113U - (IValue >> 23U); + IValue = (0x800000U | (IValue & 0x7FFFFFU)) >> Shift; + } + else + { + // Rebias the exponent to represent the value as a normalized half. + IValue += 0xC8000000U; + } + + Result = ((IValue + 0x0FFFU + ((IValue >> 13U) & 1U)) >> 13U)&0x7FFFU; + } + return (Result|Sign); +} + +uint3 float2half( float3 endPoint_f ) +{ + //uint3 sign = asuint(endPoint_f) & 0x80000000; + //uint3 expo = asuint(endPoint_f) & 0x7F800000; + //uint3 base = asuint(endPoint_f) & 0x007FFFFF; + //return ( expo < 0x33800000 ) ? 0 + // //0x33800000 indicating 2^-24, which is minimal denormalized number that half can present + // : ( ( expo < 0x38800000 ) ? ( sign >> 16 ) | ( ( base + 0x00800000 ) >> ( 23 - ( ( expo - 0x33800000 ) >> 23 ) ) )//fixed a bug in v0.2 + // //0x38800000 indicating 2^-14, which is minimal normalized number that half can present, so need to use denormalized half presentation + // : ( ( expo == 0x7F800000 || expo > 0x47000000 ) ? ( ( sign >> 16 ) | 0x7bff ) + // // treat NaN as INF, treat INF (including NaN) as the maximum/minimum number that half can present + // // 0x47000000 indicating 2^15, which is maximum exponent that half can present, so cut to 0x7bff which is the maximum half number + // : ( ( sign >> 16 ) | ( ( ( expo - 0x38000000 ) | base ) >> 13 ) ) ) ); + + + return uint3( float2half1( endPoint_f.x ), float2half1( endPoint_f.y ), float2half1( endPoint_f.z ) ); +} +int3 start_quantize( uint3 pixel_h ) +{ + if ( g_format == UNSIGNED_F16 ) + { + return asint( ( pixel_h << 6 ) / 31 ); + } + else + { + return ( pixel_h < 0x8000 ) ? ( ( pixel_h == 0x7bff ) ? 0x7fff : asint( ( pixel_h << 5 ) / 31 ) )// fixed a bug in v0.2 + : ( ( pixel_h == 0x7bff ) ? 0xffff8001 : -asint( ( ( 0x00007fff & pixel_h ) << 5 ) / 31 ) );// fixed a bug in v0.2 + } +} +void quantize( inout int2x3 endPoint, uint prec ) +{ + int iprec = asint( prec ); + if ( g_format == UNSIGNED_F16 ) + { + endPoint = ( ( iprec >= 15 ) | ( endPoint == 0 ) ) ? endPoint + : ( ( endPoint == asint(0xFFFF) ) ? ( ( 1 << iprec ) - 1 ) + : ( ( ( endPoint << iprec ) + asint(0x0000) ) >> 16 ) ); + } + else + { + endPoint = ( ( iprec >= 16 ) | ( endPoint == 0 ) ) ? endPoint + : ( ( endPoint >= 0 ) ? ( ( endPoint == asint(0x7FFF) ) ? ( ( 1 << ( iprec - 1 ) ) - 1 ) : ( ( ( endPoint << ( iprec - 1 ) ) + asint(0x0000) ) >> 15 ) ) + : ( ( -endPoint == asint(0x7FFF) ) ? -( ( 1 << ( iprec - 1 ) ) - 1 ) : -( ( ( -endPoint << ( iprec - 1 ) ) + asint(0x0000) ) >> 15 ) ) ); + } +} +void finish_quantize_0( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed ) +{ + if ( transformed ) + { + bool3 bBadComponent = ( endPoint[1] >= 0 ) ? ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) + : ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ); + bBadQuantize |= any(bBadComponent); + + endPoint[0] = endPoint[0] & ( ( 1 << prec.x ) - 1 ); + endPoint[1] = ( endPoint[1] >= 0 ) ? ( ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[1] ) + : ( ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[1] & ( ( 1 << prec.yzw ) - 1 ) ) ); + } + else + { + endPoint &= ( ( 1 << prec.x ) - 1 ); + } +} +void finish_quantize_1( inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed ) +{ + if ( transformed ) + { + bool2x3 bBadComponent; + bBadComponent[0] = ( endPoint[0] >= 0 ) ? ( endPoint[0] >= ( 1 << ( prec.yzw - 1 ) ) ) + : ( -endPoint[0] > ( 1 << ( prec.yzw - 1 ) ) ); + bBadComponent[1] = ( endPoint[1] >= 0 ) ? ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) + : ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ); + bBadQuantize |= any(bBadComponent); + + endPoint[0] = ( endPoint[0] >= 0 ) ? ( ( endPoint[0] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[0] ) + : ( ( -endPoint[0] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[0] & ( ( 1 << prec.yzw ) - 1 ) ) ); + endPoint[1] = ( endPoint[1] >= 0 ) ? ( ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[1] ) + : ( ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[1] & ( ( 1 << prec.yzw ) - 1 ) ) ); + } + else + { + endPoint &= ( ( 1 << prec.x ) - 1 ); + } +} +void finish_quantize( out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed ) +{ + if ( transformed ) + { + bool3 bBadComponent; + bBadComponent = ( endPoint[1] >= 0 ) ? ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) + : ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ); + bBadQuantize = any( bBadComponent ); + + endPoint[0] = endPoint[0] & ( ( 1 << prec.x ) - 1 ); + endPoint[1] = ( endPoint[1] >= 0 ) ? ( ( endPoint[1] >= ( 1 << ( prec.yzw - 1 ) ) ) ? ( ( 1 << ( prec.yzw - 1 ) ) - 1 ) : endPoint[1] ) + : ( ( -endPoint[1] > ( 1 << ( prec.yzw - 1 ) ) ) ? ( 1 << ( prec.yzw - 1 ) ) : ( endPoint[1] & ( ( 1 << prec.yzw ) - 1 ) ) ); + } + else + { + endPoint &= ( ( 1 << prec.x ) - 1 ); + + bBadQuantize = 0; + } +} + +void SIGN_EXTEND( uint3 prec, inout int3 color ) +{ + uint3 p = 1 << (prec - 1); + color = (color & p) ? (color & (p - 1)) - p : color; +} + +void sign_extend( bool transformed, uint4 prec, inout int2x3 endPoint ) +{ + if ( g_format == SIGNED_F16 ) + SIGN_EXTEND( prec.x, endPoint[0] ); + if ( g_format == SIGNED_F16 || transformed ) + SIGN_EXTEND( prec.yzw, endPoint[1] ); +} + +void sign_extend( bool transformed, uint4 prec, inout int2x3 endPoint[2] ) +{ + if ( g_format == SIGNED_F16 ) + SIGN_EXTEND( prec.x, endPoint[0][0] ); + if ( g_format == SIGNED_F16 || transformed ) + { + SIGN_EXTEND( prec.yzw, endPoint[0][1] ); + SIGN_EXTEND( prec.yzw, endPoint[1][0] ); + SIGN_EXTEND( prec.yzw, endPoint[1][1] ); + } +} +void start_unquantize( inout int2x3 endPoint[2], uint4 prec, bool transformed ) +{ + sign_extend( transformed, prec, endPoint ); + if ( transformed ) + { + endPoint[0][1] += endPoint[0][0]; + endPoint[1][0] += endPoint[0][0]; + endPoint[1][1] += endPoint[0][0]; + } +} +void start_unquantize( inout int2x3 endPoint, uint4 prec, bool transformed ) +{ + sign_extend( transformed, prec, endPoint ); + if ( transformed ) + endPoint[1] += endPoint[0]; +} +void unquantize( inout int2x3 color, uint prec ) +{ + int iprec = asint( prec ); + if (g_format == UNSIGNED_F16 ) + { + if (prec < 15) + { + color = (color != 0) ? (color == ((1 << iprec) - 1) ? 0xFFFF : (((color << 16) + 0x8000) >> iprec)) : color; + } + } + else + { + if (prec < 16) + { + uint2x3 s = color >= 0 ? 0 : 1; + color = abs(color); + color = (color != 0) ? (color >= ((1 << (iprec - 1)) - 1) ? 0x7FFF : (((color << 15) + 0x4000) >> (iprec - 1))) : color; + color = s > 0 ? -color : color; + } + } +} +uint3 finish_unquantize( int3 color ) +{ + if ( g_format == UNSIGNED_F16 ) + color = ( color * 31 ) >> 6; + else + { + color = ( color < 0 ) ? -( ( -color * 31 ) >> 5 ) : ( color * 31 ) >> 5; + color = ( color < 0 ) ? ( ( -color ) | 0x8000 ) : color; + } + return asuint(color); +} +void generate_palette_unquantized8( out uint3 palette, int3 low, int3 high, int i ) +{ + static const int aWeight3[] = {0, 9, 18, 27, 37, 46, 55, 64}; + + int3 tmp = ( low * ( 64 - aWeight3[i] ) + high * aWeight3[i] + 32 ) >> 6; + palette = finish_unquantize( tmp ); +} +void generate_palette_unquantized16( out uint3 palette, int3 low, int3 high, int i ) +{ + static const int aWeight4[] = {0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64}; + + int3 tmp = ( low * ( 64 - aWeight4[i] ) + high * aWeight4[i] + 32 ) >> 6; + palette = finish_unquantize( tmp ); +} + +float half2float1( uint Value ) +{ + uint Mantissa = (uint)(Value & 0x03FF); + + uint Exponent; + if ((Value & 0x7C00) != 0) // The value is normalized + { + Exponent = (uint)((Value >> 10) & 0x1F); + } + else if (Mantissa != 0) // The value is denormalized + { + // Normalize the value in the resulting float + Exponent = 1; + + do + { + Exponent--; + Mantissa <<= 1; + } while ((Mantissa & 0x0400) == 0); + + Mantissa &= 0x03FF; + } + else // The value is zero + { + Exponent = (uint)(-112); + } + + uint Result = ((Value & 0x8000) << 16) | // Sign + ((Exponent + 112) << 23) | // Exponent + (Mantissa << 13); // Mantissa + + return asfloat(Result); +} + +float3 half2float(uint3 color_h ) +{ + //uint3 sign = color_h & 0x8000; + //uint3 expo = color_h & 0x7C00; + //uint3 base = color_h & 0x03FF; + //return ( expo == 0 ) ? asfloat( ( sign << 16 ) | asuint( float3(base) / 16777216 ) ) //16777216 = 2^24 + // : asfloat( ( sign << 16 ) | ( ( ( expo + 0x1C000 ) | base ) << 13 ) ); //0x1C000 = 0x1FC00 - 0x3C00 + + return float3( half2float1( color_h.x ), half2float1( color_h.y ), half2float1( color_h.z ) ); +} + +void block_package( inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index ) // for mode 1 - 10 +{ + block.xy = 0; + block.z &= 0xFFFC0000; + + //block.z |= (partition_index & 0x1f) << 13; + + if ( mode_type == candidateModeFlag[0]) + { + /*block.x = candidateModeMemory[0]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.x |= ( endPoint[1][0].g >> 2 ) & 0x00000004; + block.x |= ( endPoint[1][0].b >> 1 ) & 0x00000008; + block.x |= endPoint[1][1].b & 0x00000010; + block.y |= ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ); + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); + block.yz |= ( ( endPoint[1][1].b << uint2(27, 9) ) & uint2(0x10000000, 0x00001000) ) | ( ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000040) ); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[0] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[0] >> 1) & 1) << 1; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 2; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 3; + block.x |= ((endPoint[1][1].b >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[1]) + { + /*block.x = candidateModeMemory[1]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00000FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x003F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000001F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0007E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x1F800000 ); + block.x |= ( ( endPoint[1][0].g >> 3 ) & 0x00000004 ) | ( ( endPoint[1][0].g << 20 ) & 0x01000000 ); + block.x |= ( endPoint[1][1].g >> 1 ) & 0x00000018; + block.x |= ( ( endPoint[1][1].b << 21 ) & 0x00800000 ) | ( ( endPoint[1][1].b << 12 ) & 0x00003000 ); + block.x |= ( ( endPoint[1][0].b << 17 ) & 0x00400000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000007E); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00001F80); + block.y |= ( ( endPoint[1][1].b >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ) | ( ( endPoint[1][1].b >> 3 ) & 0x00000001 ); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[1] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[1] >> 1) & 1) << 1; + block.x |= ((endPoint[1][0].g >> 5) & 1) << 2; + block.x |= ((endPoint[1][1].g >> 4) & 1) << 3; + block.x |= ((endPoint[1][1].g >> 5) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[1][1].b >> 0) & 1) << 12; + block.x |= ((endPoint[1][1].b >> 1) & 1) << 13; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[1][0].b >> 5) & 1) << 22; + block.x |= ((endPoint[1][1].b >> 2) & 1) << 23; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[1][1].b >> 3) & 1) << 0; + block.y |= ((endPoint[1][1].b >> 5) & 1) << 1; + block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[0][1].r >> 5) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[0][1].g >> 5) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[0][1].b >> 5) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][0].r >> 5) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].r >> 5) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[2]) + { + /*block.x = candidateModeMemory[2]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0][0].r >> 2 ) & 0x00000100; + block.y |= ( endPoint[0][0].g << 7 ) & 0x00020000; + block.y |= ( ( endPoint[0][0].b << 17 ) & 0x08000000 ) | ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0001E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x07800000 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); + block.yz |= ( ( endPoint[1][1].b << uint2(27, 9) ) & uint2(0x10000000, 0x00001000) ) | ( ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000040) ); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[2] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[2] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[2] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[2] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[2] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[0][0].r >> 10) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][0].g >> 10) & 1) << 17; + block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][0].b >> 10) & 1) << 27; + block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[3]) + { + /*block.x = candidateModeMemory[3]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0][0].r >> 3 ) & 0x00000080; + block.y |= ( endPoint[0][0].g << 8 ) & 0x00040000; + block.y |= ( ( endPoint[0][0].b << 17 ) & 0x08000000 ) | ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x00000078 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x07800000 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000001E); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ); + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000780); + block.yz |= ( endPoint[1][1].b << uint2(27, 9) ) & uint2(0x10000000, 0x00001000); + block.z |= ( ( endPoint[1][0].g << 7 ) & 0x00000800 ); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; + block.z |= ( endPoint[1][1].b << 4 ) & 0x00000040; + block.z |= ( endPoint[1][1].b << 5 ) & 0x00000020;*/ + + block.x |= ((candidateModeMemory[3] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[3] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[3] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[3] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[3] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][0].r >> 10) & 1) << 7; + block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[0][0].g >> 10) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][0].b >> 10) & 1) << 27; + block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][1].b >> 0) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][0].g >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[4]) + { + /*block.x = candidateModeMemory[4]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0][0].r >> 3 ) & 0x00000080; + block.y |= ( endPoint[0][0].g << 7 ) & 0x00020000; + block.y |= ( ( endPoint[0][0].b << 18 ) & 0x10000000 ) | ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x00000078 ) | ( ( endPoint[0][1].g << 13 ) & 0x0001E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); + block.y |= ( ( endPoint[1][0].g << 9 ) & 0x00001E00 ) | ( ( endPoint[1][0].b << 4 ) & 0x00000100 ); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000780); + block.yz |= ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000060); + block.z |= ( endPoint[1][0].r << 1 ) & 0x0000001E; + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; + block.z |= ( ( endPoint[1][1].b << 7 ) & 0x00000800 ) | ( ( endPoint[1][1].b << 9 ) & 0x00001000 );*/ + + block.x |= ((candidateModeMemory[4] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[4] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[4] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[4] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[4] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][0].r >> 10) & 1) << 7; + block.y |= ((endPoint[1][0].b >> 4) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][0].g >> 10) & 1) << 17; + block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[0][0].b >> 10) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][1].b >> 1) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].b >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[5]) + { + /*block.x = candidateModeMemory[5]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00003FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x00FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000); + block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000003; + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); + block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ); + block.y |= ( ( endPoint[1][1].b << 27 ) & 0x10000000 ); + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); + block.yz |= ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000040); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; + block.z |= ( ( endPoint[1][1].b << 9 ) & 0x00001000 );*/ + + block.x |= ((candidateModeMemory[5] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[5] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[5] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[5] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[5] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; + block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[6]) + { + /*block.x = candidateModeMemory[6]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000001; + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000001F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); + block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000); + block.x |= ( ( endPoint[1][1].g << 9 ) & 0x00002000 ) | ( ( endPoint[1][1].b << 21 ) & 0x00800000); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000007E); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00001F80); + block.y |= ( ( endPoint[1][1].b >> 2 ) & 0x00000006 ); + block.y |= ( ( endPoint[1][1].b << 27 ) & 0x10000000 ) | ( ( endPoint[1][1].b << 18 ) & 0x00040000 ); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[6] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[6] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[6] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[6] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[6] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[1][1].g >> 4) & 1) << 13; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[1][1].b >> 2) & 1) << 23; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[1][1].b >> 3) & 1) << 1; + block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[0][1].r >> 5) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][0].r >> 5) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].r >> 5) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[7]) + { + /*block.x = candidateModeMemory[7]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000001; + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0007E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); + block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); + block.x |= ( ( endPoint[1][0].g << 18 ) & 0x00800000 ); + block.x |= ( ( endPoint[1][1].b << 13 ) & 0x00002000 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.y |= ( ( endPoint[1][1].g >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].g << 4 ) & 0x00000100 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ); + block.y |= ( endPoint[1][1].b << 27 ) & 0x10000000; + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; + block.z |= ( ( endPoint[1][1].b << 9 ) & 0x00001000 ) | ( ( endPoint[1][1].b << 4 ) & 0x00000040 );*/ + + block.x |= ((candidateModeMemory[7] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[7] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[7] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[7] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[7] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[1][1].b >> 0) & 1) << 13; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[1][0].g >> 5) & 1) << 23; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[1][1].g >> 5) & 1) << 1; + block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[0][1].g >> 5) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[8]) + { + /*block.x = candidateModeMemory[8]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000001; + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x1F800000 ); + block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); + block.x |= ( ( endPoint[1][0].b << 18 ) & 0x00800000 ); + block.x |= ( endPoint[1][1].b << 12 ) & 0x00002000; + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ) | ( ( endPoint[1][1].b >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); + block.y |= ( endPoint[1][1].b << 18 ) & 0x00040000; + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; + block.z |= ( ( endPoint[1][1].b << 9 ) & 0x00001000 ) | ( ( endPoint[1][1].b << 4 ) & 0x00000040 );*/ + + block.x |= ((candidateModeMemory[8] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[8] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[8] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[8] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[8] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; + block.x |= ((endPoint[1][1].b >> 1) & 1) << 13; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; + block.x |= ((endPoint[1][0].b >> 5) & 1) << 23; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; + block.y |= ((endPoint[1][1].b >> 5) & 1) << 1; + block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[0][1].b >> 5) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } + else if ( mode_type == candidateModeFlag[9]) + { + /*block.x = candidateModeMemory[9]; + block.x |= ( ( endPoint[0][0].r << 5 ) & 0x000007E0 ) | ( ( endPoint[0][0].g << 15 ) & 0x001F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0x7E000000 ); + block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000001F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0007E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x1F800000 ); + block.x |= ( ( endPoint[1][0].g << 16 ) & 0x00200000 ) | ( ( endPoint[1][0].g << 20 ) & 0x01000000 ); + block.x |= ( ( endPoint[1][0].b << 17 ) & 0x00400000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); + block.x |= ( ( endPoint[1][1].b << 21 ) & 0x00800000 ) | ( ( endPoint[1][1].b << 12 ) & 0x00003000 ); + block.x |= ( ( endPoint[1][1].g << 26 ) & 0x80000000 ) | ( ( endPoint[1][1].g << 7 ) & 0x00000800 ); + block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000007E); + block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00001F80); + block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; + block.y |= ( ( endPoint[1][1].b >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ) | ( ( endPoint[1][1].b >> 3 ) & 0x00000001 ); + block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[9] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[9] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[9] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[9] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[9] >> 4) & 1) << 4; + block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; + block.x |= ((endPoint[1][1].g >> 4) & 1) << 11; + block.x |= ((endPoint[1][1].b >> 0) & 1) << 12; + block.x |= ((endPoint[1][1].b >> 1) & 1) << 13; + block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; + block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; + block.x |= ((endPoint[1][0].g >> 5) & 1) << 21; + block.x |= ((endPoint[1][0].b >> 5) & 1) << 22; + block.x |= ((endPoint[1][1].b >> 2) & 1) << 23; + block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; + block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; + block.x |= ((endPoint[1][1].g >> 5) & 1) << 31; + block.y |= ((endPoint[1][1].b >> 3) & 1) << 0; + block.y |= ((endPoint[1][1].b >> 5) & 1) << 1; + block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; + block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; + block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; + block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; + block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; + block.y |= ((endPoint[0][1].r >> 5) & 1) << 8; + block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; + block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; + block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; + block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; + block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; + block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; + block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; + block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; + block.y |= ((endPoint[0][1].g >> 5) & 1) << 18; + block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; + block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; + block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; + block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; + block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; + block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; + block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; + block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; + block.y |= ((endPoint[0][1].b >> 5) & 1) << 28; + block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; + block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; + block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; + block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; + block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; + block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; + block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; + block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; + block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; + block.z |= ((endPoint[1][0].r >> 5) & 1) << 6; + block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; + block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; + block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; + block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; + block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; + block.z |= ((endPoint[1][1].r >> 5) & 1) << 12; + block.z |= ((partition_index >> 0) & 1) << 13; + block.z |= ((partition_index >> 1) & 1) << 14; + block.z |= ((partition_index >> 2) & 1) << 15; + block.z |= ((partition_index >> 3) & 1) << 16; + block.z |= ((partition_index >> 4) & 1) << 17; + } +} +void block_package( inout uint4 block, int2x3 endPoint, uint mode_type ) // for mode 11 - 14 +{ + /*block.x = ( ( endPoint[0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0].b << 25 ) & 0xFE000000 ); + block.y |= ( endPoint[0].b >> 7 ) & 0x00000007;*/ + + block.xy = 0; + block.z &= 0xFFFFFFFE; + + + if ( mode_type == candidateModeFlag[10]) + { + /* block.x |= candidateModeMemory[10]; + block.y |= ( ( endPoint[1].r << 3 ) & 0x00001FF8 ) | ( ( endPoint[1].g << 13 ) & 0x007FE000 ) | ( ( endPoint[1].b << 23 ) & 0xFF800000 ); + block.z |= ( endPoint[1].b >> 9 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[10] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[10] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[10] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[10] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[10] >> 4) & 1) << 4; + block.x |= ((endPoint[0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0].b >> 9) & 1) << 2; + block.y |= ((endPoint[1].r >> 0) & 1) << 3; + block.y |= ((endPoint[1].r >> 1) & 1) << 4; + block.y |= ((endPoint[1].r >> 2) & 1) << 5; + block.y |= ((endPoint[1].r >> 3) & 1) << 6; + block.y |= ((endPoint[1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1].r >> 5) & 1) << 8; + block.y |= ((endPoint[1].r >> 6) & 1) << 9; + block.y |= ((endPoint[1].r >> 7) & 1) << 10; + block.y |= ((endPoint[1].r >> 8) & 1) << 11; + block.y |= ((endPoint[1].r >> 9) & 1) << 12; + block.y |= ((endPoint[1].g >> 0) & 1) << 13; + block.y |= ((endPoint[1].g >> 1) & 1) << 14; + block.y |= ((endPoint[1].g >> 2) & 1) << 15; + block.y |= ((endPoint[1].g >> 3) & 1) << 16; + block.y |= ((endPoint[1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1].g >> 5) & 1) << 18; + block.y |= ((endPoint[1].g >> 6) & 1) << 19; + block.y |= ((endPoint[1].g >> 7) & 1) << 20; + block.y |= ((endPoint[1].g >> 8) & 1) << 21; + block.y |= ((endPoint[1].g >> 9) & 1) << 22; + block.y |= ((endPoint[1].b >> 0) & 1) << 23; + block.y |= ((endPoint[1].b >> 1) & 1) << 24; + block.y |= ((endPoint[1].b >> 2) & 1) << 25; + block.y |= ((endPoint[1].b >> 3) & 1) << 26; + block.y |= ((endPoint[1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1].b >> 5) & 1) << 28; + block.y |= ((endPoint[1].b >> 6) & 1) << 29; + block.y |= ((endPoint[1].b >> 7) & 1) << 30; + block.y |= ((endPoint[1].b >> 8) & 1) << 31; + block.z |= ((endPoint[1].b >> 9) & 1) << 0; + } + else if (mode_type == candidateModeFlag[11]) + { + /*block.x |= candidateModeMemory[11]; + block.y |= ( ( endPoint[0].r << 2 ) & 0x00001000 ) | ( ( endPoint[0].g << 12 ) & 0x00400000 ); + block.y |= ( ( endPoint[1].r << 3 ) & 0x00000FF8 ) | ( ( endPoint[1].g << 13 ) & 0x003FE000 ) | ( ( endPoint[1].b << 23 ) & 0xFF800000 ); + block.z |= ( endPoint[0].b >> 10 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[11] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[11] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[11] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[11] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[11] >> 4) & 1) << 4; + block.x |= ((endPoint[0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0].b >> 9) & 1) << 2; + block.y |= ((endPoint[1].r >> 0) & 1) << 3; + block.y |= ((endPoint[1].r >> 1) & 1) << 4; + block.y |= ((endPoint[1].r >> 2) & 1) << 5; + block.y |= ((endPoint[1].r >> 3) & 1) << 6; + block.y |= ((endPoint[1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1].r >> 5) & 1) << 8; + block.y |= ((endPoint[1].r >> 6) & 1) << 9; + block.y |= ((endPoint[1].r >> 7) & 1) << 10; + block.y |= ((endPoint[1].r >> 8) & 1) << 11; + block.y |= ((endPoint[0].r >> 10) & 1) << 12; + block.y |= ((endPoint[1].g >> 0) & 1) << 13; + block.y |= ((endPoint[1].g >> 1) & 1) << 14; + block.y |= ((endPoint[1].g >> 2) & 1) << 15; + block.y |= ((endPoint[1].g >> 3) & 1) << 16; + block.y |= ((endPoint[1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1].g >> 5) & 1) << 18; + block.y |= ((endPoint[1].g >> 6) & 1) << 19; + block.y |= ((endPoint[1].g >> 7) & 1) << 20; + block.y |= ((endPoint[1].g >> 8) & 1) << 21; + block.y |= ((endPoint[0].g >> 10) & 1) << 22; + block.y |= ((endPoint[1].b >> 0) & 1) << 23; + block.y |= ((endPoint[1].b >> 1) & 1) << 24; + block.y |= ((endPoint[1].b >> 2) & 1) << 25; + block.y |= ((endPoint[1].b >> 3) & 1) << 26; + block.y |= ((endPoint[1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1].b >> 5) & 1) << 28; + block.y |= ((endPoint[1].b >> 6) & 1) << 29; + block.y |= ((endPoint[1].b >> 7) & 1) << 30; + block.y |= ((endPoint[1].b >> 8) & 1) << 31; + block.z |= ((endPoint[0].b >> 10) & 1) << 0; + } + else if (mode_type == candidateModeFlag[12])// violate the spec in [0].low + { + /*block.x |= candidateModeMemory[12]; + block.y |= ( ( endPoint[0].r << 2 ) & 0x00001000 ) | ( ( endPoint[0].g << 12 ) & 0x00400000 ); + block.y |= ( ( endPoint[0].r << 0 ) & 0x00000800 ) | ( ( endPoint[0].g << 10 ) & 0x00200000 ); + block.y |= ( endPoint[0].b << 20 ) & 0x80000000; + block.y |= ( ( endPoint[1].r << 3 ) & 0x000007F8 ) | ( ( endPoint[1].g << 13 ) & 0x001FE000 ) | ( ( endPoint[1].b << 23 ) & 0x7F800000 ); + block.z |= ( endPoint[0].b >> 10 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[12] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[12] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[12] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[12] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[12] >> 4) & 1) << 4; + block.x |= ((endPoint[0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0].b >> 9) & 1) << 2; + block.y |= ((endPoint[1].r >> 0) & 1) << 3; + block.y |= ((endPoint[1].r >> 1) & 1) << 4; + block.y |= ((endPoint[1].r >> 2) & 1) << 5; + block.y |= ((endPoint[1].r >> 3) & 1) << 6; + block.y |= ((endPoint[1].r >> 4) & 1) << 7; + block.y |= ((endPoint[1].r >> 5) & 1) << 8; + block.y |= ((endPoint[1].r >> 6) & 1) << 9; + block.y |= ((endPoint[1].r >> 7) & 1) << 10; + block.y |= ((endPoint[0].r >> 11) & 1) << 11; + block.y |= ((endPoint[0].r >> 10) & 1) << 12; + block.y |= ((endPoint[1].g >> 0) & 1) << 13; + block.y |= ((endPoint[1].g >> 1) & 1) << 14; + block.y |= ((endPoint[1].g >> 2) & 1) << 15; + block.y |= ((endPoint[1].g >> 3) & 1) << 16; + block.y |= ((endPoint[1].g >> 4) & 1) << 17; + block.y |= ((endPoint[1].g >> 5) & 1) << 18; + block.y |= ((endPoint[1].g >> 6) & 1) << 19; + block.y |= ((endPoint[1].g >> 7) & 1) << 20; + block.y |= ((endPoint[0].g >> 11) & 1) << 21; + block.y |= ((endPoint[0].g >> 10) & 1) << 22; + block.y |= ((endPoint[1].b >> 0) & 1) << 23; + block.y |= ((endPoint[1].b >> 1) & 1) << 24; + block.y |= ((endPoint[1].b >> 2) & 1) << 25; + block.y |= ((endPoint[1].b >> 3) & 1) << 26; + block.y |= ((endPoint[1].b >> 4) & 1) << 27; + block.y |= ((endPoint[1].b >> 5) & 1) << 28; + block.y |= ((endPoint[1].b >> 6) & 1) << 29; + block.y |= ((endPoint[1].b >> 7) & 1) << 30; + block.y |= ((endPoint[0].b >> 11) & 1) << 31; + block.z |= ((endPoint[0].b >> 10) & 1) << 0; + } + else if (mode_type == candidateModeFlag[13]) + { + /*block.x |= candidateModeMemory[13]; + block.y |= ( ( endPoint[0].r >> 8 ) & 0x00000080 ); + block.y |= ( ( endPoint[0].r >> 6 ) & 0x00000100 ); + block.y |= ( ( endPoint[0].r >> 4 ) & 0x00000200 ); + block.y |= ( ( endPoint[0].r >> 2 ) & 0x00000400 ); + block.y |= ( ( endPoint[0].r >> 0 ) & 0x00000800 ); + block.y |= ( ( endPoint[0].r << 2 ) & 0x00001000 ); + block.y |= ( ( endPoint[0].g << 2 ) & 0x00020000 ); + block.y |= ( ( endPoint[0].g << 4 ) & 0x00040000 ); + block.y |= ( ( endPoint[0].g << 6 ) & 0x00080000 ); + block.y |= ( ( endPoint[0].g << 8 ) & 0x00100000 ); + block.y |= ( ( endPoint[0].g << 10 ) & 0x00200000 ); + block.y |= ( ( endPoint[0].g << 12 ) & 0x00400000 ); + block.y |= ( ( endPoint[0].b << 12 ) & 0x08000000 ); + block.y |= ( ( endPoint[0].b << 14 ) & 0x10000000 ); + block.y |= ( ( endPoint[0].b << 16 ) & 0x20000000 ); + block.y |= ( ( endPoint[0].b << 18 ) & 0x40000000 ); + block.y |= ( ( endPoint[0].b << 20 ) & 0x80000000 ); + block.y |= ( ( endPoint[1].r << 3 ) & 0x00000078 ) | ( ( endPoint[1].g << 13 ) & 0x0001E000 ) | ( ( endPoint[1].b << 23 ) & 0x07800000 ); + block.z |= ( endPoint[0].b >> 10 ) & 0x00000001;*/ + + block.x |= ((candidateModeMemory[13] >> 0) & 1) << 0; + block.x |= ((candidateModeMemory[13] >> 1) & 1) << 1; + block.x |= ((candidateModeMemory[13] >> 2) & 1) << 2; + block.x |= ((candidateModeMemory[13] >> 3) & 1) << 3; + block.x |= ((candidateModeMemory[13] >> 4) & 1) << 4; + block.x |= ((endPoint[0].r >> 0) & 1) << 5; + block.x |= ((endPoint[0].r >> 1) & 1) << 6; + block.x |= ((endPoint[0].r >> 2) & 1) << 7; + block.x |= ((endPoint[0].r >> 3) & 1) << 8; + block.x |= ((endPoint[0].r >> 4) & 1) << 9; + block.x |= ((endPoint[0].r >> 5) & 1) << 10; + block.x |= ((endPoint[0].r >> 6) & 1) << 11; + block.x |= ((endPoint[0].r >> 7) & 1) << 12; + block.x |= ((endPoint[0].r >> 8) & 1) << 13; + block.x |= ((endPoint[0].r >> 9) & 1) << 14; + block.x |= ((endPoint[0].g >> 0) & 1) << 15; + block.x |= ((endPoint[0].g >> 1) & 1) << 16; + block.x |= ((endPoint[0].g >> 2) & 1) << 17; + block.x |= ((endPoint[0].g >> 3) & 1) << 18; + block.x |= ((endPoint[0].g >> 4) & 1) << 19; + block.x |= ((endPoint[0].g >> 5) & 1) << 20; + block.x |= ((endPoint[0].g >> 6) & 1) << 21; + block.x |= ((endPoint[0].g >> 7) & 1) << 22; + block.x |= ((endPoint[0].g >> 8) & 1) << 23; + block.x |= ((endPoint[0].g >> 9) & 1) << 24; + block.x |= ((endPoint[0].b >> 0) & 1) << 25; + block.x |= ((endPoint[0].b >> 1) & 1) << 26; + block.x |= ((endPoint[0].b >> 2) & 1) << 27; + block.x |= ((endPoint[0].b >> 3) & 1) << 28; + block.x |= ((endPoint[0].b >> 4) & 1) << 29; + block.x |= ((endPoint[0].b >> 5) & 1) << 30; + block.x |= ((endPoint[0].b >> 6) & 1) << 31; + block.y |= ((endPoint[0].b >> 7) & 1) << 0; + block.y |= ((endPoint[0].b >> 8) & 1) << 1; + block.y |= ((endPoint[0].b >> 9) & 1) << 2; + block.y |= ((endPoint[1].r >> 0) & 1) << 3; + block.y |= ((endPoint[1].r >> 1) & 1) << 4; + block.y |= ((endPoint[1].r >> 2) & 1) << 5; + block.y |= ((endPoint[1].r >> 3) & 1) << 6; + block.y |= ((endPoint[0].r >> 15) & 1) << 7; + block.y |= ((endPoint[0].r >> 14) & 1) << 8; + block.y |= ((endPoint[0].r >> 13) & 1) << 9; + block.y |= ((endPoint[0].r >> 12) & 1) << 10; + block.y |= ((endPoint[0].r >> 11) & 1) << 11; + block.y |= ((endPoint[0].r >> 10) & 1) << 12; + block.y |= ((endPoint[1].g >> 0) & 1) << 13; + block.y |= ((endPoint[1].g >> 1) & 1) << 14; + block.y |= ((endPoint[1].g >> 2) & 1) << 15; + block.y |= ((endPoint[1].g >> 3) & 1) << 16; + block.y |= ((endPoint[0].g >> 15) & 1) << 17; + block.y |= ((endPoint[0].g >> 14) & 1) << 18; + block.y |= ((endPoint[0].g >> 13) & 1) << 19; + block.y |= ((endPoint[0].g >> 12) & 1) << 20; + block.y |= ((endPoint[0].g >> 11) & 1) << 21; + block.y |= ((endPoint[0].g >> 10) & 1) << 22; + block.y |= ((endPoint[1].b >> 0) & 1) << 23; + block.y |= ((endPoint[1].b >> 1) & 1) << 24; + block.y |= ((endPoint[1].b >> 2) & 1) << 25; + block.y |= ((endPoint[1].b >> 3) & 1) << 26; + block.y |= ((endPoint[0].b >> 15) & 1) << 27; + block.y |= ((endPoint[0].b >> 14) & 1) << 28; + block.y |= ((endPoint[0].b >> 13) & 1) << 29; + block.y |= ((endPoint[0].b >> 12) & 1) << 30; + block.y |= ((endPoint[0].b >> 11) & 1) << 31; + block.z |= ((endPoint[0].b >> 10) & 1) << 0; + } +} diff --git a/extern/CMP_Core/shaders/BC7_Encode_Kernel.cpp b/extern/CMP_Core/shaders/BC7_Encode_Kernel.cpp new file mode 100644 index 00000000..b7fad182 --- /dev/null +++ b/extern/CMP_Core/shaders/BC7_Encode_Kernel.cpp @@ -0,0 +1,5352 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +// Ref: GPUOpen-Tools/Compressonator + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2016, Intel Corporation +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of +// the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//-------------------------------------- +// Common BC7 Header +//-------------------------------------- +#include "BC7_Encode_Kernel.h" + +#ifndef ASPM +//--------------------------------------------- +// Predefinitions for GPU and CPU compiled code +//--------------------------------------------- +#define ENABLE_CODE + +#ifndef ASPM_GPU + // using code for CPU or hybrid (CPU/GPU) + //#include "BC7.h" +#endif + + +INLINE CGU_INT a_compare( const void *arg1, const void *arg2 ) +{ + if (((CMP_di* )arg1)->image-((CMP_di* )arg2)->image > 0 ) return 1; + if (((CMP_di* )arg1)->image-((CMP_di* )arg2)->image < 0 ) return -1; + return 0; +}; + +#endif + +#ifndef ASPM_GPU +CMP_GLOBAL BC7_EncodeRamps BC7EncodeRamps +#ifndef ASPM + = {0} +#endif +; + +//--------------------------------------------- +// CPU: Computes max of two float values +//--------------------------------------------- +float bc7_maxf(float l1, float r1) +{ + return (l1 > r1 ? l1 : r1); +} + +//--------------------------------------------- +// CPU: Computes max of two float values +//--------------------------------------------- +float bc7_minf(float l1, float r1) +{ + return (l1 < r1 ? l1 : r1); +} + +#endif + +INLINE CGV_EPOCODE shift_right_epocode(CGV_EPOCODE v, CGU_INT bits) +{ + return v>>bits; // (perf warning expected) +} + +INLINE CGV_EPOCODE expand_epocode(CGV_EPOCODE v, CGU_INT bits) +{ + CGV_EPOCODE vv = v<<(8-bits); + return vv + shift_right_epocode(vv, bits); +} + +// valid bit range is 0..8 +CGU_INT expandbits(CGU_INT bits, CGU_INT v) +{ + return ( v << (8-bits) | v >> (2* bits - 8)); +} + +CMP_EXPORT CGU_INT bc7_isa() { +#ifndef ASPM_GPU +#if defined(ISPC_TARGET_SSE2) + ASPM_PRINT(("SSE2")); + return 0; +#elif defined(ISPC_TARGET_SSE4) + ASPM_PRINT(("SSE4")); + return 1; +#elif defined(ISPC_TARGET_AVX) + ASPM_PRINT(("AVX")); + return 2; +#elif defined(ISPC_TARGET_AVX2) + ASPM_PRINT(("AVX2")); + return 3; +#else + ASPM_PRINT(("CPU")); +#endif +#endif + return -1; +} + +CMP_EXPORT void init_BC7ramps() +{ +#ifdef ASPM_GPU +#else + CMP_STATIC CGU_BOOL g_rampsInitialized = FALSE; + if (g_rampsInitialized == TRUE) return; + g_rampsInitialized = TRUE; + BC7EncodeRamps.ramp_init = TRUE; + + //bc7_isa(); ASPM_PRINT((" INIT Ramps\n")); + + CGU_INT bits; + CGU_INT p1; + CGU_INT p2; + CGU_INT clogBC7; + CGU_INT index; + CGU_INT j; + CGU_INT o1; + CGU_INT o2; + CGU_INT maxi = 0; + + + for (bits = BIT_BASE; bits maxi) maxi = index; + BC7EncodeRamps.ramp[(CLT(clogBC7)*4*256*256*16)+(BTT(bits)*256*256*16)+(p1*256*16)+(p2*16)+index] = + //floor((CGV_IMAGE)BC7EncodeRamps.ep_d[BTT(bits)][p1] + rampWeights[clogBC7][index] * (CGV_IMAGE)((BC7EncodeRamps.ep_d[BTT(bits)][p2] - BC7EncodeRamps.ep_d[BTT(bits)][p1]))+ 0.5F); + floor(BC7EncodeRamps.ep_d[BTT(bits)][p1] + rampWeights[clogBC7][index] *((BC7EncodeRamps.ep_d[BTT(bits)][p2] - BC7EncodeRamps.ep_d[BTT(bits)][p1]))+ 0.5F); + }//index<(1 << clogBC7) + }//p2<(1 << bits) + }//p1<(1 << bits) +#endif + +#ifdef USE_BC7_SP_ERR_IDX + for (j = 0; j<256; j++) + { + for (o1 = 0; o1<2; o1++) + { + for (o2 = 0; o2<2; o2++) + { + for (index = 0; index<16; index++) { + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+0] = 0; + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+1] = 255; + BC7EncodeRamps.sp_err[(CLT(clogBC7)*4*256*2*2*16)+(BTT(bits)*256*2*2*16)+(j*2*2*16)+(o1*2*16)+(o2*16)+index] = 255; + } // i<16 + }//o2<2; + }//o1<2 + } //j<256 + + for (p1 = 0; p1<(1 << bits); p1++) + { + for (p2 = 0; p2<(1 << bits); p2++) + { + for (index = 0; index<(1 << clogBC7); index++) + { +#ifdef USE_BC7_RAMP + CGV_EPOCODE floatf = (CGV_EPOCODE)BC7EncodeRamps.ramp[(CLT(clogBC7)*4*256*256*16)+(BTT(bits)*256*256*16)+(p1*256*16)+(p2*16)+index]; +#else + CGV_EPOCODE floatf = floor((CGV_IMAGE)BC7EncodeRamps.ep_d[BTT(bits)][p1] + rampWeights[clogBC7][index] * (CGV_IMAGE)((BC7EncodeRamps.ep_d[BTT(bits)][p2] - BC7EncodeRamps.ep_d[BTT(bits)][p1]))+ 0.5F); +#endif + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(floatf*2*2*16*2)+((p1 & 0x1)*2*16*2)+((p2 & 0x1)*16*2)+(index*2)+0] = p1; + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(floatf*2*2*16*2)+((p1 & 0x1)*2*16*2)+((p2 & 0x1)*16*2)+(index*2)+1] = p2; + BC7EncodeRamps.sp_err[(CLT(clogBC7)*4*256*2*2*16)+(BTT(bits)*256*2*2*16)+(floatf*2*2*16)+((p1 & 0x1)*2*16)+(p2 & 0x1*16)+index] = 0; + } //i<(1 << clogBC7) + } //p2 + }//p1<(1 << bits) + + for (j = 0; j<256; j++) + { + for (o1 = 0; o1<2; o1++) + { + for (o2 = 0; o2<2; o2++) + { + for (index = 0; index<(1 << clogBC7); index++) + { + if ( // check for unitialized sp_idx + (BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+0] == 0) && + (BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+1] == 255) + ) + + { + CGU_INT k; + CGU_INT tf; + CGU_INT tc; + + for (k = 1; k<256; k++) + { + tf = j - k; + tc = j + k; + if ((tf >= 0 && BC7EncodeRamps.sp_err[(CLT(clogBC7)*4*256*2*2*16)+(BTT(bits)*256*2*2*16)+(tf*2*2*16)+(o1*2*16)+(o2*16)+index] == 0)) + { + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+0] = BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(tf*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+0]; + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+1] = BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(tf*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+1]; + break; + } + else if ((tc < 256 && BC7EncodeRamps.sp_err[(CLT(clogBC7)*4*256*2*2*16)+(BTT(bits)*256*2*2*16)+(tc*2*2*16)+(o1*2*16)+(o2*16)+index] == 0)) + { + BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(j*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+0] = BC7EncodeRamps.sp_idx[(CLT(clogBC7)*4*256*2*2*16*2)+(BTT(bits)*256*2*2*16*2)+(tc*2*2*16*2)+(o1*2*16*2)+(o2*16*2)+(index*2)+0]; + break; + } + } + + //BC7EncodeRamps.sp_err[(CLT(clogBC7)*4*256*2*2*16)+(BTT(bits)*256*2*2*16)+(j*2*2*16)+(o1*2*16)+(o2*16)+index] = (CGV_ERROR) k; + BC7EncodeRamps.sp_err[(CLT(clogBC7)*4*256*2*2*16)+(BTT(bits)*256*2*2*16)+(j*2*2*16)+(o1*2*16)+(o2*16)+index] = (CGU_UINT8)k; + + } //sp_idx < 0 + }//i<(1 << clogBC7) + }//o2 + }//o1 + }//j +#endif + + } //bits b) + return b; + return v; +} + +INLINE CGV_INDEX clampIndex(CGV_INDEX v, CGV_INDEX a, CGV_INDEX b) +{ + if (v < a) + return a; + else + if (v > b) + return b; + return v; +} + +INLINE CGV_SHIFT32 shift_right_uint32(CGV_SHIFT32 v, CGU_INT bits) +{ + return v>>bits; // (perf warning expected) +} + +INLINE CGV_BYTE shift_right_uint8(CGV_BYTE v, CGU_UINT8 bits) +{ + return v>>bits; // (perf warning expected) +} + +INLINE CGV_BYTE shift_right_uint8V(CGV_BYTE v, CGV_UINT8 bits) +{ + return v>>bits; // (perf warning expected) +} + +// valid bit range is 0..8 +INLINE CGV_EPOCODE expandEPObits(CGV_EPOCODE v, uniform CGV_EPOCODE bits) +{ + CGV_EPOCODE vv = v<<(8-bits); + return vv + shift_right_uint32(vv, bits); +} + +CGV_ERROR err_absf(CGV_ERROR a) { return a>0.0F?a:-a;} +CGV_IMAGE img_absf(CGV_IMAGE a) { return a>0.0F?a:-a;} + +CGU_UINT8 min8(CGU_UINT8 a, CGU_UINT8 b) { return ab?a:b;} + +void pack_index(CGV_INDEXPACKED packed_index[2], CGV_INDEX src_index[MAX_SUBSET_SIZE]) +{ + // Converts from unpacked index to packed index + packed_index[0] = 0x0000; + packed_index[1] = 0x0000; + CGV_BYTE shift = 0; // was CGV_UINT8 + for (CGU_INT k=0; k<16; k++) + { + packed_index[k/8] |= (CGV_UINT32)(src_index[k]&0x0F) << shift; + shift +=4; + } +} + +void unpack_index(CGV_INDEX unpacked_index[MAX_SUBSET_SIZE],CGV_INDEXPACKED src_packed[2]) +{ + // Converts from packed index to unpacked index + CGV_BYTE shift = 0; // was CGV_UINT8 + for (CGV_BYTE k=0; k<16; k++) + { + unpacked_index[k] = (CGV_BYTE)(src_packed[k/8] >> shift)&0xF; + if (k == 7) + shift = 0; + else + shift +=4; + } +} + +//====================================== CMP MATH UTILS ============================================ +CGV_ERROR err_Total( + CGV_IMAGE image_src1[SOURCE_BLOCK_SIZE*MAX_CHANNELS], + CGV_IMAGE image_src2[SOURCE_BLOCK_SIZE*MAX_CHANNELS], + CGV_ENTRIES numEntries, // < 16 + CGU_CHANNEL channels3or4) // IN: 3 = RGB or 4 = RGBA (4 = MAX_CHANNELS) +{ + CGV_ERROR err_t=0.0F; + for (CGU_CHANNEL ch=0;ch 0) + { + for (CGV_ENTRIES k=0;k> 16; + CGV_UINT32 mask = 0x01 << index; + + return ((mask1 & mask)?2:0 + (mask0 & mask)?1:0); // This can be moved to caller, just return mask!! +} + +void GetPartitionSubSet_mode01237( + CGV_IMAGE subsets_out[MAX_SUBSETS][SOURCE_BLOCK_SIZE][MAX_CHANNELS], // OUT: Subset pattern mapped with image src colors + CGV_ENTRIES entryCount_out[MAX_SUBSETS], // OUT: Number of entries per subset + CGV_UINT8 partition, // Partition Shape 0..63 + CGV_IMAGE image_src[SOURCE_BLOCK_SIZE*MAX_CHANNELS], // Image colors + CGU_INT blockMode, // [0,1,2,3 or 7] + CGU_CHANNEL channels3or4) // 3 = RGB or 4 = RGBA (4 = MAX_CHANNELS) +{ + CGU_UINT8 maxSubsets = 2; if (blockMode == 0 || blockMode == 2) maxSubsets = 3; + + entryCount_out[0] = 0; + entryCount_out[1] = 0; + entryCount_out[2] = 0; + + for (CGV_INT i = 0; i < MAX_SUBSET_SIZE; i++) + { + CGV_UINT8 subset = get_partition_subset(partition,maxSubsets,i); + + for (CGU_INT ch = 0; ch<3; ch++) + subsets_out[subset][entryCount_out[subset]][ch] = image_src[i+(ch*SOURCE_BLOCK_SIZE)]; + //subsets_out[subset*64+(entryCount_out[subset]*MAX_CHANNELS+ch)] = image_src[i+(ch*SOURCE_BLOCK_SIZE)]; + + // if we have only 3 channels then set the alpha subset to 0 + if (channels3or4 == 3) + subsets_out[subset][entryCount_out[subset]][3] = 0.0F; + else + subsets_out[subset][entryCount_out[subset]][3] = image_src[i+(COMP_ALPHA*SOURCE_BLOCK_SIZE)]; + entryCount_out[subset]++; + } +} + +INLINE void GetClusterMean( + CGV_IMAGE cluster_mean_out[SOURCE_BLOCK_SIZE][MAX_CHANNELS], + CGV_IMAGE image_src[SOURCE_BLOCK_SIZE*MAX_CHANNELS], + CGV_INDEX index_in[MAX_SUBSET_SIZE], + CGV_ENTRIES numEntries, // < 16 + CGU_CHANNEL channels3or4) // IN: 3 = RGB or 4 = RGBA (4 = MAX_CHANNELS) +{ + // unused index values are underfined + CGV_INDEX i_cnt[MAX_SUBSET_SIZE]; + CGV_INDEX i_comp[MAX_SUBSET_SIZE]; + + + for (CGV_ENTRIES i=0;i< numEntries;i++) + for (CGU_CHANNEL ch=0; ch< channels3or4; ch++) + { + CGV_INDEX idx = index_in[i]&0x0F; + cluster_mean_out[idx][ch] = 0; + i_cnt[idx]=0; + } + + CGV_INDEX ic = 0; // was CGV_INT + for (CGV_ENTRIES i=0;i< numEntries;i++) + { + CGV_INDEX idx = index_in[i]&0x0F; + if (i_cnt[idx]==0) + i_comp[ic++]=idx; + i_cnt[idx]++; + + for (CGU_CHANNEL ch=0; ch< channels3or4; ch++) + { + cluster_mean_out[idx][ch] += image_src[i+(ch*SOURCE_BLOCK_SIZE)]; + } + } + + for (CGU_CHANNEL ch=0; ch< channels3or4; ch++) + for (CGU_INT i=0;i < ic;i++) + { + if (i_cnt[i_comp[i]] != 0) + { + CGV_INDEX icmp = i_comp[i]; + cluster_mean_out[icmp][ch] = (CGV_IMAGE) floor( (cluster_mean_out[icmp][ch] / (CGV_IMAGE) i_cnt[icmp]) +0.5F); + } + } + +} + +INLINE void GetImageMean( + CGV_IMAGE image_mean_out[SOURCE_BLOCK_SIZE*MAX_CHANNELS], + CGV_IMAGE image_src[SOURCE_BLOCK_SIZE*MAX_CHANNELS], + CGV_ENTRIES numEntries, + CGU_CHANNEL channels) +{ + for (CGU_CHANNEL ch=0; ch< channels; ch++) + image_mean_out[ch] =0; + + for (CGV_ENTRIES i=0;i< numEntries;i++) + for (CGU_CHANNEL ch=0; ch< channels; ch++) + image_mean_out[ch] += image_src[i+ch*SOURCE_BLOCK_SIZE]; + + for (CGU_CHANNEL ch=0; ch< channels; ch++) + image_mean_out[ch] /=(CGV_IMAGE) numEntries; // Performance Warning: Conversion from unsigned int to float is slow. Use "int" if possible +} + +// calculate an eigen vector corresponding to a biggest eigen value +// will work for non-zero non-negative matricies only +void GetEigenVector( + CGV_IMAGE EigenVector_out[MAX_CHANNELS], // Normalized Eigen Vector output + CGV_IMAGE CovarianceVector[MAX_CHANNELS*MAX_CHANNELS], // Covariance Vector + CGU_CHANNEL channels3or4) // IN: 3 = RGB or 4 = RGBA +{ + CGV_IMAGE vector_covIn[MAX_CHANNELS*MAX_CHANNELS]; + CGV_IMAGE vector_covOut[MAX_CHANNELS*MAX_CHANNELS]; + CGV_IMAGE vector_maxCovariance; + + for (CGU_CHANNEL ch1=0; ch1 vector_maxCovariance) + vector_maxCovariance = vector_covIn[ch+ch*4]; + } + + // Normalize Input Covariance Vector + for (CGU_CHANNEL ch1=0; ch1 0) + vector_covIn[ch1+ch2*4] = vector_covIn[ch1+ch2*4] / vector_maxCovariance; + } + + for (CGU_CHANNEL ch1=0; ch1 vector_maxCovariance) + { + maxCovariance_channel = ch; + vector_maxCovariance = vector_covOut[ch+ch*4]; + } + } + + CGV_IMAGE vector_t = 0; + + for (CGU_CHANNEL ch=0; ch 0) + EigenVector_out[ch] = EigenVector_out[ch] / vector_t; + } + +} + +CGV_INDEX index_collapse( + CGV_INDEX index[MAX_SUBSET_SIZE], + CGV_ENTRIES numEntries) +{ + CGV_INDEX minIndex=index[0]; + CGV_INDEX MaxIndex=index[0]; + + for (CGV_ENTRIES k=1;k MaxIndex) + MaxIndex = index[k]; + } + + CGV_INDEX D=1; + + for (CGV_INDEX d=2; d<= MaxIndex-minIndex; d++) + { + for (CGV_ENTRIES ent=0;ent=numEntries) + D =d; + break; + } + } + } + + for (CGV_ENTRIES k=0;k MaxIndex) + MaxIndex = index[k]; + } + + return (MaxIndex); + +} + +void sortProjected_indexs( + CGV_INDEX index_ordered[MAX_SUBSET_SIZE], + CGV_IMAGE projection[SOURCE_BLOCK_SIZE], + CGV_ENTRIES numEntries // max 16 + ) +{ + CMP_di what[SOURCE_BLOCK_SIZE]; + + for (CGV_INDEX i=0; i < numEntries;i++) + { + what[i].index = i; + what[i].image = projection[i]; + } + + CGV_INDEX tmp_index; + CGV_IMAGE tmp_image; + + for (CGV_ENTRIES i = 1; i < numEntries; i++) + { + for (CGV_ENTRIES j=i; j>0; j--) + { + if (what[j - 1].image > what[j].image) + { + tmp_index = what[j].index; + tmp_image = what[j].image; + what[j].index = what[j - 1].index; + what[j].image = what[j - 1].image; + what[j - 1].index = tmp_index; + what[j - 1].image = tmp_image; + } + } + } + + for (CGV_ENTRIES i=0; i < numEntries;i++) + index_ordered[i]=what[i].index; + +}; + +void sortPartitionProjection( + CGV_IMAGE projection[MAX_PARTITION_ENTRIES], + CGV_UINT8 order[MAX_PARTITION_ENTRIES], + CGU_UINT8 numPartitions // max 64 + ) +{ + CMP_du what[MAX_PARTITION_ENTRIES]; + + for (CGU_UINT8 Parti=0; Parti < numPartitions;Parti++) + { + what[Parti].index = Parti; + what[Parti].image = projection[Parti]; + } + + CGV_UINT8 index; + CGV_IMAGE data; + + for (CGU_UINT8 Parti = 1; Parti < numPartitions; Parti++) + { + for (CGU_UINT8 Partj=Parti; Partj>0; Partj--) + { + if (what[Partj - 1].image > what[Partj].image) + { + index = what[Partj].index; + data = what[Partj].image; + what[Partj].index = what[Partj - 1].index; + what[Partj].image = what[Partj - 1].image; + what[Partj - 1].index = index; + what[Partj - 1].image = data; + } + } + } + + for (CGU_UINT8 Parti=0; Parti < numPartitions;Parti++) + order[Parti]=what[Parti].index; + +}; + + +void cmp_Write8Bit( + CGV_CMPOUT base[], + CGU_INT* uniform offset, + CGU_INT bits, + CGV_BYTE bitVal) +{ + base[*offset/8] |= bitVal << (*offset%8); + if (*offset%8+bits>8) + { + base[*offset/8+1] |= shift_right_uint8(bitVal, 8-*offset%8); + } + *offset += bits; +} + +void cmp_Write8BitV( + CGV_CMPOUT base[], + CGV_INT offset, + CGU_INT bits, + CGV_BYTE bitVal) +{ + base[offset/8] |= bitVal << (offset%8); + if (offset%8+bits>8) + { + base[offset/8+1] |= shift_right_uint8V(bitVal, 8-offset%8); + } +} + +INLINE CGV_EPOCODE ep_find_floor( + CGV_IMAGE v, + CGU_UINT8 bits, + CGV_BYTE use_par, + CGV_BYTE odd) + { + CGV_EPOCODE i1=0; + CGV_EPOCODE i2=1<<(bits-use_par); + odd = use_par ? odd : 0; + while (i2-i1>1) + { + CGV_EPOCODE j = (i1+i2)/2; // Warning in ASMP code + CGV_EPOCODE ep_d = expandEPObits((j<= ep_d ) + i1=j; + else + i2=j; + } + + return (i1<>4; + fixup[2] = skip_packed&15; +} + +//===================================== COMPRESS CODE ============================================= +INLINE void SetDefaultIndex(CGV_INDEX index_io[MAX_SUBSET_SIZE]) +{ + // Use this a final call + for (CGU_INT i=0; i image_projected[i]) + image_max = image_projected[i]; + } + + CGV_IMAGE img_diff = image_max-image_min; + + if (img_diff == 0.0f) return; + if (isnan(img_diff)) return; + + image_s = (clusters-1)/img_diff; + + for (CGV_INDEX i=0; i < numEntries;i++) + { + + image_v[i] = image_projected[i]*image_s; + image_z[i] = floor(image_v[i] + 0.5F - image_min *image_s); + projected_index_out[i] = (CGV_INDEX)image_z[i]; + + what[i].image = image_v[i]-image_z[i]- image_min *image_s; + what[i].index = i; + image_dm+= what[i].image; + image_r += what[i].image*what[i].image; + } + + if (numEntries*image_r- image_dm*image_dm >= (CGV_IMAGE)(numEntries-1)/8) + { + + image_dm /= numEntries; + + for (CGV_INT i=0; i < numEntries;i++) + what[i].image -= image_dm; + + CGV_INDEX tmp_index; + CGV_IMAGE tmp_image; + for (CGV_ENTRIES i = 1; i < numEntries; i++) + { + for (CGV_ENTRIES j=i; j>0; j--) + { + if (what[j - 1].image > what[j].image) + { + tmp_index = what[j].index; + tmp_image = what[j].image; + what[j].index = what[j - 1].index; + what[j].image = what[j - 1].image; + what[j - 1].index = tmp_index; + what[j - 1].image = tmp_image; + } + } + } + + // got into fundamental simplex + // move coordinate system origin to its center + + // i=0 < numEntries avoids varying int division by 0 + for (CGV_ENTRIES i=0; i < numEntries;i++) + { + what[i].image = what[i].image - (CGV_IMAGE) (((2.0f*i+1)-numEntries)/(2.0f*numEntries)); + } + + image_mm=0.0F; + image_l=0.0F; + + CGV_INT j = -1; + for (CGV_ENTRIES i=0; i < numEntries;i++) + { + image_l += what[i].image; + if (image_l < image_mm) + { + image_mm = image_l; + j=i; + } + } + + + j = j + 1; + // avoid j = j%numEntries us this + while (j > numEntries) j = j - numEntries; + + for (CGV_ENTRIES i=j; i < numEntries;i++) + { + CGV_INDEX idx = what[i].index; + CGV_INDEX pidx = projected_index_out[idx] + 1; //gather_index(projected_index_out,idx)+1; + projected_index_out[idx] = pidx; // scatter_index(projected_index_out,idx,pidx); + } + } + + // get minimum index + CGV_INDEX index_min=projected_index_out[0]; + for (CGV_ENTRIES i=1; i < numEntries;i++) + { + if (projected_index_out[i] < index_min) + index_min = projected_index_out[i]; + } + + // reposition all index by min index (using min index as 0) + for (CGV_ENTRIES i=0; i < numEntries;i++) + { + projected_index_out[i] = clampIndex(projected_index_out[i] - index_min,0,15); + } + +} + +CGV_ERROR GetQuantizeIndex( + CGV_INDEXPACKED index_packed_out[2], + CGV_INDEX index_out[MAX_SUBSET_SIZE], // OUT: + CGV_IMAGE image_src[SOURCE_BLOCK_SIZE*MAX_CHANNELS], + CGV_ENTRIES numEntries, //IN: range 0..15 (MAX_SUBSET_SIZE) + CGU_INT numClusters, + CGU_CHANNEL channels3or4) // IN: 3 = RGB or 4 = RGBA (4 = MAX_CHANNELS) +{ + CGV_IMAGE image_centered[SOURCE_BLOCK_SIZE*MAX_CHANNELS]; + CGV_IMAGE image_mean[MAX_CHANNELS]; + CGV_IMAGE eigen_vector[MAX_CHANNELS]; + CGV_IMAGE covariance_vector[MAX_CHANNELS*MAX_CHANNELS]; + + GetImageCentered(image_centered,image_mean, image_src, numEntries, channels3or4); + GetCovarianceVector(covariance_vector, image_centered, numEntries, channels3or4); + + //----------------------------------------------------- + // check if all covariances are the same + // if so then set all index to same value 0 and return + // use EPSILON to set the limit for all same limit + //----------------------------------------------------- + + CGV_IMAGE image_covt=0.0F; + for (CGU_CHANNEL ch=0; ch>= 1) + clogBC7++; + + // init epo_0 + CGV_EPOCODE epo_0[2*MAX_CHANNELS]; + SetDefaultEPOCode(epo_0,0xFF,0,0,0); + + CGV_INDEX image_log = 0; + CGV_INDEX image_idx = 0; + CGU_BOOL use_par = FALSE; + if (type != 0) + use_par = TRUE; + CGV_ERROR error_1 = CMP_FLOAT_MAX; + + for (CGU_INT pn = 0; pn err_tc) + image_tcr[ch1] = image_tc; + else if (err_tf < err_tc) + image_tcr[ch1] = image_tf; + else + image_tcr[ch1] = (CGV_EPOCODE)floor(image_src[COMP_RED+(ch1*SOURCE_BLOCK_SIZE)] + 0.5F); + + //image_tcr[ch1] = image_tf + (image_tc - image_tf)/2; + + //=============================== + // Refine this for better quality! + //=============================== + error_tr = get_sperr(clogBC7,bits[ch1],image_tcr[ch1],t1,t2,iclogBC7); + error_tr = (error_tr*error_tr) + + 2 * error_tr + * img_absf(image_tcr[ch1]- image_src[COMP_RED+(ch1*SOURCE_BLOCK_SIZE)]) + + (image_tcr[ch1] - image_src[COMP_RED+(ch1*SOURCE_BLOCK_SIZE)]) + * (image_tcr[ch1] - image_src[COMP_RED+(ch1*SOURCE_BLOCK_SIZE)]); + + if (error_tr < error_ta) + { + error_ta = error_tr; + t1o[ch1] = t1; + t2o[ch1] = t2; + epo_dr_0[ch1] = clampEPO(image_tcr[ch1],0,255); + } +#else + image_tcr[ch1] = floor(image_src[COMP_RED+(ch1*SOURCE_BLOCK_SIZE)] + 0.5F); + error_ta = 0; + t1o[ch1] = t1; + t2o[ch1] = t2; + epo_dr_0[ch1] = clampi(image_tcr[ch1],0,255); +#endif + } // B + } //C + + error_t += error_ta; + } // D + + if (error_t < error_0) + { + // We have a solid color: Use image src if on GPU + image_log = iclogBC7; + image_idx = image_log; + +#ifdef ASPM_GPU // This needs improving + CGV_IMAGE MinC[4] = {255,255,255,255}; + CGV_IMAGE MaxC[4] = {0,0,0,0}; + // get min max colors + for (CGU_CHANNEL ch=0;ch MaxC[ch] ) MaxC[ch] = image_src[k+ch*SOURCE_BLOCK_SIZE]; + } + for (CGU_CHANNEL ch = 0; chsp_idx,index+0)&0xFF; + epo_0[4+ch] = BC7EncodeRamps.sp_idx[index+1]&0xFF;// gather_epocode(u_BC7Encode->sp_idx,index+1)&0xFF; + } + else { + epo_0[ch] = 0; + epo_0[4 + ch] = 0; + } +#else + epo_0[ ch] = 0; + epo_0[4+ch] = 0; +#endif + } +#endif + error_0 = error_t; + } + //if (error_0 == 0) + // break; + } // E + + if (error_0 < error_1) + { + + image_idx = image_log; + for (CGU_CHANNEL chE = 0; chE 0) + { + image_ramp = GetRamp(clogBC7,max_bits[ch],epo_p1,epo_p2,index_cidx[_mc-1]); + + image_square_diff += sq_image(image_ramp-image_src[(_mc-1)+(ch*SOURCE_BLOCK_SIZE)]); + _mc--; + } + if (image_square_diff < err_ed[(ppA*8)+(ppB*4)+ch]) + { + err_ed[(ppA*8)+(ppB*4)+ch] = image_square_diff; + epo_code_par[ppA][ppB][0][ch] = epo_p1; + epo_code_par[ppA][ppB][1][ch] = epo_p2; + } + } + } // pp1 + } // pp0 + } // j + + //--------------------------------------------------------- + for (CGU_INT pn=0; pn < npv_nd[channels3or4-3][type]; pn++) + { + CGV_ERROR err_2=0.0F; + CGU_INT d1; + CGU_INT d2; + + for (CGU_CHANNEL ch=0; ch>=1) + clogBC7++; + + CGU_INT clt_clogBC7 = CLT(clogBC7); + + if (clt_clogBC7 > 3) + { + ASPM_PRINT(("Err: optimize_IndexAndEndPoints, clt_clogBC7\n")); + return CMP_FLOAT_MAX; + } + + Mi_ = Mi_ - 1; + + CGV_INDEX MaxIndex; + CGV_INDEX index_tmp[MAX_SUBSET_SIZE]; + CGU_INT maxTry = MAX_TRY_SHAKER; + + CGV_INDEX index_best[MAX_SUBSET_SIZE]; + + for (CGV_ENTRIES k=0;kerrorThreshold) + { + break; + } + + CGV_TYPEINT done; + done = !(change && better); + if ((maxTry > 0)&&(!done)) + { + maxTry--; + MaxIndex = index_collapse(index_tmp, numEntries); + } + else + { + maxTry = 0; + } + + } while (maxTry); + + if (err_best == CMP_FLOAT_MAX) + { + ASPM_PRINT(("Err: requantized_image_err\n")); + } + + return err_best; +} + +CGU_UINT8 get_partitionsToTry(uniform CMP_GLOBAL BC7_Encode u_BC7Encode[],CGU_UINT8 maxPartitions) +{ + CGU_FLOAT u_minPartitionSearchSize = 0.30f; + if(u_BC7Encode->quality <= BC7_qFAST_THRESHOLD) // Using this to match performance and quality of CPU code + { + u_minPartitionSearchSize = u_minPartitionSearchSize + ( u_BC7Encode->quality*BC7_qFAST_THRESHOLD); + } + else + { + u_minPartitionSearchSize = u_BC7Encode->quality; + } + return (CGU_UINT8)(maxPartitions * u_minPartitionSearchSize); +} + +INLINE void cmp_encode_swap(CGV_EPOCODE endpoint[], CGU_INT channels, CGV_INDEX block_index[MAX_SUBSET_SIZE], CGU_INT bits) +{ + CGU_INT levels = 1 << bits; + if (block_index[0]>=levels/2) + { + cmp_swap_epo(&endpoint[0], &endpoint[channels], channels); + for (CGU_INT k=0; k0) q = (levels-1)-q; + + if (k1==0 && k2==0) cmp_Write8Bit(data, pPos, bits-1, CMP_STATIC_CAST(CGV_BYTE,q)); + else cmp_Write8Bit(data, pPos, bits , CMP_STATIC_CAST(CGV_BYTE,q)); + qbits_shifted >>= 4; + flips_shifted >>= 1; + } + } +} + + +INLINE CGV_SHIFT32 pow32(CGV_SHIFT32 x) +{ + return 1<>= 1; + packedColours[1] >>= 1; + } + else + if(blockMode == 1) // ONE_PBIT + { + parityBits[subset][0] = packedColours[1] & 1; + parityBits[subset][1] = packedColours[1] & 1; + packedColours[0] >>= 1; + packedColours[1] >>= 1; + } + else + if(blockMode == 2) + { + parityBits[subset][0] = 0; + parityBits[subset][1] = 0; + } + + for (CGU_INT ch=0; ch>= componentBits; + packedColours[1] >>= componentBits; + } + } + + // Loop over component + for (CGU_INT ch=0; ch < channels; ch++) + { + // loop over subsets + for (CGU_INT subset=0; subsetrotated_channel)); + + // idxMode 1 bit + cmp_Write8Bit(cmp_out, &bitPosition, 1,CMP_STATIC_CAST(CGV_BYTE,params->idxMode)); + + CGU_INT idxBits[2] = {2,3}; + + if(params->idxMode) + { + idxBits[0] = 3; + idxBits[1] = 2; + // Indicate if we need to fixup the index + cmp_swap_index(params->color_index,params->alpha_index,16); + cmp_encode_swap(params->alpha_qendpoint, 4, params->color_index,2); + cmp_encode_swap(params->color_qendpoint, 4, params->alpha_index,3); + } + else + { + cmp_encode_swap(params->color_qendpoint, 4, params->color_index,2); + cmp_encode_swap(params->alpha_qendpoint, 4, params->alpha_index,3); + } + + // color endpoints 5 bits each + // R0 : R1 + // G0 : G1 + // B0 : B1 + for (CGU_INT component=0; component < 3; component++) + { + cmp_Write8Bit(cmp_out,&bitPosition,5,CMP_STATIC_CAST(CGV_BYTE,params->color_qendpoint[component])); + cmp_Write8Bit(cmp_out,&bitPosition,5,CMP_STATIC_CAST(CGV_BYTE,params->color_qendpoint[4 + component])); + } + + // alpha endpoints (6 bits each) + // A0 : A1 + cmp_Write8Bit(cmp_out,&bitPosition,6,CMP_STATIC_CAST(CGV_BYTE,params->alpha_qendpoint[0])); + cmp_Write8Bit(cmp_out,&bitPosition,6,CMP_STATIC_CAST(CGV_BYTE,params->alpha_qendpoint[4])); + + // index 2 bits each (31 bits total) + cmp_encode_index(cmp_out, &bitPosition, params->color_index, 2); + // index 3 bits each (47 bits total) + cmp_encode_index(cmp_out, &bitPosition, params->alpha_index, 3); +} + +void Encode_mode5( CGV_CMPOUT cmp_out[COMPRESSED_BLOCK_SIZE], + varying cmp_mode_parameters* uniform params) +{ + for (CGU_INT k=0; krotated_channel)); + + cmp_encode_swap(params->color_qendpoint, 4, params->color_index,2); + cmp_encode_swap(params->alpha_qendpoint, 4, params->alpha_index,2); + + // color endpoints (7 bits each) + // R0 : R1 + // G0 : G1 + // B0 : B1 + for (CGU_INT component=0; component < 3; component++) + { + cmp_Write8Bit(cmp_out,&bitPosition,7,CMP_STATIC_CAST(CGV_BYTE,params->color_qendpoint[component])); + cmp_Write8Bit(cmp_out,&bitPosition,7,CMP_STATIC_CAST(CGV_BYTE,params->color_qendpoint[4 + component])); + } + + // alpha endpoints (8 bits each) + // A0 : A1 + cmp_Write8Bit(cmp_out,&bitPosition,8,CMP_STATIC_CAST(CGV_BYTE,params->alpha_qendpoint[0])); + cmp_Write8Bit(cmp_out,&bitPosition,8,CMP_STATIC_CAST(CGV_BYTE,params->alpha_qendpoint[4])); + + + // color index 2 bits each (31 bits total) + // alpha index 2 bits each (31 bits total) + cmp_encode_index(cmp_out, &bitPosition, params->color_index, 2); + cmp_encode_index(cmp_out, &bitPosition, params->alpha_index, 2); +} + +void Encode_mode6( + CGV_INDEX index[MAX_SUBSET_SIZE], + CGV_EPOCODE epo_code[8], + CGV_CMPOUT cmp_out[COMPRESSED_BLOCK_SIZE]) +{ + for (CGU_INT k=0; k> 1)); + cmp_Write8Bit(cmp_out, &bitPosition, 7, CMP_STATIC_CAST(CGV_BYTE,epo_code[4 + p] >> 1)); + } + + // p bits + cmp_Write8Bit(cmp_out, &bitPosition, 1, epo_code[0]&1); + cmp_Write8Bit(cmp_out, &bitPosition, 1, epo_code[4]&1); + + // quantized values + cmp_encode_index(cmp_out, &bitPosition, index, 4); +} + + +void Compress_mode01237( + CGU_INT blockMode, + BC7_EncodeState EncodeState[], +uniform CMP_GLOBAL BC7_Encode u_BC7Encode[]) +{ + CGV_INDEX storedBestindex[MAX_PARTITIONS][MAX_SUBSETS][MAX_SUBSET_SIZE]; + CGV_ERROR storedError[MAX_PARTITIONS]; + CGV_UINT8 sortedPartition[MAX_PARTITIONS]; + + EncodeState->numPartitionModes = 64; + EncodeState->maxSubSets = 2; + + if (blockMode == 0) + { + EncodeState->numPartitionModes = 16; + EncodeState->channels3or4 = 3; + EncodeState->bits = 26; + EncodeState->clusters = 8; + EncodeState->componentBits = 4; + EncodeState->maxSubSets = 3; + } + else + if (blockMode == 2) + { + EncodeState->channels3or4 = 3; + EncodeState->bits = 30; + EncodeState->clusters = 4; + EncodeState->componentBits = 5; + EncodeState->maxSubSets = 3; + } + else + if (blockMode == 1) + { + + EncodeState->channels3or4 = 3; + EncodeState->bits = 37; + EncodeState->clusters = 8; + EncodeState->componentBits = 6; + } + else + if (blockMode == 3) + { + EncodeState->channels3or4 = 3; + EncodeState->bits = 44; + EncodeState->clusters = 4; + EncodeState->componentBits = 7; + } + else + if (blockMode == 7) + { + EncodeState->channels3or4 = 4; + EncodeState->bits = 42; // (2* (R 5 + G 5 + B 5 + A 5)) + 2 parity bits + EncodeState->clusters = 4; + EncodeState->componentBits = 5; // 5 bit components + } + + CGV_IMAGE image_subsets[MAX_SUBSETS][MAX_SUBSET_SIZE][MAX_CHANNELS]; + CGV_ENTRIES subset_entryCount[MAX_SUBSETS] = {0,0,0}; + + // Loop over the available partitions for the block mode and quantize them + // to figure out the best candidates for further refinement + CGU_UINT8 mode_partitionsToTry; + mode_partitionsToTry = get_partitionsToTry(u_BC7Encode,EncodeState->numPartitionModes); + + CGV_UINT8 bestPartition = 0; + + for (CGU_INT mode_blockPartition = 0; mode_blockPartition < mode_partitionsToTry; mode_blockPartition++) + { + + GetPartitionSubSet_mode01237( + image_subsets, + subset_entryCount, + CMP_STATIC_CAST(CGV_UINT8,mode_blockPartition), + EncodeState->image_src, + blockMode, + EncodeState->channels3or4); + + CGV_IMAGE subset_image_src[SOURCE_BLOCK_SIZE*MAX_CHANNELS]; + CGV_INDEX index_out1[SOURCE_BLOCK_SIZE]; + CGV_ERROR err_quant = 0.0F; + + // Store the quntize error for this partition to be sorted and processed later + for (CGU_INT subset=0; subset < EncodeState->maxSubSets; subset++) + { + CGV_ENTRIES numEntries = subset_entryCount[subset]; + + for (CGU_INT ii=0; iiclusters, + EncodeState->channels3or4); + + for (CGV_INT idx=0; idx < numEntries; idx++) + { + storedBestindex[mode_blockPartition][subset][idx] = index_out1[idx]; + } + } + + storedError[mode_blockPartition] = err_quant; + } + + // Sort the results + sortPartitionProjection( storedError, + sortedPartition, + mode_partitionsToTry); + + CGV_EPOCODE epo_code[MAX_SUBSETS*2*MAX_CHANNELS]; + CGV_EPOCODE bestEndpoints[MAX_SUBSETS*2*MAX_CHANNELS]; + CGV_BYTE bestindex[MAX_SUBSETS*MAX_SUBSET_SIZE]; + CGV_ENTRIES bestEntryCount[MAX_SUBSETS]; + CGV_BYTE bestindex16[MAX_SUBSET_SIZE]; + + // Extensive shaking is most important when the ramp is short, and + // when we have less index. On a long ramp the quality of the + // initial quantizing is relatively more important + // We modulate the shake size according to the number of ramp index + // - the more index we have the less shaking should be required to find a near + // optimal match + + CGU_UINT8 numShakeAttempts = max8(1, min8((CGU_UINT8)floor(8 * u_BC7Encode->quality + 0.5), mode_partitionsToTry)); + CGV_ERROR err_best = CMP_FLOAT_MAX; + + // Now do the endpoint shaking + for (CGU_INT nSA =0; nSA < numShakeAttempts; nSA++) + { + + CGV_ERROR err_optimized = 0.0F; + CGV_UINT8 sortedBlockPartition; + sortedBlockPartition = sortedPartition[nSA]; + + //******************************************** + // Get the partition shape for the given mode + //******************************************** + GetPartitionSubSet_mode01237( + image_subsets, + subset_entryCount, + sortedBlockPartition, + EncodeState->image_src, + blockMode, + EncodeState->channels3or4); + + //***************************** + // Process the partition shape + //***************************** + for (CGU_INT subset=0; subset < EncodeState->maxSubSets; subset++) + { + CGV_ENTRIES numEntries = subset_entryCount[subset]; + CGV_IMAGE src_image_block[SOURCE_BLOCK_SIZE*MAX_CHANNELS]; + CGV_INDEX index_io[MAX_SUBSET_SIZE]; + CGV_EPOCODE tmp_epo_code[8]; + + for (CGU_INT k=0; kclusters), // Mi_ + EncodeState->bits, + EncodeState->channels3or4, + u_BC7Encode); + + for (CGU_INT k=0; k < MAX_SUBSET_SIZE; k++) + { + storedBestindex[sortedBlockPartition][subset][k] = index_io[k]; + } + + for (CGU_INT ch=0; chmaxSubSets; subset++) + { + CGV_ENTRIES numEntries = subset_entryCount[subset]; + bestEntryCount[subset] = numEntries; + + if(numEntries) + { + for (CGU_INT ch=0; ch < EncodeState->channels3or4; ch++) + { + bestEndpoints[(subset*2+0)*4+ch] = epo_code[(subset*2+0)*4+ch]; + bestEndpoints[(subset*2+1)*4+ch] = epo_code[(subset*2+1)*4+ch]; + } + + for (CGV_ENTRIES k=0; k< numEntries; k++) + { + bestindex[subset*MAX_SUBSET_SIZE+k] = storedBestindex[sortedBlockPartition][subset][k]; + bestindex16[bestIndexCount++] = storedBestindex[sortedBlockPartition][subset][k]; + } + } + } + + err_best = err_optimized; + // Early out if we found we can compress with error below the quality threshold + if(err_best <= u_BC7Encode->errorThreshold) + { + break; + } + } + } + + + if (blockMode != 7) + err_best += EncodeState->opaque_err; + + if(err_best > EncodeState->best_err) + return; + + //************************** + // Save the encoded block + //************************** + EncodeState->best_err = err_best; + + + // Now we have all the data needed to encode the block + // We need to pack the endpoints prior to encoding + CGV_TYPEUINT32 packedEndpoints[MAX_SUBSETS*2] = {0,0,0,0,0,0}; + for (CGU_INT subset=0; subsetmaxSubSets; subset++) + { + packedEndpoints[(subset*2)+0] = 0; + packedEndpoints[(subset*2)+1] = 0; + + if(bestEntryCount[subset]) + { + CGU_UINT32 rightAlignment = 0; + + // Sort out parity bits + if(blockMode != 2) + { + // Sort out BCC parity bits + packedEndpoints[(subset*2)+0] = bestEndpoints[(subset*2+0)*4+0] & 1; + packedEndpoints[(subset*2)+1] = bestEndpoints[(subset*2+1)*4+0] & 1; + for (CGU_INT ch=0; chchannels3or4; ch++) + { + bestEndpoints[(subset*2+0)*4+ch] >>= 1; + bestEndpoints[(subset*2+1)*4+ch] >>= 1; + } + rightAlignment++; + } + + // Fixup endpoints + for (CGU_INT ch=0; chchannels3or4; ch++) + { + packedEndpoints[(subset*2)+0] |= bestEndpoints[((subset*2)+0)*4+ch] << rightAlignment; + packedEndpoints[(subset*2)+1] |= bestEndpoints[((subset*2)+1)*4+ch] << rightAlignment; + rightAlignment += EncodeState->componentBits; + } + } + } + + CGV_UINT8 idxCount[3] = {0, 0, 0}; + for (CGV_INT k=0; kmaxSubSets,k); + CGV_UINT8 idxC = idxCount[partsub]; + bestindex16[k] = bestindex[partsub*MAX_SUBSET_SIZE+idxC]; + idxCount[partsub] = idxC + 1; + } + + Encode_mode02137( + blockMode, + bestPartition, + packedEndpoints, + bestindex16, + EncodeState->cmp_out); +} + +void Compress_mode45( + CGU_INT blockMode, + BC7_EncodeState EncodeState[], +uniform CMP_GLOBAL BC7_Encode u_BC7Encode[]) +{ + + cmp_mode_parameters best_candidate; + EncodeState->channels3or4 = 4; + cmp_memsetBC7((CGV_BYTE *)&best_candidate, 0, sizeof(cmp_mode_parameters)); + + if (blockMode == 4) + { + EncodeState->max_idxMode = 2; + EncodeState->modeBits[0] = 30; // bits = 2 * (Red 5+ Grn 5+ blu 5) + EncodeState->modeBits[1] = 36; // bits = 2 * (Alpha 6+6+6) + EncodeState->numClusters0[0] = 4; + EncodeState->numClusters0[1] = 8; + EncodeState->numClusters1[0] = 8; + EncodeState->numClusters1[1] = 4; + } + else + { + EncodeState->max_idxMode = 1; + EncodeState->modeBits[0] = 42; // bits = 2 * (Red 7+ Grn 7+ blu 7) + EncodeState->modeBits[1] = 48; // bits = 2 * (Alpha 8+8+8) = 48 + EncodeState->numClusters0[0] = 4; + EncodeState->numClusters0[1] = 4; + EncodeState->numClusters1[0] = 4; + EncodeState->numClusters1[1] = 4; + } + + + CGV_IMAGE src_color_Block[SOURCE_BLOCK_SIZE*MAX_CHANNELS]; + CGV_IMAGE src_alpha_Block[SOURCE_BLOCK_SIZE*MAX_CHANNELS]; + + // Go through each possible rotation and selection of index rotationBits) + for (CGU_CHANNEL rotated_channel = 0; rotated_channel < EncodeState->channels3or4; rotated_channel++) + { // A + + for (CGU_INT k=0; kimage_src[k+componentRotations[rotated_channel][p+1]*SOURCE_BLOCK_SIZE]; + src_alpha_Block[k+p*SOURCE_BLOCK_SIZE] = EncodeState->image_src[k+componentRotations[rotated_channel][0]*SOURCE_BLOCK_SIZE]; + } + } + + CGV_ERROR err_quantizer; + CGV_ERROR err_bestQuantizer = CMP_FLOAT_MAX; + + for (CGU_INT idxMode = 0; idxMode < EncodeState->max_idxMode; idxMode++) + { // B + CGV_INDEXPACKED color_index2[2]; // reserved .. Not used! + + err_quantizer = GetQuantizeIndex( + color_index2, + best_candidate.color_index, + src_color_Block, + SOURCE_BLOCK_SIZE, + EncodeState->numClusters0[idxMode], + 3); + + err_quantizer += GetQuantizeIndex( + color_index2, + best_candidate.alpha_index, + src_alpha_Block, + SOURCE_BLOCK_SIZE, + EncodeState->numClusters1[idxMode], + 3) / 3.0F; + + // If quality is high then run the full shaking for this config and + // store the result if it beats the best overall error + // Otherwise only run the shaking if the error is better than the best + // quantizer error + if(err_quantizer <= err_bestQuantizer) + { + err_bestQuantizer = err_quantizer; + + // Shake size gives the size of the shake cube + CGV_ERROR err_overallError; + + err_overallError = optimize_IndexAndEndPoints( + best_candidate.color_index, + best_candidate.color_qendpoint, + src_color_Block, + SOURCE_BLOCK_SIZE, + EncodeState->numClusters0[idxMode], + CMP_STATIC_CAST(CGU_UINT8,EncodeState->modeBits[0]), + 3, + u_BC7Encode); + + // Alpha scalar block + err_overallError += optimize_IndexAndEndPoints( + best_candidate.alpha_index, + best_candidate.alpha_qendpoint, + src_alpha_Block, + SOURCE_BLOCK_SIZE, + EncodeState->numClusters1[idxMode], + CMP_STATIC_CAST(CGU_UINT8,EncodeState->modeBits[1]), + 3, + u_BC7Encode) / 3.0f; + + // If we beat the previous best then encode the block + if(err_overallError < EncodeState->best_err) + { + best_candidate.idxMode = idxMode; + best_candidate.rotated_channel = rotated_channel; + if (blockMode == 4) + Encode_mode4( EncodeState->cmp_out, &best_candidate); + else + Encode_mode5( EncodeState->cmp_out, &best_candidate); + EncodeState->best_err = err_overallError; + } + } + } // B + } // A +} + + +void Compress_mode6( BC7_EncodeState EncodeState[], +uniform CMP_GLOBAL BC7_Encode u_BC7Encode[]) +{ + CGV_ERROR err; + + CGV_EPOCODE epo_code_out[8] = {0}; + CGV_INDEX best_index_out[MAX_SUBSET_SIZE]; + CGV_INDEXPACKED best_packedindex_out[2]; + + + // CGV_IMAGE block_endpoints[8]; + // icmp_get_block_endpoints(block_endpoints, EncodeState->image_src, -1, 4); + // icmp_GetQuantizedEpoCode(epo_code_out, block_endpoints, 6,4); + // err = icmp_GetQuantizeIndex(best_packedindex_out, best_index_out, EncodeState->image_src, 4, block_endpoints, 0,4); + + err = GetQuantizeIndex( + best_packedindex_out, + best_index_out, + EncodeState->image_src, + 16, // numEntries + 16, // clusters + 4); // channels3or4 + + //***************************** + // Process the partition shape + //***************************** + err = optimize_IndexAndEndPoints( + best_index_out, + epo_code_out, + EncodeState->image_src, + 16, //numEntries + 16, // Mi_ = clusters + 58, // bits + 4, // channels3or4 + u_BC7Encode); + + //************************** + // Save the encoded block + //************************** + + if (err < EncodeState->best_err) + { + EncodeState->best_err = err; + Encode_mode6( + best_index_out, + epo_code_out, + EncodeState->cmp_out); + } +} + +void copy_BC7_Encode_settings(BC7_EncodeState EncodeState[], uniform CMP_GLOBAL BC7_Encode settings []) +{ + EncodeState->best_err = CMP_FLOAT_MAX; + EncodeState->validModeMask = settings->validModeMask; + #ifdef USE_ICMP + EncodeState->part_count = settings->part_count; + EncodeState->channels = settings->channels; +#endif +} + +//===================================== ICMP CODE ========================================================= +#ifdef USE_ICMP +//======================================== +// Modified Intel Texture Compression Code +//======================================== + +void icmp_Write32Bit(CGV_CMPOUTPACKED base[], CGU_INT* uniform offset, CGU_INT bits, CGV_CMPOUTPACKED bitVal) +{ + base[*offset / 32] |= ((CGV_CMPOUTPACKED)bitVal) << (*offset % 32); + if (*offset % 32 + bits > 32) + { + base[*offset / 32 + 1] |= shift_right_uint32(bitVal, 32 - *offset % 32); + } + *offset += bits; +} + +//================ 32 bit cmp_out mode encoders =============== + +INLINE void icmp_swap_epocode(CGV_EPOCODE u[], CGV_EPOCODE v[], CGU_INT n) +{ + for (CGU_INT i = 0; i < n; i++) + { + CGV_EPOCODE t = u[i]; + u[i] = v[i]; + v[i] = t; + } +} + +void icmp_encode_apply_swap(CGV_EPOCODE endpoint[], CGU_INT channel, CGV_INDEXPACKED block_index[2], CGU_INT bits) +{ + CGU_INT levels = 1 << bits; + if ((block_index[0] & 15) >= levels / 2) + { + icmp_swap_epocode(&endpoint[0], &endpoint[channel], channel); + + for (CGU_INT k = 0; k < 2; k++) + block_index[k] = (CGV_INDEXPACKED)(0x11111111 * (levels - 1)) - block_index[k]; + } +} + +void icmp_encode_index(CGV_CMPOUTPACKED data[5], CGU_INT* uniform pPos, CGV_INDEXPACKED block_index[2], CGU_INT bits, CGV_MASK flips) +{ + CGU_INT levels = 1 << bits; + CGV_MASK flips_shifted = flips; + for (CGU_INT k1 = 0; k1 < 2; k1++) + { + CGV_CMPOUTPACKED qbits_shifted = block_index[k1]; + for (CGU_INT k2 = 0; k2 < 8; k2++) + { + CGV_CMPOUTPACKED q = qbits_shifted & 15; + if ((flips_shifted & 1) > 0) q = (levels - 1) - q; + + if (k1 == 0 && k2 == 0) icmp_Write32Bit(data, pPos, bits - 1, q); + else icmp_Write32Bit(data, pPos, bits, q); + qbits_shifted >>= 4; + flips_shifted >>= 1; + } + } +} + +void icmp_bc7_encode_endpoint2(CGV_CMPOUTPACKED data[5], CGU_INT* uniform pPos, CGV_INDEXPACKED color_index[2], CGU_INT bits, CGV_MASK flips) +{ + CGU_INT levels = 1 << bits; + CGV_MASK flips_shifted = flips; + for (CGU_INT k1 = 0; k1 < 2; k1++) + { + CGV_INDEXPACKED qbits_shifted = color_index[k1]; + for (CGU_INT k2 = 0; k2 < 8; k2++) + { + CGV_INDEXPACKED q = qbits_shifted & 15; + if ((flips_shifted & 1) > 0) q = (levels - 1) - q; + + if (k1 == 0 && k2 == 0) icmp_Write32Bit(data, pPos, bits - 1, q); + else icmp_Write32Bit(data, pPos, bits, q); + qbits_shifted >>= 4; + flips_shifted >>= 1; + } + } +} + +INLINE CGV_CMPOUTPACKED icmp_pow2Packed(CGV_FIXUPINDEX x) +{ + return 1 << x; +} + +INLINE void icmp_encode_data_shl_1bit_from(CGV_CMPOUTPACKED data[5], CGV_FIXUPINDEX from) +{ + if (from < 96) + { + //assert(from > 64+10); + + CGV_CMPOUTPACKED shifted = (data[2] >> 1) | (data[3] << 31); + CGV_CMPOUTPACKED mask = (icmp_pow2Packed(from - 64) - 1) >> 1; + data[2] = (mask&data[2]) | (~mask&shifted); + data[3] = (data[3] >> 1) | (data[4] << 31); + data[4] = data[4] >> 1; + } + else if (from < 128) + { + CGV_CMPOUTPACKED shifted = (data[3] >> 1) | (data[4] << 31); + CGV_CMPOUTPACKED mask = (icmp_pow2Packed(from - 96) - 1) >> 1; + data[3] = (mask&data[3]) | (~mask&shifted); + data[4] = data[4] >> 1; + } +} + +INLINE void icmp_get_fixuptable(CGV_FIXUPINDEX fixup[3], CGV_PARTID part_id) +{ + // same as CMP SDK v3.1 BC7_FIXUPINDEX1 & BC7_FIXUPINDEX2 for each partition range 0..63 + // The data is saved as a packed INT = (BC7_FIXUPINDEX1 << 4 + BC7_FIXUPINDEX2) + CMP_STATIC uniform __constant CGV_FIXUPINDEX FIXUPINDEX[] = { + // 2 subset partitions 0..63 + 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, + 0xf0u, 0x20u, 0x80u, 0x20u, 0x20u, 0x80u, 0x80u, 0xf0u, 0x20u, 0x80u, 0x20u, 0x20u, 0x80u, 0x80u, 0x20u, 0x20u, + 0xf0u, 0xf0u, 0x60u, 0x80u, 0x20u, 0x80u, 0xf0u, 0xf0u, 0x20u, 0x80u, 0x20u, 0x20u, 0x20u, 0xf0u, 0xf0u, 0x60u, + 0x60u, 0x20u, 0x60u, 0x80u, 0xf0u, 0xf0u, 0x20u, 0x20u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0xf0u, 0x20u, 0x20u, 0xf0u, + // 3 subset partitions 64..128 + 0x3fu, 0x38u, 0xf8u, 0xf3u, 0x8fu, 0x3fu, 0xf3u, 0xf8u, 0x8fu, 0x8fu, 0x6fu, 0x6fu, 0x6fu, 0x5fu, 0x3fu, 0x38u, + 0x3fu, 0x38u, 0x8fu, 0xf3u, 0x3fu, 0x38u, 0x6fu, 0xa8u, 0x53u, 0x8fu, 0x86u, 0x6au, 0x8fu, 0x5fu, 0xfau, 0xf8u, + 0x8fu, 0xf3u, 0x3fu, 0x5au, 0x6au, 0xa8u, 0x89u, 0xfau, 0xf6u, 0x3fu, 0xf8u, 0x5fu, 0xf3u, 0xf6u, 0xf6u, 0xf8u, + 0x3fu, 0xf3u, 0x5fu, 0x5fu, 0x5fu, 0x8fu, 0x5fu, 0xafu, 0x5fu, 0xafu, 0x8fu, 0xdfu, 0xf3u, 0xcfu, 0x3fu, 0x38u + }; + + CGV_FIXUPINDEX skip_packed = FIXUPINDEX[part_id];// gather_int2(FIXUPINDEX, part_id); + fixup[0] = 0; + fixup[1] = skip_packed >> 4; + fixup[2] = skip_packed & 15; +} + +void icmp_bc7_encode_adjust_skip_mode01237_2(CGV_CMPOUTPACKED data[5], CGU_INT mode, CGV_PARTID part_id) +{ + CGU_INT bits = 2; if (mode == 0 || mode == 1) bits = 3; + CGU_INT maxSubSets = 2; if (mode == 0 || mode == 2) maxSubSets = 3; + + CGV_FIXUPINDEX fixup[3]; + icmp_get_fixuptable(fixup, part_id); + + if (maxSubSets > 2 && fixup[1] < fixup[2]) + { + CGV_FIXUPINDEX t = fixup[1]; fixup[1] = fixup[2]; fixup[2] = t; + } + + for (CGU_INT j = 1; j < maxSubSets; j++) + { + CGV_FIXUPINDEX k = fixup[j]; + icmp_encode_data_shl_1bit_from(data, 128 + (maxSubSets - 1) - (15 - k)*bits); + } +} + +INLINE CGV_UINT32 gather_uint32(__constant CGU_UINT32 * const uniform ptr, CGV_INT idx) +{ + return ptr[idx]; // (perf warning expected) +} + +INLINE CGV_MASK icmp_get_partition_mask(CGV_PARTID part_id, CGU_INT subset) +{ + CMP_STATIC uniform __constant CGV_SHIFT32 pattern_mask_table[] = { + // 2 subset partitions + 0xCCCC3333u, 0x88887777u, 0xEEEE1111u, 0xECC81337u, 0xC880377Fu, 0xFEEC0113u, 0xFEC80137u, 0xEC80137Fu, + 0xC80037FFu, 0xFFEC0013u, 0xFE80017Fu, 0xE80017FFu, 0xFFE80017u, 0xFF0000FFu, 0xFFF0000Fu, 0xF0000FFFu, + 0xF71008EFu, 0x008EFF71u, 0x71008EFFu, 0x08CEF731u, 0x008CFF73u, 0x73108CEFu, 0x3100CEFFu, 0x8CCE7331u, + 0x088CF773u, 0x3110CEEFu, 0x66669999u, 0x366CC993u, 0x17E8E817u, 0x0FF0F00Fu, 0x718E8E71u, 0x399CC663u, + 0xAAAA5555u, 0xF0F00F0Fu, 0x5A5AA5A5u, 0x33CCCC33u, 0x3C3CC3C3u, 0x55AAAA55u, 0x96966969u, 0xA55A5AA5u, + 0x73CE8C31u, 0x13C8EC37u, 0x324CCDB3u, 0x3BDCC423u, 0x69969669u, 0xC33C3CC3u, 0x99666699u, 0x0660F99Fu, + 0x0272FD8Du, 0x04E4FB1Bu, 0x4E40B1BFu, 0x2720D8DFu, 0xC93636C9u, 0x936C6C93u, 0x39C6C639u, 0x639C9C63u, + 0x93366CC9u, 0x9CC66339u, 0x817E7E81u, 0xE71818E7u, 0xCCF0330Fu, 0x0FCCF033u, 0x774488BBu, 0xEE2211DDu, + + // 3 subset partitions + 0x08CC0133u, 0x8CC80037u, 0xCC80006Fu, 0xEC001331u, 0x330000FFu, 0x00CC3333u, 0xFF000033u, 0xCCCC0033u, + 0x0F0000FFu, 0x0FF0000Fu, 0x00F0000Fu, 0x44443333u, 0x66661111u, 0x22221111u, 0x136C0013u, 0x008C8C63u, + 0x36C80137u, 0x08CEC631u, 0x3330000Fu, 0xF0000333u, 0x00EE1111u, 0x88880077u, 0x22C0113Fu, 0x443088CFu, + 0x0C22F311u, 0x03440033u, 0x69969009u, 0x9960009Fu, 0x03303443u, 0x00660699u, 0xC22C3113u, 0x8C0000EFu, + 0x1300007Fu, 0xC4003331u, 0x004C1333u, 0x22229999u, 0x00F0F00Fu, 0x24929249u, 0x29429429u, 0xC30C30C3u, + 0xC03C3C03u, 0x00AA0055u, 0xAA0000FFu, 0x30300303u, 0xC0C03333u, 0x90900909u, 0xA00A5005u, 0xAAA0000Fu, + 0x0AAA0555u, 0xE0E01111u, 0x70700707u, 0x6660000Fu, 0x0EE01111u, 0x07707007u, 0x06660999u, 0x660000FFu, + 0x00660099u, 0x0CC03333u, 0x03303003u, 0x60000FFFu, 0x80807777u, 0x10100101u, 0x000A0005u, 0x08CE8421u + }; + + CGV_MASK mask_packed = gather_uint32(pattern_mask_table, part_id); + CGV_MASK mask0 = mask_packed & 0xFFFF; + CGV_MASK mask1 = mask_packed >> 16; + + CGV_MASK mask = (subset == 2) ? (~mask0)&(~mask1) : ((subset == 0) ? mask0 : mask1); + return mask; +} + +#ifdef USE_VARYING +#ifdef ASPM_GPU +INLINE CGV_INDEXPACKED gather_packedindex(CGV_INDEXPACKED* ptr, CGV_FIXUPINDEX idx) +{ + return ptr[idx]; +} +#else +INLINE CGV_INDEXPACKED gather_packedindex(CMP_CONSTANT varying CGV_INDEXPACKED* CMP_CONSTANT uniform ptr, CGV_FIXUPINDEX idx) +{ + return ptr[idx]; // (perf warning expected) +} +#endif +#endif + +CGV_MASK icmp_encode_apply_swap_mode01237(CGV_EPOCODE qep[], CGV_INDEXPACKED color_index[2], CGU_INT blockMode, CGV_PARTID part_id) +{ + CGU_INT bits = 2; if (blockMode == 0 || blockMode == 1) bits = 3; + CGU_INT maxSubSets = 2; if (blockMode == 0 || blockMode == 2) maxSubSets = 3; + + CGV_MASK flips = 0; + CGU_INT levels = 1 << bits; + CGV_FIXUPINDEX fixup[3]; + icmp_get_fixuptable(fixup, part_id); + + for (CGU_INT j = 0; j < maxSubSets; j++) + { + CGV_FIXUPINDEX k0 = fixup[j]; + +#ifdef USE_VARYING + CGV_INDEXPACKED q = ((gather_packedindex(color_index, k0 >> 3) << (28 - (k0 & 7) * 4)) >> 28); +#else + CGV_INDEXPACKED q = ((color_index[k0 >> 3] << (28 - (k0 & 7) * 4)) >> 28); +#endif + + if (q >= levels / 2) + { + icmp_swap_epocode(&qep[8 * j], &qep[8 * j + 4], 4); + CGV_MASK partition_mask = icmp_get_partition_mask(part_id, j); + flips |= partition_mask; + } + } + + return flips; +} + +void icmp_encode_mode01237(CGV_CMPOUTPACKED cmp_out[5], CGV_EPOCODE color_qendpoint[], CGV_INDEXPACKED color_index[2], CGV_PARTID part_id, CGU_INT blockMode) +{ + CGU_INT bits = 2; if (blockMode == 0 || blockMode == 1) bits = 3; + CGU_INT maxSubSets = 2; if (blockMode == 0 || blockMode == 2) maxSubSets = 3; + CGU_INT channels = 3; if (blockMode == 7) channels = 4; + + CGV_MASK flips = icmp_encode_apply_swap_mode01237(color_qendpoint, color_index, blockMode, part_id); + + for (CGU_INT k = 0; k < 5; k++) cmp_out[k] = 0; + CGU_INT pos = 0; + + // mode 0-3, 7 + icmp_Write32Bit(cmp_out, &pos, blockMode + 1, 1 << blockMode); + + // partition + if (blockMode == 0) + { + icmp_Write32Bit(cmp_out, &pos, 4, part_id & 15); + } + else + { + icmp_Write32Bit(cmp_out, &pos, 6, part_id & 63); + } + + // endpoints + for (CGU_INT ch = 0; ch < channels; ch++) + for (CGU_INT j = 0; j < maxSubSets * 2; j++) + { + if (blockMode == 0) + { + icmp_Write32Bit(cmp_out, &pos, 4, color_qendpoint[j * 4 + 0 + ch] >> 1); + } + else if (blockMode == 1) + { + icmp_Write32Bit(cmp_out, &pos, 6, color_qendpoint[j * 4 + 0 + ch] >> 1); + } + else if (blockMode == 2) + { + icmp_Write32Bit(cmp_out, &pos, 5, color_qendpoint[j * 4 + 0 + ch]); + } + else if (blockMode == 3) + { + icmp_Write32Bit(cmp_out, &pos, 7, color_qendpoint[j * 4 + 0 + ch] >> 1); + } + else if (blockMode == 7) + { + icmp_Write32Bit(cmp_out, &pos, 5, color_qendpoint[j * 4 + 0 + ch] >> 1); + } + //else + //{ + // assert(false); + //} + } + + // p bits + if (blockMode == 1) + for (CGU_INT j = 0; j < 2; j++) + { + icmp_Write32Bit(cmp_out, &pos, 1, color_qendpoint[j * 8] & 1); + } + + if (blockMode == 0 || blockMode == 3 || blockMode == 7) + for (CGU_INT j = 0; j < maxSubSets * 2; j++) + { + icmp_Write32Bit(cmp_out, &pos, 1, color_qendpoint[j * 4] & 1); + } + + // quantized values + icmp_bc7_encode_endpoint2(cmp_out, &pos, color_index, bits, flips); + icmp_bc7_encode_adjust_skip_mode01237_2(cmp_out, blockMode, part_id); +} + +INLINE void icmp_swap_indexpacked(CGV_INDEXPACKED u[], CGV_INDEXPACKED v[], CGU_INT n) +{ + for (CGU_INT i = 0; i < n; i++) + { + CGV_INDEXPACKED t = u[i]; + u[i] = v[i]; + v[i] = t; + } +} + + +void icmp_encode_mode4(CGV_CMPOUTPACKED cmp_out[5], varying cmp_mode_parameters* uniform params) +{ + CGV_EPOCODE color_qendpoint[8]; + CGV_INDEXPACKED color_index[2]; + CGV_EPOCODE alpha_qendpoint[2]; + CGV_INDEXPACKED alpha_index[2]; + + CGV_CMPOUTPACKED rotated_channel = params->rotated_channel; + CGV_SHIFT32 idxMode = params->idxMode; + + icmp_swap_epocode(params->color_qendpoint, color_qendpoint, 8); + icmp_swap_indexpacked(params->best_color_index, color_index, 2); + icmp_swap_epocode(params->alpha_qendpoint, alpha_qendpoint, 2); + icmp_swap_indexpacked(params->best_alpha_index, alpha_index, 2); + + for (CGU_INT k = 0; k < 5; k++) cmp_out[k] = 0; + CGU_INT pos = 0; + + // mode 4 (5 bits) 00001 + icmp_Write32Bit(cmp_out, &pos, 5, 16); + + // rotation channel 2 bits + icmp_Write32Bit(cmp_out, &pos, 2, (rotated_channel + 1) & 3); + + // idxMode 1 bit + icmp_Write32Bit(cmp_out, &pos, 1, idxMode); + + if (!idxMode) + { + icmp_encode_apply_swap(color_qendpoint, 4, color_index, 2); + icmp_encode_apply_swap(alpha_qendpoint, 1, alpha_index, 3); + } + else + { + icmp_swap_indexpacked(color_index, alpha_index, 2); + icmp_encode_apply_swap(alpha_qendpoint, 1, color_index, 2); + icmp_encode_apply_swap(color_qendpoint, 4, alpha_index, 3); + } + + // color endpoints 5 bits each + // R0 : R1 + // G0 : G1 + // B0 : B1 + for (CGU_INT p = 0; p < 3; p++) + { + CGV_EPOCODE c0 = color_qendpoint[0 + p]; + CGV_EPOCODE c1 = color_qendpoint[4 + p]; + icmp_Write32Bit(cmp_out, &pos, 5, c0); // 0 + icmp_Write32Bit(cmp_out, &pos, 5, c1); // 1 + } + + // alpha endpoints (6 bits each) + // A0 : A1 + icmp_Write32Bit(cmp_out, &pos, 6, alpha_qendpoint[0]); + icmp_Write32Bit(cmp_out, &pos, 6, alpha_qendpoint[1]); + + // index data (color index 2 bits each) 31 bits total + icmp_encode_index(cmp_out, &pos, color_index, 2, 0); + + // index data (alpha index 3 bits each) 47 bits total + icmp_encode_index(cmp_out, &pos, alpha_index, 3, 0); +} + +void icmp_Encode_mode5(CGV_CMPOUTPACKED cmp_out[5], varying cmp_mode_parameters* uniform params) +{ + + CGV_EPOCODE qep[8]; + CGV_INDEXPACKED color_index[2]; + CGV_EPOCODE alpha_qendpoint[2]; + CGV_INDEXPACKED alpha_index[2]; + + icmp_swap_epocode(params->color_qendpoint, qep, 8); + icmp_swap_indexpacked(params->best_color_index, color_index, 2); + icmp_swap_epocode(params->alpha_qendpoint, alpha_qendpoint, 2); + icmp_swap_indexpacked(params->best_alpha_index, alpha_index, 2); + + CGV_CMPOUTPACKED rotated_channel = params->rotated_channel; + + icmp_encode_apply_swap(qep, 4, color_index, 2); + icmp_encode_apply_swap(alpha_qendpoint, 1, alpha_index, 2); + + for (CGU_INT k = 0; k < 5; k++) cmp_out[k] = 0; + CGU_INT pos = 0; + + // mode 5 + icmp_Write32Bit(cmp_out, &pos, 6, 1 << 5); + + // rotated channel + icmp_Write32Bit(cmp_out, &pos, 2, (rotated_channel + 1) & 3); + + // endpoints + for (CGU_INT p = 0; p < 3; p++) + { + icmp_Write32Bit(cmp_out, &pos, 7, qep[0 + p]); + icmp_Write32Bit(cmp_out, &pos, 7, qep[4 + p]); + } + + // alpha endpoints + icmp_Write32Bit(cmp_out, &pos, 8, alpha_qendpoint[0]); + icmp_Write32Bit(cmp_out, &pos, 8, alpha_qendpoint[1]); + + // quantized values + icmp_encode_index(cmp_out, &pos, color_index, 2, 0); + icmp_encode_index(cmp_out, &pos, alpha_index, 2, 0); + +} + +void icmp_encode_mode6(CGV_CMPOUTPACKED cmp_out[5], CGV_EPOCODE qep[8], CGV_INDEXPACKED color_index[2]) +{ + icmp_encode_apply_swap(qep, 4, color_index, 4); + + for (CGU_INT k = 0; k < 5; k++) cmp_out[k] = 0; + CGU_INT pos = 0; + + // mode 6 + icmp_Write32Bit(cmp_out, &pos, 7, 64); + + // endpoints + for (CGU_INT p = 0; p < 4; p++) + { + icmp_Write32Bit(cmp_out, &pos, 7, qep[0 + p] >> 1); + icmp_Write32Bit(cmp_out, &pos, 7, qep[4 + p] >> 1); + } + + // p bits + icmp_Write32Bit(cmp_out, &pos, 1, qep[0] & 1); + icmp_Write32Bit(cmp_out, &pos, 1, qep[4] & 1); + + // quantized values + icmp_encode_index(cmp_out, &pos, color_index, 4, 0); +} + +/////////////////////////// +// PCA helpers + +INLINE void icmp_compute_stats_masked(CGV_IMAGE stats[15], CGV_IMAGE image_src[64], CGV_MASK mask, CGU_CHANNEL channels) +{ + for (CGU_INT i = 0; i < 15; i++) stats[i] = 0; + + CGV_MASK mask_shifted = mask << 1; + for (CGU_INT k = 0; k < 16; k++) + { + mask_shifted >>= 1; + //if ((mask_shifted&1) == 0) continue; + CGV_MASK flag = (mask_shifted & 1); + + CGV_IMAGE rgba[4]; + for (CGU_CHANNEL ch = 0; ch < channels; ch++) rgba[ch] = image_src[k + ch * 16]; + + for (CGU_CHANNEL ch = 0; ch < channels; ch++) rgba[ch] *= flag; + stats[14] += flag; + + stats[10] += rgba[0]; + stats[11] += rgba[1]; + stats[12] += rgba[2]; + + stats[0] += rgba[0] * rgba[0]; + stats[1] += rgba[0] * rgba[1]; + stats[2] += rgba[0] * rgba[2]; + + stats[4] += rgba[1] * rgba[1]; + stats[5] += rgba[1] * rgba[2]; + + stats[7] += rgba[2] * rgba[2]; + + if (channels == 4) + { + stats[13] += rgba[3]; + + stats[3] += rgba[0] * rgba[3]; + stats[6] += rgba[1] * rgba[3]; + stats[8] += rgba[2] * rgba[3]; + stats[9] += rgba[3] * rgba[3]; + } + } +} + +INLINE void icmp_covar_from_stats(CGV_IMAGE covar[10], CGV_IMAGE stats[15], CGU_CHANNEL channels3or4) +{ + covar[0] = stats[0] - stats[10 + 0] * stats[10 + 0] / stats[14]; + covar[1] = stats[1] - stats[10 + 0] * stats[10 + 1] / stats[14]; + covar[2] = stats[2] - stats[10 + 0] * stats[10 + 2] / stats[14]; + + covar[4] = stats[4] - stats[10 + 1] * stats[10 + 1] / stats[14]; + covar[5] = stats[5] - stats[10 + 1] * stats[10 + 2] / stats[14]; + + covar[7] = stats[7] - stats[10 + 2] * stats[10 + 2] / stats[14]; + + if (channels3or4 == 4) + { + covar[3] = stats[3] - stats[10 + 0] * stats[10 + 3] / stats[14]; + covar[6] = stats[6] - stats[10 + 1] * stats[10 + 3] / stats[14]; + covar[8] = stats[8] - stats[10 + 2] * stats[10 + 3] / stats[14]; + covar[9] = stats[9] - stats[10 + 3] * stats[10 + 3] / stats[14]; + } +} + +INLINE void icmp_compute_covar_dc_masked(CGV_IMAGE covar[6], CGV_IMAGE dc[3], CGV_IMAGE image_src[64], CGV_MASK mask, CGU_INT channels3or4) +{ + CGV_IMAGE stats[15]; + icmp_compute_stats_masked(stats, image_src, mask, channels3or4); + + icmp_covar_from_stats(covar, stats, channels3or4); + for (CGU_INT ch = 0; ch < channels3or4; ch++) dc[ch] = stats[10 + ch] / stats[14]; +} + +INLINE void icmp_ssymv3(CGV_IMAGE a[4], CGV_IMAGE covar[10], CGV_IMAGE b[4]) +{ + a[0] = covar[0] * b[0] + covar[1] * b[1] + covar[2] * b[2]; + a[1] = covar[1] * b[0] + covar[4] * b[1] + covar[5] * b[2]; + a[2] = covar[2] * b[0] + covar[5] * b[1] + covar[7] * b[2]; +} + +INLINE void icmp_ssymv4_2(CGV_IMAGE a[4], CGV_IMAGE covar[10], CGV_IMAGE b[4]) +{ + a[0] = covar[0] * b[0] + covar[1] * b[1] + covar[2] * b[2] + covar[3] * b[3]; + a[1] = covar[1] * b[0] + covar[4] * b[1] + covar[5] * b[2] + covar[6] * b[3]; + a[2] = covar[2] * b[0] + covar[5] * b[1] + covar[7] * b[2] + covar[8] * b[3]; + a[3] = covar[3] * b[0] + covar[6] * b[1] + covar[8] * b[2] + covar[9] * b[3]; +} + +#ifndef ASPM +// Computes inverse square root over an implementation-defined range. The maximum error is implementation-defined. +CGV_IMAGE Image_rsqrt(CGV_IMAGE f) +{ + CGV_IMAGE sf = sqrt(f); + if (sf != 0) + return 1 / sqrt(f); + else + return 0.0f; +} +#endif + +INLINE void icmp_compute_axis(CGV_IMAGE axis[4], + CGV_IMAGE covar[10], +#ifdef ASPM_GPU + CGV_ITTERATIONS powerIterations, +#else + uniform __constant CGV_ITTERATIONS powerIterations, +#endif + CGU_CHANNEL channels) +{ + CGV_IMAGE vec[4] = { 1,1,1,1 }; + + for (CGU_INT i = 0; i < powerIterations; i++) + { + if (channels == 3) icmp_ssymv3(axis, covar, vec); + if (channels == 4) icmp_ssymv4_2(axis, covar, vec); + + for (CGU_CHANNEL ch = 0; ch < channels; ch++) vec[ch] = axis[ch]; + + if (i % 2 == 1) // renormalize every other iteration + { + CGV_IMAGE norm_sq = 0; + for (CGU_CHANNEL ch = 0; ch < channels; ch++) + norm_sq += axis[ch] * axis[ch]; + +#ifndef ASPM + CGV_IMAGE rnorm = Image_rsqrt(norm_sq); +#else + CGV_IMAGE rnorm = rsqrt(norm_sq); +#endif + for (CGU_CHANNEL ch = 0; ch < channels; ch++) vec[ch] *= rnorm; + } + } + + for (CGU_CHANNEL ch = 0; ch < channels; ch++) axis[ch] = vec[ch]; +} + +void icmp_block_pca_axis(CGV_IMAGE axis[4], CGV_IMAGE dc[4], CGV_IMAGE image_src[64], CGV_MASK mask, CGU_INT channels3or4) +{ + uniform __constant CGV_ITTERATIONS powerIterations = 8; // 4 not enough for HQ + + CGV_IMAGE covar[10]; + icmp_compute_covar_dc_masked(covar, dc, image_src, mask, channels3or4); + + CGV_IMAGE inv_var = 1.0 / (256 * 256); + for (CGU_INT k = 0; k < 10; k++) + { + covar[k] *= inv_var; + } + + CGV_IMAGE eps = sq_image(0.001F); + covar[0] += eps; + covar[4] += eps; + covar[7] += eps; + covar[9] += eps; + + icmp_compute_axis(axis, covar, powerIterations, channels3or4); +} + +CGV_IMAGE minImage(CGV_IMAGE a, CGV_IMAGE b) { return a < b ? a : b; } +CGV_IMAGE maxImage(CGV_IMAGE a, CGV_IMAGE b) { return a > b ? a : b; } + + +void icmp_block_segment_core(CGV_IMAGE epo_code[], CGV_IMAGE image_src[64], CGV_MASK mask, CGU_INT channels3or4) +{ + CGV_IMAGE axis[4]; + CGV_IMAGE dc[4]; + icmp_block_pca_axis(axis, dc, image_src, mask, channels3or4); + + CGV_IMAGE ext[2]; + ext[0] = +1e32; + ext[1] = -1e32; + + // find min/max + CGV_MASK mask_shifted = mask << 1; + for (CGU_INT k = 0; k < 16; k++) + { + mask_shifted >>= 1; + if ((mask_shifted & 1) == 0) continue; + + CGV_IMAGE dot = 0; + for (CGU_INT ch = 0; ch < channels3or4; ch++) + dot += axis[ch] * (image_src[16 * ch + k] - dc[ch]); + + ext[0] = minImage(ext[0], dot); + ext[1] = maxImage(ext[1], dot); + } + + // create some distance if the endpoints collapse + if (ext[1] - ext[0] < 1.0f) + { + ext[0] -= 0.5f; + ext[1] += 0.5f; + } + + for (CGU_INT i = 0; i < 2; i++) + for (CGU_INT ch = 0; ch < channels3or4; ch++) + { + epo_code[4 * i + ch] = ext[i] * axis[ch] + dc[ch]; + } +} + +INLINE CGV_IMAGE clampf(CGV_IMAGE v, CGV_IMAGE a, CGV_IMAGE b) +{ + if (v < a) + return a; + else + if (v > b) + return b; + return v; +} + + +void icmp_get_block_endpoints(CGV_IMAGE block_endpoints[], CGV_IMAGE image_src[64], CGV_MASK mask, CGU_CHANNEL channels3or4) +{ + icmp_block_segment_core(block_endpoints, image_src, mask, channels3or4); + + for (CGU_INT i = 0; i < 2; i++) + for (CGU_INT ch = 0; ch < channels3or4; ch++) + { + block_endpoints[4 * i + ch] = clampf(block_endpoints[4 * i + ch], 0.0f, 255.0f); + } +} + +void icmp_ep_quant0367_2(CGV_EPOCODE qep[], CGV_IMAGE ep[], CGU_INT blockMode, CGU_INT channels) +{ + CGU_INT bits = 7; + if (blockMode == 0) bits = 4; + if (blockMode == 7) bits = 5; + + CGU_INT levels = 1 << bits; + CGU_INT levels2 = levels * 2 - 1; + + for (CGU_INT i = 0; i < 2; i++) + { + CGV_EPOCODE qep_b[8]; + + for (CGU_INT b = 0; b < 2; b++) + for (CGU_INT p = 0; p < 4; p++) + { + CGV_EPOCODE v = (CGV_TYPEINT)((ep[i * 4 + p] / 255.0f*levels2 - b) / 2.0f + 0.5f) * 2 + b; + qep_b[b * 4 + p] = clampEPO(v, b, levels2 - 1 + b); + } + + CGV_IMAGE ep_b[8]; + for (CGU_INT j = 0; j < 8; j++) + ep_b[j] = qep_b[j]; + + if (blockMode == 0) + for (CGU_INT j = 0; j < 8; j++) + ep_b[j] = expandEPObits(qep_b[j], 5); + + CGV_ERROR err0 = 0.0f; + CGV_ERROR err1 = 0.0f; + for (CGU_INT ch = 0; ch < channels; ch++) + { + err0 += sq_image(ep[i * 4 + ch] - ep_b[0 + ch]); + err1 += sq_image(ep[i * 4 + ch] - ep_b[4 + ch]); + } + + for (CGU_INT p = 0; p < 4; p++) + qep[i * 4 + p] = (err0 < err1) ? qep_b[0 + p] : qep_b[4 + p]; + } +} + +void icmp_ep_quant245_2(CGV_EPOCODE qep[], CGV_IMAGE ep[], CGU_INT mode) +{ + CGU_INT bits = 5; + if (mode == 5) bits = 7; + CGU_INT levels = 1 << bits; + + for (CGU_INT i = 0; i < 8; i++) + { + CGV_EPOCODE v = ((CGV_TYPEINT)(ep[i] / 255.0f*(levels - 1) + 0.5)); + qep[i] = clampEPO(v, 0, levels - 1); + } +} + +void icmp_ep_quant1_2(CGV_EPOCODE qep[], CGV_IMAGE ep[], CGU_INT mode) +{ + CGV_EPOCODE qep_b[16]; + + for (CGU_INT b = 0; b < 2; b++) + for (CGU_INT i = 0; i < 8; i++) + { + CGV_EPOCODE v = ((CGV_TYPEINT)((ep[i] / 255.0f*127.0f - b) / 2 + 0.5)) * 2 + b; + qep_b[b * 8 + i] = clampEPO(v, b, 126 + b); + } + + // dequant + CGV_IMAGE ep_b[16]; + for (CGU_INT k = 0; k < 16; k++) + ep_b[k] = expandEPObits(qep_b[k], 7); + + CGV_ERROR err0 = 0.0f; + CGV_ERROR err1 = 0.0f; + for (CGU_INT j = 0; j < 2; j++) + for (CGU_INT p = 0; p < 3; p++) + { + err0 += sq_image(ep[j * 4 + p] - ep_b[0 + j * 4 + p]); + err1 += sq_image(ep[j * 4 + p] - ep_b[8 + j * 4 + p]); + } + + for (CGU_INT i = 0; i < 8; i++) + qep[i] = (err0 < err1) ? qep_b[0 + i] : qep_b[8 + i]; + +} + +void icmp_ep_quant2_2(CGV_EPOCODE qep[], CGV_IMAGE ep[], CGU_INT blockMode, CGU_INT channels3or4) +{ + //assert(mode <= 7); + CMP_STATIC uniform __constant CGV_SUBSETS SubSetTable[] = { 3,2,3,2,1,1,1,2 }; +#ifndef ASPM_GPU + uniform CMP_CONSTANT +#endif + CGV_SUBSETS maxSubSets = SubSetTable[blockMode]; + + if (blockMode == 0 || blockMode == 3 || blockMode == 6 || blockMode == 7) + { + for (CGU_INT i = 0; i < maxSubSets; i++) + icmp_ep_quant0367_2(&qep[i * 8], &ep[i * 8], blockMode, channels3or4); + } + else + if (blockMode == 1) + { + for (CGU_INT i = 0; i < maxSubSets; i++) + icmp_ep_quant1_2(&qep[i * 8], &ep[i * 8], blockMode); + } + else + if (blockMode == 2 || blockMode == 4 || blockMode == 5) + { + for (CGU_INT i = 0; i < maxSubSets; i++) + icmp_ep_quant245_2(&qep[i * 8], &ep[i * 8], blockMode); + } + // else + // assert(false); + +} + +void icmp_ep_dequant2(CGV_IMAGE ep[], CGV_EPOCODE qep[], CGU_INT blockMode) +{ + //assert(mode <= 7); + CMP_STATIC uniform __constant CGV_SUBSETS subSetTable[] = { 3,2,3,2,1,1,1,2 }; +#ifndef ASPM_GPU + uniform CMP_CONSTANT +#endif + CGV_SUBSETS maxSubSets = subSetTable[blockMode]; + + // mode 3, 6 are 8-bit + if (blockMode == 3 || blockMode == 6) + { + for (CGU_INT i = 0; i < 8 * maxSubSets; i++) + ep[i] = qep[i]; + } + else + if (blockMode == 1 || blockMode == 5) + { + for (CGU_INT i = 0; i < 8 * maxSubSets; i++) + ep[i] = expandEPObits(qep[i], 7); + } + else + if (blockMode == 0 || blockMode == 2 || blockMode == 4) + { + for (CGU_INT i = 0; i < 8 * maxSubSets; i++) + ep[i] = expandEPObits(qep[i], 5); + } + else + if (blockMode == 7) + { + for (CGU_INT i = 0; i < 8 * maxSubSets; i++) + ep[i] = expandEPObits(qep[i], 6); + } + //else + // assert(false); +} + +void icmp_GetQuantizedEpoCode(CGV_EPOCODE epo_code_out[], CGV_IMAGE block_endpoints[], CGU_INT blockMode, CGU_CHANNEL channels3or4) +{ + icmp_ep_quant2_2(epo_code_out, block_endpoints, blockMode, channels3or4); + icmp_ep_dequant2(block_endpoints, epo_code_out, blockMode); +} + +void icmp_ep_quant_dequant_mode4(CGV_EPOCODE qep[], CGV_IMAGE ep[]) +{ + icmp_ep_quant2_2(qep, ep, 4, 3); + icmp_ep_dequant2(ep, qep, 4); +} + +/////////////////////////// +// pixel quantization +//======================================== +// Modified Intel Texture Compression Code +//======================================== + +INLINE uniform __constant CGV_RAMP* uniform icmp_GetRamp(CGU_INT bits) +{ + //assert(bits>=2 && bits<=4); // invalid bit size + + CMP_STATIC uniform __constant CGV_RAMP unquant_table_2bits[] = { 0, 21, 43, 64 }; + CMP_STATIC uniform __constant CGV_RAMP unquant_table_3bits[] = { 0, 9, 18, 27, 37, 46, 55, 64 }; + CMP_STATIC uniform __constant CGV_RAMP unquant_table_4bits[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 }; + + uniform __constant CGV_RAMP* uniform unquant_tables[] = { unquant_table_2bits, unquant_table_3bits, unquant_table_4bits }; + + return unquant_tables[bits - 2]; +} + +#ifdef USE_VARYING +INLINE CGV_IMAGE gather_image(varying CGV_IMAGE* uniform ptr, CGV_SHIFT32 idx) +{ + return ptr[idx]; // (perf warning expected) +} +#endif + +INLINE CGV_RAMP gather_ramp( +#ifdef ASPM_GPU + CMP_CONSTANT CGV_RAMP* ptr, +#else + CMP_CONSTANT CGV_RAMP* CMP_CONSTANT uniform ptr, +#endif + CGV_INDEX idx) +{ + return ptr[idx]; // (perf warning expected) +} + +CGV_ERROR icmp_GetQuantizeIndex( + CGV_INDEXPACKED index_packed_out[2], + CGV_INDEX index_out[MAX_SUBSET_SIZE], + CGV_IMAGE image_src[64], + CGU_INT bits, + CGV_IMAGE image_block[], + CGV_SHIFT32 pattern, + CGU_CHANNEL channels3or4) +{ + CGV_ERROR total_err = 0; + uniform __constant CGV_RAMP* uniform Ramp = icmp_GetRamp(bits); + CGV_LEVELS levels = 1 << bits; + + // 64-bit color_qendpoint: 5% overhead in this function + for (CGU_INT k = 0; k < 2; k++) index_packed_out[k] = 0; + + CGV_SHIFT32 pattern_shifted = pattern; + for (CGU_INT k = 0; k < 16; k++) + { + CGV_SHIFT32 j = pattern_shifted & 3; + pattern_shifted >>= 2; + + CGV_IMAGE proj = 0; + CGV_IMAGE div = 0; + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) + { +#ifdef USE_VARYING + CGV_IMAGE ep_a = gather_image(image_block, 8 * j + 0 + ch); + CGV_IMAGE ep_b = gather_image(image_block, 8 * j + 4 + ch); +#else + CGV_IMAGE ep_a = image_block[8 * j + 0 + ch]; + CGV_IMAGE ep_b = image_block[8 * j + 4 + ch]; +#endif + proj += (image_src[k + ch * 16] - ep_a)*(ep_b - ep_a); + div += sq_image(ep_b - ep_a); + } + + proj /= div; + + CGV_INDEX index_q1 = (CGV_INDEX)(proj*levels + 0.5); + index_q1 = clampIndex(index_q1, 1, levels - 1); + + CGV_ERROR err0 = 0; + CGV_ERROR err1 = 0; + CGV_RAMP ramp0 = gather_ramp(Ramp, index_q1 - 1); + CGV_RAMP ramp1 = gather_ramp(Ramp, index_q1); + + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) + { +#ifdef USE_VARYING + CGV_IMAGE ep_a = gather_image(image_block, 8 * j + 0 + ch); + CGV_IMAGE ep_b = gather_image(image_block, 8 * j + 4 + ch); +#else + CGV_IMAGE ep_a = image_block[8 * j + 0 + ch]; + CGV_IMAGE ep_b = image_block[8 * j + 4 + ch]; +#endif + CGV_IMAGE dec_v0 = (CGV_TYPEINT)(((64 - ramp0)*ep_a + ramp0 * ep_b + 32) / 64); + CGV_IMAGE dec_v1 = (CGV_TYPEINT)(((64 - ramp1)*ep_a + ramp1 * ep_b + 32) / 64); + err0 += sq_image(dec_v0 - image_src[k + ch * 16]); + err1 += sq_image(dec_v1 - image_src[k + ch * 16]); + } + + CGV_ERROR best_err = err1; + CGV_INDEX best_index = index_q1; + if (err0 < err1) + { + best_err = err0; + best_index = index_q1 - 1; + } + + index_out[k] = best_index; + index_packed_out[k / 8] += ((CGV_INDEXPACKED)best_index) << 4 * (k % 8); + total_err += best_err; + } + + return total_err; +} + +/////////////////////////// +// LS endpoint refinement + +void icmp_opt_endpoints(CGV_IMAGE ep[], CGV_IMAGE image_src[64], CGU_INT bits, CGV_INDEXPACKED color_qendpoint[2], CGV_MASK mask, CGU_CHANNEL channels3or4) +{ + CGU_INT levels = 1 << bits; + + CGV_IMAGE Atb1[4] = { 0,0,0,0 }; + CGV_IMAGE sum_q = 0; + CGV_IMAGE sum_qq = 0; + CGV_IMAGE sum[5] = { 0,0,0,0,0 }; + + CGV_MASK mask_shifted = mask << 1; + for (CGU_INT k1 = 0; k1 < 2; k1++) + { + CGV_INDEXPACKED qbits_shifted = color_qendpoint[k1]; + for (CGU_INT k2 = 0; k2 < 8; k2++) + { + CGU_INT k = k1 * 8 + k2; + CGV_IMAGE q = (CGV_TYPEINT)(qbits_shifted & 15); + + qbits_shifted >>= 4; + + mask_shifted >>= 1; + if ((mask_shifted & 1) == 0) continue; + + CGV_LEVELS x = (levels - 1) - q; + CGV_LEVELS y = q; + + sum_q += q; + sum_qq += q * q; + + sum[4] += 1; + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) sum[ch] += image_src[k + ch * 16]; + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) Atb1[ch] += x * image_src[k + ch * 16]; + } + } + + CGV_IMAGE Atb2[4]; + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) + { + //sum[ch] = dc[ch]*16; + Atb2[ch] = (levels - 1)*sum[ch] - Atb1[ch]; + } + + CGV_IMAGE Cxx = sum[4] * sq_image(levels - 1) - 2 * (levels - 1)*sum_q + sum_qq; + CGV_IMAGE Cyy = sum_qq; + CGV_IMAGE Cxy = (levels - 1)*sum_q - sum_qq; + CGV_IMAGE scale = (levels - 1) / (Cxx*Cyy - Cxy * Cxy); + + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) + { + ep[0 + ch] = (Atb1[ch] * Cyy - Atb2[ch] * Cxy)*scale; + ep[4 + ch] = (Atb2[ch] * Cxx - Atb1[ch] * Cxy)*scale; + + //ep[0+ch] = clamp(ep[0+ch], 0, 255); + //ep[4+ch] = clamp(ep[4+ch], 0, 255); + } + + if (img_absf(Cxx*Cyy - Cxy * Cxy) < 0.001f) + { + // flatten + for (CGU_CHANNEL ch = 0; ch < channels3or4; ch++) + { + ep[0 + ch] = sum[ch] / sum[4]; + ep[4 + ch] = ep[0 + ch]; + } + } +} + +////////////////////////// +// parameter estimation + +void icmp_channel_quant_dequant2(CGV_EPOCODE qep[2], CGV_IMAGE ep[2], CGU_INT epbits) +{ + CGV_LEVELS elevels = (1 << epbits); + + for (CGU_INT i = 0; i < 2; i++) + { + CGV_EPOCODE v = ((CGV_EPOCODE)(ep[i] / 255.0f*(elevels - 1) + 0.5f)); + qep[i] = clampEPO(v, 0, elevels - 1); + ep[i] = expandEPObits(qep[i], epbits); + } +} + +void icmp_refineEndpoints(CGV_IMAGE ep[2], CGV_IMAGE block[16], CGU_INT bits, CGV_INDEXPACKED color_index[2]) +{ + CGU_INT levels = 1 << bits; + + CGV_IMAGE Atb1 = 0; + CGV_IMAGE sum_q = 0; + CGV_IMAGE sum_qq = 0; + CGV_IMAGE sum = 0; + + for (CGU_INT k1 = 0; k1 < 2; k1++) + { + CGV_INDEXPACKED qbits_shifted = color_index[k1]; + for (CGU_INT k2 = 0; k2 < 8; k2++) + { + CGU_INT k = k1 * 8 + k2; + CGV_IMAGE q = (CGV_TYPEINT)(qbits_shifted & 15); + qbits_shifted >>= 4; + + CGV_TYPEINT x = (levels - 1) - q; + CGV_TYPEINT y = q; + + sum_q += q; + sum_qq += q * q; + + sum += block[k]; + Atb1 += x * block[k]; + } + } + + CGV_IMAGE Atb2 = (levels - 1)*sum - Atb1; + + CGV_IMAGE Cxx = 16 * sq_image(levels - 1) - 2 * (levels - 1)*sum_q + sum_qq; + CGV_IMAGE Cyy = sum_qq; + CGV_IMAGE Cxy = (levels - 1)*sum_q - sum_qq; + CGV_IMAGE scale = (levels - 1) / (Cxx*Cyy - Cxy * Cxy); + + ep[0] = (Atb1*Cyy - Atb2 * Cxy)*scale; + ep[1] = (Atb2*Cxx - Atb1 * Cxy)*scale; + + ep[0] = clampf(ep[0], 0.0f, 255.0f); + ep[1] = clampf(ep[1], 0.0f, 255.0f); + + if (img_absf(Cxx*Cyy - Cxy * Cxy) < 0.001) + { + ep[0] = sum / 16; + ep[1] = ep[0]; + } +} + +CGV_ERROR icmp_channelQuantizeIndex(CGV_INDEXPACKED color_index[2], CGV_INDEX index[MAX_SUBSET_SIZE], CGV_IMAGE block[16], CGU_INT bits, CGV_IMAGE ep[]) +{ + uniform __constant CGV_RAMP* uniform Ramp = icmp_GetRamp(bits); + CGV_LEVELS levels = (1 << bits); + + color_index[0] = 0; + color_index[1] = 0; + + CGV_ERROR total_err = 0; + + for (CGU_INT k = 0; k < 16; k++) + { + CGV_IMAGE proj = (block[k] - ep[0]) / (ep[1] - ep[0] + 0.001f); + + CGV_INDEX q1 = (CGV_TYPEINT)(proj*levels + 0.5); + q1 = clampEPO(q1, 1, levels - 1); + + CGV_ERROR err0 = 0; + CGV_ERROR err1 = 0; + CGV_RAMP ramp0 = gather_ramp(Ramp, q1 - 1); + CGV_RAMP ramp1 = gather_ramp(Ramp, q1); + + CGV_IMAGE dec_v0 = (CGV_TYPEINT)(((64 - ramp0)*ep[0] + ramp0 * ep[1] + 32) / 64); + CGV_IMAGE dec_v1 = (CGV_TYPEINT)(((64 - ramp1)*ep[0] + ramp1 * ep[1] + 32) / 64); + err0 += sq_image(dec_v0 - block[k]); + err1 += sq_image(dec_v1 - block[k]); + + CGV_TYPEINT best_err = err1; + CGV_INDEX best_q = q1; + if (err0 < err1) + { + best_err = err0; + best_q = q1 - 1; + } + + index[k] = best_q; + color_index[k / 8] += ((CGV_INDEXPACKED)best_q) << 4 * (k % 8); + total_err += best_err; + } + + return total_err; +} + +CGV_ERROR icmp_optQuantizeIndex(BC7_EncodeState EncodeState[], CGV_INDEXPACKED color_index[2], CGV_INDEX index[MAX_SUBSET_SIZE], CGV_EPOCODE qep[2], CGV_IMAGE block[16], CGU_INT bits, CGU_INT epbits) +{ + CGV_IMAGE ep[2] = { 255,0 }; + + for (CGU_INT k = 0; k < 16; k++) + { + ep[0] = minImage(ep[0], block[k]); + ep[1] = maxImage(ep[1], block[k]); + } + + icmp_channel_quant_dequant2(qep, ep, epbits); + CGV_ERROR err = icmp_channelQuantizeIndex(color_index, index, block, bits, ep); + + // refine +#ifndef ASPM_GPU + uniform CMP_CONSTANT +#endif + CGV_ITTERATIONS refineIterations = EncodeState->refineIterations; + for (CGU_INT i = 0; i < refineIterations; i++) + { + icmp_refineEndpoints(ep, block, bits, color_index); + icmp_channel_quant_dequant2(qep, ep, epbits); + err = icmp_channelQuantizeIndex(color_index, index, block, bits, ep); + } + + return err; +} + + +INLINE CGV_SHIFT32 icmp_get_pattern2(CGV_PARTID part_id) +{ + CMP_STATIC uniform __constant CGV_SHIFT32 pattern_table[] = { + 0x50505050u, 0x40404040u, 0x54545454u, 0x54505040u, 0x50404000u, 0x55545450u, 0x55545040u, 0x54504000u, + 0x50400000u, 0x55555450u, 0x55544000u, 0x54400000u, 0x55555440u, 0x55550000u, 0x55555500u, 0x55000000u, + 0x55150100u, 0x00004054u, 0x15010000u, 0x00405054u, 0x00004050u, 0x15050100u, 0x05010000u, 0x40505054u, + 0x00404050u, 0x05010100u, 0x14141414u, 0x05141450u, 0x01155440u, 0x00555500u, 0x15014054u, 0x05414150u, + 0x44444444u, 0x55005500u, 0x11441144u, 0x05055050u, 0x05500550u, 0x11114444u, 0x41144114u, 0x44111144u, + 0x15055054u, 0x01055040u, 0x05041050u, 0x05455150u, 0x14414114u, 0x50050550u, 0x41411414u, 0x00141400u, + 0x00041504u, 0x00105410u, 0x10541000u, 0x04150400u, 0x50410514u, 0x41051450u, 0x05415014u, 0x14054150u, + 0x41050514u, 0x41505014u, 0x40011554u, 0x54150140u, 0x50505500u, 0x00555050u, 0x15151010u, 0x54540404u, + 0xAA685050u, 0x6A5A5040u, 0x5A5A4200u, 0x5450A0A8u, 0xA5A50000u, 0xA0A05050u, 0x5555A0A0u, 0x5A5A5050u, + 0xAA550000u, 0xAA555500u, 0xAAAA5500u, 0x90909090u, 0x94949494u, 0xA4A4A4A4u, 0xA9A59450u, 0x2A0A4250u, + 0xA5945040u, 0x0A425054u, 0xA5A5A500u, 0x55A0A0A0u, 0xA8A85454u, 0x6A6A4040u, 0xA4A45000u, 0x1A1A0500u, + 0x0050A4A4u, 0xAAA59090u, 0x14696914u, 0x69691400u, 0xA08585A0u, 0xAA821414u, 0x50A4A450u, 0x6A5A0200u, + 0xA9A58000u, 0x5090A0A8u, 0xA8A09050u, 0x24242424u, 0x00AA5500u, 0x24924924u, 0x24499224u, 0x50A50A50u, + 0x500AA550u, 0xAAAA4444u, 0x66660000u, 0xA5A0A5A0u, 0x50A050A0u, 0x69286928u, 0x44AAAA44u, 0x66666600u, + 0xAA444444u, 0x54A854A8u, 0x95809580u, 0x96969600u, 0xA85454A8u, 0x80959580u, 0xAA141414u, 0x96960000u, + 0xAAAA1414u, 0xA05050A0u, 0xA0A5A5A0u, 0x96000000u, 0x40804080u, 0xA9A8A9A8u, 0xAAAAAA44u, 0x2A4A5254u + }; + + return gather_uint32(pattern_table, part_id); +} + +CGV_IMAGE icmp_get_pca_bound(CGV_IMAGE covar[10], CGU_CHANNEL channels) +{ + uniform __constant CGV_TYPEINT powerIterations = 4; // quite approximative, but enough for bounding + + CGV_IMAGE inv_var = 1.0 / (256 * 256); + for (CGU_INT k = 0; k < 10; k++) + { + covar[k] *= inv_var; + } + + CGV_IMAGE eps = sq_image(0.001); + covar[0] += eps; + covar[4] += eps; + covar[7] += eps; + + CGV_IMAGE axis[4]; + icmp_compute_axis(axis, covar, powerIterations, channels); + + CGV_IMAGE vec[4]; + if (channels == 3) icmp_ssymv3(vec, covar, axis); + if (channels == 4) icmp_ssymv4_2(vec, covar, axis); + + CGV_IMAGE sq_sum = 0.0f; + for (CGU_INT p = 0; p < channels; p++) sq_sum += sq_image(vec[p]); + CGV_IMAGE lambda = sqrt(sq_sum); + + CGV_IMAGE bound = covar[0] + covar[4] + covar[7]; + if (channels == 4) bound += covar[9]; + bound -= lambda; + bound = maxImage(bound, 0.0f); + + return bound; +} + +CGV_IMAGE icmp_block_pca_bound_split2(CGV_IMAGE image_src[64], CGV_MASK mask, CGV_IMAGE full_stats[15], CGU_CHANNEL channels) +{ + CGV_IMAGE stats[15]; + icmp_compute_stats_masked(stats, image_src, mask, channels); + + CGV_IMAGE covar1[10]; + icmp_covar_from_stats(covar1, stats, channels); + + for (CGU_INT i = 0; i < 15; i++) + stats[i] = full_stats[i] - stats[i]; + + CGV_IMAGE covar2[10]; + icmp_covar_from_stats(covar2, stats, channels); + + CGV_IMAGE bound = 0.0f; + bound += icmp_get_pca_bound(covar1, channels); + bound += icmp_get_pca_bound(covar2, channels); + + return sqrt(bound) * 256; +} + + +#ifdef USE_VARYING +INLINE void scatter_partid(varying CGV_PARTID* uniform ptr, CGV_TYPEINT idx, CGV_PARTID value) +{ + ptr[idx] = value; // (perf warning expected) +} +#endif + +void icmp_sort_partlist(CGV_PARTID list[], CGU_INT length, CGU_INT partial_count) +{ + for (CGU_INT k = 0; k < partial_count; k++) + { + CGV_TYPEINT best_idx = k; + CGV_PARTID best_value = list[k]; + for (CGU_INT i = k + 1; i < length; i++) + { + if (best_value > list[i]) + { + best_value = list[i]; + best_idx = i; + } + } + + // swap +#ifdef USE_VARYING + scatter_partid(list, best_idx, list[k]); +#else + list[best_idx] = list[k]; +#endif + list[k] = best_value; + } +} + +INLINE void copy_epocode(CGV_EPOCODE u[], CGV_EPOCODE v[], CGU_INT n) +{ + for (CGU_INT i = 0; i < n; i++) + { + u[i] = v[i]; + } +} + + +INLINE void copy_indexpacked(CGV_INDEXPACKED u[], CGV_INDEXPACKED v[], CGU_INT n) +{ + for (CGU_INT i = 0; i < n; i++) + { + u[i] = v[i]; + } +} + + +void icmp_enc_mode4_candidate( + BC7_EncodeState EncodeState[], + cmp_mode_parameters best_candidate[], + CGV_ERROR best_err[], + CGU_INT rotated_channel, + CGU_INT idxMode) +{ + CGU_INT bits = 2; + CGU_INT abits = 3; + CGU_INT aepbits = 6; + + if (idxMode == 1) + { + bits = 3; + abits = 2; + } + + CGV_IMAGE src_block[48]; + for (CGU_INT k = 0; k < 16; k++) + { + for (CGU_INT p = 0; p < 3; p++) + src_block[k + p * 16] = EncodeState->image_src[k + p * 16]; + + if (rotated_channel < 3) + { + // apply channel rotation + if (EncodeState->channels == 4) src_block[k + rotated_channel * 16] = EncodeState->image_src[k + 3 * 16]; + if (EncodeState->channels == 3) src_block[k + rotated_channel * 16] = 255; + } + } + + CGV_IMAGE block_endpoints[8]; + CGV_INDEXPACKED color_index[2]; + CGV_INDEX c_index[MAX_SUBSET_SIZE]; + CGV_EPOCODE color_qendpoint[8]; + + icmp_get_block_endpoints(block_endpoints, src_block, -1, 3); + icmp_ep_quant_dequant_mode4(color_qendpoint, block_endpoints); + CGV_ERROR err = icmp_GetQuantizeIndex(color_index, c_index, src_block, bits, block_endpoints, 0, 3); + + // refine + CGU_INT refineIterations = EncodeState->refineIterations; + for (CGU_INT i = 0; i < refineIterations; i++) + { + icmp_opt_endpoints(block_endpoints, src_block, bits, color_index, -1, 3); + icmp_ep_quant_dequant_mode4(color_qendpoint, block_endpoints); + err = icmp_GetQuantizeIndex(color_index, c_index, src_block, bits, block_endpoints, 0, 3); + } + + // encoding selected channel + CGV_EPOCODE alpha_qendpoint[2]; + CGV_INDEXPACKED alpha_index[2]; + CGV_INDEX a_index[MAX_SUBSET_SIZE]; + err += icmp_optQuantizeIndex(EncodeState, alpha_index, a_index, alpha_qendpoint, &EncodeState->image_src[rotated_channel * 16], abits, aepbits); + + if (err < *best_err) + { + copy_epocode(best_candidate->color_qendpoint, color_qendpoint, 8); + copy_epocode(best_candidate->alpha_qendpoint, alpha_qendpoint, 2); + copy_indexpacked(best_candidate->best_color_index, color_index, 2); + copy_indexpacked(best_candidate->best_alpha_index, alpha_index, 2); + best_candidate->rotated_channel = rotated_channel; + best_candidate->idxMode = idxMode; + *best_err = err; + } +} + +void icmp_mode5_candidate( + BC7_EncodeState EncodeState[], + cmp_mode_parameters best_candidate[], + CGV_ERROR best_err[], + CGU_INT rotated_channel) +{ + CGU_INT bits = 2; + CGU_INT abits = 2; + CGU_INT aepbits = 8; + + CGV_IMAGE block[48]; + for (CGU_INT k = 0; k < 16; k++) + { + for (CGU_INT p = 0; p < 3; p++) + block[k + p * 16] = EncodeState->image_src[k + p * 16]; + + if (rotated_channel < 3) + { + // apply channel rotation + if (EncodeState->channels == 4) block[k + rotated_channel * 16] = EncodeState->image_src[k + 3 * 16]; + if (EncodeState->channels == 3) block[k + rotated_channel * 16] = 255; + } + } + + CGV_IMAGE block_endpoints[8]; + CGV_EPOCODE color_qendpoint[8]; + CGV_INDEXPACKED color_index[2]; + CGV_INDEX c_index[MAX_SUBSET_SIZE]; + + icmp_get_block_endpoints(block_endpoints, block, -1, 3); + icmp_GetQuantizedEpoCode(color_qendpoint, block_endpoints, 5, 3); + CGV_ERROR err = icmp_GetQuantizeIndex(color_index, c_index, block, bits, block_endpoints, 0, 3); + + // refine + CGU_INT refineIterations = EncodeState->refineIterations; + for (CGU_INT i = 0; i < refineIterations; i++) + { + icmp_opt_endpoints(block_endpoints, block, bits, color_index, -1, 3); + icmp_GetQuantizedEpoCode(color_qendpoint, block_endpoints, 5, 3); + err = icmp_GetQuantizeIndex(color_index, c_index, block, bits, block_endpoints, 0, 3); + } + + // encoding selected channel + CGV_EPOCODE alpha_qendpoint[2]; + CGV_INDEXPACKED alpha_index[2]; + CGV_INDEX a_index[MAX_SUBSET_SIZE]; + err += icmp_optQuantizeIndex(EncodeState, alpha_index, a_index, alpha_qendpoint, &EncodeState->image_src[rotated_channel * 16], abits, aepbits); + + if (err < *best_err) + { + + icmp_swap_epocode(best_candidate->color_qendpoint, color_qendpoint, 8); + icmp_swap_indexpacked(best_candidate->best_color_index, color_index, 2); + icmp_swap_epocode(best_candidate->alpha_qendpoint, alpha_qendpoint, 2); + icmp_swap_indexpacked(best_candidate->best_alpha_index, alpha_index, 2); + best_candidate->rotated_channel = rotated_channel; + *best_err = err; + } +} + + +// =============== Mode Compression + +CGV_ERROR icmp_enc_mode01237_part_fast( + CGV_EPOCODE qep[24], + CGV_INDEXPACKED color_index[2], + CGV_INDEX index[MAX_SUBSET_SIZE], + CGV_IMAGE image_src[64], + CGV_PARTID part_id, + CGU_INT blockMode) +{ + CGV_SHIFT32 pattern = icmp_get_pattern2(part_id); + CGU_INT bits = 2; if (blockMode == 0 || blockMode == 1) bits = 3; + CGU_INT maxSubSets = 2; if (blockMode == 0 || blockMode == 2) maxSubSets = 3; + CGU_CHANNEL channels = 3; if (blockMode == 7) channels = 4; + + CGV_IMAGE block_endpoints[24]; + for (CGU_INT subset = 0; subset < maxSubSets; subset++) + { + CGV_MASK partition_mask = icmp_get_partition_mask(part_id, subset); + icmp_get_block_endpoints(&block_endpoints[subset * 8], image_src, partition_mask, channels); + } + + icmp_GetQuantizedEpoCode(qep, block_endpoints, blockMode, channels); + CGV_ERROR total_err = icmp_GetQuantizeIndex(color_index, index, image_src, bits, block_endpoints, pattern, channels); + + return total_err; +} + +void icmp_enc_mode01237(BC7_EncodeState EncodeState[], CGU_INT blockMode, CGV_PARTID part_list[], CGU_INT part_count) +{ + if (part_count == 0) return; + CGU_INT bits = 2; if (blockMode == 0 || blockMode == 1) bits = 3; + CGU_INT maxSubSets = 2; if (blockMode == 0 || blockMode == 2) maxSubSets = 3; + CGU_CHANNEL channels = 3; if (blockMode == 7) channels = 4; + + CGV_EPOCODE best_qep[24]; + CGV_INDEXPACKED best_endpoint[2]; + CGV_PARTID best_part_id = -1; + CGV_ERROR best_err = 1e99; + + for (CGU_INT part = 0; part < part_count; part++) + { + CGV_PARTID part_id = part_list[part] & 63; + if (maxSubSets == 3) part_id += 64; + + CGV_EPOCODE qep[24]; + CGV_INDEXPACKED color_index[2]; + CGV_INDEX index[MAX_SUBSET_SIZE]; + CGV_ERROR err = icmp_enc_mode01237_part_fast(qep, color_index, index, EncodeState->image_src, part_id, blockMode); + + if (err < best_err) + { + for (CGU_INT subset = 0; subset < 8 * maxSubSets; subset++) best_qep[subset] = qep[subset]; + for (CGU_INT k = 0; k < 2; k++) best_endpoint[k] = color_index[k]; + best_part_id = part_id; + best_err = err; + } + } + + // refine + CGU_INT refineIterations = EncodeState->refineIterations; + for (CGU_INT _i = 0; _i < refineIterations; _i++) + { + CGV_IMAGE ep[24]; + for (CGU_INT subset = 0; subset < maxSubSets; subset++) + { + CGV_SHIFT32 partition_mask = icmp_get_partition_mask(best_part_id, subset); + icmp_opt_endpoints(&ep[subset * 8], EncodeState->image_src, bits, best_endpoint, partition_mask, channels); + } + + CGV_EPOCODE qep[24]; + CGV_INDEXPACKED color_index[2]; + CGV_INDEX index[MAX_SUBSET_SIZE]; + + icmp_GetQuantizedEpoCode(qep, ep, blockMode, channels); + + CGV_SHIFT32 pattern = icmp_get_pattern2(best_part_id); + CGV_ERROR err = icmp_GetQuantizeIndex(color_index, index, EncodeState->image_src, bits, ep, pattern, channels); + + if (err < best_err) + { + for (CGU_INT subset = 0; subset < 8 * maxSubSets; subset++) best_qep[subset] = qep[subset]; + for (CGU_INT k = 0; k < 2; k++) best_endpoint[k] = color_index[k]; + best_err = err; + } + } + + if (blockMode != 7) best_err += EncodeState->opaque_err; // take into account alpha channel + + if (best_err < EncodeState->best_err) + { + EncodeState->best_err = best_err; + icmp_encode_mode01237(EncodeState->best_cmp_out, best_qep, best_endpoint, best_part_id, blockMode); + } +} + +void icmp_mode5(BC7_EncodeState EncodeState[]) +{ + cmp_mode_parameters best_candidate; + CGV_ERROR best_err = EncodeState->best_err; + +#ifdef ASPM_GPU + cmp_memsetBC7((CGV_BYTE *)&best_candidate, 0, sizeof(cmp_mode_parameters)); +#else + memset(&best_candidate, 0, sizeof(cmp_mode_parameters)); +#endif + + for (CGU_CHANNEL ch = 0; ch < EncodeState->channels; ch++) + { + icmp_mode5_candidate(EncodeState, &best_candidate, &best_err, ch); + } + + if (best_err < EncodeState->best_err) + { + EncodeState->best_err = best_err; + EncodeState->cmp_isout16Bytes = FALSE; + icmp_Encode_mode5(EncodeState->best_cmp_out, &best_candidate); + } +} + +void icmp_mode6(BC7_EncodeState EncodeState[]) +{ + CGV_IMAGE block_endpoints[8]; + icmp_get_block_endpoints(block_endpoints, EncodeState->image_src, -1, 4); + + CGV_EPOCODE epo_code[8]; + icmp_GetQuantizedEpoCode(epo_code, block_endpoints, 6, 4); + + CGV_INDEXPACKED color_index[2]; + CGV_INDEX index[MAX_SUBSET_SIZE]; + CGV_ERROR err = icmp_GetQuantizeIndex(color_index, index, EncodeState->image_src, 4, block_endpoints, 0, 4); + + // refine + CGU_INT refineIterations = EncodeState->refineIterations; + for (CGU_INT i = 0; i < refineIterations; i++) + { + icmp_opt_endpoints(block_endpoints, EncodeState->image_src, 4, color_index, -1, 4); + icmp_GetQuantizedEpoCode(epo_code, block_endpoints, 6, EncodeState->channels); + err = icmp_GetQuantizeIndex(color_index, index, EncodeState->image_src, 4, block_endpoints, 0, 4); + } + + if (err < EncodeState->best_err) + { + EncodeState->best_err = err; + EncodeState->cmp_isout16Bytes = FALSE; + icmp_encode_mode6(EncodeState->best_cmp_out, epo_code, color_index); + } +} + +void icmp_mode02(BC7_EncodeState EncodeState[]) +{ + CGV_PARTID part_list[64]; + for (CGU_INT part = 0; part < 64; part++) + part_list[part] = part; + + if (EncodeState->validModeMask & 0x01) + icmp_enc_mode01237(EncodeState, 0, part_list, 16); + if (EncodeState->validModeMask & 0x04) + icmp_enc_mode01237(EncodeState, 2, part_list, 64); // usually not worth the time +} + +void icmp_mode7(BC7_EncodeState EncodeState[]) +{ + CGV_IMAGE full_stats[15]; + icmp_compute_stats_masked(full_stats, EncodeState->image_src, -1, EncodeState->channels); + + CGV_PARTID part_list[64]; + for (CGU_INT part = 0; part < 64; part++) + { + CGV_MASK partition_mask = icmp_get_partition_mask(part + 0, 0); + CGV_IMAGE bound12 = icmp_block_pca_bound_split2(EncodeState->image_src, partition_mask, full_stats, EncodeState->channels); + CGV_PARTID bound = (CGV_TYPEINT)(bound12); + part_list[part] = part + bound * 64; + } + + icmp_sort_partlist(part_list, 64, EncodeState->part_count); + icmp_enc_mode01237(EncodeState, 7, part_list, EncodeState->part_count); +} + +void icmp_mode13(BC7_EncodeState EncodeState[]) +{ + CGV_IMAGE full_stats[15]; + icmp_compute_stats_masked(full_stats, EncodeState->image_src, -1, 3); + + CGV_PARTID part_list[64]; + for (CGU_INT part = 0; part < 64; part++) + { + CGV_MASK partition_mask = icmp_get_partition_mask(part + 0, 0); + CGV_IMAGE bound12 = icmp_block_pca_bound_split2(EncodeState->image_src, partition_mask, full_stats, 3); + CGV_PARTID bound = (CGV_TYPEINT)(bound12); + part_list[part] = part + bound * 64; + } + + icmp_sort_partlist(part_list, 64, EncodeState->part_count); + + if (EncodeState->validModeMask & 0x02) + icmp_enc_mode01237(EncodeState, 1, part_list, EncodeState->part_count); + if (EncodeState->validModeMask & 0x08) + icmp_enc_mode01237(EncodeState, 3, part_list, EncodeState->part_count); +} + +void icmp_mode4(BC7_EncodeState EncodeState[]) +{ + cmp_mode_parameters best_candidate; + CGV_ERROR best_err = EncodeState->best_err; +#ifdef ASPM_GPU + cmp_memsetBC7((CGV_BYTE *)&best_candidate, 0, sizeof(cmp_mode_parameters)); +#else + memset(&best_candidate, 0, sizeof(cmp_mode_parameters)); +#endif + + for (CGU_CHANNEL rotated_channel = 0; rotated_channel < EncodeState->channels; rotated_channel++) + { + icmp_enc_mode4_candidate(EncodeState, &best_candidate, &best_err, rotated_channel, 0); + icmp_enc_mode4_candidate(EncodeState, &best_candidate, &best_err, rotated_channel, 1); + } + + // mode 4 + if (best_err < EncodeState->best_err) + { + EncodeState->best_err = best_err; + icmp_encode_mode4(EncodeState->best_cmp_out, &best_candidate); + } +} + +#endif +//===================================== COMPRESS CODE ============================================= + +bool notValidBlockForMode( + CGU_UINT32 blockMode, + CGU_BOOL blockNeedsAlpha, + CGU_BOOL blockAlphaZeroOne, + uniform CMP_GLOBAL BC7_Encode u_BC7Encode[]) +{ + // Do we need to skip alpha processing blocks + if((blockNeedsAlpha == FALSE) && (blockMode > 3)) + { + return TRUE; + } + + // Optional restriction for colour-only blocks so that they + // don't use modes that have combined colour+alpha - this + // avoids the possibility that the encoder might choose an + // alpha other than 1.0 (due to parity) and cause something to + // become accidentally slightly transparent (it's possible that + // when encoding 3-component texture applications will assume that + // the 4th component can safely be assumed to be 1.0 all the time) + if ((blockNeedsAlpha == FALSE) && + (u_BC7Encode->colourRestrict == TRUE) && + ((blockMode == 6)||(blockMode == 7))) // COMBINED_ALPHA + { + return TRUE; + } + + // Optional restriction for blocks with alpha to avoid issues with + // punch-through or thresholded alpha encoding + if((blockNeedsAlpha == TRUE) && + (u_BC7Encode->alphaRestrict == TRUE) && + (blockAlphaZeroOne == TRUE) && + ((blockMode == 6)||(blockMode == 7))) // COMBINED_ALPHA + { + return TRUE; + } + + return FALSE; +} + +void BC7_CompressBlock( + BC7_EncodeState EncodeState[], +uniform CMP_GLOBAL BC7_Encode u_BC7Encode[]) +{ + CGU_BOOL blockNeedsAlpha = FALSE; + CGU_BOOL blockAlphaZeroOne = FALSE; + + CGV_ERROR alpha_err = 0.0f; + CGV_IMAGE alpha_min = 255.0F; + + for (CGU_INT k=0; kimage_src[k+COMP_ALPHA*SOURCE_BLOCK_SIZE] < alpha_min) + alpha_min = EncodeState->image_src[k+COMP_ALPHA*SOURCE_BLOCK_SIZE]; + + alpha_err += sq_image( EncodeState->image_src[k+COMP_ALPHA*SOURCE_BLOCK_SIZE]-255.0F); + + if (blockAlphaZeroOne == FALSE) + { + if(( EncodeState->image_src[k+COMP_ALPHA*SOURCE_BLOCK_SIZE] == 255.0F) || + ( EncodeState->image_src[k+COMP_ALPHA*SOURCE_BLOCK_SIZE] == 0.0F)) + { + blockAlphaZeroOne = TRUE; + } + } + } + + if (alpha_min != 255.0F) + { + blockNeedsAlpha = TRUE; + } + + EncodeState->best_err = CMP_FLOAT_MAX; + EncodeState->opaque_err = alpha_err; + +#ifdef USE_ICMP + EncodeState->refineIterations = 4; + EncodeState->fastSkipTreshold = 4; + EncodeState->channels = 4; + EncodeState->part_count = 64; + EncodeState->cmp_isout16Bytes = FALSE; +#else + EncodeState->cmp_isout16Bytes = TRUE; +#endif + + // We change the order in which we visit the block modes to try to maximize the chance + // that we manage to early out as quickly as possible. + // This is a significant performance optimization for the lower quality modes where the + // exit threshold is higher, and also tends to improve quality (as the generally higher quality + // modes are now enumerated earlier, so the first encoding that passes the threshold will + // tend to pass by a greater margin than if we used a dumb ordering, and thus overall error will + // be improved) + CGU_INT blockModeOrder[NUM_BLOCK_TYPES] = {4, 6, 1, 3, 0, 2, 7, 5}; + + for (CGU_INT block=0; block < NUM_BLOCK_TYPES; block++) + { + CGU_INT blockMode = blockModeOrder[block]; + + if (u_BC7Encode->quality < BC7_qFAST_THRESHOLD) + { + if ( notValidBlockForMode(blockMode,blockNeedsAlpha,blockAlphaZeroOne,u_BC7Encode) ) + continue; + } + + CGU_INT Mode = 0x0001 << blockMode; + if (!(u_BC7Encode->validModeMask & Mode)) + continue; + + switch (blockMode) + { + // image processing with no alpha + case 0: + #ifdef USE_ICMP + icmp_mode02(EncodeState); + #else + Compress_mode01237(blockMode, EncodeState, u_BC7Encode); + #endif + break; + case 1: + #ifdef USE_ICMP + icmp_mode13(EncodeState); + #else + Compress_mode01237(blockMode, EncodeState, u_BC7Encode); + #endif + break; + case 2: + #ifdef USE_ICMP + icmp_mode13(EncodeState); + #else + Compress_mode01237(blockMode, EncodeState, u_BC7Encode); + #endif + break; + case 3: + #ifdef USE_ICMP + icmp_mode13(EncodeState); + #else + Compress_mode01237(blockMode, EncodeState, u_BC7Encode); + #endif + break; + // image processing with alpha + case 4: + #ifdef USE_ICMP + icmp_mode4(EncodeState); + #else + Compress_mode45(blockMode, EncodeState, u_BC7Encode); + #endif + break; + case 5: + #ifdef USE_ICMP + icmp_mode5(EncodeState); + #else + Compress_mode45(blockMode, EncodeState, u_BC7Encode); + #endif + break; + case 6: + #ifdef USE_ICMP + icmp_mode6(EncodeState); + #else + Compress_mode6( EncodeState, u_BC7Encode); + #endif + break; + case 7: + #ifdef USE_ICMP + icmp_mode7(EncodeState); + #else + Compress_mode01237(blockMode, EncodeState, u_BC7Encode); + #endif + break; + } + + // Early out if we found we can compress with error below the quality threshold + if( EncodeState->best_err <= u_BC7Encode->errorThreshold) + { + break; + } + } + +} + +//====================================== BC7_ENCODECLASS END ============================================= + +#ifndef ASPM_GPU + +INLINE void load_block_interleaved_rgba2(CGV_IMAGE image_src[64], uniform texture_surface* uniform src, CGUV_BLOCKWIDTH block_xx, CGU_INT block_yy) +{ + for (CGU_INT y=0; y<4; y++) + for (CGU_INT x=0; x<4; x++) + { + CGU_UINT32 * uniform src_ptr = (CGV_SHIFT32*)&src->ptr[(block_yy*4+y)*src->stride]; +#ifdef USE_VARYING + CGV_SHIFT32 rgba = gather_partid(src_ptr, block_xx*4+x); + image_src[16*0+y*4+x] = (CGV_FLOAT)((rgba>> 0)&255); + image_src[16*1+y*4+x] = (CGV_FLOAT)((rgba>> 8)&255); + image_src[16*2+y*4+x] = (CGV_FLOAT)((rgba>>16)&255); + image_src[16*3+y*4+x] = (CGV_FLOAT)((rgba>>24)&255); +#else + CGV_SHIFT32 rgba = src_ptr[block_xx*4+x]; + image_src[16*0+y*4+x] = (CGU_FLOAT)((rgba>> 0)&255); + image_src[16*1+y*4+x] = (CGU_FLOAT)((rgba>> 8)&255); + image_src[16*2+y*4+x] = (CGU_FLOAT)((rgba>>16)&255); + image_src[16*3+y*4+x] = (CGU_FLOAT)((rgba>>24)&255); +#endif + } +} + + +#if defined(CMP_USE_FOREACH_ASPM) || defined(USE_VARYING) +INLINE void scatter_uint2(CGU_UINT32 * ptr, CGUV_BLOCKWIDTH idx, CGV_SHIFT32 value) +{ + ptr[idx] = value; // (perf warning expected) +} +#endif + +INLINE void store_data_uint32(CGU_UINT8 dst[], CGU_INT width, CGUV_BLOCKWIDTH v_xx, CGU_INT yy, CGV_SHIFT32 data[], CGU_INT data_size) +{ + for (CGU_INT k=0; kimage_src,u_srcptr, block_x, block_y); + + BC7_CompressBlock(state, u_settings); + + if (state->cmp_isout16Bytes) + store_data_uint8(u_dst, u_srcptr->width, block_x, block_y, state->cmp_out, 16); + else + store_data_uint32(u_dst, u_srcptr->width, block_x, block_y, state->best_cmp_out, 4); + +} + + CMP_EXPORT void CompressBlockBC7_encode( uniform texture_surface src[], CGU_UINT8 dst[], uniform BC7_Encode settings[]) +{ + // bc7_isa(); ASPM_PRINT(("ASPM encode [%d,%d]\n",bc7_isa(),src->width,src->height)); + + for (CGU_INT u_yy = 0; u_yyheight/4; u_yy++) + #ifdef CMP_USE_FOREACH_ASPM + foreach (v_xx = 0 ... src->width/4) + { + #else + for (CGUV_BLOCKWIDTH v_xx = 0; v_xxwidth/4; v_xx++) + { + #endif + CompressBlockBC7_XY(src, v_xx, u_yy, dst, settings); + } +} + +#endif + +#ifndef ASPM_GPU +#ifndef ASPM +//======================= DECOMPRESS ========================================= +#ifndef USE_HIGH_PRECISION_INTERPOLATION_BC7 +CGU_UINT16 aWeight2[] = { 0, 21, 43, 64 }; +CGU_UINT16 aWeight3[] = { 0, 9, 18, 27, 37, 46, 55, 64 }; +CGU_UINT16 aWeight4[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 }; + +CGU_UINT8 interpolate(CGU_UINT8 e0, CGU_UINT8 e1, CGU_UINT8 index, CGU_UINT8 indexprecision) +{ + if (indexprecision == 2) + return (CGU_UINT8)(((64 - aWeight2[index])*CGU_UINT16(e0) + aWeight2[index] * CGU_UINT16(e1) + 32) >> 6); + else if (indexprecision == 3) + return (CGU_UINT8)(((64 - aWeight3[index])*CGU_UINT16(e0) + aWeight3[index] * CGU_UINT16(e1) + 32) >> 6); + else // indexprecision == 4 + return (CGU_UINT8)(((64 - aWeight4[index])*CGU_UINT16(e0) + aWeight4[index] * CGU_UINT16(e1) + 32) >> 6); +} +#endif + +void GetBC7Ramp(CGU_UINT32 endpoint[][MAX_DIMENSION_BIG], + CGU_FLOAT ramp[MAX_DIMENSION_BIG][(1<> componentBits[i]); + ep[1][i] += (CGU_UINT32)(ep[1][i] >> componentBits[i]); + + ep[0][i] = min8(255, max8(0,CMP_STATIC_CAST(CGU_UINT8,ep[0][i]))); + ep[1][i] = min8(255, max8(0,CMP_STATIC_CAST(CGU_UINT8,ep[1][i]))); + } + } + + // If this block type has no explicit alpha channel + // then make sure alpha is 1.0 for all points on the ramp + if(!componentBits[COMP_ALPHA]) + { + ep[0][COMP_ALPHA] = ep[1][COMP_ALPHA] = 255; + } + + CGU_UINT32 rampIndex = clusters[0]; + + rampIndex = (CGU_UINT32)(log((double)rampIndex) / log(2.0)); + + // Generate colours for the RGB ramp + for(i=0; i < clusters[0]; i++) + { +#ifdef USE_HIGH_PRECISION_INTERPOLATION_BC7 + ramp[COMP_RED][i] = (CGU_FLOAT)floor((ep[0][COMP_RED] * (1.0-rampLerpWeightsBC7[rampIndex][i])) + + (ep[1][COMP_RED] * rampLerpWeightsBC7[rampIndex][i]) + 0.5); + ramp[COMP_RED][i] = bc7_minf(255.0, bc7_maxf(0., ramp[COMP_RED][i])); + ramp[COMP_GREEN][i] = (CGU_FLOAT)floor((ep[0][COMP_GREEN] * (1.0-rampLerpWeightsBC7[rampIndex][i])) + + (ep[1][COMP_GREEN] * rampLerpWeightsBC7[rampIndex][i]) + 0.5); + ramp[COMP_GREEN][i] = bc7_minf(255.0, bc7_maxf(0., ramp[COMP_GREEN][i])); + ramp[COMP_BLUE][i] = (CGU_FLOAT)floor((ep[0][COMP_BLUE] * (1.0-rampLerpWeightsBC7[rampIndex][i])) + + (ep[1][COMP_BLUE] * rampLerpWeightsBC7[rampIndex][i]) + 0.5); + ramp[COMP_BLUE][i] = bc7_minf(255.0, bc7_maxf(0., ramp[COMP_BLUE][i])); +#else + ramp[COMP_RED][i] = interpolate(ep[0][COMP_RED], ep[1][COMP_RED], i, rampIndex); + ramp[COMP_GREEN][i] = interpolate(ep[0][COMP_GREEN], ep[1][COMP_GREEN], i, rampIndex); + ramp[COMP_BLUE][i] = interpolate(ep[0][COMP_BLUE], ep[1][COMP_BLUE], i, rampIndex); +#endif + } + + + rampIndex = clusters[1]; + rampIndex = (CGU_UINT32)(log((CGU_FLOAT)rampIndex) / log(2.0)); + + if(!componentBits[COMP_ALPHA]) + { + for(i=0; i < clusters[1]; i++) + { + ramp[COMP_ALPHA][i] = 255.; + } + } + else + { + + // Generate alphas + for(i=0; i < clusters[1]; i++) + { +#ifdef USE_HIGH_PRECISION_INTERPOLATION_BC7 + ramp[COMP_ALPHA][i] = (CGU_FLOAT)floor((ep[0][COMP_ALPHA] * (1.0-rampLerpWeightsBC7[rampIndex][i])) + + (ep[1][COMP_ALPHA] * rampLerpWeightsBC7[rampIndex][i]) + 0.5); + ramp[COMP_ALPHA][i] = bc7_minf(255.0, bc7_maxf(0., ramp[COMP_ALPHA][i])); +#else + ramp[COMP_ALPHA][i] = interpolate(ep[0][COMP_ALPHA], ep[1][COMP_ALPHA], i, rampIndex); +#endif + } + + } +} + +// +// Bit reader - reads one bit from a buffer at the current bit offset +// and increments the offset +// + +CGU_UINT32 ReadBit(const CGU_UINT8 base[],CGU_UINT32 &m_bitPosition) +{ + int byteLocation; + int remainder; + CGU_UINT32 bit = 0; + byteLocation = m_bitPosition/8; + remainder = m_bitPosition % 8; + + bit = base[byteLocation]; + bit >>= remainder; + bit &= 0x1; + // Increment bit position + m_bitPosition++; + return (bit); +} + +void DecompressDualIndexBlock( + CGU_UINT8 out[MAX_SUBSET_SIZE][MAX_DIMENSION_BIG], + const CGU_UINT8 in[COMPRESSED_BLOCK_SIZE], + CGU_UINT32 endpoint[2][MAX_DIMENSION_BIG], + CGU_UINT32 &m_bitPosition, + CGU_UINT32 m_rotation, + CGU_UINT32 m_blockMode, + CGU_UINT32 m_indexSwap, + CGU_UINT32 m_componentBits[MAX_DIMENSION_BIG]) +{ + CGU_UINT32 i, j, k; + CGU_FLOAT ramp[MAX_DIMENSION_BIG][1<(bti[m_blockMode].indexBits[i] - 1); k++) + { + blockIndices[i][j] |= (CGU_UINT32)ReadBit(in,m_bitPosition) << k; + } + } + else + { + for(k=0;k 7) + { + // Something really bad happened... + return; + } + + for (i = 0; i < bti[m_blockMode].rotationBits; i++) + { + m_rotation |= ReadBit(in, m_bitPosition) << i; + } + for (i = 0; i < bti[m_blockMode].indexModeBits; i++) + { + m_indexSwap |= ReadBit(in, m_bitPosition) << i; + } + + for (i = 0; i < bti[m_blockMode].partitionBits; i++) + { + m_partition |= ReadBit(in, m_bitPosition) << i; + } + + + + if (bti[m_blockMode].encodingType == NO_ALPHA) + { + m_componentBits[COMP_ALPHA] = 0; + m_componentBits[COMP_RED] = + m_componentBits[COMP_GREEN] = + m_componentBits[COMP_BLUE] = bti[m_blockMode].vectorBits / 3; + } + else if (bti[m_blockMode].encodingType == COMBINED_ALPHA) + { + m_componentBits[COMP_ALPHA] = + m_componentBits[COMP_RED] = + m_componentBits[COMP_GREEN] = + m_componentBits[COMP_BLUE] = bti[m_blockMode].vectorBits / 4; + } + else if (bti[m_blockMode].encodingType == SEPARATE_ALPHA) + { + m_componentBits[COMP_ALPHA] = bti[m_blockMode].scalarBits; + m_componentBits[COMP_RED] = + m_componentBits[COMP_GREEN] = + m_componentBits[COMP_BLUE] = bti[m_blockMode].vectorBits / 3; + } + + CGU_UINT32 subset, ep, component; + // Endpoints are stored in the following order RRRR GGGG BBBB (AAAA) (PPPP) + // i.e. components are packed together + // Loop over components + for (component = 0; component < MAX_DIMENSION_BIG; component++) + { + // loop over subsets + for (subset = 0; subset < (int)bti[m_blockMode].subsetCount; subset++) + { + // Loop over endpoints + for (ep = 0; ep < 2; ep++) + { + endpoint[subset][ep][component] = 0; + for (j = 0; j < m_componentBits[component]; j++) + { + endpoint[subset][ep][component] |= ReadBit(in, m_bitPosition) << j; + } + } + } + } + + + // Now get any parity bits + if (bti[m_blockMode].pBitType != NO_PBIT) + { + for (subset = 0; subset < (int)bti[m_blockMode].subsetCount; subset++) + { + CGU_UINT32 pBit[2]; + if (bti[m_blockMode].pBitType == ONE_PBIT) + { + pBit[0] = ReadBit(in, m_bitPosition); + pBit[1] = pBit[0]; + } + else if (bti[m_blockMode].pBitType == TWO_PBIT) + { + pBit[0] = ReadBit(in, m_bitPosition); + pBit[1] = ReadBit(in, m_bitPosition); + } + + for (component = 0; component < MAX_DIMENSION_BIG; component++) + { + if (m_componentBits[component]) + { + endpoint[subset][0][component] <<= 1; + endpoint[subset][1][component] <<= 1; + endpoint[subset][0][component] |= pBit[0]; + endpoint[subset][1][component] |= pBit[1]; + } + } + } + } + + if (bti[m_blockMode].pBitType != NO_PBIT) + { + // Now that we've unpacked the parity bits, update the component size information + // for the ramp generator + for (j = 0; j < MAX_DIMENSION_BIG; j++) + { + if (m_componentBits[j]) + { + m_componentBits[j] += 1; + } + } + } + + // If this block has two independent sets of indices then put it to that decoder + if (bti[m_blockMode].encodingType == SEPARATE_ALPHA) + { + DecompressDualIndexBlock(out, in, endpoint[0], m_bitPosition, m_rotation, m_blockMode, m_indexSwap, m_componentBits); + return; + } + + CGU_UINT32 fixup[MAX_SUBSETS] = { 0, 0, 0 }; + switch (bti[m_blockMode].subsetCount) + { + case 3: + fixup[1] = BC7_FIXUPINDICES_LOCAL[2][m_partition][1]; + fixup[2] = BC7_FIXUPINDICES_LOCAL[2][m_partition][2]; + break; + case 2: + fixup[1] = BC7_FIXUPINDICES_LOCAL[1][m_partition][1]; + break; + default: + break; + } + + //-------------------------------------------------------------------- + // New Code : Possible replacement for BC7_PARTITIONS for CPU code + //-------------------------------------------------------------------- + // Extract index bits + // for (i = 0; i < MAX_SUBSET_SIZE; i++) + // { + // CGV_UINT8 p = get_partition_subset(m_partition, bti[m_blockMode].subsetCount - 1, i); + // //CGU_UINT32 p = partitionTable[i]; + // blockIndices[i] = 0; + // CGU_UINT32 bitsToRead = bti[m_blockMode].indexBits[0]; + // + // // If this is a fixup index then set the implicit bit + // if (i == fixup[p]) + // { + // blockIndices[i] &= ~(1 << (bitsToRead - 1)); + // bitsToRead--; + // } + // + // for (j = 0; j < bitsToRead; j++) + // { + // blockIndices[i] |= ReadBit(in, m_bitPosition) << j; + // } + // } + CGU_BYTE *partitionTable = (CGU_BYTE*)BC7_PARTITIONS[bti[m_blockMode].subsetCount-1][m_partition]; + + // Extract index bits + for(i=0; i < MAX_SUBSET_SIZE; i++) + { + CGU_BYTE p = partitionTable[i]; + blockIndices[i] = 0; + CGU_BYTE bitsToRead = bti[m_blockMode].indexBits[0]; + + // If this is a fixup index then set the implicit bit + if(i==fixup[p]) + { + blockIndices[i] &= ~(1 << (bitsToRead-1)); + bitsToRead--; + } + + for(j=0;jimage_src[offsetR++] = (CGV_IMAGE)image_src[i][0]; + state->image_src[offsetG++] = (CGV_IMAGE)image_src[i][1]; + state->image_src[offsetB++] = (CGV_IMAGE)image_src[i][2]; + state->image_src[offsetA++] = (CGV_IMAGE)image_src[i][3]; + } + + BC7_CompressBlock(state, u_BC7Encode); + + if (state->cmp_isout16Bytes) + { + for (CGU_UINT8 i = 0; i < COMPRESSED_BLOCK_SIZE; i++) + { + cmp_out[i] = state->cmp_out[i]; + } + } + else + { +#ifdef ASPM_GPU + cmp_memcpy(cmp_out, (CGU_UINT8 *)state->best_cmp_out, 16); +#else + memcpy(cmp_out, state->best_cmp_out, 16); +#endif + } +} + +//======================= CPU USER INTERFACES ==================================== + +int CMP_CDECL CreateOptionsBC7(void **options) +{ + (*options) = new BC7_Encode; + if (!options) return CGU_CORE_ERR_NEWMEM; + init_BC7ramps(); + SetDefaultBC7Options((BC7_Encode *)(*options)); + return CGU_CORE_OK; +} + +int CMP_CDECL DestroyOptionsBC7(void *options) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + BC7_Encode *BCOptions = reinterpret_cast (options); + delete BCOptions; + return CGU_CORE_OK; +} + +int CMP_CDECL SetErrorThresholdBC7(void *options, CGU_FLOAT minThreshold, CGU_FLOAT maxThreshold) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + BC7_Encode *BC7optionsDefault = (BC7_Encode *)options; + + if (minThreshold < 0.0f) minThreshold = 0.0f; + if (maxThreshold < 0.0f) maxThreshold = 0.0f; + + BC7optionsDefault->minThreshold = minThreshold; + BC7optionsDefault->maxThreshold = maxThreshold; + return CGU_CORE_OK; +} + +int CMP_CDECL SetQualityBC7(void *options, CGU_FLOAT fquality) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + + BC7_Encode *BC7optionsDefault = (BC7_Encode *)options; + if (fquality < 0.0f) fquality = 0.0f; + else + if (fquality > 1.0f) fquality = 1.0f; + BC7optionsDefault->quality = fquality; + + // Set Error Thresholds + BC7optionsDefault->errorThreshold = BC7optionsDefault->maxThreshold * (1.0f - fquality); + if(fquality > BC7_qFAST_THRESHOLD) + BC7optionsDefault->errorThreshold += BC7optionsDefault->minThreshold; + + return CGU_CORE_OK; +} + +int CMP_CDECL SetMaskBC7(void *options, CGU_UINT8 mask) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + BC7_Encode *BC7options = (BC7_Encode *)options; + BC7options->validModeMask = mask; + return CGU_CORE_OK; +} + +int CMP_CDECL SetAlphaOptionsBC7(void *options, CGU_BOOL imageNeedsAlpha, CGU_BOOL colourRestrict, CGU_BOOL alphaRestrict) +{ + if (!options) return CGU_CORE_ERR_INVALIDPTR; + BC7_Encode *u_BC7Encode = (BC7_Encode *)options; + u_BC7Encode->imageNeedsAlpha = imageNeedsAlpha; + u_BC7Encode->colourRestrict = colourRestrict; + u_BC7Encode->alphaRestrict = alphaRestrict; + return CGU_CORE_OK; +} + +int CMP_CDECL CompressBlockBC7( const unsigned char *srcBlock, + unsigned int srcStrideInBytes, + CMP_GLOBAL unsigned char cmpBlock[16], + const void* options = NULL) +{ + CMP_Vec4uc inBlock[SOURCE_BLOCK_SIZE]; + + //---------------------------------- + // Fill the inBlock with source data + //---------------------------------- + CGU_INT srcpos = 0; + CGU_INT dstptr = 0; + for (CGU_UINT8 row = 0; row < 4; row++) + { + srcpos = row * srcStrideInBytes; + for (CGU_UINT8 col = 0; col < 4; col++) + { + inBlock[dstptr].x = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].y = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].z = CGU_UINT8(srcBlock[srcpos++]); + inBlock[dstptr].w = CGU_UINT8(srcBlock[srcpos++]); + dstptr++; + } + } + + + BC7_Encode *u_BC7Encode = (BC7_Encode *)options; + BC7_Encode BC7EncodeDefault = { 0 }; + if (u_BC7Encode == NULL) + { + u_BC7Encode = &BC7EncodeDefault; + SetDefaultBC7Options(u_BC7Encode); + init_BC7ramps(); + } + + BC7_EncodeState EncodeState +#ifndef ASPM + = { 0 } +#endif + ; + EncodeState.best_err = CMP_FLOAT_MAX; + EncodeState.validModeMask = u_BC7Encode->validModeMask; + EncodeState.part_count = u_BC7Encode->part_count; + EncodeState.channels = CMP_STATIC_CAST(CGU_CHANNEL,u_BC7Encode->channels); + + CGU_UINT8 offsetR = 0; + CGU_UINT8 offsetG = 16; + CGU_UINT8 offsetB = 32; + CGU_UINT8 offsetA = 48; + CGU_UINT32 offsetSRC = 0; + for (CGU_UINT8 i = 0; i < SOURCE_BLOCK_SIZE; i++) + { + EncodeState.image_src[offsetR++] = (CGV_IMAGE)inBlock[offsetSRC].x; + EncodeState.image_src[offsetG++] = (CGV_IMAGE)inBlock[offsetSRC].y; + EncodeState.image_src[offsetB++] = (CGV_IMAGE)inBlock[offsetSRC].z; + EncodeState.image_src[offsetA++] = (CGV_IMAGE)inBlock[offsetSRC].w; + offsetSRC++; + } + + BC7_CompressBlock(&EncodeState, u_BC7Encode); + + if (EncodeState.cmp_isout16Bytes) + { + for (CGU_UINT8 i = 0; i < COMPRESSED_BLOCK_SIZE; i++) + { + cmpBlock[i] = EncodeState.cmp_out[i]; + } + } + else + { + memcpy(cmpBlock, EncodeState.best_cmp_out, 16); + } + + return CGU_CORE_OK; +} + + +int CMP_CDECL DecompressBlockBC7(const unsigned char cmpBlock[16], + unsigned char srcBlock[64], + const void *options = NULL) { + BC7_Encode *u_BC7Encode = (BC7_Encode *)options; + BC7_Encode BC7EncodeDefault = { 0 }; // for q = 0.05 + if (u_BC7Encode == NULL) + { + // set for q = 1.0 + u_BC7Encode = &BC7EncodeDefault; + SetDefaultBC7Options(u_BC7Encode); + init_BC7ramps(); + } + DecompressBC7_internal((CGU_UINT8(*)[4])srcBlock, (CGU_UINT8 *)cmpBlock,u_BC7Encode); + return CGU_CORE_OK; +} +#endif +#endif + +//============================================== OpenCL USER INTERFACE ==================================================== +#ifdef ASPM_OPENCL +CMP_STATIC CMP_KERNEL void CMP_GPUEncoder(uniform CMP_GLOBAL const CGU_Vec4uc ImageSource[], + CMP_GLOBAL CGV_CMPOUT ImageDestination[], + uniform CMP_GLOBAL Source_Info SourceInfo[], + uniform CMP_GLOBAL BC7_Encode BC7Encode[] ) +{ + CGU_INT xID=0; + CGU_INT yID=0; + + xID = get_global_id(0); // ToDo: Define a size_t 32 bit and 64 bit based on clGetDeviceInfo + yID = get_global_id(1); + CGU_INT srcWidth = SourceInfo->m_src_width; + CGU_INT srcHeight = SourceInfo->m_src_height; + if (xID >= (srcWidth / BlockX)) return; + if (yID >= (srcHeight / BlockY)) return; + + //ASPM_PRINT(("[ASPM_OCL] %d %d size %d\n",xID,yID,sizeof(BC7_Encode))); + + CGU_INT destI = (xID*COMPRESSED_BLOCK_SIZE) + (yID*(srcWidth / BlockX)*COMPRESSED_BLOCK_SIZE); + CGU_INT srcindex = 4 * (yID * srcWidth + xID); + CGU_INT blkindex = 0; + BC7_EncodeState EncodeState; + cmp_memsetBC7(&EncodeState,0,sizeof(EncodeState)); + copy_BC7_Encode_settings(&EncodeState, BC7Encode); + + //Check if it is a complete 4X4 block + if (((xID + 1)*BlockX <= srcWidth) && ((yID + 1)*BlockY <= srcHeight)) + { + srcWidth = srcWidth - 4; + for (CGU_INT j = 0; j < 4; j++) { + for (CGU_INT i = 0; i < 4; i++) { + EncodeState.image_src[blkindex+0*SOURCE_BLOCK_SIZE] = ImageSource[srcindex].x; + EncodeState.image_src[blkindex+1*SOURCE_BLOCK_SIZE] = ImageSource[srcindex].y; + EncodeState.image_src[blkindex+2*SOURCE_BLOCK_SIZE] = ImageSource[srcindex].z; + EncodeState.image_src[blkindex+3*SOURCE_BLOCK_SIZE] = ImageSource[srcindex].w; + blkindex++; + srcindex++; + } + + srcindex += srcWidth; + } + + BC7_CompressBlock(&EncodeState, BC7Encode); + + // printf("CMP %x %x %x %x %x %x %x", + // state->cmp_out[0], + // state->cmp_out[1], + // state->cmp_out[2], + // state->cmp_out[3], + // state->cmp_out[4], + // state->cmp_out[5], + // state->cmp_out[6] + // ); + + for (CGU_INT i=0; iquality = 1.0f; + BC7Encode->minThreshold = 5.0f; + BC7Encode->maxThreshold = 80.0f; + BC7Encode->errorThreshold = 5.0f; + BC7Encode->validModeMask = 0xFF; + + BC7Encode->imageNeedsAlpha = FALSE; + BC7Encode->colourRestrict = FALSE; + BC7Encode->alphaRestrict = FALSE; + + BC7Encode->channels = 4; + BC7Encode->part_count = 128; +} +} + +#ifndef ASPM +//===================== +// Used by Decoder +//===================== +__constant CGU_FLOAT rampLerpWeightsBC7[5][16] = +{ + { 0.0 }, // 0 bit index + { 0.0, 1.0 }, // 1 bit index + { 0.0, 21.0 / 64.0, 43.0 / 64.0, 1.0 }, // 2 bit index + { 0.0, 9.0 / 64.0, 18.0 / 64.0, 27.0 / 64.0, 37.0 / 64.0, 46.0 / 64.0, 55.0 / 64.0, 1.0 }, // 3 bit index + { 0.0, 4.0 / 64.0, 9.0 / 64.0, 13.0 / 64.0, 17.0 / 64.0, 21.0 / 64.0, 26.0 / 64.0, 30.0 / 64.0, + 34.0 / 64.0, 38.0 / 64.0, 43.0 / 64.0, 47.0 / 64.0, 51.0 / 64.0, 55.0 / 64.0, 60.0 / 64.0, 1.0 } // 4 bit index +}; + + +__constant CGU_UINT8 BC7_PARTITIONS[MAX_SUBSETS][MAX_PARTITIONS][MAX_SUBSET_SIZE] = +{ + // Single subset partitions for both BC6H abd BC7 + { + { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + }, + }, + + { + { // 0 + 0,0,1,1, + 0,0,1,1, + 0,0,1,1, + 0,0,1,1 + }, + + { // 1 + 0,0,0,1, + 0,0,0,1, + 0,0,0,1, + 0,0,0,1 + }, + + { // 2 + 0,1,1,1, + 0,1,1,1, + 0,1,1,1, + 0,1,1,1 + }, + + { // 3 + 0,0,0,1, + 0,0,1,1, + 0,0,1,1, + 0,1,1,1 + }, + + { // 4 + 0,0,0,0, + 0,0,0,1, + 0,0,0,1, + 0,0,1,1 + }, + + { // 5 + 0,0,1,1, + 0,1,1,1, + 0,1,1,1, + 1,1,1,1 + }, + + { // 6 + 0,0,0,1, + 0,0,1,1, + 0,1,1,1, + 1,1,1,1 + }, + + { // 7 + 0,0,0,0, + 0,0,0,1, + 0,0,1,1, + 0,1,1,1 + }, + + { // 8 + 0,0,0,0, + 0,0,0,0, + 0,0,0,1, + 0,0,1,1 + }, + + { // 9 + 0,0,1,1, + 0,1,1,1, + 1,1,1,1, + 1,1,1,1 + }, + + { // 10 + 0,0,0,0, + 0,0,0,1, + 0,1,1,1, + 1,1,1,1 + }, + + { // 11 + 0,0,0,0, + 0,0,0,0, + 0,0,0,1, + 0,1,1,1 + }, + + { // 12 + 0,0,0,1, + 0,1,1,1, + 1,1,1,1, + 1,1,1,1 + }, + + { // 13 + 0,0,0,0, + 0,0,0,0, + 1,1,1,1, + 1,1,1,1 + }, + + { // 14 + 0,0,0,0, + 1,1,1,1, + 1,1,1,1, + 1,1,1,1 + }, + + { // 15 + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 1,1,1,1 + }, + + { // 16 + 0,0,0,0, + 1,0,0,0, + 1,1,1,0, + 1,1,1,1 + }, + + { // 17 + 0,1,1,1, + 0,0,0,1, + 0,0,0,0, + 0,0,0,0 + }, + + { // 18 + 0,0,0,0, + 0,0,0,0, + 1,0,0,0, + 1,1,1,0 + }, + + { // 19 + 0,1,1,1, + 0,0,1,1, + 0,0,0,1, + 0,0,0,0 + }, + + { // 20 + 0,0,1,1, + 0,0,0,1, + 0,0,0,0, + 0,0,0,0 + }, + + { // 21 + 0,0,0,0, + 1,0,0,0, + 1,1,0,0, + 1,1,1,0 + }, + + { // 22 + 0,0,0,0, + 0,0,0,0, + 1,0,0,0, + 1,1,0,0 + }, + + { // 23 + 0,1,1,1, + 0,0,1,1, + 0,0,1,1, + 0,0,0,1 + }, + + { // 24 + 0,0,1,1, + 0,0,0,1, + 0,0,0,1, + 0,0,0,0 + }, + + { // 25 + 0,0,0,0, + 1,0,0,0, + 1,0,0,0, + 1,1,0,0 + }, + + { // 26 + 0,1,1,0, + 0,1,1,0, + 0,1,1,0, + 0,1,1,0 + }, + + { // 27 + 0,0,1,1, + 0,1,1,0, + 0,1,1,0, + 1,1,0,0 + }, + + { // 28 + 0,0,0,1, + 0,1,1,1, + 1,1,1,0, + 1,0,0,0 + }, + + { // 29 + 0,0,0,0, + 1,1,1,1, + 1,1,1,1, + 0,0,0,0 + }, + + { // 30 + 0,1,1,1, + 0,0,0,1, + 1,0,0,0, + 1,1,1,0 + }, + + { // 31 + 0,0,1,1, + 1,0,0,1, + 1,0,0,1, + 1,1,0,0 + }, + // ----------- BC7 only shapes from here on ------------- + { // 32 + 0,1,0,1, + 0,1,0,1, + 0,1,0,1, + 0,1,0,1 + }, + + { // 33 + 0,0,0,0, + 1,1,1,1, + 0,0,0,0, + 1,1,1,1 + }, + + { // 34 + 0,1,0,1, + 1,0,1,0, + 0,1,0,1, + 1,0,1,0 + }, + + { // 35 + 0,0,1,1, + 0,0,1,1, + 1,1,0,0, + 1,1,0,0 + }, + + { // 36 + 0,0,1,1, + 1,1,0,0, + 0,0,1,1, + 1,1,0,0 + }, + + { // 37 + 0,1,0,1, + 0,1,0,1, + 1,0,1,0, + 1,0,1,0 + }, + + { // 38 + 0,1,1,0, + 1,0,0,1, + 0,1,1,0, + 1,0,0,1 + }, + + { // 39 + 0,1,0,1, + 1,0,1,0, + 1,0,1,0, + 0,1,0,1 + }, + + { // 40 + 0,1,1,1, + 0,0,1,1, + 1,1,0,0, + 1,1,1,0 + }, + + { // 41 + 0,0,0,1, + 0,0,1,1, + 1,1,0,0, + 1,0,0,0 + }, + + { // 42 + 0,0,1,1, + 0,0,1,0, + 0,1,0,0, + 1,1,0,0 + }, + + { // 43 + 0,0,1,1, + 1,0,1,1, + 1,1,0,1, + 1,1,0,0 + }, + + { // 44 + 0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0 + }, + + { // 45 + 0,0,1,1, + 1,1,0,0, + 1,1,0,0, + 0,0,1,1 + }, + + { // 46 + 0,1,1,0, + 0,1,1,0, + 1,0,0,1, + 1,0,0,1 + }, + + { // 47 + 0,0,0,0, + 0,1,1,0, + 0,1,1,0, + 0,0,0,0 + }, + + { // 48 + 0,1,0,0, + 1,1,1,0, + 0,1,0,0, + 0,0,0,0 + }, + + { // 49 + 0,0,1,0, + 0,1,1,1, + 0,0,1,0, + 0,0,0,0 + }, + + { // 50 + 0,0,0,0, + 0,0,1,0, + 0,1,1,1, + 0,0,1,0 + }, + + { // 51 + 0,0,0,0, + 0,1,0,0, + 1,1,1,0, + 0,1,0,0 + }, + + { // 52 + 0,1,1,0, + 1,1,0,0, + 1,0,0,1, + 0,0,1,1 + }, + + { // 53 + 0,0,1,1, + 0,1,1,0, + 1,1,0,0, + 1,0,0,1 + }, + + { // 54 + 0,1,1,0, + 0,0,1,1, + 1,0,0,1, + 1,1,0,0 + }, + + { // 55 + 0,0,1,1, + 1,0,0,1, + 1,1,0,0, + 0,1,1,0 + }, + + { // 56 + 0,1,1,0, + 1,1,0,0, + 1,1,0,0, + 1,0,0,1 + }, + + { // 57 + 0,1,1,0, + 0,0,1,1, + 0,0,1,1, + 1,0,0,1 + }, + + { // 58 + 0,1,1,1, + 1,1,1,0, + 1,0,0,0, + 0,0,0,1 + }, + + { // 59 + 0,0,0,1, + 1,0,0,0, + 1,1,1,0, + 0,1,1,1 + }, + + { // 60 + 0,0,0,0, + 1,1,1,1, + 0,0,1,1, + 0,0,1,1 + }, + + { // 61 + 0,0,1,1, + 0,0,1,1, + 1,1,1,1, + 0,0,0,0 + }, + + { // 62 + 0,0,1,0, + 0,0,1,0, + 1,1,1,0, + 1,1,1,0 + }, + + { // 63 + 0,1,0,0, + 0,1,0,0, + 0,1,1,1, + 0,1,1,1 + }, + }, + + + // Table.P3 - only for BC7 + + { + + { + 0,0,1,1, + 0,0,1,1, + 0,2,2,1, + 2,2,2,2 + }, + + { + 0,0,0,1, + 0,0,1,1, + 2,2,1,1, + 2,2,2,1 + }, + + { + 0,0,0,0, + 2,0,0,1, + 2,2,1,1, + 2,2,1,1 + }, + + { + 0,2,2,2, + 0,0,2,2, + 0,0,1,1, + 0,1,1,1 + }, + + { + 0,0,0,0, + 0,0,0,0, + 1,1,2,2, + 1,1,2,2 + }, + + { + 0,0,1,1, + 0,0,1,1, + 0,0,2,2, + 0,0,2,2 + }, + + { + 0,0,2,2, + 0,0,2,2, + 1,1,1,1, + 1,1,1,1 + }, + + { + 0,0,1,1, + 0,0,1,1, + 2,2,1,1, + 2,2,1,1 + }, + + { + 0,0,0,0, + 0,0,0,0, + 1,1,1,1, + 2,2,2,2 + }, + + { + 0,0,0,0, + 1,1,1,1, + 1,1,1,1, + 2,2,2,2 + }, + + { + 0,0,0,0, + 1,1,1,1, + 2,2,2,2, + 2,2,2,2 + }, + + { + 0,0,1,2, + 0,0,1,2, + 0,0,1,2, + 0,0,1,2 + }, + + { + 0,1,1,2, + 0,1,1,2, + 0,1,1,2, + 0,1,1,2 + }, + + { + 0,1,2,2, + 0,1,2,2, + 0,1,2,2, + 0,1,2,2 + }, + + { + 0,0,1,1, + 0,1,1,2, + 1,1,2,2, + 1,2,2,2 + }, + + { + 0,0,1,1, + 2,0,0,1, + 2,2,0,0, + 2,2,2,0 + }, + + { + 0,0,0,1, + 0,0,1,1, + 0,1,1,2, + 1,1,2,2 + }, + + { + 0,1,1,1, + 0,0,1,1, + 2,0,0,1, + 2,2,0,0 + }, + + { + 0,0,0,0, + 1,1,2,2, + 1,1,2,2, + 1,1,2,2 + }, + + { + 0,0,2,2, + 0,0,2,2, + 0,0,2,2, + 1,1,1,1 + }, + + { + 0,1,1,1, + 0,1,1,1, + 0,2,2,2, + 0,2,2,2 + }, + + { + 0,0,0,1, + 0,0,0,1, + 2,2,2,1, + 2,2,2,1 + }, + + { + 0,0,0,0, + 0,0,1,1, + 0,1,2,2, + 0,1,2,2 + }, + + { + 0,0,0,0, + 1,1,0,0, + 2,2,1,0, + 2,2,1,0 + }, + + { + 0,1,2,2, + 0,1,2,2, + 0,0,1,1, + 0,0,0,0 + }, + + { + 0,0,1,2, + 0,0,1,2, + 1,1,2,2, + 2,2,2,2 + }, + + { + 0,1,1,0, + 1,2,2,1, + 1,2,2,1, + 0,1,1,0 + }, + + { + 0,0,0,0, + 0,1,1,0, + 1,2,2,1, + 1,2,2,1 + }, + + { + 0,0,2,2, + 1,1,0,2, + 1,1,0,2, + 0,0,2,2 + }, + + { + 0,1,1,0, + 0,1,1,0, + 2,0,0,2, + 2,2,2,2 + }, + + { + 0,0,1,1, + 0,1,2,2, + 0,1,2,2, + 0,0,1,1 + }, + + { + 0,0,0,0, + 2,0,0,0, + 2,2,1,1, + 2,2,2,1 + }, + + { + 0,0,0,0, + 0,0,0,2, + 1,1,2,2, + 1,2,2,2 + }, + + { + 0,2,2,2, + 0,0,2,2, + 0,0,1,2, + 0,0,1,1 + }, + + { + 0,0,1,1, + 0,0,1,2, + 0,0,2,2, + 0,2,2,2 + }, + + { + 0,1,2,0, + 0,1,2,0, + 0,1,2,0, + 0,1,2,0 + }, + + { + 0,0,0,0, + 1,1,1,1, + 2,2,2,2, + 0,0,0,0 + }, + + { + 0,1,2,0, + 1,2,0,1, + 2,0,1,2, + 0,1,2,0 + }, + + { + 0,1,2,0, + 2,0,1,2, + 1,2,0,1, + 0,1,2,0 + }, + + { + 0,0,1,1, + 2,2,0,0, + 1,1,2,2, + 0,0,1,1 + }, + + { + 0,0,1,1, + 1,1,2,2, + 2,2,0,0, + 0,0,1,1 + }, + + { + 0,1,0,1, + 0,1,0,1, + 2,2,2,2, + 2,2,2,2 + }, + + { + 0,0,0,0, + 0,0,0,0, + 2,1,2,1, + 2,1,2,1 + }, + + { + 0,0,2,2, + 1,1,2,2, + 0,0,2,2, + 1,1,2,2 + }, + + { + 0,0,2,2, + 0,0,1,1, + 0,0,2,2, + 0,0,1,1 + }, + + { + 0,2,2,0, + 1,2,2,1, + 0,2,2,0, + 1,2,2,1 + }, + + { + 0,1,0,1, + 2,2,2,2, + 2,2,2,2, + 0,1,0,1 + }, + + { + 0,0,0,0, + 2,1,2,1, + 2,1,2,1, + 2,1,2,1 + }, + + { + 0,1,0,1, + 0,1,0,1, + 0,1,0,1, + 2,2,2,2 + }, + + { + 0,2,2,2, + 0,1,1,1, + 0,2,2,2, + 0,1,1,1 + }, + + { + 0,0,0,2, + 1,1,1,2, + 0,0,0,2, + 1,1,1,2 + }, + + { + 0,0,0,0, + 2,1,1,2, + 2,1,1,2, + 2,1,1,2 + }, + + { + 0,2,2,2, + 0,1,1,1, + 0,1,1,1, + 0,2,2,2 + }, + + { + 0,0,0,2, + 1,1,1,2, + 1,1,1,2, + 0,0,0,2 + }, + + { + 0,1,1,0, + 0,1,1,0, + 0,1,1,0, + 2,2,2,2 + }, + + { + 0,0,0,0, + 0,0,0,0, + 2,1,1,2, + 2,1,1,2 + }, + + { + 0,1,1,0, + 0,1,1,0, + 2,2,2,2, + 2,2,2,2 + }, + + { + 0,0,2,2, + 0,0,1,1, + 0,0,1,1, + 0,0,2,2 + }, + + { + 0,0,2,2, + 1,1,2,2, + 1,1,2,2, + 0,0,2,2 + }, + + { + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 2,1,1,2 + }, + + { + 0,0,0,2, + 0,0,0,1, + 0,0,0,2, + 0,0,0,1 + }, + + { + 0,2,2,2, + 1,2,2,2, + 0,2,2,2, + 1,2,2,2 + }, + + { + 0,1,0,1, + 2,2,2,2, + 2,2,2,2, + 2,2,2,2 + }, + + { + 0,1,1,1, + 2,0,1,1, + 2,2,0,1, + 2,2,2,0 + }, + }, +}; +#endif + +#endif // !ASPM_GPU + + + +#endif diff --git a/extern/CMP_Core/shaders/BC7_Encode_kernel.hlsl b/extern/CMP_Core/shaders/BC7_Encode_kernel.hlsl new file mode 100644 index 00000000..216b0217 --- /dev/null +++ b/extern/CMP_Core/shaders/BC7_Encode_kernel.hlsl @@ -0,0 +1,1936 @@ +//-------------------------------------------------------------------------------------- +// File: BC7Encode.hlsl +// +// The Compute Shader for BC7 Encoder +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +//-------------------------------------------------------------------------------------- + +#define REF_DEVICE +#ifndef ASPM_HLSL +#define ASPM_HLSL +#endif + +#define CHAR_LENGTH 8 +#define NCHANNELS 4 +#define BC7_UNORM 98 +#define MAX_UINT 0xFFFFFFFF +#define MIN_UINT 0 + +static const uint candidateSectionBit[64] = //Associated to partition 0-63 +{ + 0xCCCC, 0x8888, 0xEEEE, 0xECC8, + 0xC880, 0xFEEC, 0xFEC8, 0xEC80, + 0xC800, 0xFFEC, 0xFE80, 0xE800, + 0xFFE8, 0xFF00, 0xFFF0, 0xF000, + 0xF710, 0x008E, 0x7100, 0x08CE, + 0x008C, 0x7310, 0x3100, 0x8CCE, + 0x088C, 0x3110, 0x6666, 0x366C, + 0x17E8, 0x0FF0, 0x718E, 0x399C, + 0xaaaa, 0xf0f0, 0x5a5a, 0x33cc, + 0x3c3c, 0x55aa, 0x9696, 0xa55a, + 0x73ce, 0x13c8, 0x324c, 0x3bdc, + 0x6996, 0xc33c, 0x9966, 0x660, + 0x272, 0x4e4, 0x4e40, 0x2720, + 0xc936, 0x936c, 0x39c6, 0x639c, + 0x9336, 0x9cc6, 0x817e, 0xe718, + 0xccf0, 0xfcc, 0x7744, 0xee22, +}; +static const uint candidateSectionBit2[64] = //Associated to partition 64-127 +{ + 0xaa685050, 0x6a5a5040, 0x5a5a4200, 0x5450a0a8, + 0xa5a50000, 0xa0a05050, 0x5555a0a0, 0x5a5a5050, + 0xaa550000, 0xaa555500, 0xaaaa5500, 0x90909090, + 0x94949494, 0xa4a4a4a4, 0xa9a59450, 0x2a0a4250, + 0xa5945040, 0x0a425054, 0xa5a5a500, 0x55a0a0a0, + 0xa8a85454, 0x6a6a4040, 0xa4a45000, 0x1a1a0500, + 0x0050a4a4, 0xaaa59090, 0x14696914, 0x69691400, + 0xa08585a0, 0xaa821414, 0x50a4a450, 0x6a5a0200, + 0xa9a58000, 0x5090a0a8, 0xa8a09050, 0x24242424, + 0x00aa5500, 0x24924924, 0x24499224, 0x50a50a50, + 0x500aa550, 0xaaaa4444, 0x66660000, 0xa5a0a5a0, + 0x50a050a0, 0x69286928, 0x44aaaa44, 0x66666600, + 0xaa444444, 0x54a854a8, 0x95809580, 0x96969600, + 0xa85454a8, 0x80959580, 0xaa141414, 0x96960000, + 0xaaaa1414, 0xa05050a0, 0xa0a5a5a0, 0x96000000, + 0x40804080, 0xa9a8a9a8, 0xaaaaaa44, 0x2a4a5254, +}; +static const uint2 candidateFixUpIndex1D[128] = +{ + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{ 2, 0},{ 8, 0},{ 2, 0}, + { 2, 0},{ 8, 0},{ 8, 0},{15, 0}, + { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, + { 8, 0},{ 8, 0},{ 2, 0},{ 2, 0}, + + {15, 0},{15, 0},{ 6, 0},{ 8, 0}, + { 2, 0},{ 8, 0},{15, 0},{15, 0}, + { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, + { 2, 0},{15, 0},{15, 0},{ 6, 0}, + { 6, 0},{ 2, 0},{ 6, 0},{ 8, 0}, + {15, 0},{15, 0},{ 2, 0},{ 2, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{ 2, 0},{ 2, 0},{15, 0}, + //candidateFixUpIndex1D[i][1], i < 64 should not be used + + { 3,15},{ 3, 8},{15, 8},{15, 3}, + { 8,15},{ 3,15},{15, 3},{15, 8}, + { 8,15},{ 8,15},{ 6,15},{ 6,15}, + { 6,15},{ 5,15},{ 3,15},{ 3, 8}, + { 3,15},{ 3, 8},{ 8,15},{15, 3}, + { 3,15},{ 3, 8},{ 6,15},{10, 8}, + { 5, 3},{ 8,15},{ 8, 6},{ 6,10}, + { 8,15},{ 5,15},{15,10},{15, 8}, + + { 8,15},{15, 3},{ 3,15},{ 5,10}, + { 6,10},{10, 8},{ 8, 9},{15,10}, + {15, 6},{ 3,15},{15, 8},{ 5,15}, + {15, 3},{15, 6},{15, 6},{15, 8}, //The Spec doesn't mark the first fixed up index in this row, so I apply 15 for them, and seems correct + { 3,15},{15, 3},{ 5,15},{ 5,15}, + { 5,15},{ 8,15},{ 5,15},{10,15}, + { 5,15},{10,15},{ 8,15},{13,15}, + {15, 3},{12,15},{ 3,15},{ 3, 8}, +}; +static const uint2 candidateFixUpIndex1DOrdered[128] = //Same with candidateFixUpIndex1D but order the result when i >= 64 +{ + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{ 2, 0},{ 8, 0},{ 2, 0}, + { 2, 0},{ 8, 0},{ 8, 0},{15, 0}, + { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, + { 8, 0},{ 8, 0},{ 2, 0},{ 2, 0}, + + {15, 0},{15, 0},{ 6, 0},{ 8, 0}, + { 2, 0},{ 8, 0},{15, 0},{15, 0}, + { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, + { 2, 0},{15, 0},{15, 0},{ 6, 0}, + { 6, 0},{ 2, 0},{ 6, 0},{ 8, 0}, + {15, 0},{15, 0},{ 2, 0},{ 2, 0}, + {15, 0},{15, 0},{15, 0},{15, 0}, + {15, 0},{ 2, 0},{ 2, 0},{15, 0}, + //candidateFixUpIndex1DOrdered[i][1], i < 64 should not be used + + { 3,15},{ 3, 8},{ 8,15},{ 3,15}, + { 8,15},{ 3,15},{ 3,15},{ 8,15}, + { 8,15},{ 8,15},{ 6,15},{ 6,15}, + { 6,15},{ 5,15},{ 3,15},{ 3, 8}, + { 3,15},{ 3, 8},{ 8,15},{ 3,15}, + { 3,15},{ 3, 8},{ 6,15},{ 8,10}, + { 3, 5},{ 8,15},{ 6, 8},{ 6,10}, + { 8,15},{ 5,15},{10,15},{ 8,15}, + + { 8,15},{ 3,15},{ 3,15},{ 5,10}, + { 6,10},{ 8,10},{ 8, 9},{10,15}, + { 6,15},{ 3,15},{ 8,15},{ 5,15}, + { 3,15},{ 6,15},{ 6,15},{ 8,15}, //The Spec doesn't mark the first fixed up index in this row, so I apply 15 for them, and seems correct + { 3,15},{ 3,15},{ 5,15},{ 5,15}, + { 5,15},{ 8,15},{ 5,15},{10,15}, + { 5,15},{10,15},{ 8,15},{13,15}, + { 3,15},{12,15},{ 3,15},{ 3, 8}, +}; +//static const uint4x4 candidateRotation[4] = +//{ +// {1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}, +// {0,0,0,1},{0,1,0,0},{0,0,1,0},{1,0,0,0}, +// {1,0,0,0},{0,0,0,1},{0,0,1,0},{0,1,0,0}, +// {1,0,0,0},{0,1,0,0},{0,0,0,1},{0,0,1,0} +//}; +//static const uint2 candidateIndexPrec[8] = {{3,0},{3,0},{2,0},{2,0}, +// {2,3}, //color index and alpha index can exchange +// {2,2},{4,4},{2,2}}; + +static const uint aWeight[3][16] = { {0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64}, + {0, 9, 18, 27, 37, 46, 55, 64, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 21, 43, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; + + //4 bit index: 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 +static const uint aStep[3][64] = { { 0, 0, 0, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 4, 4, 5, 5, 5, 5, + 6, 6, 6, 6, 6, 7, 7, 7, + 7, 8, 8, 8, 8, 9, 9, 9, + 9,10,10,10,10,10,11,11, + 11,11,12,12,12,12,13,13, + 13,13,14,14,14,14,15,15 }, + //3 bit index: 0, 9, 18, 27, 37, 46, 55, 64 + { 0,0,0,0,0,1,1,1, + 1,1,1,1,1,1,2,2, + 2,2,2,2,2,2,2,3, + 3,3,3,3,3,3,3,3, + 3,4,4,4,4,4,4,4, + 4,4,5,5,5,5,5,5, + 5,5,5,6,6,6,6,6, + 6,6,6,6,7,7,7,7 }, + //2 bit index: 0, 21, 43, 64 + { 0,0,0,0,0,0,0,0, + 0,0,0,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,3,3, + 3,3,3,3,3,3,3,3 } }; + +cbuffer cbCS : register( b0 ) +{ + uint g_tex_width; + uint g_num_block_x; + uint g_format; + uint g_mode_id; + uint g_start_block_id; + uint g_num_total_blocks; + float g_alpha_weight; + float g_quality; +}; + +//Forward declaration +uint2x4 compress_endpoints0( inout uint2x4 endPoint, uint2 P ); //Mode = 0 +uint2x4 compress_endpoints1( inout uint2x4 endPoint, uint2 P ); //Mode = 1 +uint2x4 compress_endpoints2( inout uint2x4 endPoint ); //Mode = 2 +uint2x4 compress_endpoints3( inout uint2x4 endPoint, uint2 P ); //Mode = 3 +uint2x4 compress_endpoints7( inout uint2x4 endPoint, uint2 P ); //Mode = 7 +uint2x4 compress_endpoints6( inout uint2x4 endPoint, uint2 P ); //Mode = 6 +uint2x4 compress_endpoints4( inout uint2x4 endPoint ); //Mode = 4 +uint2x4 compress_endpoints5( inout uint2x4 endPoint ); //Mode = 5 + +void block_package0( out uint4 block, uint partition, uint threadBase ); //Mode0 +void block_package1( out uint4 block, uint partition, uint threadBase ); //Mode1 +void block_package2( out uint4 block, uint partition, uint threadBase ); //Mode2 +void block_package3( out uint4 block, uint partition, uint threadBase ); //Mode3 +void block_package4( out uint4 block, uint rotation, uint index_selector, uint threadBase ); //Mode4 +void block_package5( out uint4 block, uint rotation, uint threadBase ); //Mode5 +void block_package6( out uint4 block, uint threadBase ); //Mode6 +void block_package7( out uint4 block, uint partition, uint threadBase ); //Mode7 + + +void swap(inout uint4 lhs, inout uint4 rhs) +{ + uint4 tmp = lhs; + lhs = rhs; + rhs = tmp; +} +void swap(inout uint3 lhs, inout uint3 rhs) +{ + uint3 tmp = lhs; + lhs = rhs; + rhs = tmp; +} +void swap(inout uint lhs, inout uint rhs) +{ + uint tmp = lhs; + lhs = rhs; + rhs = tmp; +} + +uint ComputeError(in uint4 a, in uint4 b) +{ + return dot(a.rgb, b.rgb) + g_alpha_weight * a.a*b.a; +} + +void Ensure_A_Is_Larger( inout uint4 a, inout uint4 b ) +{ + if ( a.x < b.x ) + swap( a.x, b.x ); + if ( a.y < b.y ) + swap( a.y, b.y ); + if ( a.z < b.z ) + swap( a.z, b.z ); + if ( a.w < b.w ) + swap( a.w, b.w ); +} + + +Texture2D g_Input : register( t0 ); +StructuredBuffer g_InBuff : register( t1 ); + +RWStructuredBuffer g_OutBuff : register( u0 ); + +#define THREAD_GROUP_SIZE 64 +#define BLOCK_SIZE_Y 4 +#define BLOCK_SIZE_X 4 +#define BLOCK_SIZE (BLOCK_SIZE_Y * BLOCK_SIZE_X) + +struct BufferShared +{ + uint4 pixel; + uint error; + uint mode; + uint partition; + uint index_selector; + uint rotation; + uint4 endPoint_low; + uint4 endPoint_high; + uint4 endPoint_low_quantized; + uint4 endPoint_high_quantized; +}; +groupshared BufferShared shared_temp[THREAD_GROUP_SIZE]; + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void TryMode456CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID ) // mode 4 5 6 all have 1 subset per block, and fix-up index is always index 0 +{ + // we process 4 BC blocks per thread group + const uint MAX_USED_THREAD = 16; // pixels in a BC (block compressed) block + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; // the number of BC blocks a thread group processes = 64 / 16 = 4 + uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on + uint threadBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group + uint threadInBlock = GI - threadBase; // id of the pixel in this BC block + +#ifndef REF_DEVICE + if (blockID >= g_num_total_blocks) + { + return; + } +#endif + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + if (threadInBlock < 16) + { + shared_temp[GI].pixel = clamp(uint4(g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ) * 255), 0, 255); + + shared_temp[GI].endPoint_low = shared_temp[GI].pixel; + shared_temp[GI].endPoint_high = shared_temp[GI].pixel; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 8) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 8].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 8].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 4].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 4].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 2].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 2].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 1].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 1].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + uint2x4 endPoint; + endPoint[0] = shared_temp[threadBase].endPoint_low; + endPoint[1] = shared_temp[threadBase].endPoint_high; + + uint error = 0xFFFFFFFF; + uint mode = 0; + uint index_selector = 0; + uint rotation = 0; + + uint2 indexPrec; + if (threadInBlock < 8) // all threads of threadInBlock < 8 will be working on trying out mode 4, since only mode 4 has index selector bit + { + if (0 == (threadInBlock & 1)) // thread 0, 2, 4, 6 + { + //2 represents 2bit index precision; 1 represents 3bit index precision + index_selector = 0; + indexPrec = uint2( 2, 1 ); + } + else // thread 1, 3, 5, 7 + { + //2 represents 2bit index precision; 1 represents 3bit index precision + index_selector = 1; + indexPrec = uint2( 1, 2 ); + } + } + else + { + //2 represents 2bit index precision + indexPrec = uint2( 2, 2 ); + } + + uint4 pixel_r; + uint color_index; + uint alpha_index; + int4 span; + int2 span_norm_sqr; + int2 dotProduct; + if (threadInBlock < 12) // Try mode 4 5 in threads 0..11 + { + // mode 4 5 have component rotation + if ((threadInBlock < 2) || (8 == threadInBlock)) // rotation = 0 in thread 0, 1 + { + rotation = 0; + } + else if ((threadInBlock < 4) || (9 == threadInBlock)) // rotation = 1 in thread 2, 3 + { + endPoint[0].ra = endPoint[0].ar; + endPoint[1].ra = endPoint[1].ar; + + rotation = 1; + } + else if ((threadInBlock < 6) || (10 == threadInBlock)) // rotation = 2 in thread 4, 5 + { + endPoint[0].ga = endPoint[0].ag; + endPoint[1].ga = endPoint[1].ag; + + rotation = 2; + } + else if ((threadInBlock < 8) || (11 == threadInBlock)) // rotation = 3 in thread 6, 7 + { + endPoint[0].ba = endPoint[0].ab; + endPoint[1].ba = endPoint[1].ab; + + rotation = 3; + } + + if (threadInBlock < 8) // try mode 4 in threads 0..7 + { + // mode 4 thread distribution + // Thread 0 1 2 3 4 5 6 7 + // Rotation 0 0 1 1 2 2 3 3 + // Index selector 0 1 0 1 0 1 0 1 + + mode = 4; + compress_endpoints4( endPoint ); + } + else // try mode 5 in threads 8..11 + { + // mode 5 thread distribution + // Thread 8 9 10 11 + // Rotation 0 1 2 3 + + mode = 5; + compress_endpoints5( endPoint ); + } + + uint4 pixel = shared_temp[threadBase + 0].pixel; + if (1 == rotation) + { + pixel.ra = pixel.ar; + } + else if (2 == rotation) + { + pixel.ga = pixel.ag; + } + else if (3 == rotation) + { + pixel.ba = pixel.ab; + } + + span = endPoint[1] - endPoint[0]; + span_norm_sqr = uint2( dot( span.rgb, span.rgb ), span.a * span.a ); + + // in mode 4 5 6, end point 0 must be closer to pixel 0 than end point 1, because of the fix-up index is always index 0 + // TODO: this shouldn't be necessary here in error calculation + /* + dotProduct = int2( dot( span.rgb, pixel.rgb - endPoint[0].rgb ), span.a * ( pixel.a - endPoint[0].a ) ); + if ( span_norm_sqr.x > 0 && dotProduct.x > 0 && uint( dotProduct.x * 63.49999 ) > uint( 32 * span_norm_sqr.x ) ) + { + span.rgb = -span.rgb; + swap(endPoint[0].rgb, endPoint[1].rgb); + } + if ( span_norm_sqr.y > 0 && dotProduct.y > 0 && uint( dotProduct.y * 63.49999 ) > uint( 32 * span_norm_sqr.y ) ) + { + span.a = -span.a; + swap(endPoint[0].a, endPoint[1].a); + } + */ + + // should be the same as above + dotProduct = int2( dot( pixel.rgb - endPoint[0].rgb, pixel.rgb - endPoint[0].rgb ), dot( pixel.rgb - endPoint[1].rgb, pixel.rgb - endPoint[1].rgb ) ); + if ( dotProduct.x > dotProduct.y ) + { + span.rgb = -span.rgb; + swap(endPoint[0].rgb, endPoint[1].rgb); + } + dotProduct = int2( dot( pixel.a - endPoint[0].a, pixel.a - endPoint[0].a ), dot( pixel.a - endPoint[1].a, pixel.a - endPoint[1].a ) ); + if ( dotProduct.x > dotProduct.y ) + { + span.a = -span.a; + swap(endPoint[0].a, endPoint[1].a); + } + + error = 0; + for ( uint i = 0; i < 16; i ++ ) + { + pixel = shared_temp[threadBase + i].pixel; + if (1 == rotation) + { + pixel.ra = pixel.ar; + } + else if (2 == rotation) + { + pixel.ga = pixel.ag; + } + else if (3 == rotation) + { + pixel.ba = pixel.ab; + } + + dotProduct.x = dot( span.rgb, pixel.rgb - endPoint[0].rgb ); + color_index = ( span_norm_sqr.x <= 0 /*endPoint[0] == endPoint[1]*/ || dotProduct.x <= 0 /*pixel == endPoint[0]*/ ) ? 0 + : ( ( dotProduct.x < span_norm_sqr.x ) ? aStep[indexPrec.x][ uint( dotProduct.x * 63.49999 / span_norm_sqr.x ) ] : aStep[indexPrec.x][63] ); + dotProduct.y = dot( span.a, pixel.a - endPoint[0].a ); + alpha_index = ( span_norm_sqr.y <= 0 || dotProduct.y <= 0 ) ? 0 + : ( ( dotProduct.y < span_norm_sqr.y ) ? aStep[indexPrec.y][ uint( dotProduct.y * 63.49999 / span_norm_sqr.y ) ] : aStep[indexPrec.y][63] ); + + // the same color_index and alpha_index should be used for reconstruction, so this should be left commented out + /*if (index_selector) + { + swap(color_index, alpha_index); + }*/ + + pixel_r.rgb = ( ( 64 - aWeight[indexPrec.x][color_index] ) * endPoint[0].rgb + + aWeight[indexPrec.x][color_index] * endPoint[1].rgb + + 32 ) >> 6; + pixel_r.a = ( ( 64 - aWeight[indexPrec.y][alpha_index] ) * endPoint[0].a + + aWeight[indexPrec.y][alpha_index] * endPoint[1].a + + 32 ) >> 6; + + Ensure_A_Is_Larger( pixel_r, pixel ); + pixel_r -= pixel; + if (1 == rotation) + { + pixel_r.ra = pixel_r.ar; + } + else if (2 == rotation) + { + pixel_r.ga = pixel_r.ag; + } + else if (3 == rotation) + { + pixel_r.ba = pixel_r.ab; + } + error += ComputeError(pixel_r, pixel_r); + } + } + else if (threadInBlock < 16) // Try mode 6 in threads 12..15, since in mode 4 5 6, only mode 6 has p bit + { + uint p = threadInBlock - 12; + + compress_endpoints6( endPoint, uint2(p >> 0, p >> 1) & 1 ); + + uint4 pixel = shared_temp[threadBase + 0].pixel; + + span = endPoint[1] - endPoint[0]; + span_norm_sqr = dot( span, span ); + dotProduct = dot( span, pixel - endPoint[0] ); + if ( span_norm_sqr.x > 0 && dotProduct.x >= 0 && uint( dotProduct.x * 63.49999 ) > uint( 32 * span_norm_sqr.x ) ) + { + span = -span; + swap(endPoint[0], endPoint[1]); + } + + error = 0; + for ( uint i = 0; i < 16; i ++ ) + { + pixel = shared_temp[threadBase + i].pixel; + + dotProduct.x = dot( span, pixel - endPoint[0] ); + color_index = ( span_norm_sqr.x <= 0 || dotProduct.x <= 0 ) ? 0 + : ( ( dotProduct.x < span_norm_sqr.x ) ? aStep[0][ uint( dotProduct.x * 63.49999 / span_norm_sqr.x ) ] : aStep[0][63] ); + + pixel_r = ( ( 64 - aWeight[0][color_index] ) * endPoint[0] + + aWeight[0][color_index] * endPoint[1] + 32 ) >> 6; + + Ensure_A_Is_Larger( pixel_r, pixel ); + pixel_r -= pixel; + error += ComputeError(pixel_r, pixel_r); + } + + mode = 6; + rotation = p; // Borrow rotation for p + } + + shared_temp[GI].error = error; + shared_temp[GI].mode = mode; + shared_temp[GI].index_selector = index_selector; + shared_temp[GI].rotation = rotation; + +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 8) + { + if ( shared_temp[GI].error > shared_temp[GI + 8].error ) + { + shared_temp[GI].error = shared_temp[GI + 8].error; + shared_temp[GI].mode = shared_temp[GI + 8].mode; + shared_temp[GI].index_selector = shared_temp[GI + 8].index_selector; + shared_temp[GI].rotation = shared_temp[GI + 8].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + if ( shared_temp[GI].error > shared_temp[GI + 4].error ) + { + shared_temp[GI].error = shared_temp[GI + 4].error; + shared_temp[GI].mode = shared_temp[GI + 4].mode; + shared_temp[GI].index_selector = shared_temp[GI + 4].index_selector; + shared_temp[GI].rotation = shared_temp[GI + 4].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + if ( shared_temp[GI].error > shared_temp[GI + 2].error ) + { + shared_temp[GI].error = shared_temp[GI + 2].error; + shared_temp[GI].mode = shared_temp[GI + 2].mode; + shared_temp[GI].index_selector = shared_temp[GI + 2].index_selector; + shared_temp[GI].rotation = shared_temp[GI + 2].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + if ( shared_temp[GI].error > shared_temp[GI + 1].error ) + { + shared_temp[GI].error = shared_temp[GI + 1].error; + shared_temp[GI].mode = shared_temp[GI + 1].mode; + shared_temp[GI].index_selector = shared_temp[GI + 1].index_selector; + shared_temp[GI].rotation = shared_temp[GI + 1].rotation; + } + + g_OutBuff[blockID] = uint4(shared_temp[GI].error, (shared_temp[GI].index_selector << 31) | shared_temp[GI].mode, + 0, shared_temp[GI].rotation); // rotation is indeed rotation for mode 4 5. for mode 6, rotation is p bit + } +} + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void TryMode137CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID ) // mode 1 3 7 all have 2 subsets per block +{ + const uint MAX_USED_THREAD = 64; + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; + uint blockInGroup = GI / MAX_USED_THREAD; + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; + uint threadBase = blockInGroup * MAX_USED_THREAD; + uint threadInBlock = GI - threadBase; + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + if (threadInBlock < 16) + { + shared_temp[GI].pixel = clamp(uint4(g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ) * 255), 0, 255); + } + GroupMemoryBarrierWithGroupSync(); + + shared_temp[GI].error = 0xFFFFFFFF; + + uint4 pixel_r; + uint2x4 endPoint[2]; // endPoint[0..1 for subset id][0..1 for low and high in the subset] + uint2x4 endPointBackup[2]; + uint color_index; + if (threadInBlock < 64) + { + uint partition = threadInBlock; + + endPoint[0][0] = MAX_UINT; + endPoint[0][1] = MIN_UINT; + endPoint[1][0] = MAX_UINT; + endPoint[1][1] = MIN_UINT; + uint bits = candidateSectionBit[partition]; + for ( uint i = 0; i < 16; i ++ ) + { + uint4 pixel = shared_temp[threadBase + i].pixel; + if ( (( bits >> i ) & 0x01) == 1 ) + { + endPoint[1][0] = min( endPoint[1][0], pixel ); + endPoint[1][1] = max( endPoint[1][1], pixel ); + } + else + { + endPoint[0][0] = min( endPoint[0][0], pixel ); + endPoint[0][1] = max( endPoint[0][1], pixel ); + } + } + + endPointBackup[0] = endPoint[0]; + endPointBackup[1] = endPoint[1]; + + uint max_p; + if (1 == g_mode_id) + { + // in mode 1, there is only one p bit per subset + max_p = 2; + } + else + { + // in mode 3 7, there are two p bits per subset, one for each end point + max_p = 4; + } + + uint final_p[2] = { 0, 0 }; + uint error[2] = { MAX_UINT, MAX_UINT }; + for ( uint p = 0; p < max_p; p ++ ) + { + endPoint[0] = endPointBackup[0]; + endPoint[1] = endPointBackup[1]; + + for ( i = 0; i < 2; i ++ ) // loop through 2 subsets + { + if (g_mode_id == 1) + { + compress_endpoints1( endPoint[i], p ); + } + else if (g_mode_id == 3) + { + compress_endpoints3( endPoint[i], uint2(p, p >> 1) & 1 ); + } + else if (g_mode_id == 7) + { + compress_endpoints7( endPoint[i], uint2(p, p >> 1) & 1 ); + } + } + + int4 span[2]; + span[0] = endPoint[0][1] - endPoint[0][0]; + span[1] = endPoint[1][1] - endPoint[1][0]; + + if (g_mode_id != 7) + { + span[0].w = span[1].w = 0; + } + + int span_norm_sqr[2]; + span_norm_sqr[0] = dot( span[0], span[0] ); + span_norm_sqr[1] = dot( span[1], span[1] ); + + // TODO: again, this shouldn't be necessary here in error calculation + int dotProduct = dot( span[0], shared_temp[threadBase + 0].pixel - endPoint[0][0] ); + if ( span_norm_sqr[0] > 0 && dotProduct > 0 && uint( dotProduct * 63.49999 ) > uint( 32 * span_norm_sqr[0] ) ) + { + span[0] = -span[0]; + swap(endPoint[0][0], endPoint[0][1]); + } + dotProduct = dot( span[1], shared_temp[threadBase + candidateFixUpIndex1D[partition].x].pixel - endPoint[1][0] ); + if ( span_norm_sqr[1] > 0 && dotProduct > 0 && uint( dotProduct * 63.49999 ) > uint( 32 * span_norm_sqr[1] ) ) + { + span[1] = -span[1]; + swap(endPoint[1][0], endPoint[1][1]); + } + + uint step_selector; + if (g_mode_id != 1) + { + step_selector = 2; // mode 3 7 have 2 bit index + } + else + { + step_selector = 1; // mode 1 has 3 bit index + } + + uint p_error[2] = { 0, 0 }; + for ( i = 0; i < 16; i ++ ) + { + uint subset_index = (bits >> i) & 0x01; + + if (subset_index == 1) + { + dotProduct = dot( span[1], shared_temp[threadBase + i].pixel - endPoint[1][0] ); + color_index = (span_norm_sqr[1] <= 0 || dotProduct <= 0) ? 0 + : ((dotProduct < span_norm_sqr[1]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[1])] : aStep[step_selector][63]); + } + else + { + dotProduct = dot( span[0], shared_temp[threadBase + i].pixel - endPoint[0][0] ); + color_index = (span_norm_sqr[0] <= 0 || dotProduct <= 0) ? 0 + : ((dotProduct < span_norm_sqr[0]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[0])] : aStep[step_selector][63]); + } + + pixel_r = ((64 - aWeight[step_selector][color_index]) * endPoint[subset_index][0] + + aWeight[step_selector][color_index] * endPoint[subset_index][1] + 32) >> 6; + if (g_mode_id != 7) + { + pixel_r.a = 255; + } + + uint4 pixel = shared_temp[threadBase + i].pixel; + Ensure_A_Is_Larger( pixel_r, pixel ); + pixel_r -= pixel; + uint pixel_error = ComputeError(pixel_r, pixel_r); + if ( subset_index == 1 ) + p_error[1] += pixel_error; + else + p_error[0] += pixel_error; + } + + for ( i = 0; i < 2; i++ ) + { + if (p_error[i] < error[i]) + { + error[i] = p_error[i]; + final_p[i] = p; + } + } + } + + shared_temp[GI].error = error[0] + error[1]; + shared_temp[GI].mode = g_mode_id; + shared_temp[GI].partition = partition; + + // mode 1 3 7 don't have rotation, we use rotation for p bits + if ( g_mode_id == 1 ) + shared_temp[GI].rotation = (final_p[1] << 1) | final_p[0]; + else + shared_temp[GI].rotation = (final_p[1] << 2) | final_p[0]; + } + GroupMemoryBarrierWithGroupSync(); + + if (threadInBlock < 32) + { + if ( shared_temp[GI].error > shared_temp[GI + 32].error ) + { + shared_temp[GI].error = shared_temp[GI + 32].error; + shared_temp[GI].mode = shared_temp[GI + 32].mode; + shared_temp[GI].partition = shared_temp[GI + 32].partition; + shared_temp[GI].rotation = shared_temp[GI + 32].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif +if (threadInBlock < 16) + { + if ( shared_temp[GI].error > shared_temp[GI + 16].error ) + { + shared_temp[GI].error = shared_temp[GI + 16].error; + shared_temp[GI].mode = shared_temp[GI + 16].mode; + shared_temp[GI].partition = shared_temp[GI + 16].partition; + shared_temp[GI].rotation = shared_temp[GI + 16].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 8) + { + if ( shared_temp[GI].error > shared_temp[GI + 8].error ) + { + shared_temp[GI].error = shared_temp[GI + 8].error; + shared_temp[GI].mode = shared_temp[GI + 8].mode; + shared_temp[GI].partition = shared_temp[GI + 8].partition; + shared_temp[GI].rotation = shared_temp[GI + 8].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + if ( shared_temp[GI].error > shared_temp[GI + 4].error ) + { + shared_temp[GI].error = shared_temp[GI + 4].error; + shared_temp[GI].mode = shared_temp[GI + 4].mode; + shared_temp[GI].partition = shared_temp[GI + 4].partition; + shared_temp[GI].rotation = shared_temp[GI + 4].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + if ( shared_temp[GI].error > shared_temp[GI + 2].error ) + { + shared_temp[GI].error = shared_temp[GI + 2].error; + shared_temp[GI].mode = shared_temp[GI + 2].mode; + shared_temp[GI].partition = shared_temp[GI + 2].partition; + shared_temp[GI].rotation = shared_temp[GI + 2].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + if ( shared_temp[GI].error > shared_temp[GI + 1].error ) + { + shared_temp[GI].error = shared_temp[GI + 1].error; + shared_temp[GI].mode = shared_temp[GI + 1].mode; + shared_temp[GI].partition = shared_temp[GI + 1].partition; + shared_temp[GI].rotation = shared_temp[GI + 1].rotation; + } + + if (g_InBuff[blockID].x > shared_temp[GI].error) + { + g_OutBuff[blockID] = uint4(shared_temp[GI].error, shared_temp[GI].mode, shared_temp[GI].partition, shared_temp[GI].rotation); // mode 1 3 7 don't have rotation, we use rotation for p bits + } + else + { + g_OutBuff[blockID] = g_InBuff[blockID]; + } + } +} + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void TryMode02CS( uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID ) // mode 0 2 have 3 subsets per block +{ + const uint MAX_USED_THREAD = 64; + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; + uint blockInGroup = GI / MAX_USED_THREAD; + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; + uint threadBase = blockInGroup * MAX_USED_THREAD; + uint threadInBlock = GI - threadBase; + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + if (threadInBlock < 16) + { + shared_temp[GI].pixel = clamp(uint4(g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ) * 255), 0, 255); + } + GroupMemoryBarrierWithGroupSync(); + + shared_temp[GI].error = 0xFFFFFFFF; + + uint num_partitions; + if (0 == g_mode_id) + { + num_partitions = 16; + } + else + { + num_partitions = 64; + } + + uint4 pixel_r; + uint2x4 endPoint[3]; // endPoint[0..1 for subset id][0..1 for low and high in the subset] + uint2x4 endPointBackup[3]; + uint color_index[16]; + if (threadInBlock < num_partitions) + { + uint partition = threadInBlock + 64; + + endPoint[0][0] = MAX_UINT; + endPoint[0][1] = MIN_UINT; + endPoint[1][0] = MAX_UINT; + endPoint[1][1] = MIN_UINT; + endPoint[2][0] = MAX_UINT; + endPoint[2][1] = MIN_UINT; + uint bits2 = candidateSectionBit2[partition - 64]; + for ( uint i = 0; i < 16; i ++ ) + { + uint4 pixel = shared_temp[threadBase + i].pixel; + uint subset_index = ( bits2 >> ( i * 2 ) ) & 0x03; + if ( subset_index == 2 ) + { + endPoint[2][0] = min( endPoint[2][0], pixel ); + endPoint[2][1] = max( endPoint[2][1], pixel ); + } + else if ( subset_index == 1 ) + { + endPoint[1][0] = min( endPoint[1][0], pixel ); + endPoint[1][1] = max( endPoint[1][1], pixel ); + } + else + { + endPoint[0][0] = min( endPoint[0][0], pixel ); + endPoint[0][1] = max( endPoint[0][1], pixel ); + } + } + + endPointBackup[0] = endPoint[0]; + endPointBackup[1] = endPoint[1]; + endPointBackup[2] = endPoint[2]; + + uint max_p; + if (0 == g_mode_id) + { + max_p = 4; + } + else + { + max_p = 1; + } + + uint final_p[3] = { 0, 0, 0 }; + uint error[3] = { MAX_UINT, MAX_UINT, MAX_UINT }; + for ( uint p = 0; p < max_p; p ++ ) + { + endPoint[0] = endPointBackup[0]; + endPoint[1] = endPointBackup[1]; + endPoint[2] = endPointBackup[2]; + + for ( i = 0; i < 3; i ++ ) + { + if (0 == g_mode_id) + { + compress_endpoints0( endPoint[i], uint2(p, p >> 1) & 1 ); + } + else + { + compress_endpoints2( endPoint[i] ); + } + } + + uint step_selector = 1 + (2 == g_mode_id); + + int4 span[3]; + span[0] = endPoint[0][1] - endPoint[0][0]; + span[1] = endPoint[1][1] - endPoint[1][0]; + span[2] = endPoint[2][1] - endPoint[2][0]; + span[0].w = span[1].w = span[2].w = 0; + int span_norm_sqr[3]; + span_norm_sqr[0] = dot( span[0], span[0] ); + span_norm_sqr[1] = dot( span[1], span[1] ); + span_norm_sqr[2] = dot( span[2], span[2] ); + + // TODO: again, this shouldn't be necessary here in error calculation + uint ci[3] = { 0, candidateFixUpIndex1D[partition].x, candidateFixUpIndex1D[partition].y }; + for (i = 0; i < 3; i ++) + { + int dotProduct = dot( span[i], shared_temp[threadBase + ci[i]].pixel - endPoint[i][0] ); + if ( span_norm_sqr[i] > 0 && dotProduct > 0 && uint( dotProduct * 63.49999 ) > uint( 32 * span_norm_sqr[i] ) ) + { + span[i] = -span[i]; + swap(endPoint[i][0], endPoint[i][1]); + } + } + + uint p_error[3] = { 0, 0, 0 }; + for ( i = 0; i < 16; i ++ ) + { + uint subset_index = ( bits2 >> ( i * 2 ) ) & 0x03; + if ( subset_index == 2 ) + { + int dotProduct = dot( span[2], shared_temp[threadBase + i].pixel - endPoint[2][0] ); + color_index[i] = ( span_norm_sqr[2] <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr[2] ) ? aStep[step_selector][ uint( dotProduct * 63.49999 / span_norm_sqr[2] ) ] : aStep[step_selector][63] ); + } + else if ( subset_index == 1 ) + { + int dotProduct = dot( span[1], shared_temp[threadBase + i].pixel - endPoint[1][0] ); + color_index[i] = ( span_norm_sqr[1] <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr[1] ) ? aStep[step_selector][ uint( dotProduct * 63.49999 / span_norm_sqr[1] ) ] : aStep[step_selector][63] ); + } + else + { + int dotProduct = dot( span[0], shared_temp[threadBase + i].pixel - endPoint[0][0] ); + color_index[i] = ( span_norm_sqr[0] <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr[0] ) ? aStep[step_selector][ uint( dotProduct * 63.49999 / span_norm_sqr[0] ) ] : aStep[step_selector][63] ); + } + + pixel_r = ( ( 64 - aWeight[step_selector][color_index[i]] ) * endPoint[subset_index][0] + + aWeight[step_selector][color_index[i]] * endPoint[subset_index][1] + 32 ) >> 6; + pixel_r.a = 255; + + uint4 pixel = shared_temp[threadBase + i].pixel; + Ensure_A_Is_Larger( pixel_r, pixel ); + pixel_r -= pixel; + + uint pixel_error = ComputeError(pixel_r, pixel_r); + + if ( subset_index == 2 ) + p_error[2] += pixel_error; + else if ( subset_index == 1 ) + p_error[1] += pixel_error; + else + p_error[0] += pixel_error; + } + + for ( i = 0; i < 3; i++ ) + { + if (p_error[i] < error[i]) + { + error[i] = p_error[i]; + final_p[i] = p; // Borrow rotation for p + } + } + } + + shared_temp[GI].error = error[0] + error[1] + error[2]; + shared_temp[GI].partition = partition; + shared_temp[GI].rotation = (final_p[2] << 4) | (final_p[1] << 2) | final_p[0]; + } + GroupMemoryBarrierWithGroupSync(); + + if (threadInBlock < 32) + { + if ( shared_temp[GI].error > shared_temp[GI + 32].error ) + { + shared_temp[GI].error = shared_temp[GI + 32].error; + shared_temp[GI].partition = shared_temp[GI + 32].partition; + shared_temp[GI].rotation = shared_temp[GI + 32].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 16) + { + if ( shared_temp[GI].error > shared_temp[GI + 16].error ) + { + shared_temp[GI].error = shared_temp[GI + 16].error; + shared_temp[GI].partition = shared_temp[GI + 16].partition; + shared_temp[GI].rotation = shared_temp[GI + 16].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 8) + { + if ( shared_temp[GI].error > shared_temp[GI + 8].error ) + { + shared_temp[GI].error = shared_temp[GI + 8].error; + shared_temp[GI].partition = shared_temp[GI + 8].partition; + shared_temp[GI].rotation = shared_temp[GI + 8].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + if ( shared_temp[GI].error > shared_temp[GI + 4].error ) + { + shared_temp[GI].error = shared_temp[GI + 4].error; + shared_temp[GI].partition = shared_temp[GI + 4].partition; + shared_temp[GI].rotation = shared_temp[GI + 4].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + if ( shared_temp[GI].error > shared_temp[GI + 2].error ) + { + shared_temp[GI].error = shared_temp[GI + 2].error; + shared_temp[GI].partition = shared_temp[GI + 2].partition; + shared_temp[GI].rotation = shared_temp[GI + 2].rotation; + } + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + if ( shared_temp[GI].error > shared_temp[GI + 1].error ) + { + shared_temp[GI].error = shared_temp[GI + 1].error; + shared_temp[GI].partition = shared_temp[GI + 1].partition; + shared_temp[GI].rotation = shared_temp[GI + 1].rotation; + } + + if (g_InBuff[blockID].x > shared_temp[GI].error) + { + g_OutBuff[blockID] = uint4(shared_temp[GI].error, g_mode_id, shared_temp[GI].partition, shared_temp[GI].rotation); // rotation is actually p bit for mode 0. for mode 2, rotation is always 0 + } + else + { + g_OutBuff[blockID] = g_InBuff[blockID]; + } + } +} + +[numthreads( THREAD_GROUP_SIZE, 1, 1 )] +void EncodeBlocks(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) +{ + const uint MAX_USED_THREAD = 16; + uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; + uint blockInGroup = GI / MAX_USED_THREAD; + uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; + uint threadBase = blockInGroup * MAX_USED_THREAD; + uint threadInBlock = GI - threadBase; + +#ifndef REF_DEVICE + if (blockID >= g_num_total_blocks) + { + return; + } +#endif + + uint block_y = blockID / g_num_block_x; + uint block_x = blockID - block_y * g_num_block_x; + uint base_x = block_x * BLOCK_SIZE_X; + uint base_y = block_y * BLOCK_SIZE_Y; + + uint mode = g_InBuff[blockID].y & 0x7FFFFFFF; + uint partition = g_InBuff[blockID].z; + uint index_selector = (g_InBuff[blockID].y >> 31) & 1; + uint rotation = g_InBuff[blockID].w; + + if (threadInBlock < 16) + { + uint4 pixel = clamp(uint4(g_Input.Load( uint3( base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0 ) ) * 255), 0, 255); + + if ((4 == mode) || (5 == mode)) + { + if (1 == rotation) + { + pixel.ra = pixel.ar; + } + else if (2 == rotation) + { + pixel.ga = pixel.ag; + } + else if (3 == rotation) + { + pixel.ba = pixel.ab; + } + } + + shared_temp[GI].pixel = pixel; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + uint bits = candidateSectionBit[partition]; + uint bits2 = candidateSectionBit2[partition - 64]; + + uint2x4 ep; + ep[0] = MAX_UINT; + ep[1] = MIN_UINT; + uint2x4 ep_quantized; + [unroll] + for (int ii = 2; ii >= 0; -- ii) + { + if (threadInBlock < 16) + { + uint2x4 ep; + ep[0] = MAX_UINT; + ep[1] = MIN_UINT; + + uint4 pixel = shared_temp[GI].pixel; + + uint subset_index = ( bits >> threadInBlock ) & 0x01; + uint subset_index2 = ( bits2 >> ( threadInBlock * 2 ) ) & 0x03; + if (0 == ii) + { + if ((0 == mode) || (2 == mode)) + { + if (0 == subset_index2) + { + ep[0] = ep[1] = pixel; + } + } + else if ((1 == mode) || (3 == mode) || (7 == mode)) + { + if (0 == subset_index) + { + ep[0] = ep[1] = pixel; + } + } + else if ((4 == mode) || (5 == mode) || (6 == mode)) + { + ep[0] = ep[1] = pixel; + } + } + else if (1 == ii) + { + if ((0 == mode) || (2 == mode)) + { + if (1 == subset_index2) + { + ep[0] = ep[1] = pixel; + } + } + else if ((1 == mode) || (3 == mode) || (7 == mode)) + { + if (1 == subset_index) + { + ep[0] = ep[1] = pixel; + } + } + } + else + { + if ((0 == mode) || (2 == mode)) + { + if (2 == subset_index2) + { + ep[0] = ep[1] = pixel; + } + } + } + + shared_temp[GI].endPoint_low = ep[0]; + shared_temp[GI].endPoint_high = ep[1]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 8) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 8].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 8].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 4) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 4].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 4].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 2) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 2].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 2].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + if (threadInBlock < 1) + { + shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 1].endPoint_low); + shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 1].endPoint_high); + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (ii == (int)threadInBlock) + { + ep[0] = shared_temp[threadBase].endPoint_low; + ep[1] = shared_temp[threadBase].endPoint_high; + } + } + + if (threadInBlock < 3) + { + uint2 P; + if (1 == mode) + { + P = (rotation >> threadInBlock) & 1; + } + else + { + P = uint2(rotation >> (threadInBlock * 2 + 0), rotation >> (threadInBlock * 2 + 1)) & 1; + } + + if (0 == mode) + { + ep_quantized = compress_endpoints0( ep, P ); + } + else if (1 == mode) + { + ep_quantized = compress_endpoints1( ep, P ); + } + else if (2 == mode) + { + ep_quantized = compress_endpoints2( ep ); + } + else if (3 == mode) + { + ep_quantized = compress_endpoints3( ep, P ); + } + else if (4 == mode) + { + ep_quantized = compress_endpoints4( ep ); + } + else if (5 == mode) + { + ep_quantized = compress_endpoints5( ep ); + } + else if (6 == mode) + { + ep_quantized = compress_endpoints6( ep, P ); + } + else //if (7 == mode) + { + ep_quantized = compress_endpoints7( ep, P ); + } + + int4 span = ep[1] - ep[0]; + if (mode < 4) + { + span.w = 0; + } + + if ((4 == mode) || (5 == mode)) + { + if (0 == threadInBlock) + { + int2 span_norm_sqr = uint2( dot( span.rgb, span.rgb ), span.a * span.a ); + int2 dotProduct = int2( dot( span.rgb, shared_temp[threadBase + 0].pixel.rgb - ep[0].rgb ), span.a * ( shared_temp[threadBase + 0].pixel.a - ep[0].a ) ); + if ( span_norm_sqr.x > 0 && dotProduct.x > 0 && uint( dotProduct.x * 63.49999 ) > uint( 32 * span_norm_sqr.x ) ) + { + swap(ep[0].rgb, ep[1].rgb); + swap(ep_quantized[0].rgb, ep_quantized[1].rgb); + } + if ( span_norm_sqr.y > 0 && dotProduct.y > 0 && uint( dotProduct.y * 63.49999 ) > uint( 32 * span_norm_sqr.y ) ) + { + swap(ep[0].a, ep[1].a); + swap(ep_quantized[0].a, ep_quantized[1].a); + } + } + } + else //if ((0 == mode) || (2 == mode) || (1 == mode) || (3 == mode) || (7 == mode) || (6 == mode)) + { + int p; + if (0 == threadInBlock) + { + p = 0; + } + else if (1 == threadInBlock) + { + p = candidateFixUpIndex1D[partition].x; + } + else //if (2 == threadInBlock) + { + p = candidateFixUpIndex1D[partition].y; + } + + int span_norm_sqr = dot( span, span ); + int dotProduct = dot( span, shared_temp[threadBase + p].pixel - ep[0] ); + if ( span_norm_sqr > 0 && dotProduct > 0 && uint( dotProduct * 63.49999 ) > uint( 32 * span_norm_sqr ) ) + { + swap(ep[0], ep[1]); + swap(ep_quantized[0], ep_quantized[1]); + } + } + + shared_temp[GI].endPoint_low = ep[0]; + shared_temp[GI].endPoint_high = ep[1]; + shared_temp[GI].endPoint_low_quantized = ep_quantized[0]; + shared_temp[GI].endPoint_high_quantized = ep_quantized[1]; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (threadInBlock < 16) + { + uint color_index = 0; + uint alpha_index = 0; + + uint2x4 ep; + + uint2 indexPrec; + if ((0 == mode) || (1 == mode)) + { + indexPrec = 1; + } + else if (6 == mode) + { + indexPrec = 0; + } + else if (4 == mode) + { + if (0 == index_selector) + { + indexPrec = uint2(2, 1); + } + else + { + indexPrec = uint2(1, 2); + } + } + else + { + indexPrec = 2; + } + + int subset_index; + if ((0 == mode) || (2 == mode)) + { + subset_index = (bits2 >> (threadInBlock * 2)) & 0x03; + } + else if ((1 == mode) || (3 == mode) || (7 == mode)) + { + subset_index = (bits >> threadInBlock) & 0x01; + } + else + { + subset_index = 0; + } + + ep[0] = shared_temp[threadBase + subset_index].endPoint_low; + ep[1] = shared_temp[threadBase + subset_index].endPoint_high; + + int4 span = ep[1] - ep[0]; + if (mode < 4) + { + span.w = 0; + } + + if ((4 == mode) || (5 == mode)) + { + int2 span_norm_sqr; + span_norm_sqr.x = dot( span.rgb, span.rgb ); + span_norm_sqr.y = span.a * span.a; + + int dotProduct = dot( span.rgb, shared_temp[threadBase + threadInBlock].pixel.rgb - ep[0].rgb ); + color_index = ( span_norm_sqr.x <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr.x ) ? aStep[indexPrec.x][ uint( dotProduct * 63.49999 / span_norm_sqr.x ) ] : aStep[indexPrec.x][63] ); + dotProduct = dot( span.a, shared_temp[threadBase + threadInBlock].pixel.a - ep[0].a ); + alpha_index = ( span_norm_sqr.y <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr.y ) ? aStep[indexPrec.y][ uint( dotProduct * 63.49999 / span_norm_sqr.y ) ] : aStep[indexPrec.y][63] ); + + if (index_selector) + { + swap(color_index, alpha_index); + } + } + else + { + int span_norm_sqr = dot( span, span ); + + int dotProduct = dot( span, shared_temp[threadBase + threadInBlock].pixel - ep[0] ); + color_index = ( span_norm_sqr <= 0 || dotProduct <= 0 ) ? 0 + : ( ( dotProduct < span_norm_sqr ) ? aStep[indexPrec.x][ uint( dotProduct * 63.49999 / span_norm_sqr ) ] : aStep[indexPrec.x][63] ); + } + + shared_temp[GI].error = color_index; + shared_temp[GI].mode = alpha_index; + } +#ifdef REF_DEVICE + GroupMemoryBarrierWithGroupSync(); +#endif + + if (0 == threadInBlock) + { + uint4 block; + if (0 == mode) + { + block_package0( block, partition, threadBase ); + } + else if (1 == mode) + { + block_package1( block, partition, threadBase ); + } + else if (2 == mode) + { + block_package2( block, partition, threadBase ); + } + else if (3 == mode) + { + block_package3( block, partition, threadBase ); + } + else if (4 == mode) + { + block_package4( block, rotation, index_selector, threadBase ); + } + else if (5 == mode) + { + block_package5( block, rotation, threadBase ); + } + else if (6 == mode) + { + block_package6( block, threadBase ); + } + else //if (7 == mode) + { + block_package7( block, partition, threadBase ); + } + + g_OutBuff[blockID] = block; + } +} + +//uint4 truncate_and_round( uint4 color, uint bits) +//{ +// uint precisionMask = ((1 << bits) - 1) << (8 - bits); +// uint precisionHalf = (1 << (7-bits)); +// +// uint4 truncated = color & precisionMask; +// uint4 rounded = min(255, color + precisionHalf) & precisionMask; +// +// uint4 truncated_bak = truncated = truncated | (truncated >> bits); +// uint4 rounded_bak = rounded = rounded | (rounded >> bits); +// +// uint4 color_bak = color; +// +// Ensure_A_Is_Larger( rounded, color ); +// Ensure_A_Is_Larger( truncated, color_bak ); +// +// if (dot(rounded - color, rounded - color) < +// dot(truncated - color_bak, truncated - color_bak)) +// { +// return rounded_bak; +// } +// else +// { +// return truncated_bak; +// } +//} + +uint4 quantize( uint4 color, uint uPrec ) +{ + return (((color << 8) + color) * ((1 << uPrec) - 1) + 32768) >> 16; +} + +uint4 unquantize( uint4 color, uint uPrec ) +{ + color = color << (8 - uPrec); + return color | (color >> uPrec); +} + +uint2x4 compress_endpoints0( inout uint2x4 endPoint, uint2 P ) +{ + uint2x4 quantized; + [unroll] for ( uint j = 0; j < 2; j ++ ) + { + quantized[j].rgb = quantize(endPoint[j].rgbb, 5).rgb & 0xFFFFFFFE; + quantized[j].rgb |= P[j]; + quantized[j].a = 0xFF; + + endPoint[j].rgb = unquantize(quantized[j].rgbb, 5).rgb; + endPoint[j].a = 0xFF; + + quantized[j] <<= 3; + } + return quantized; +} +uint2x4 compress_endpoints1( inout uint2x4 endPoint, uint2 P ) +{ + uint2x4 quantized; + [unroll] for ( uint j = 0; j < 2; j ++ ) + { + quantized[j].rgb = quantize(endPoint[j].rgbb, 7).rgb & 0xFFFFFFFE; + quantized[j].rgb |= P[j]; + quantized[j].a = 0xFF; + + endPoint[j].rgb = unquantize(quantized[j].rgbb, 7).rgb; + endPoint[j].a = 0xFF; + + quantized[j] <<= 1; + } + return quantized; +} +uint2x4 compress_endpoints2( inout uint2x4 endPoint ) +{ + uint2x4 quantized; + [unroll] for ( uint j = 0; j < 2; j ++ ) + { + quantized[j].rgb = quantize(endPoint[j].rgbb, 5).rgb; + quantized[j].a = 0xFF; + + endPoint[j].rgb = unquantize(quantized[j].rgbb, 5).rgb; + endPoint[j].a = 0xFF; + + quantized[j] <<= 3; + } + return quantized; +} +uint2x4 compress_endpoints3( inout uint2x4 endPoint, uint2 P ) +{ + uint2x4 quantized; + for ( uint j = 0; j < 2; j ++ ) + { + quantized[j].rgb = endPoint[j].rgb & 0xFFFFFFFE; + quantized[j].rgb |= P[j]; + quantized[j].a = 0xFF; + + endPoint[j].rgb = quantized[j].rgb; + endPoint[j].a = 0xFF; + } + return quantized; +} +uint2x4 compress_endpoints4( inout uint2x4 endPoint ) +{ + uint2x4 quantized; + [unroll] for ( uint j = 0; j < 2; j ++ ) + { + quantized[j].rgb = quantize(endPoint[j].rgbb, 5).rgb; + quantized[j].a = quantize(endPoint[j].a, 6).r; + + endPoint[j].rgb = unquantize(quantized[j].rgbb, 5).rgb; + endPoint[j].a = unquantize(quantized[j].a, 6).r; + + quantized[j].rgb <<= 3; + quantized[j].a <<= 2; + } + return quantized; +} +uint2x4 compress_endpoints5( inout uint2x4 endPoint ) +{ + uint2x4 quantized; + [unroll] for ( uint j = 0; j < 2; j ++ ) + { + quantized[j].rgb = quantize(endPoint[j].rgbb, 7).rgb; + quantized[j].a = endPoint[j].a; + + endPoint[j].rgb = unquantize(quantized[j].rgbb, 7).rgb; + // endPoint[j].a Alpha is full precision + + quantized[j].rgb <<= 1; + } + return quantized; +} +uint2x4 compress_endpoints6( inout uint2x4 endPoint, uint2 P ) +{ + uint2x4 quantized; + for ( uint j = 0; j < 2; j ++ ) + { + quantized[j] = endPoint[j] & 0xFFFFFFFE; + quantized[j] |= P[j]; + + endPoint[j] = quantized[j]; + } + return quantized; +} +uint2x4 compress_endpoints7( inout uint2x4 endPoint, uint2 P ) +{ + uint2x4 quantized; + [unroll] for ( uint j = 0; j < 2; j ++ ) + { + quantized[j] = quantize(endPoint[j], 6) & 0xFFFFFFFE; + quantized[j] |= P[j]; + + endPoint[j] = unquantize(quantized[j], 6); + } + return quantized << 2; +} + +#define get_end_point_l(subset) shared_temp[threadBase + subset].endPoint_low_quantized +#define get_end_point_h(subset) shared_temp[threadBase + subset].endPoint_high_quantized +#define get_color_index(index) shared_temp[threadBase + index].error +#define get_alpha_index(index) shared_temp[threadBase + index].mode + +void block_package0( out uint4 block, uint partition, uint threadBase ) +{ + block.x = 0x01 | ( (partition - 64) << 1 ) + | ( ( get_end_point_l(0).r & 0xF0 ) << 1 ) | ( ( get_end_point_h(0).r & 0xF0 ) << 5 ) + | ( ( get_end_point_l(1).r & 0xF0 ) << 9 ) | ( ( get_end_point_h(1).r & 0xF0 ) << 13 ) + | ( ( get_end_point_l(2).r & 0xF0 ) << 17 ) | ( ( get_end_point_h(2).r & 0xF0 ) << 21 ) + | ( ( get_end_point_l(0).g & 0xF0 ) << 25 ); + block.y = ( ( get_end_point_l(0).g & 0xF0 ) >> 7 ) | ( ( get_end_point_h(0).g & 0xF0 ) >> 3 ) + | ( ( get_end_point_l(1).g & 0xF0 ) << 1 ) | ( ( get_end_point_h(1).g & 0xF0 ) << 5 ) + | ( ( get_end_point_l(2).g & 0xF0 ) << 9 ) | ( ( get_end_point_h(2).g & 0xF0 ) << 13 ) + | ( ( get_end_point_l(0).b & 0xF0 ) << 17 ) | ( ( get_end_point_h(0).b & 0xF0 ) << 21 ) + | ( ( get_end_point_l(1).b & 0xF0 ) << 25 ); + block.z = ( ( get_end_point_l(1).b & 0xF0 ) >> 7 ) | ( ( get_end_point_h(1).b & 0xF0 ) >> 3 ) + | ( ( get_end_point_l(2).b & 0xF0 ) << 1 ) | ( ( get_end_point_h(2).b & 0xF0 ) << 5 ) + | ( ( get_end_point_l(0).r & 0x08 ) << 10 ) | ( ( get_end_point_h(0).r & 0x08 ) << 11 ) + | ( ( get_end_point_l(1).r & 0x08 ) << 12 ) | ( ( get_end_point_h(1).r & 0x08 ) << 13 ) + | ( ( get_end_point_l(2).r & 0x08 ) << 14 ) | ( ( get_end_point_h(2).r & 0x08 ) << 15 ) + | ( get_color_index(0) << 19 ); + block.w = 0; + uint i = 1; + for ( ; i <= min( candidateFixUpIndex1DOrdered[partition][0], 4 ); i ++ ) + { + block.z |= get_color_index(i) << ( i * 3 + 18 ); + } + if ( candidateFixUpIndex1DOrdered[partition][0] < 4 ) //i = 4 + { + block.z |= get_color_index(4) << 29; + i += 1; + } + else //i = 5 + { + block.w |= ( get_color_index(4) & 0x04 ) >> 2; + for ( ; i <= candidateFixUpIndex1DOrdered[partition][0]; i ++ ) + block.w |= get_color_index(i) << ( i * 3 - 14 ); + } + for ( ; i <= candidateFixUpIndex1DOrdered[partition][1]; i ++ ) + { + block.w |= get_color_index(i) << ( i * 3 - 15 ); + } + for ( ; i < 16; i ++ ) + { + block.w |= get_color_index(i) << ( i * 3 - 16 ); + } +} +void block_package1( out uint4 block, uint partition, uint threadBase ) +{ + block.x = 0x02 | ( partition << 2 ) + | ( ( get_end_point_l(0).r & 0xFC ) << 6 ) | ( ( get_end_point_h(0).r & 0xFC ) << 12 ) + | ( ( get_end_point_l(1).r & 0xFC ) << 18 ) | ( ( get_end_point_h(1).r & 0xFC ) << 24 ); + block.y = ( ( get_end_point_l(0).g & 0xFC ) >> 2 ) | ( ( get_end_point_h(0).g & 0xFC ) << 4 ) + | ( ( get_end_point_l(1).g & 0xFC ) << 10 ) | ( ( get_end_point_h(1).g & 0xFC ) << 16 ) + | ( ( get_end_point_l(0).b & 0xFC ) << 22 ) | ( ( get_end_point_h(0).b & 0xFC ) << 28 ); + block.z = ( ( get_end_point_h(0).b & 0xFC ) >> 4 ) | ( ( get_end_point_l(1).b & 0xFC ) << 2 ) + | ( ( get_end_point_h(1).b & 0xFC ) << 8 ) + | ( ( get_end_point_l(0).r & 0x02 ) << 15 ) | ( ( get_end_point_l(1).r & 0x02 ) << 16 ) + | ( get_color_index(0) << 18 ); + if ( candidateFixUpIndex1DOrdered[partition][0] == 15 ) + { + block.w = (get_color_index(15) << 30) | (get_color_index(14) << 27) | (get_color_index(13) << 24) | (get_color_index(12) << 21) | (get_color_index(11) << 18) | (get_color_index(10) << 15) + | (get_color_index(9) << 12) | (get_color_index(8) << 9) | (get_color_index(7) << 6) | (get_color_index(6) << 3) | get_color_index(5); + block.z |= (get_color_index(4) << 29) | (get_color_index(3) << 26) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); + } + else if ( candidateFixUpIndex1DOrdered[partition][0] == 2 ) + { + block.w = (get_color_index(15) << 29) | (get_color_index(14) << 26) | (get_color_index(13) << 23) | (get_color_index(12) << 20) | (get_color_index(11) << 17) | (get_color_index(10) << 14) + | (get_color_index(9) << 11) | (get_color_index(8) << 8) | (get_color_index(7) << 5) | (get_color_index(6) << 2) | (get_color_index(5) >> 1); + block.z |= (get_color_index(5) << 31) | (get_color_index(4) << 28) | (get_color_index(3) << 25) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); + } + else if ( candidateFixUpIndex1DOrdered[partition][0] == 8 ) + { + block.w = (get_color_index(15) << 29) | (get_color_index(14) << 26) | (get_color_index(13) << 23) | (get_color_index(12) << 20) | (get_color_index(11) << 17) | (get_color_index(10) << 14) + | (get_color_index(9) << 11) | (get_color_index(8) << 9) | (get_color_index(7) << 6) | (get_color_index(6) << 3) | get_color_index(5); + block.z |= (get_color_index(4) << 29) | (get_color_index(3) << 26) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); + } + else //candidateFixUpIndex1DOrdered[partition] == 6 + { + block.w = (get_color_index(15) << 29) | (get_color_index(14) << 26) | (get_color_index(13) << 23) | (get_color_index(12) << 20) | (get_color_index(11) << 17) | (get_color_index(10) << 14) + | (get_color_index(9) << 11) | (get_color_index(8) << 8) | (get_color_index(7) << 5) | (get_color_index(6) << 3) | get_color_index(5); + block.z |= (get_color_index(4) << 29) | (get_color_index(3) << 26) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); + } +} +void block_package2( out uint4 block, uint partition, uint threadBase ) +{ + block.x = 0x04 | ( (partition - 64) << 3 ) + | ( ( get_end_point_l(0).r & 0xF8 ) << 6 ) | ( ( get_end_point_h(0).r & 0xF8 ) << 11 ) + | ( ( get_end_point_l(1).r & 0xF8 ) << 16 ) | ( ( get_end_point_h(1).r & 0xF8 ) << 21 ) + | ( ( get_end_point_l(2).r & 0xF8 ) << 26 ); + block.y = ( ( get_end_point_l(2).r & 0xF8 ) >> 6 ) | ( ( get_end_point_h(2).r & 0xF8 ) >> 1 ) + | ( ( get_end_point_l(0).g & 0xF8 ) << 4 ) | ( ( get_end_point_h(0).g & 0xF8 ) << 9 ) + | ( ( get_end_point_l(1).g & 0xF8 ) << 14 ) | ( ( get_end_point_h(1).g & 0xF8 ) << 19 ) + | ( ( get_end_point_l(2).g & 0xF8 ) << 24 ); + block.z = ( ( get_end_point_h(2).g & 0xF8 ) >> 3 ) | ( ( get_end_point_l(0).b & 0xF8 ) << 2 ) + | ( ( get_end_point_h(0).b & 0xF8 ) << 7 ) | ( ( get_end_point_l(1).b & 0xF8 ) << 12 ) + | ( ( get_end_point_h(1).b & 0xF8 ) << 17 ) | ( ( get_end_point_l(2).b & 0xF8 ) << 22 ) + | ( ( get_end_point_h(2).b & 0xF8 ) << 27 ); + block.w = ( ( get_end_point_h(2).b & 0xF8 ) >> 5 ) + | ( get_color_index(0) << 3 ); + uint i = 1; + for ( ; i <= candidateFixUpIndex1DOrdered[partition][0]; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 + 2 ); + } + for ( ; i <= candidateFixUpIndex1DOrdered[partition][1]; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 + 1 ); + } + for ( ; i < 16; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 ); + } +} +void block_package3( out uint4 block, uint partition, uint threadBase ) +{ + block.x = 0x08 | ( partition << 4 ) + | ( ( get_end_point_l(0).r & 0xFE ) << 9 ) | ( ( get_end_point_h(0).r & 0xFE ) << 16 ) + | ( ( get_end_point_l(1).r & 0xFE ) << 23 ) | ( ( get_end_point_h(1).r & 0xFE ) << 30 ); + block.y = ( ( get_end_point_h(1).r & 0xFE ) >> 2 ) | ( ( get_end_point_l(0).g & 0xFE ) << 5 ) + | ( ( get_end_point_h(0).g & 0xFE ) << 12 ) | ( ( get_end_point_l(1).g & 0xFE ) << 19 ) + | ( ( get_end_point_h(1).g & 0xFE ) << 26 ); + block.z = ( ( get_end_point_h(1).g & 0xFE ) >> 6 ) | ( ( get_end_point_l(0).b & 0xFE ) << 1 ) + | ( ( get_end_point_h(0).b & 0xFE ) << 8 ) | ( ( get_end_point_l(1).b & 0xFE ) << 15 ) + | ( ( get_end_point_h(1).b & 0xFE ) << 22 ) + | ( ( get_end_point_l(0).r & 0x01 ) << 30 ) | ( ( get_end_point_h(0).r & 0x01 ) << 31 ); + block.w = ( ( get_end_point_l(1).r & 0x01 ) << 0 ) | ( ( get_end_point_h(1).r & 0x01 ) << 1 ) + | ( get_color_index(0) << 2 ); + uint i = 1; + for ( ; i <= candidateFixUpIndex1DOrdered[partition][0]; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 + 1 ); + } + for ( ; i < 16; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 ); + } +} +void block_package4( out uint4 block, uint rotation, uint index_selector, uint threadBase ) +{ + block.x = 0x10 | ( (rotation & 3) << 5 ) | ( (index_selector & 1) << 7 ) + | ( ( get_end_point_l(0).r & 0xF8 ) << 5 ) | ( ( get_end_point_h(0).r & 0xF8 ) << 10 ) + | ( ( get_end_point_l(0).g & 0xF8 ) << 15 ) | ( ( get_end_point_h(0).g & 0xF8 ) << 20 ) + | ( ( get_end_point_l(0).b & 0xF8 ) << 25 ); + + block.y = ( ( get_end_point_l(0).b & 0xF8 ) >> 7 ) | ( ( get_end_point_h(0).b & 0xF8 ) >> 2 ) + | ( ( get_end_point_l(0).a & 0xFC ) << 4 ) | ( ( get_end_point_h(0).a & 0xFC ) << 10 ) + | ( (get_color_index(0) & 1) << 18 ) | ( get_color_index(1) << 19 ) | ( get_color_index(2) << 21 ) | ( get_color_index(3) << 23 ) + | ( get_color_index(4) << 25 ) | ( get_color_index(5) << 27 ) | ( get_color_index(6) << 29 ) | ( get_color_index(7) << 31 ); + + block.z = ( get_color_index(7) >> 1 ) | ( get_color_index(8) << 1 ) | ( get_color_index(9) << 3 ) | ( get_color_index(10)<< 5 ) + | ( get_color_index(11)<< 7 ) | ( get_color_index(12)<< 9 ) | ( get_color_index(13)<< 11 ) | ( get_color_index(14)<< 13 ) + | ( get_color_index(15)<< 15 ) | ( (get_alpha_index(0) & 3) << 17 ) | ( get_alpha_index(1) << 19 ) | ( get_alpha_index(2) << 22 ) + | ( get_alpha_index(3) << 25 ) | ( get_alpha_index(4) << 28 ) | ( get_alpha_index(5) << 31 ); + + block.w = ( get_alpha_index(5) >> 1 ) | ( get_alpha_index(6) << 2 ) | ( get_alpha_index(7) << 5 ) | ( get_alpha_index(8) << 8 ) + | ( get_alpha_index(9) << 11 ) | ( get_alpha_index(10)<< 14 ) | ( get_alpha_index(11)<< 17 ) | ( get_alpha_index(12)<< 20 ) + | ( get_alpha_index(13)<< 23 ) | ( get_alpha_index(14)<< 26 ) | ( get_alpha_index(15)<< 29 ); +} +void block_package5( out uint4 block, uint rotation, uint threadBase ) +{ + block.x = 0x20 | ( rotation << 6 ) + | ( ( get_end_point_l(0).r & 0xFE ) << 7 ) | ( ( get_end_point_h(0).r & 0xFE ) << 14 ) + | ( ( get_end_point_l(0).g & 0xFE ) << 21 ) | ( ( get_end_point_h(0).g & 0xFE ) << 28 ); + block.y = ( ( get_end_point_h(0).g & 0xFE ) >> 4 ) | ( ( get_end_point_l(0).b & 0xFE ) << 3 ) + | ( ( get_end_point_h(0).b & 0xFE ) << 10 ) | ( get_end_point_l(0).a << 18 ) | ( get_end_point_h(0).a << 26 ); + block.z = ( get_end_point_h(0).a >> 6 ) + | ( get_color_index(0) << 2 ) | ( get_color_index(1) << 3 ) | ( get_color_index(2) << 5 ) | ( get_color_index(3) << 7 ) + | ( get_color_index(4) << 9 ) | ( get_color_index(5) << 11 ) | ( get_color_index(6) << 13 ) | ( get_color_index(7) << 15 ) + | ( get_color_index(8) << 17 ) | ( get_color_index(9) << 19 ) | ( get_color_index(10)<< 21 ) | ( get_color_index(11)<< 23 ) + | ( get_color_index(12)<< 25 ) | ( get_color_index(13)<< 27 ) | ( get_color_index(14)<< 29 ) | ( get_color_index(15)<< 31 ); + block.w = ( get_color_index(15)>> 1 ) | ( get_alpha_index(0) << 1 ) | ( get_alpha_index(1) << 2 ) | ( get_alpha_index(2) << 4 ) + | ( get_alpha_index(3) << 6 ) | ( get_alpha_index(4) << 8 ) | ( get_alpha_index(5) << 10 ) | ( get_alpha_index(6) << 12 ) + | ( get_alpha_index(7) << 14 ) | ( get_alpha_index(8) << 16 ) | ( get_alpha_index(9) << 18 ) | ( get_alpha_index(10)<< 20 ) + | ( get_alpha_index(11)<< 22 ) | ( get_alpha_index(12)<< 24 ) | ( get_alpha_index(13)<< 26 ) | ( get_alpha_index(14)<< 28 ) + | ( get_alpha_index(15)<< 30 ); +} +void block_package6( out uint4 block, uint threadBase ) +{ + block.x = 0x40 + | ( ( get_end_point_l(0).r & 0xFE ) << 6 ) | ( ( get_end_point_h(0).r & 0xFE ) << 13 ) + | ( ( get_end_point_l(0).g & 0xFE ) << 20 ) | ( ( get_end_point_h(0).g & 0xFE ) << 27 ); + block.y = ( ( get_end_point_h(0).g & 0xFE ) >> 5 ) | ( ( get_end_point_l(0).b & 0xFE ) << 2 ) + | ( ( get_end_point_h(0).b & 0xFE ) << 9 ) | ( ( get_end_point_l(0).a & 0xFE ) << 16 ) + | ( ( get_end_point_h(0).a & 0xFE ) << 23 ) + | ( get_end_point_l(0).r & 0x01 ) << 31; + block.z = ( get_end_point_h(0).r & 0x01 ) + | ( get_color_index(0) << 1 ) | ( get_color_index(1) << 4 ) | ( get_color_index(2) << 8 ) | ( get_color_index(3) << 12 ) + | ( get_color_index(4) << 16 ) | ( get_color_index(5) << 20 ) | ( get_color_index(6) << 24 ) | ( get_color_index(7) << 28 ); + block.w = ( get_color_index(8) << 0 ) | ( get_color_index(9) << 4 ) | ( get_color_index(10)<< 8 ) | ( get_color_index(11)<< 12 ) + | ( get_color_index(12)<< 16 ) | ( get_color_index(13)<< 20 ) | ( get_color_index(14)<< 24 ) | ( get_color_index(15)<< 28 ); +} +void block_package7( out uint4 block, uint partition, uint threadBase ) +{ + block.x = 0x80 | ( partition << 8 ) + | ( ( get_end_point_l(0).r & 0xF8 ) << 11 ) | ( ( get_end_point_h(0).r & 0xF8 ) << 16 ) + | ( ( get_end_point_l(1).r & 0xF8 ) << 21 ) | ( ( get_end_point_h(1).r & 0xF8 ) << 26 ); + block.y = ( ( get_end_point_h(1).r & 0xF8 ) >> 6 ) | ( ( get_end_point_l(0).g & 0xF8 ) >> 1 ) + | ( ( get_end_point_h(0).g & 0xF8 ) << 4 ) | ( ( get_end_point_l(1).g & 0xF8 ) << 9 ) + | ( ( get_end_point_h(1).g & 0xF8 ) << 14 ) | ( ( get_end_point_l(0).b & 0xF8 ) << 19 ) + | ( ( get_end_point_h(0).b & 0xF8 ) << 24 ); + block.z = ( ( get_end_point_l(1).b & 0xF8 ) >> 3 ) | ( ( get_end_point_h(1).b & 0xF8 ) << 2 ) + | ( ( get_end_point_l(0).a & 0xF8 ) << 7 ) | ( ( get_end_point_h(0).a & 0xF8 ) << 12 ) + | ( ( get_end_point_l(1).a & 0xF8 ) << 17 ) | ( ( get_end_point_h(1).a & 0xF8 ) << 22 ) + | ( ( get_end_point_l(0).r & 0x04 ) << 28 ) | ( ( get_end_point_h(0).r & 0x04 ) << 29 ); + block.w = ( ( get_end_point_l(1).r & 0x04 ) >> 2 ) | ( ( get_end_point_h(1).r & 0x04 ) >> 1 ) + | ( get_color_index(0) << 2 ); + uint i = 1; + for ( ; i <= candidateFixUpIndex1DOrdered[partition][0]; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 + 1 ); + } + for ( ; i < 16; i ++ ) + { + block.w |= get_color_index(i) << ( i * 2 ); + } +} \ No newline at end of file diff --git a/extern/CMP_Core/shaders/BCn_Common_Kernel.h b/extern/CMP_Core/shaders/BCn_Common_Kernel.h new file mode 100644 index 00000000..92b04791 --- /dev/null +++ b/extern/CMP_Core/shaders/BCn_Common_Kernel.h @@ -0,0 +1,2515 @@ +//============================================================================= +// Copyright (c) 2018-2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef _BCn_Common_Kernel_H +#define _BCn_Common_Kernel_H + +#pragma warning(disable:4505) // disable warnings on unreferenced local function has been removed + +#include "Common_Def.h" + +//----------------------------------------------------------------------- +// When build is for CPU, we have some missing API calls common to GPU +// Use CPU CMP_Core replacements +//----------------------------------------------------------------------- +#if defined(ASPM_GPU) || defined(ASPM_HLSL) || defined(ASPM_OPENCL) +#define ALIGN_16 +#else +#include INC_cmp_math_func +#if defined(WIN32) || defined(_WIN64) +#define ALIGN_16 __declspec(align(16)) +#else // !WIN32 && !_WIN64 +#define ALIGN_16 +#endif // !WIN32 && !_WIN64 +#endif + +#ifdef ASPM_HLSL +#define fabs(x) abs(x) +#endif + +#define DXTC_OFFSET_ALPHA 0 +#define DXTC_OFFSET_RGB 2 + +#define BC1CompBlockSize 8 + +#define RC 2 +#define GC 1 +#define BC 0 +#define AC 3 + +/* +Channel Bits +*/ +#define RGBA8888_CHANNEL_A 3 +#define RGBA8888_CHANNEL_R 2 +#define RGBA8888_CHANNEL_G 1 +#define RGBA8888_CHANNEL_B 0 +#define RGBA8888_OFFSET_A (RGBA8888_CHANNEL_A * 8) +#define RGBA8888_OFFSET_R (RGBA8888_CHANNEL_R * 8) +#define RGBA8888_OFFSET_G (RGBA8888_CHANNEL_G * 8) +#define RGBA8888_OFFSET_B (RGBA8888_CHANNEL_B * 8) + +#ifndef MAX_ERROR +#define MAX_ERROR 128000.f +#endif + +#define MAX_BLOCK 64 +#define MAX_POINTS 16 +#define BLOCK_SIZE MAX_BLOCK +#define NUM_CHANNELS 4 +#define NUM_ENDPOINTS 2 +#define BLOCK_SIZE_4X4 16 +#define CMP_ALPHA_RAMP 8 // Number of Ramp Points used for Alpha Channels in BC5 + +#define ConstructColour(r, g, b) (((r) << 11) | ((g) << 5) | (b)) + +#define BYTEPP 4 +#define CMP_QUALITY1 0.10f +#define CMP_QUALITY2 0.601f +#define POS(x,y) (pos_on_axis[(x)+(y)*4]) + +// Find the first approximation of the line +// Assume there is a linear relation +// Z = a * X_In +// Z = b * Y_In +// Find a,b to minimize MSE between Z and Z_In +#define EPS (2.f / 255.f) * (2.f / 255.f) +#define EPS2 3.f * (2.f / 255.f) * (2.f / 255.f) + +// Grid precision +#define PIX_GRID 8 + +#define BYTE_MASK 0x00ff + +#define SCH_STPS 3 // number of search steps to make at each end of interval +static CMP_CONSTANT CGU_FLOAT sMvF[] = {0.f, -1.f, 1.f, -2.f, 2.f, -3.f, + 3.f, -4.f, 4.f, -5.f, 5.f, -6.f, + 6.f, -7.f, 7.f, -8.f, 8.f}; + +#ifndef GBL_SCH_STEP +#define GBL_SCH_STEP_MXS 0.018f +#define GBL_SCH_EXT_MXS 0.1f +#define LCL_SCH_STEP_MXS 0.6f +#define GBL_SCH_STEP_MXQ 0.0175f +#define GBL_SCH_EXT_MXQ 0.154f +#define LCL_SCH_STEP_MXQ 0.45f + +#define GBL_SCH_STEP GBL_SCH_STEP_MXS +#define GBL_SCH_EXT GBL_SCH_EXT_MXS +#define LCL_SCH_STEP LCL_SCH_STEP_MXS +#endif + +typedef struct { + CGU_UINT32 data; + CGU_UINT32 index; +} CMP_di; + +typedef struct { + CGU_FLOAT data; + CGU_UINT32 index; +} CMP_df; + +typedef struct { + // user setable + CGU_FLOAT m_fquality; + CGU_FLOAT m_fChannelWeights[3]; + CGU_BOOL m_bUseChannelWeighting; + CGU_BOOL m_bUseAdaptiveWeighting; + CGU_BOOL m_bUseFloat; + CGU_BOOL m_b3DRefinement; + CGU_BOOL m_bUseAlpha; + CGU_BOOL m_bIsSRGB; // Use Linear to SRGB color conversion used in BC1, default is false + CGU_BOOL m_bIsSNORM; // Reserved for support in BC4&5, currently always false! + CGU_UINT32 m_nRefinementSteps; + CGU_UINT32 m_nAlphaThreshold; + CGU_BOOL m_mapDecodeRGBA; + CGU_UINT32 m_src_width; + CGU_UINT32 m_src_height; +} CMP_BC15Options; + +typedef struct { + CGU_Vec3f Color0; + CGU_Vec3f Color1; +} CMP_EndPoints; + +// gets 2 bit values from a 32 bit variable at the kth index range (0..15) +// same as get values (0..3) from CGU_UINT32 variable[16] +static CGU_UINT32 cmp_get2Bit32(CGU_UINT32 value, CGU_UINT32 indexPos) +{ + return (value >> (indexPos*2))&0x3; +} + +// sets 2 bit values into a 32 bit variable +// same as set values (0..3) to CGU_UINT32 variable[16] +static CGU_UINT32 cmp_set2Bit32(CGU_UINT32 value, CGU_UINT32 indexPos) +{ + return ((value&0x3) << (indexPos*2)); +} + +static CGU_UINT32 cmp_constructColor(CGU_UINT32 R,CGU_UINT32 G, CGU_UINT32 B) +{ + return (((R & 0x000000F8) << 8) | ((G & 0x000000FC) << 3) | ((B & 0x000000F8) >> 3) ); +} + +static CGU_Vec3f cmp_powVec3f(CGU_Vec3f color, CGU_FLOAT ex) +{ +#ifdef ASPM_GPU + return pow(color, ex); +#else + CGU_Vec3f ColorSrgbPower; + ColorSrgbPower.x = pow(color.x, ex); + ColorSrgbPower.y = pow(color.y, ex); + ColorSrgbPower.z = pow(color.z, ex); + return ColorSrgbPower; +#endif +} + +static CGU_Vec3f cmp_clamp3f(CGU_Vec3f value, CGU_FLOAT minValue, CGU_FLOAT maxValue) +{ +#ifdef ASPM_GPU + return clamp(value,minValue,maxValue); +#else + CGU_Vec3f revalue = value; + if (revalue.x > maxValue) revalue.x = maxValue; + else + if (revalue.x < minValue) revalue.x = minValue; + + if (revalue.y > maxValue) revalue.y = maxValue; + else + if (revalue.y < minValue) revalue.y = minValue; + + if (revalue.z > maxValue) revalue.z = maxValue; + else + if (revalue.z < minValue) revalue.z = minValue; + return revalue; +#endif +} + +static CGU_Vec3f cmp_saturate(CGU_Vec3f value) +{ +#ifdef ASPM_HLSL + return saturate(value); +#else + return cmp_clamp3f(value,0.0f,1.0f); +#endif +} + +// Helper functions to cut precision of floats +// Prec is a power of 10 value from 1,10,100,...,10000... INT MAX power 10 +static CGU_BOOL cmp_compareprecision(CGU_FLOAT f1,CGU_FLOAT f2,CGU_INT Prec) +{ + CGU_INT scale1 = (CGU_INT)(f1*Prec); + CGU_INT scale2 = (CGU_INT)(f2*Prec); + return(scale1 == scale2); +} + +// Helper function to compare floats to a set precision +static CGU_FLOAT cmp_getfloatprecision(CGU_FLOAT f1,CGU_INT Prec) +{ + CGU_INT scale1 = (CGU_INT)(f1*Prec); + return((CGU_FLOAT)(scale1)/Prec); +} + +static CGU_FLOAT cmp_linearToSrgbf(CMP_IN CGU_FLOAT Color) +{ +if (Color <= 0.0f) return (0.0f); +if (Color >= 1.0f) return (1.0f); +// standard : 0.0031308f +if (Color <= 0.00313066844250063) return (Color*12.92f); +return(pow(Color, 1.0f/2.4f) * 1.055f - 0.055f); +} + + +static CGU_Vec3f cmp_linearToSrgb(CMP_IN CGU_Vec3f Color) +{ + Color.x = cmp_linearToSrgbf(Color.x); + Color.y = cmp_linearToSrgbf(Color.y); + Color.z = cmp_linearToSrgbf(Color.z); + return Color; +} + + +static CGU_FLOAT cmp_srgbToLinearf(CMP_IN CGU_FLOAT Color) +{ + if (Color <= 0.0f) return (0.0f); + if (Color >= 1.0f) return (1.0f); + // standard 0.04045f + if (Color <= 0.0404482362771082) return (Color/12.92f); + return pow((Color+0.055f)/1.055f, 2.4f); +} + +static CGU_Vec3f cmp_srgbToLinear(CMP_IN CGU_Vec3f Color) +{ + Color.x = cmp_srgbToLinearf(Color.x); + Color.y = cmp_srgbToLinearf(Color.y); + Color.z = cmp_srgbToLinearf(Color.z); + return Color; +} + +inline CGU_Vec3f cmp_min3f( CMP_IN CGU_Vec3f value1, CMP_IN CGU_Vec3f value2) +{ +#ifdef ASPM_GPU + return min(value1,value2); +#else + CGU_Vec3f res; + res.x = min(value1.x, value2.x); + res.y = min(value1.y, value2.y); + res.z = min(value1.z, value2.z); + return res; +#endif +} + +inline CGU_Vec3f cmp_max3f( CMP_IN CGU_Vec3f value1, CMP_IN CGU_Vec3f value2) +{ +#ifdef ASPM_GPU + return max(value1,value2); +#else + CGU_Vec3f res; + res.x = max(value1.x, value2.x); + res.y = max(value1.y, value2.y); + res.z = max(value1.z, value2.z); + return res; +#endif +} + +static CGU_FLOAT cmp_getIndicesRGB(CMP_INOUT CGU_UINT32 CMP_PTRINOUT cmpindex, const CGU_Vec3f block[16], CGU_Vec3f minColor, CGU_Vec3f maxColor,CGU_BOOL getErr) +{ + CGU_UINT32 PackedIndices = 0; + CGU_FLOAT err = 0.0f; + CGU_Vec3f cn[4]; + CGU_FLOAT minDistance; + + if (getErr) { + // remap to BC1 spec for decoding offsets, + // where cn[0] > cn[1] Max Color = index 0, 2/3 offset =index 2, 1/3 offset = index 3, Min Color = index 1 + cn[0] = maxColor; + cn[1] = minColor; + cn[2] = cn[0]*2.0f/3.0f + cn[1]*1.0f/3.0f; + cn[3] = cn[0]*1.0f/3.0f + cn[1]*2.0f/3.0f; + } + + CGU_FLOAT Scale = 3.f / dot(minColor - maxColor, minColor - maxColor); + CGU_Vec3f ScaledRange = (minColor - maxColor) * Scale; + CGU_FLOAT Bias = (dot(maxColor, maxColor) - dot(maxColor, minColor)) * Scale; + CGU_INT indexMap[4] = {0,2,3,1}; // mapping based on BC1 Spec for color0 > color1 + CGU_UINT32 index; + CGU_FLOAT diff; + + for (CGU_UINT32 i = 0; i < 16; i++) + { + // Get offset from base scale + diff = dot(block[i], ScaledRange) + Bias; + index = ((CGU_UINT32)round(diff))&0x3; + + // remap linear offset to spec offset + index = indexMap[index]; + + // use err calc for use in higher quality code + if (getErr) + { + minDistance = dot(block[i] - cn[index],block[i] - cn[index]); + err += minDistance; + } + + // Map the 2 bit index into compress 32 bit block + if (index) + PackedIndices |= (index << (2*i)); + + } + + if (getErr) + err = err * 0.0208333f; + + CMP_PTRINOUT cmpindex = PackedIndices; + return err; +} + +//---------------------------------------- Common Utility Code ------------------------------------------------------- + +#ifndef ASPM_GPU +static void SetDefaultBC15Options(CMP_BC15Options *BC15Options) +{ + if (BC15Options) { + BC15Options->m_fquality = 1.0f; + BC15Options->m_bUseChannelWeighting = false; + BC15Options->m_bUseAdaptiveWeighting= false; + BC15Options->m_fChannelWeights[0] = 0.3086f; + BC15Options->m_fChannelWeights[1] = 0.6094f; + BC15Options->m_fChannelWeights[2] = 0.0820f; + BC15Options->m_nAlphaThreshold = 128; + BC15Options->m_bUseFloat = false; + BC15Options->m_b3DRefinement = false; + BC15Options->m_bUseAlpha = false; + BC15Options->m_bIsSNORM = false; + BC15Options->m_bIsSRGB = false; + BC15Options->m_nRefinementSteps = 1; + BC15Options->m_src_width = 4; + BC15Options->m_src_height = 4; +#ifdef CMP_SET_BC13_DECODER_RGBA + BC15Options->m_mapDecodeRGBA = true; +#else + BC15Options->m_mapDecodeRGBA = false; +#endif + } +} +#endif + +static CMP_BC15Options CalculateColourWeightings(CGU_Vec4f rgbaBlock[BLOCK_SIZE_4X4],CMP_BC15Options BC15options) +{ + CGU_FLOAT fBaseChannelWeights[3] = {0.3086f, 0.6094f, 0.0820f}; + + if (!BC15options.m_bUseChannelWeighting) { + BC15options.m_fChannelWeights[0] = 1.0F; + BC15options.m_fChannelWeights[1] = 1.0F; + BC15options.m_fChannelWeights[2] = 1.0F; + return BC15options; + } + + if (BC15options.m_bUseAdaptiveWeighting) { + float medianR = 0.0f, medianG = 0.0f, medianB = 0.0f; + + for (CGU_UINT32 k = 0; k < BLOCK_SIZE_4X4; k++) { + medianR += rgbaBlock[k].x; + medianG += rgbaBlock[k].y; + medianB += rgbaBlock[k].z; + } + + medianR /= BLOCK_SIZE_4X4; + medianG /= BLOCK_SIZE_4X4; + medianB /= BLOCK_SIZE_4X4; + + // Now skew the colour weightings based on the gravity center of the block + float largest = max(max(medianR, medianG), medianB); + + if (largest > 0) { + medianR /= largest; + medianG /= largest; + medianB /= largest; + } else + medianR = medianG = medianB = 1.0f; + + // Scale weightings back up to 1.0f + CGU_FLOAT fWeightScale = + 1.0f / (fBaseChannelWeights[0] + fBaseChannelWeights[1] + + fBaseChannelWeights[2]); + + BC15options.m_fChannelWeights[0] = fBaseChannelWeights[0] * fWeightScale; + BC15options.m_fChannelWeights[1] = fBaseChannelWeights[1] * fWeightScale; + BC15options.m_fChannelWeights[2] = fBaseChannelWeights[2] * fWeightScale; + + BC15options.m_fChannelWeights[0] = ((BC15options.m_fChannelWeights[0] * 3 * medianR) + BC15options.m_fChannelWeights[0]) *0.25f; + BC15options.m_fChannelWeights[1] = ((BC15options.m_fChannelWeights[1] * 3 * medianG) + BC15options.m_fChannelWeights[1]) *0.25f; + BC15options.m_fChannelWeights[2] = ((BC15options.m_fChannelWeights[2] * 3 * medianB) + BC15options.m_fChannelWeights[2]) *0.25f; + + fWeightScale = 1.0f / (BC15options.m_fChannelWeights[0] + BC15options.m_fChannelWeights[1] + BC15options.m_fChannelWeights[2]); + + BC15options.m_fChannelWeights[0] *= fWeightScale; + BC15options.m_fChannelWeights[1] *= fWeightScale; + BC15options.m_fChannelWeights[2] *= fWeightScale; + } + else { + BC15options.m_fChannelWeights[0] = fBaseChannelWeights[0]; + BC15options.m_fChannelWeights[1] = fBaseChannelWeights[1]; + BC15options.m_fChannelWeights[2] = fBaseChannelWeights[2]; + } + + return BC15options; +} + +static CMP_BC15Options CalculateColourWeightings3f(CGU_Vec3f rgbBlock[BLOCK_SIZE_4X4],CMP_BC15Options BC15options) +{ + CGU_FLOAT fBaseChannelWeights[3] = {0.3086f, 0.6094f, 0.0820f}; + + if (!BC15options.m_bUseChannelWeighting) { + BC15options.m_fChannelWeights[0] = 1.0F; + BC15options.m_fChannelWeights[1] = 1.0F; + BC15options.m_fChannelWeights[2] = 1.0F; + return BC15options; + } + + if (BC15options.m_bUseAdaptiveWeighting) { + float medianR = 0.0f, medianG = 0.0f, medianB = 0.0f; + + for (CGU_UINT32 k = 0; k < BLOCK_SIZE_4X4; k++) { + medianR += rgbBlock[k].x; + medianG += rgbBlock[k].y; + medianB += rgbBlock[k].z; + } + + medianR /= BLOCK_SIZE_4X4; + medianG /= BLOCK_SIZE_4X4; + medianB /= BLOCK_SIZE_4X4; + + // Now skew the colour weightings based on the gravity center of the block + float largest = max(max(medianR, medianG), medianB); + + if (largest > 0) { + medianR /= largest; + medianG /= largest; + medianB /= largest; + } else + medianR = medianG = medianB = 1.0f; + + // Scale weightings back up to 1.0f + CGU_FLOAT fWeightScale = + 1.0f / (fBaseChannelWeights[0] + fBaseChannelWeights[1] + + fBaseChannelWeights[2]); + + BC15options.m_fChannelWeights[0] = fBaseChannelWeights[0] * fWeightScale; + BC15options.m_fChannelWeights[1] = fBaseChannelWeights[1] * fWeightScale; + BC15options.m_fChannelWeights[2] = fBaseChannelWeights[2] * fWeightScale; + + BC15options.m_fChannelWeights[0] = ((BC15options.m_fChannelWeights[0] * 3 * medianR) + BC15options.m_fChannelWeights[0]) *0.25f; + BC15options.m_fChannelWeights[1] = ((BC15options.m_fChannelWeights[1] * 3 * medianG) + BC15options.m_fChannelWeights[1]) *0.25f; + BC15options.m_fChannelWeights[2] = ((BC15options.m_fChannelWeights[2] * 3 * medianB) + BC15options.m_fChannelWeights[2]) *0.25f; + + fWeightScale = 1.0f / (BC15options.m_fChannelWeights[0] + BC15options.m_fChannelWeights[1] + BC15options.m_fChannelWeights[2]); + + BC15options.m_fChannelWeights[0] *= fWeightScale; + BC15options.m_fChannelWeights[1] *= fWeightScale; + BC15options.m_fChannelWeights[2] *= fWeightScale; + } + else { + BC15options.m_fChannelWeights[0] = fBaseChannelWeights[0]; + BC15options.m_fChannelWeights[1] = fBaseChannelWeights[1]; + BC15options.m_fChannelWeights[2] = fBaseChannelWeights[2]; + } + + return BC15options; +} + +static CGU_FLOAT cmp_getRampErr(CGU_FLOAT Prj[BLOCK_SIZE_4X4], + CGU_FLOAT PrjErr[BLOCK_SIZE_4X4], + CGU_FLOAT PreMRep[BLOCK_SIZE_4X4], + CGU_FLOAT StepErr, + CGU_FLOAT lowPosStep, + CGU_FLOAT highPosStep, + CGU_UINT32 dwUniqueColors) +{ + CGU_FLOAT error = 0; + CGU_FLOAT step = (highPosStep - lowPosStep) / 3; // using (dwNumChannels=4 - 1); + CGU_FLOAT step_h = step * (CGU_FLOAT)0.5; + CGU_FLOAT rstep = (CGU_FLOAT)1.0f / step; + + for (CGU_UINT32 i = 0; i < dwUniqueColors; i++) { + CGU_FLOAT v; + // Work out which value in the block this select + CGU_FLOAT del; + + if ((del = Prj[i] - lowPosStep) <= 0) + v = lowPosStep; + else if (Prj[i] - highPosStep >= 0) + v = highPosStep; + else + v = floor((del + step_h) * rstep) * step + lowPosStep; + + // And accumulate the error + CGU_FLOAT d = (Prj[i] - v); + d *= d; + CGU_FLOAT err = PreMRep[i] * d + PrjErr[i]; + error += err; + if (StepErr < error) { + error = StepErr; + break; + } + } + return error; +} + +static CGU_Vec2ui cmp_compressExplicitAlphaBlock(const CGU_FLOAT AlphaBlockUV[16]) +{ + CGU_Vec2ui compBlock = {0,0}; + CGU_UINT8 i; + for (i = 0; i < 16; i++) + { + CGU_UINT8 v = (CGU_UINT8)(AlphaBlockUV[i]*255.0F); + v = (v + 7 - (v >> 4)); + v >>= 4; + + if (v < 0) + v = 0; + else + if (v > 0xf) + v = 0xf; + + if (i < 8) + compBlock.x |= v << (4 * i); + else + compBlock.y |= v << (4 * (i - 8)); + } + return compBlock; +} + +static CGU_FLOAT cmp_getRampError( CGU_FLOAT _Blk[BLOCK_SIZE_4X4], + CGU_FLOAT _Rpt[BLOCK_SIZE_4X4], + CGU_FLOAT _maxerror, + CGU_FLOAT _min_ex, + CGU_FLOAT _max_ex, + CGU_INT _NmbrClrs) // Max 16 +{ + CGU_INT i; + CGU_FLOAT error = 0; + const CGU_FLOAT step = (_max_ex - _min_ex) / 7; // (CGU_FLOAT)(dwNumPoints - 1); + const CGU_FLOAT step_h = step * 0.5f; + const CGU_FLOAT rstep = 1.0f / step; + + for (i = 0; i < _NmbrClrs; i++) { + CGU_FLOAT v; + // Work out which value in the block this select + CGU_FLOAT del; + + if ((del = _Blk[i] - _min_ex) <= 0) + v = _min_ex; + else if (_Blk[i] - _max_ex >= 0) + v = _max_ex; + else + v = (floor((del + step_h) * rstep) * step) + _min_ex; + + // And accumulate the error + CGU_FLOAT del2 = (_Blk[i] - v); + error += del2 * del2 * _Rpt[i]; + + // if we've already lost to the previous step bail out + if (_maxerror < error) { + error = _maxerror; + break; + } + } + return error; +} + +static CGU_FLOAT cmp_linearBlockRefine(CGU_FLOAT _Blk[BLOCK_SIZE_4X4], + CGU_FLOAT _Rpt[BLOCK_SIZE_4X4], + CGU_FLOAT _MaxError, + CMP_INOUT CGU_FLOAT CMP_PTRINOUT _min_ex, + CMP_INOUT CGU_FLOAT CMP_PTRINOUT _max_ex, + CGU_FLOAT _m_step, CGU_FLOAT _min_bnd, + CGU_FLOAT _max_bnd, + CGU_INT _NmbrClrs) { + // Start out assuming our endpoints are the min and max values we've + // determined + + // Attempt a (simple) progressive refinement step to reduce noise in the + // output image by trying to find a better overall match for the endpoints. + + CGU_FLOAT maxerror = _MaxError; + CGU_FLOAT min_ex = CMP_PTRINOUT _min_ex; + CGU_FLOAT max_ex = CMP_PTRINOUT _max_ex; + + CGU_INT mode, bestmode; + + do { + CGU_FLOAT cr_min0 = min_ex; + CGU_FLOAT cr_max0 = max_ex; + for (bestmode = -1, mode = 0; mode < SCH_STPS * SCH_STPS; mode++) { + // check each move (see sStep for direction) + CGU_FLOAT cr_min = min_ex + _m_step * sMvF[mode / SCH_STPS]; + CGU_FLOAT cr_max = max_ex + _m_step * sMvF[mode % SCH_STPS]; + + cr_min = max(cr_min, _min_bnd); + cr_max = min(cr_max, _max_bnd); + + CGU_FLOAT error; + error = cmp_getRampError(_Blk, _Rpt, maxerror, cr_min, cr_max, _NmbrClrs); + + if (error < maxerror) { + maxerror = error; + bestmode = mode; + cr_min0 = cr_min; + cr_max0 = cr_max; + } + } + + if (bestmode != -1) { + // make move (see sStep for direction) + min_ex = cr_min0; + max_ex = cr_max0; + } + } while (bestmode != -1); + + CMP_PTRINOUT _min_ex = min_ex; + CMP_PTRINOUT _max_ex = max_ex; + + return maxerror; +} + + +static CGU_Vec2f cmp_getLinearEndPoints( + CGU_FLOAT _Blk[BLOCK_SIZE_4X4], + CMP_IN CGU_FLOAT fquality) +{ + CGU_UINT32 i; + CGU_Vec2f cmpMinMax; + + //================================================================ + // Bounding Box + // lowest quality calculation to get min and max value to use + //================================================================ + if (fquality < CMP_QUALITY2) + { + cmpMinMax.x = _Blk[0]; + cmpMinMax.y = _Blk[0]; + for (i=1; i 0; j--) { + if (what[j - 1].data > what[j].data) { + tmp_index = what[j].index; + tmp_data = what[j].data; + what[j].index = what[j - 1].index; + what[j].data = what[j - 1].data; + what[j - 1].index = tmp_index; + what[j - 1].data = tmp_data; + } + } + } + + for (i = 0; i < BLOCK_SIZE_4X4; i++) fBlk[i] = what[i].data; + #endif + + CGU_FLOAT new_p = -2.0f; + + CGU_UINT32 dwUniqueValues = 0; + afUniqueValues[0] = 0.0f; + CGU_BOOL requiresCalculation = true; + + { // Ramp not fixed + for(i = 0; i < BLOCK_SIZE_4X4; i++) + { + if(new_p != fBlk[i]) + { + afUniqueValues[dwUniqueValues] = new_p = fBlk[i]; + afValueRepeats[dwUniqueValues] = 1.f; + dwUniqueValues++; + } + else + if (dwUniqueValues) afValueRepeats[dwUniqueValues - 1] += 1.f; + } + + // if number of unique colors is less or eq 2, we've done + if(dwUniqueValues <= 2) + { + Ramp[0] = floor(afUniqueValues[0] * 255.0f + 0.5f); + if(dwUniqueValues == 1) + Ramp[1] = Ramp[0] + 1.f; + else + Ramp[1] = floor(afUniqueValues[1] * 255.0f + 0.5f); + requiresCalculation = false; + } + } // Ramp not fixed + + if (requiresCalculation) { + CGU_FLOAT min_ex = afUniqueValues[0]; + CGU_FLOAT max_ex = afUniqueValues[dwUniqueValues - 1]; + CGU_FLOAT min_bnd = 0, max_bnd = 1.; + CGU_FLOAT min_r = min_ex, max_r = max_ex; + CGU_FLOAT gbl_l = 0, gbl_r = 0; + CGU_FLOAT cntr = (min_r + max_r) / 2; + + CGU_FLOAT gbl_err = MAX_ERROR; + // Trying to avoid unnecessary calculations. Heuristics: after some analisis + // it appears that in integer case, if the input interval not more then 48 + // we won't get much better + bool wantsSearch = !((max_ex - min_ex) <= (48.f / 256.0f)); + + if (wantsSearch) { + // Search. + // 1. take the vicinities of both low and high bound of the input + // interval. + // 2. setup some search step + // 3. find the new low and high bound which provides an (sub) optimal + // (infinite precision) clusterization. + CGU_FLOAT gbl_llb = (min_bnd > min_r - GBL_SCH_EXT) ? min_bnd : min_r - GBL_SCH_EXT; + CGU_FLOAT gbl_rrb = (max_bnd < max_r + GBL_SCH_EXT) ? max_bnd : max_r + GBL_SCH_EXT; + CGU_FLOAT gbl_lrb = (cntr < min_r + GBL_SCH_EXT) ? cntr : min_r + GBL_SCH_EXT; + CGU_FLOAT gbl_rlb = (cntr > max_r - GBL_SCH_EXT) ? cntr : max_r - GBL_SCH_EXT; + + for (CGU_FLOAT step_l = gbl_llb; step_l < gbl_lrb; step_l += GBL_SCH_STEP) + { + for (CGU_FLOAT step_r = gbl_rrb; gbl_rlb <= step_r; step_r -= GBL_SCH_STEP) + { + CGU_FLOAT sch_err; + // an sse version is avaiable + sch_err = cmp_getRampError(afUniqueValues, afValueRepeats, gbl_err, step_l, step_r, dwUniqueValues); + if (sch_err < gbl_err) + { + gbl_err = sch_err; + gbl_l = step_l; + gbl_r = step_r; + } + } + } + + min_r = gbl_l; + max_r = gbl_r; + } // want search + + // This is a refinement call. The function tries to make several small + // stretches or squashes to minimize quantization error. + CGU_FLOAT m_step = LCL_SCH_STEP / 256.0f; + cmp_linearBlockRefine(afUniqueValues, afValueRepeats, gbl_err, + CMP_REFINOUT min_r, + CMP_REFINOUT max_r, + m_step, min_bnd, max_bnd, + dwUniqueValues); + + min_ex = min_r; + max_ex = max_r; + max_ex *= 255.0f; + min_ex *= 255.0f; + + Ramp[0] = floor(min_ex + 0.5f); + Ramp[1] = floor(max_ex + 0.5f); + } + + // Ensure that the two endpoints are not the same + // This is legal but serves no need & can break some optimizations in the compressor + if (Ramp[0] == Ramp[1]) { + if (Ramp[1] < 255.f) + Ramp[1] = Ramp[1] + 1.0f; + else + if (Ramp[1] > 0.0f) + Ramp[1] = Ramp[1] - 1.0f; + } + + cmpMinMax.x = Ramp[0]; + cmpMinMax.y = Ramp[1]; + + return cmpMinMax; +} + +static CGU_Vec2ui cmp_getBlockPackedIndices( + CGU_Vec2f RampMinMax, + CGU_FLOAT alphaBlock[BLOCK_SIZE_4X4], + CMP_IN CGU_FLOAT fquality) +{ + CGU_UINT32 i; + CGU_UINT32 j; + CGU_Vec2ui cmpBlock = {0,0}; + CGU_UINT32 MinRampU; + CGU_UINT32 MaxRampU; + CGU_INT32 pcIndices[BLOCK_SIZE_4X4]; + + if (fquality < CMP_QUALITY2) + { + CGU_FLOAT Range; + CGU_FLOAT RampSteps; // segments into 0..7 sections + CGU_FLOAT Bias; + + if (RampMinMax.x != RampMinMax.y) + Range = RampMinMax.x - RampMinMax.y; + else + Range = 1.0f; + + RampSteps = 7.f / Range; // segments into 0..7 sections + Bias = -RampSteps * RampMinMax.y; + + for (i=0; i < 16; ++i) + { + pcIndices[i] = (CGU_UINT32)round(alphaBlock[i] * RampSteps + Bias); + if (i < 5) + { + pcIndices[i] += (pcIndices[i] > 0) - (7 * (pcIndices[i] == 7)); + } + else if (i > 5) + { + pcIndices[i] += (pcIndices[i] > 0) - (7 * (pcIndices[i] == 7 ? 1 : 0)); + } + else + { + pcIndices[i] += (pcIndices[i] > 0) - (7 * (pcIndices[i] == 7)); + } + } + + MinRampU = (CGU_UINT32 )round(RampMinMax.x*255.0f); + MaxRampU = (CGU_UINT32 )round(RampMinMax.y*255.0f); + + cmpBlock.x = (MinRampU << 8) | MaxRampU; + cmpBlock.y = 0; + for (i=0; i < 5; ++i) + { + cmpBlock.x |= (pcIndices[i] << (16 + (i*3))); + } + { + cmpBlock.x |= (pcIndices[5] << 31); + cmpBlock.y |= (pcIndices[5] >> 1); + } + for (i=6; i < BLOCK_SIZE_4X4; ++i) + { + cmpBlock.y |= (pcIndices[i] << (i*3 - 16)); + } + + } + else { + CGU_UINT32 epoint; + CGU_FLOAT alpha[BLOCK_SIZE_4X4]; + CGU_FLOAT OverIntFctr; + CGU_FLOAT shortest; + CGU_FLOAT adist; + + for(i = 0; i < BLOCK_SIZE_4X4; i++) + pcIndices[i] = 0; + + for (i = 0; i < MAX_POINTS; i++) alpha[i] = 0; + + // GetRmp1 + { + if (RampMinMax.x <= RampMinMax.y) { + CGU_FLOAT t = RampMinMax.x; + RampMinMax.x = RampMinMax.y; + RampMinMax.y = t; + } + + //============================= + // final clusterization applied + //============================= + CGU_FLOAT ramp[NUM_ENDPOINTS]; + + ramp[0] = RampMinMax.x; + ramp[1] = RampMinMax.y; + + { // BldRmp1 + alpha[0] = ramp[0]; + alpha[1] = ramp[1]; + for (epoint = 1; epoint < CMP_ALPHA_RAMP - 1; epoint++) + alpha[epoint + 1] = (alpha[0] * (CMP_ALPHA_RAMP - 1 - epoint) + alpha[1] * epoint) / (CGU_FLOAT)(CMP_ALPHA_RAMP - 1); + for (epoint = CMP_ALPHA_RAMP; epoint < BLOCK_SIZE_4X4; epoint++) alpha[epoint] = 100000.f; + } // BldRmp1 + + // FixedRamp + for (i = 0; i < CMP_ALPHA_RAMP; i++) { + alpha[i] = floor(alpha[i] + 0.5f); + } + }// GetRmp1 + + OverIntFctr = 1.f / 255.0f; + for (i = 0; i < CMP_ALPHA_RAMP; i++) + alpha[i] *= OverIntFctr; + + // For each colour in the original block, calculate its weighted + // distance from each point in the original and assign it + // to the closest cluster + for (i = 0; i < BLOCK_SIZE_4X4; i++) { + shortest = 10000000.f; + for (j = 0; j < CMP_ALPHA_RAMP; j++) { + adist = (alphaBlock[i] - alpha[j]); + adist *= adist; + if (adist < shortest) { + shortest = adist; + pcIndices[i] = j; + } + } + } + + //================================================== + // EncodeAlphaBlock + //================================================== + MinRampU = (CGU_UINT32 )RampMinMax.x; + MaxRampU = (CGU_UINT32 )RampMinMax.y; + + cmpBlock.x = (MaxRampU << 8) | MinRampU; + cmpBlock.y = 0; + for(i = 0; i < 5; i++) + { + cmpBlock.x |= (pcIndices[i]) << (16 + (i*3)); + } + { + cmpBlock.x |= (pcIndices[5] & 0x1) << 31; + cmpBlock.y |= (pcIndices[5] & 0x6) >> 1; + } + for(i = 6; i < BLOCK_SIZE_4X4; i++) + { + cmpBlock.y |= (pcIndices[i]) << (i*3 - 16); + } + } + return cmpBlock; +} + +static CGU_Vec2ui cmp_compressAlphaBlock( CMP_IN CGU_FLOAT alphaBlock[BLOCK_SIZE_4X4], + CMP_IN CGU_FLOAT fquality) +{ + CGU_Vec2f RampMinMax; + CGU_Vec2ui CmpBlock; + + RampMinMax = cmp_getLinearEndPoints(alphaBlock,fquality); + CmpBlock = cmp_getBlockPackedIndices(RampMinMax,alphaBlock,fquality); + return CmpBlock; +} + +static void cmp_getCompressedAlphaRamp(CGU_UINT8 alpha[8], + const CGU_UINT32 compressedBlock[2]) +{ + alpha[0] = (CGU_UINT8)(compressedBlock[0] & 0xff); + alpha[1] = (CGU_UINT8)((compressedBlock[0] >> 8) & 0xff); + + if (alpha[0] > alpha[1]) { + // 8-alpha block: derive the other six alphas. + // Bit code 000 = alpha_0, 001 = alpha_1, others are interpolated. +#ifdef ASPM_GPU + alpha[2] = (CGU_UINT8)((6 * alpha[0] + 1 * alpha[1] + 3) / 7); // bit code 010 + alpha[3] = (CGU_UINT8)((5 * alpha[0] + 2 * alpha[1] + 3) / 7); // bit code 011 + alpha[4] = (CGU_UINT8)((4 * alpha[0] + 3 * alpha[1] + 3) / 7); // bit code 100 + alpha[5] = (CGU_UINT8)((3 * alpha[0] + 4 * alpha[1] + 3) / 7); // bit code 101 + alpha[6] = (CGU_UINT8)((2 * alpha[0] + 5 * alpha[1] + 3) / 7); // bit code 110 + alpha[7] = (CGU_UINT8)((1 * alpha[0] + 6 * alpha[1] + 3) / 7); // bit code 111 +#else + alpha[2] = static_cast((6 * alpha[0] + 1 * alpha[1] + 3) / 7); // bit code 010 + alpha[3] = static_cast((5 * alpha[0] + 2 * alpha[1] + 3) / 7); // bit code 011 + alpha[4] = static_cast((4 * alpha[0] + 3 * alpha[1] + 3) / 7); // bit code 100 + alpha[5] = static_cast((3 * alpha[0] + 4 * alpha[1] + 3) / 7); // bit code 101 + alpha[6] = static_cast((2 * alpha[0] + 5 * alpha[1] + 3) / 7); // bit code 110 + alpha[7] = static_cast((1 * alpha[0] + 6 * alpha[1] + 3) / 7); // bit code 111 +#endif + } else { + // 6-alpha block. + // Bit code 000 = alpha_0, 001 = alpha_1, others are interpolated. +#ifdef ASPM_GPU + alpha[2] = (CGU_UINT8)((4 * alpha[0] + 1 * alpha[1] + 2) / 5); // Bit code 010 + alpha[3] = (CGU_UINT8)((3 * alpha[0] + 2 * alpha[1] + 2) / 5); // Bit code 011 + alpha[4] = (CGU_UINT8)((2 * alpha[0] + 3 * alpha[1] + 2) / 5); // Bit code 100 + alpha[5] = (CGU_UINT8)((1 * alpha[0] + 4 * alpha[1] + 2) / 5); // Bit code 101 +#else + alpha[2] = static_cast((4 * alpha[0] + 1 * alpha[1] + 2) / 5); // Bit code 010 + alpha[3] = static_cast((3 * alpha[0] + 2 * alpha[1] + 2) / 5); // Bit code 011 + alpha[4] = static_cast((2 * alpha[0] + 3 * alpha[1] + 2) / 5); // Bit code 100 + alpha[5] = static_cast((1 * alpha[0] + 4 * alpha[1] + 2) / 5); // Bit code 101 +#endif + alpha[6] = 0; // Bit code 110 + alpha[7] = 255; // Bit code 111 + } +} + +static void cmp_decompressAlphaBlock(CGU_UINT8 alphaBlock[BLOCK_SIZE_4X4], + const CGU_UINT32 compressedBlock[2]) +{ + CGU_UINT32 i; + CGU_UINT8 alpha[8]; + cmp_getCompressedAlphaRamp(alpha, compressedBlock); + + for (i = 0; i < BLOCK_SIZE_4X4; i++) { + CGU_UINT32 index; + if (i < 5) + index = (compressedBlock[0] & (0x7 << (16 + (i * 3)))) >> (16 + (i * 3)); + else if (i > 5) + index = (compressedBlock[1] & (0x7 << (2 + (i - 6) * 3))) >> (2 + (i - 6) * 3); + else { + index = (compressedBlock[0] & 0x80000000) >> 31; + index |= (compressedBlock[1] & 0x3) << 1; + } + + alphaBlock[i] = alpha[index]; + } +} + + +static CGU_Vec3f cmp_565ToLinear(CGU_UINT32 n565) +{ + CGU_UINT32 r0; + CGU_UINT32 g0; + CGU_UINT32 b0; + + r0 = ((n565 & 0xf800) >> 8); + g0 = ((n565 & 0x07e0) >> 3); + b0 = ((n565 & 0x001f) << 3); + + // Apply the lower bit replication to give full dynamic range (5,6,5) + r0 += (r0 >> 5); + g0 += (g0 >> 6); + b0 += (b0 >> 5); + + CGU_Vec3f LinearColor; + LinearColor.x = (CGU_FLOAT)r0; + LinearColor.y = (CGU_FLOAT)g0; + LinearColor.z = (CGU_FLOAT)b0; + + return LinearColor; +} + +static void cmp_ProcessColors(CMP_INOUT CGU_Vec3f CMP_PTRINOUT colorMin, + CMP_INOUT CGU_Vec3f CMP_PTRINOUT colorMax, + CMP_INOUT CGU_UINT32 CMP_PTRINOUT c0, + CMP_INOUT CGU_UINT32 CMP_PTRINOUT c1, + CGU_INT setopt, + CGU_BOOL isSRGB) +{ + // CGU_UINT32 srbMap[32] = {0,5,8,11,12,13,14,15,16,17,18,19,20,21,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31}; + // CGU_UINT32 sgMap[64] = {0,10,14,16,19,20,22,24,25,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,42,43,43,44,45,45, + // 46,47,47,48,48,49,50,50,51,52,52,53,53,54,54,55,55,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63}; + CGU_INT32 x,y,z; + CGU_Vec3f scale = {31.0f, 63.0f, 31.0f}; + CGU_Vec3f MinColorScaled; + CGU_Vec3f MaxColorScaled; + + // Clamp or Transform is needed, the transforms have built in clamps + if (isSRGB) { + MinColorScaled = cmp_linearToSrgb(CMP_PTRINOUT colorMin); + MaxColorScaled = cmp_linearToSrgb(CMP_PTRINOUT colorMax); + } + else { + MinColorScaled = cmp_clamp3f(CMP_PTRINOUT colorMin,0.0f,1.0f); + MaxColorScaled = cmp_clamp3f(CMP_PTRINOUT colorMax,0.0f,1.0f); + } + + switch (setopt) + { + case 0 : // Use Min Max processing + MinColorScaled = floor(MinColorScaled * scale); + MaxColorScaled = ceil (MaxColorScaled * scale); + CMP_PTRINOUT colorMin = MinColorScaled / scale; + CMP_PTRINOUT colorMax = MaxColorScaled / scale; + break; + default : // Use round processing + MinColorScaled = round (MinColorScaled * scale); + MaxColorScaled = round (MaxColorScaled * scale); + break; + } + + x = (CGU_UINT32)(MinColorScaled.x); + y = (CGU_UINT32)(MinColorScaled.y); + z = (CGU_UINT32)(MinColorScaled.z); + + //if (isSRGB) { + // // scale RB + // x = srbMap[x]; // &0x1F]; + // y = sgMap [y]; // &0x3F]; + // z = srbMap[z]; // &0x1F]; + // // scale G + //} + CMP_PTRINOUT c0 = (x << 11) | (y << 5) | z; + + x = (CGU_UINT32)(MaxColorScaled.x); + y = (CGU_UINT32)(MaxColorScaled.y); + z = (CGU_UINT32)(MaxColorScaled.z); + CMP_PTRINOUT c1 = (x << 11) | (y << 5) | z; +} + +#ifndef ASPM_GPU // Used by BC1, BC2 & BC3 +//---------------------------------------------------- +// This function decompresses a DXT colour block +// The block is decompressed to 8 bits per channel +// Result buffer is RGBA format, A is set to 255 +//---------------------------------------------------- +static void cmp_decompressDXTRGBA_Internal(CGU_UINT8 rgbBlock[BLOCK_SIZE_4X4X4], + const CGU_Vec2ui compressedBlock, + const CGU_BOOL mapDecodeRGBA) { + + + CGU_BOOL bDXT1 = TRUE; + CGU_UINT32 n0 = compressedBlock.x & 0xffff; + CGU_UINT32 n1 = compressedBlock.x >> 16; + CGU_UINT32 r0; + CGU_UINT32 g0; + CGU_UINT32 b0; + CGU_UINT32 r1; + CGU_UINT32 g1; + CGU_UINT32 b1; + + r0 = ((n0 & 0xf800) >> 8); + g0 = ((n0 & 0x07e0) >> 3); + b0 = ((n0 & 0x001f) << 3); + + r1 = ((n1 & 0xf800) >> 8); + g1 = ((n1 & 0x07e0) >> 3); + b1 = ((n1 & 0x001f) << 3); + + // Apply the lower bit replication to give full dynamic range + r0 += (r0 >> 5); + r1 += (r1 >> 5); + g0 += (g0 >> 6); + g1 += (g1 >> 6); + b0 += (b0 >> 5); + b1 += (b1 >> 5); + +if (!mapDecodeRGBA) +{ + //-------------------------------------------------------------- + // Channel mapping output as BGRA + //-------------------------------------------------------------- + CGU_UINT32 c0 = 0xff000000 | (r0<<16) | (g0<<8) | b0; + CGU_UINT32 c1 = 0xff000000 | (r1<<16) | (g1<<8) | b1; + + if(!bDXT1 || n0 > n1) + { + CGU_UINT32 c2 = 0xff000000 | (((2*r0+r1)/3)<<16) | (((2*g0+g1)/3)<<8) | (((2*b0+b1)/3)); + CGU_UINT32 c3 = 0xff000000 | (((2*r1+r0)/3)<<16) | (((2*g1+g0)/3)<<8) | (((2*b1+b0)/3)); + + for(int i=0; i<16; i++) + { + int index = (compressedBlock.y >> (2 * i)) & 3; + + switch(index) + { + case 0: + ((CGU_UINT32*)rgbBlock)[i] = c0; + break; + case 1: + ((CGU_UINT32*)rgbBlock)[i] = c1; + break; + case 2: + ((CGU_UINT32*)rgbBlock)[i] = c2; + break; + case 3: + ((CGU_UINT32*)rgbBlock)[i] = c3; + break; + } + } + } + else + { + // Transparent decode + CGU_UINT32 c2 = 0xff000000 | (((r0+r1)/2)<<16) | (((g0+g1)/2)<<8) | (((b0+b1)/2)); + + for(int i=0; i<16; i++) + { + int index = (compressedBlock.y >> (2 * i)) & 3; + + switch(index) + { + case 0: + ((CGU_UINT32*)rgbBlock)[i] = c0; + break; + case 1: + ((CGU_UINT32*)rgbBlock)[i] = c1; + break; + case 2: + ((CGU_UINT32*)rgbBlock)[i] = c2; + break; + case 3: + ((CGU_UINT32*)rgbBlock)[i] = 0x00000000; + break; + } + } + } +} +else { // MAP_BC15_TO_ABGR + //-------------------------------------------------------------- + // Channel mapping output as RGBA + //-------------------------------------------------------------- + + CGU_UINT32 c0 = 0xff000000 | (b0 << 16) | (g0 << 8) | r0; + CGU_UINT32 c1 = 0xff000000 | (b1 << 16) | (g1 << 8) | r1; + + if (!bDXT1 || n0 > n1) { + CGU_UINT32 c2 = 0xff000000 | (((2 * b0 + b1 + 1) / 3) << 16) | (((2 * g0 + g1 + 1) / 3) << 8) | (((2 * r0 + r1 + 1) / 3)); + CGU_UINT32 c3 = 0xff000000 | (((2 * b1 + b0 + 1) / 3) << 16) | (((2 * g1 + g0 + 1) / 3) << 8) | (((2 * r1 + r0 + 1) / 3)); + + for (int i = 0; i < 16; i++) { + int index = (compressedBlock.y >> (2 * i)) & 3; + switch (index) { + case 0: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c0; + break; + case 1: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c1; + break; + case 2: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c2; + break; + case 3: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c3; + break; + } + } + } else { + // Transparent decode + CGU_UINT32 c2 = 0xff000000 | (((b0 + b1) / 2) << 16) | (((g0 + g1) / 2) << 8) | (((r0 + r1) / 2)); + + for (int i = 0; i < 16; i++) { + int index = (compressedBlock.y >> (2 * i)) & 3; + switch (index) { + case 0: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c0; + break; + case 1: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c1; + break; + case 2: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = c2; + break; + case 3: + ((CMP_GLOBAL CGU_UINT32 *)rgbBlock)[i] = 0x00000000; + break; + } + } + } +} //MAP_ABGR +} +#endif // !ASPM_GPU + +//-------------------------------------------------------------------------------------------------------- +// Decompress is RGB (0.0f..255.0f) +//-------------------------------------------------------------------------------------------------------- +static void cmp_decompressRGBBlock(CMP_INOUT CGU_Vec3f rgbBlock[BLOCK_SIZE_4X4], + const CGU_Vec2ui compressedBlock) { + CGU_UINT32 n0 = compressedBlock.x & 0xffff; + CGU_UINT32 n1 = compressedBlock.x >> 16; + CGU_UINT32 index; + + //------------------------------------------------------- + // Decode the compressed block 0..255 color range + //------------------------------------------------------- + CGU_Vec3f c0 = cmp_565ToLinear(n0); // max color + CGU_Vec3f c1 = cmp_565ToLinear(n1); // min color + CGU_Vec3f c2; + CGU_Vec3f c3; + + if (n0 > n1) { + c2 = (c0*2.0f + c1) / 3.0f; + c3 = (c1*2.0f + c0) / 3.0f; + + for (CGU_UINT32 i = 0; i < 16; i++) { + index = (compressedBlock.y >> (2 * i)) & 3; + switch (index) { + case 0: + rgbBlock[i] = c0; + break; + case 1: + rgbBlock[i] = c1; + break; + case 2: + rgbBlock[i] = c2; + break; + case 3: + rgbBlock[i] = c3; + break; + } + } + } + else { + // Transparent decode + c2 = (c0 + c1) / 2.0f; + + for (CGU_UINT32 i = 0; i < 16; i++) { + index = (compressedBlock.y >> (2 * i)) & 3; + switch (index) { + case 0: + rgbBlock[i] = c0; + break; + case 1: + rgbBlock[i] = c1; + break; + case 2: + rgbBlock[i] = c2; + break; + case 3: + rgbBlock[i] = 0.0f; + break; + } + } + } +} + +// The source is 0..1, decompressed data using cmp_decompressRGBBlock is 0..255 which is converted down to 0..1 +static float CMP_RGBBlockError( const CGU_Vec3f src_rgbBlock[BLOCK_SIZE_4X4], + const CGU_Vec2ui compressedBlock, + CGU_BOOL isSRGB + ) +{ + CGU_Vec3f rgbBlock[BLOCK_SIZE_4X4]; + + // Decompressed block channels are 0..255 + cmp_decompressRGBBlock(rgbBlock,compressedBlock); + + //------------------------------------------------------------------ + // Calculate MSE of the block + // Note : pow is used as Float type for the code to be usable on CPU + //------------------------------------------------------------------ + CGU_Vec3f serr; + serr = 0.0f; + + float sR,sG,sB,R,G,B; + + for (int j = 0; j<16; j++) + { + if (isSRGB) + { + sR = round(cmp_linearToSrgbf(src_rgbBlock[j].x)*255.0f); + sG = round(cmp_linearToSrgbf(src_rgbBlock[j].y)*255.0f); + sB = round(cmp_linearToSrgbf(src_rgbBlock[j].z)*255.0f); + } + else { + sR = round(src_rgbBlock[j].x*255.0f); + sG = round(src_rgbBlock[j].y*255.0f); + sB = round(src_rgbBlock[j].z*255.0f); + } + + rgbBlock[j] = rgbBlock[j]; + + R = rgbBlock[j].x; + G = rgbBlock[j].y; + B = rgbBlock[j].z; + + // Norm colors + serr.x += pow(sR - R,2.0f); + serr.y += pow(sG - G,2.0f); + serr.z += pow(sB - B,2.0f); + } + + // MSE for 16 texels + return (serr.x + serr.y + serr.z) / 48.0f; +} + + +// Processing input source 0..1.0f) +static CGU_Vec2ui CompressRGBBlock_FM(const CGU_Vec3f rgbBlockUVf[16], + CMP_IN CGU_FLOAT fquality, + CGU_BOOL isSRGB, + CMP_INOUT CGU_FLOAT CMP_PTRINOUT errout) +{ + CGU_Vec3f axisVectorRGB = {0.0f,0.0f,0.0f};// The axis vector for index projection + CGU_FLOAT pos_on_axis[16]; // The distance each unique falls along the compression axis + CGU_FLOAT axisleft = 0; // The extremities and centre (average of left/right) of srcRGB along the compression axis + CGU_FLOAT axisright = 0; // The extremities and centre (average of left/right) of srcRGB along the compression axis + CGU_FLOAT axiscentre= 0; // The extremities and centre (average of left/right) of srcRGB along the compression axis + CGU_INT32 swap = 0; // Indicator if the RGB values need swapping to generate an opaque result + CGU_Vec3f average_rgb; // The centrepoint of the axis + CGU_Vec3f srcRGB[16]; // The list of source colors with blue channel altered + CGU_Vec3f srcBlock[16]; // The list of source colors with any color space transforms and clipping + CGU_Vec3f rgb; + CGU_UINT32 c0 = 0, c1 = 0; + CGU_Vec2ui compressedBlock = {0,0}; + CGU_FLOAT Q1CompErr; + CGU_Vec2ui Q1CompData; + + // ------------------------------------------------------------------------------------- + // (1) Find the array of unique pixel values and sum them to find their average position + // ------------------------------------------------------------------------------------- + { + CGU_FLOAT errLQ = 0.0f; + CGU_BOOL fastProcess = (fquality <= CMP_QUALITY1); + CGU_Vec3f srcMin = 1.0f; // Min source color + CGU_Vec3f srcMax = 0.0f; // Max source color + CGU_Vec2ui Q1compressedBlock = {0,0}; + + average_rgb = 0.0f; + // Get average and modifed src + // find average position and save list of pixels as 0F..255F range for processing + // Note: z (blue) is average of blue+green channels + for (CGU_INT32 i = 0; i (R+G)/2 + srcRGB[i] = rgb; + average_rgb = average_rgb + rgb; + } + } + + + // Process two colors for saving in 565 format as C0 and C1 + cmp_ProcessColors(CMP_REFINOUT srcMin,CMP_REFINOUT srcMax,CMP_REFINOUT c0, CMP_REFINOUT c1,isSRGB?1:0, isSRGB); + + // Save simple min-max encoding + if (c0 < c1) { + Q1CompData.x = (c0 << 16) | c1; + CGU_UINT32 index; + errLQ = cmp_getIndicesRGB(CMP_REFINOUT index,rgbBlockUVf, srcMin, srcMax,false); + Q1CompData.y = index; + CMP_PTRINOUT errout = errLQ; + } + else { // Most simple case all colors are equal or 0.0f + Q1compressedBlock.x = (c1 << 16) | c0; + Q1compressedBlock.y = 0; + CMP_PTRINOUT errout = 0.0f; + return Q1compressedBlock; + } + + if (fastProcess) + return Q1CompData; + + // 0.0625F is (1/BLOCK_SIZE_4X4) + average_rgb = average_rgb * 0.0625F; + + } + + // ------------------------------------------------------------------------------------- + // (4) For each component, reflect points about the average so all lie on the same side + // of the average, and compute the new average - this gives a second point that defines the axis + // To compute the sign of the axis sum the positive differences of G for each of R and B (the + // G axis is always positive in this implementation + // ------------------------------------------------------------------------------------- + // An interesting situation occurs if the G axis contains no information, in which case the RB + // axis is also compared. I am not entirely sure if this is the correct implementation - should + // the priority axis be determined by magnitude? + { + + CGU_FLOAT rg_pos = 0.0f; + CGU_FLOAT bg_pos = 0.0f; + CGU_FLOAT rb_pos = 0.0f; + + for (CGU_INT32 i = 0; i < BLOCK_SIZE_4X4; i++) + { + rgb = srcRGB[i] - average_rgb; + axisVectorRGB = axisVectorRGB + fabs(rgb); + if (rgb.x > 0) { + rg_pos += rgb.y; + rb_pos += rgb.z; + } + if (rgb.z > 0) bg_pos += rgb.y; + } + + // Average over BLOCK_SIZE_4X4 + axisVectorRGB = axisVectorRGB*0.0625F; + + // New average position + if (rg_pos < 0) axisVectorRGB.x = -axisVectorRGB.x; + if (bg_pos < 0) axisVectorRGB.z = -axisVectorRGB.z; + if ((rg_pos == bg_pos) && (rg_pos == 0)) + { + if (rb_pos < 0) axisVectorRGB.z = -axisVectorRGB.z; + } + } + + // ------------------------------------------------------------------------------------- + // (5) Axis projection and remapping + // ------------------------------------------------------------------------------------- + { + CGU_FLOAT v2_recip; + // Normalize the axis for simplicity of future calculation + v2_recip = dot(axisVectorRGB,axisVectorRGB); + if (v2_recip > 0) + v2_recip = 1.0f / (CGU_FLOAT)sqrt(v2_recip); + else + v2_recip = 1.0f; + axisVectorRGB = axisVectorRGB*v2_recip; + } + + // ------------------------------------------------------------------------------------- + // (6) Map the axis + // ------------------------------------------------------------------------------------- + // the line joining (and extended on either side of) average and axis + // defines the axis onto which the points will be projected + // Project all the points onto the axis, calculate the distance along + // the axis from the centre of the axis (average) + // From Foley & Van Dam: Closest point of approach of a line (P + v) to a point (R) is + // P + ((R-P).v) / (v.v))v + // The distance along v is therefore (R-P).v / (v.v) where (v.v) is 1 if v is a unit vector. + // + // Calculate the extremities at the same time - these need to be reasonably accurately + // represented in all cases + { + axisleft = CMP_FLOAT_MAX; + axisright = -CMP_FLOAT_MAX; + for (CGU_INT32 i = 0; i < BLOCK_SIZE_4X4; i++) + { + // Compute the distance along the axis of the point of closest approach + CGU_Vec3f temp = (srcRGB[i] - average_rgb); + pos_on_axis[i] = dot(temp,axisVectorRGB); + + // Work out the extremities + if (pos_on_axis[i] < axisleft) + axisleft = pos_on_axis[i]; + if (pos_on_axis[i] > axisright) + axisright = pos_on_axis[i]; + } + } + + // --------------------------------------------------------------------------------------------- + // (7) Now we have a good axis and the basic information about how the points are mapped to it + // Our initial guess is to represent the endpoints accurately, by moving the average + // to the centre and recalculating the point positions along the line + // --------------------------------------------------------------------------------------------- + { + axiscentre = (axisleft + axisright) * 0.5F; + average_rgb = average_rgb + (axisVectorRGB*axiscentre); + for (CGU_INT32 i = 0; i cn[1] Max Color = index 0, 2/3 offset =index 2, 1/3 offset = index 3, Min Color = index 1 + // CGU_Vec3f cn[4]; + // cn[0] = MaxColor; + // cn[1] = MinColor; + // cn[2] = cn[0]*2.0f/3.0f + cn[1]*1.0f/3.0f; + // cn[3] = cn[0]*1.0f/3.0f + cn[1]*2.0f/3.0f; + + for (CGU_INT32 i = 0; i average) are 0 and 1, while + // interpolants are 2 and 3 + if (fabs(pos_on_axis[i]) >= division) + index = 0; + else + index = 2; + // Positive is in the latter half of the block + if (pos_on_axis[i] >= axiscentre) + index += 1; + + index = index^swap; + // Set the output, taking swapping into account + compressedBlock.y |= (index << (2 * i)); + + // use err calc for use in higher quality code + //CompMinErr += dot(srcRGBRef[i] - cn[index],srcRGBRef[i] - cn[index]); + } + + //CompMinErr = CompMinErr * 0.0208333f; + + CompMinErr = CMP_RGBBlockError(rgbBlockUVf,compressedBlock,isSRGB); + Q1CompErr = CMP_RGBBlockError(rgbBlockUVf,Q1CompData,isSRGB); + + if (CompMinErr > Q1CompErr) { + compressedBlock = Q1CompData; + CMP_PTRINOUT errout = Q1CompErr; + } + else + CMP_PTRINOUT errout = CompMinErr; + } + } + // done + + return compressedBlock; +} + +#ifndef CMP_USE_LOWQUALITY +static CMP_EndPoints CompressRGBBlock_Slow( + CGU_Vec3f BlkInBGRf_UV[BLOCK_SIZE_4X4], + CGU_FLOAT Rpt[BLOCK_SIZE_4X4], + CGU_UINT32 dwUniqueColors, + CGU_Vec3f channelWeightsBGR, + CGU_UINT32 m_nRefinementSteps + ) +{ + CMP_UNUSED(channelWeightsBGR); + CMP_UNUSED(m_nRefinementSteps); + ALIGN_16 CGU_FLOAT Prj0[BLOCK_SIZE_4X4]; + ALIGN_16 CGU_FLOAT Prj[BLOCK_SIZE_4X4]; + ALIGN_16 CGU_FLOAT PrjErr[BLOCK_SIZE_4X4]; + ALIGN_16 CGU_FLOAT RmpIndxs[BLOCK_SIZE_4X4]; + + CGU_Vec3f LineDirG; + CGU_Vec3f LineDir; + CGU_FLOAT LineDir0[NUM_CHANNELS]; + CGU_Vec3f BlkUV[BLOCK_SIZE_4X4]; + CGU_Vec3f BlkSh[BLOCK_SIZE_4X4]; + CGU_Vec3f Mdl; + + CGU_Vec3f rsltC0; + CGU_Vec3f rsltC1; + CGU_Vec3f PosG0 = {0.0f,0.0f,0.0f}; + CGU_Vec3f PosG1 = {0.0f,0.0f,0.0f}; + CGU_UINT32 i; + + for (i = 0; i < dwUniqueColors; i++) + { + BlkUV[i] = BlkInBGRf_UV[i]; + } + + // if not more then 2 different colors, we've done + if (dwUniqueColors <= 2) { + rsltC0 = BlkInBGRf_UV[0] * 255.0f; + rsltC1 = BlkInBGRf_UV[dwUniqueColors - 1] * 255.0f; + } + else { + // This is our first attempt to find an axis we will go along. + // The cumulation is done to find a line minimizing the MSE from the + // input 3D points. + + // While trying to find the axis we found that the diameter of the input + // set is quite small. Do not bother. + + // FindAxisIsSmall(BlkSh, LineDir0, Mdl, Blk, Rpt,dwUniqueColors); + { + CGU_UINT32 ii; + CGU_UINT32 jj; + CGU_UINT32 kk; + + // These vars cannot be Vec3 as index to them are varying + CGU_FLOAT Crrl[NUM_CHANNELS]; + CGU_FLOAT RGB2[NUM_CHANNELS]; + + LineDir0[0] = LineDir0[1] = LineDir0[2] = + RGB2[0] = RGB2[1] = RGB2[2] = + Crrl[0] = Crrl[1] = Crrl[2] = + Mdl.x = Mdl.y = Mdl.z = 0.f; + + // sum position of all points + CGU_FLOAT fNumPoints = 0.0f; + for (ii = 0; ii < dwUniqueColors; ii++) { + Mdl.x += BlkUV[ii].x * Rpt[ii]; + Mdl.y += BlkUV[ii].y * Rpt[ii]; + Mdl.z += BlkUV[ii].z * Rpt[ii]; + fNumPoints += Rpt[ii]; + } + + // and then average to calculate center coordinate of block + Mdl /= fNumPoints; + + for (ii = 0; ii < dwUniqueColors; ii++) { + // calculate output block as offsets around block center + BlkSh[ii] = BlkUV[ii] - Mdl; + + // compute correlation matrix + // RGB2 = sum of ((distance from point from center) squared) + RGB2[0] += BlkSh[ii].x * BlkSh[ii].x * Rpt[ii]; + RGB2[1] += BlkSh[ii].y * BlkSh[ii].y * Rpt[ii]; + RGB2[2] += BlkSh[ii].z * BlkSh[ii].z * Rpt[ii]; + + Crrl[0] += BlkSh[ii].x * BlkSh[ii].y * Rpt[ii]; + Crrl[1] += BlkSh[ii].y * BlkSh[ii].z * Rpt[ii]; + Crrl[2] += BlkSh[ii].z * BlkSh[ii].x * Rpt[ii]; + + } + + // if set's diameter is small + CGU_UINT32 i0 = 0, i1 = 1; + CGU_FLOAT mxRGB2 = 0.0f; + + CGU_FLOAT fEPS = fNumPoints * EPS; + for (kk = 0, jj = 0; jj < 3; jj++) { + if (RGB2[jj] >= fEPS) + kk++; + else + RGB2[jj] = 0.0f; + + if (mxRGB2 < RGB2[jj]) { + mxRGB2 = RGB2[jj]; + i0 = jj; + } + } + + CGU_FLOAT fEPS2 = fNumPoints * EPS2; + CGU_BOOL AxisIsSmall; + + AxisIsSmall = (RGB2[0] < fEPS2); + AxisIsSmall = AxisIsSmall && (RGB2[1] < fEPS2); + AxisIsSmall = AxisIsSmall && (RGB2[2] < fEPS2); + + // all are very small to avoid division on the small determinant + if (AxisIsSmall) { + rsltC0 = BlkInBGRf_UV[0]*255.0f; + rsltC1 = BlkInBGRf_UV[dwUniqueColors - 1]*255.0f; + } + else { // !AxisIsSmall + if (kk == 1) // really only 1 dimension + LineDir0[i0] = 1.; + else + if (kk == 2) // really only 2 dimensions + { + i1 = (RGB2[(i0 + 1) % 3] > 0.f) ? (i0 + 1) % 3 : (i0 + 2) % 3; + CGU_FLOAT Crl = (i1 == (i0 + 1) % 3) ? Crrl[i0] : Crrl[(i0 + 2) % 3]; + LineDir0[i1] = Crl / RGB2[i0]; + LineDir0[i0] = 1.; + } + else { + CGU_FLOAT maxDet = 100000.f; + CGU_FLOAT Cs[3]; + // select max det for precision + for (jj = 0; jj < 3; jj++) { // 3 = nDimensions + CGU_FLOAT Det = RGB2[jj] * RGB2[(jj + 1) % 3] - Crrl[jj] * Crrl[jj]; + Cs[jj] = fabs(Crrl[jj] / sqrt(RGB2[jj] * RGB2[(jj + 1) % 3])); + if (maxDet < Det) { + maxDet = Det; + i0 = jj; + } + } + + // inverse correl matrix + // -- -- -- -- + // | A B | | C -B | + // | B C | => | -B A | + // -- -- -- -- + CGU_FLOAT mtrx1[2][2]; + CGU_FLOAT vc1[2]; + CGU_FLOAT vc[2]; + vc1[0] = Crrl[(i0 + 2) % 3]; + vc1[1] = Crrl[(i0 + 1) % 3]; + // C + mtrx1[0][0] = RGB2[(i0 + 1) % 3]; + // A + mtrx1[1][1] = RGB2[i0]; + // -B + mtrx1[1][0] = mtrx1[0][1] = -Crrl[i0]; + // find a solution + vc[0] = mtrx1[0][0] * vc1[0] + mtrx1[0][1] * vc1[1]; + vc[1] = mtrx1[1][0] * vc1[0] + mtrx1[1][1] * vc1[1]; + // normalize + vc[0] /= maxDet; + vc[1] /= maxDet; + // find a line direction vector + LineDir0[i0] = 1.; + LineDir0[(i0 + 1) % 3] = 1.; + LineDir0[(i0 + 2) % 3] = vc[0] + vc[1]; + } + + // normalize direction vector + CGU_FLOAT Len = LineDir0[0] * LineDir0[0] + + LineDir0[1] * LineDir0[1] + + LineDir0[2] * LineDir0[2]; + Len = sqrt(Len); + + LineDir0[0] = (Len > 0.f) ? LineDir0[0] / Len : 0.0f; + LineDir0[1] = (Len > 0.f) ? LineDir0[1] / Len : 0.0f; + LineDir0[2] = (Len > 0.f) ? LineDir0[2] / Len : 0.0f; + } + } // FindAxisIsSmall + + // GCC is being an awful being when it comes to goto-jumps. + // So please bear with this. + CGU_FLOAT ErrG = 10000000.f; + CGU_FLOAT PrjBnd0; + CGU_FLOAT PrjBnd1; + ALIGN_16 CGU_FLOAT PreMRep[BLOCK_SIZE_4X4]; + + LineDir.x = LineDir0[0]; + LineDir.y = LineDir0[1]; + LineDir.z = LineDir0[2]; + + // Here is the main loop. + // 1. Project input set on the axis in consideration. + // 2. Run 1 dimensional search (see scalar case) to find an (sub) optimal pair of end points. + // 3. Compute the vector of indexes (or clusters) for the current approximate ramp. + // 4. Present our color channels as 3 16DIM vectors. + // 5. Find closest approximation of each of 16DIM color vector with the projection of the 16DIM index vector. + // 6. Plug the projections as a new directional vector for the axis. + // 7. Goto 1. + // D - is 16 dim "index" vector (or 16 DIM vector of indexes - {0, 1/3,2/3, 0, ...,}, but shifted and normalized). + // Ci - is a 16 dim vector of color i. for each Ci find a scalar Ai such that (Ai * D - Ci) (Ai * D - Ci) -> min , + // i.e distance between vector AiD and C is min. You can think of D as a unit interval(vector) "clusterizer", and Ai is a scale + // you need to apply to the clusterizer to approximate the Ci vector instead of the unit vector. + // Solution is + // Ai = (D . Ci) / (D . D); . - is a dot product. + // in 3 dim space Ai(s) represent a line direction, along which + // we again try to find (sub)optimal quantizer. + // That's what our for(;;) loop is about. + for (;;) { + // 1. Project input set on the axis in consideration. + // From Foley & Van Dam: Closest point of approach of a line (P + v) to a + // point (R) is + // P + ((R-P).v) / (v.v))v + // The distance along v is therefore (R-P).v / (v.v) + // (v.v) is 1 if v is a unit vector. + // + PrjBnd0 = 1000.0f; + PrjBnd1 = -1000.0f; + for (i = 0; i < BLOCK_SIZE_4X4; i++) + Prj0[i] = Prj[i] = PrjErr[i] = PreMRep[i] = 0.f; + + for (i = 0; i < dwUniqueColors; i++) { + Prj0[i] = Prj[i] = dot(BlkSh[i],LineDir); + PrjErr[i] = dot(BlkSh[i]-LineDir* Prj[i],BlkSh[i]-LineDir*Prj[i]); + PrjBnd0 = min(PrjBnd0, Prj[i]); + PrjBnd1 = max(PrjBnd1, Prj[i]); + } + + // 2. Run 1 dimensional search (see scalar case) to find an (sub) optimal + // pair of end points. + + // min and max of the search interval + CGU_FLOAT Scl0; + CGU_FLOAT Scl1; + Scl0 = PrjBnd0 - (PrjBnd1 - PrjBnd0) * 0.125f; + Scl1 = PrjBnd1 + (PrjBnd1 - PrjBnd0) * 0.125f; + + // compute scaling factor to scale down the search interval to [0.,1] + const CGU_FLOAT Scl2 = (Scl1 - Scl0) * (Scl1 - Scl0); + const CGU_FLOAT overScl = 1.f / (Scl1 - Scl0); + + for (i = 0; i < dwUniqueColors; i++) { + // scale them + Prj[i] = (Prj[i] - Scl0) * overScl; + // premultiply the scale square to plug into error computation later + PreMRep[i] = Rpt[i] * Scl2; + } + + // scale first approximation of end points + PrjBnd0 = (PrjBnd0 - Scl0) * overScl; + PrjBnd1 = (PrjBnd1 - Scl0) * overScl; + + CGU_FLOAT StepErr = MAX_ERROR; + + // search step + CGU_FLOAT searchStep = 0.025f; + + // low Start/End; high Start/End + const CGU_FLOAT lowStartEnd = (PrjBnd0 - 2.f * searchStep > 0.f) ? PrjBnd0 - 2.f * searchStep : 0.f; + const CGU_FLOAT highStartEnd = (PrjBnd1 + 2.f * searchStep < 1.f) ? PrjBnd1 + 2.f * searchStep : 1.f; + + // find the best endpoints + CGU_FLOAT Pos0 = 0; + CGU_FLOAT Pos1 = 0; + CGU_FLOAT lowPosStep, highPosStep; + CGU_FLOAT err; + + int l, h; + for (l = 0, lowPosStep = lowStartEnd; l < 8; l++, lowPosStep += searchStep) { + for (h = 0, highPosStep = highStartEnd; h < 8; h++, highPosStep -= searchStep) { + // compute an error for the current pair of end points. + err = cmp_getRampErr(Prj, PrjErr, PreMRep, StepErr, lowPosStep, highPosStep, dwUniqueColors); + + if (err < StepErr) { + // save better result + StepErr = err; + Pos0 = lowPosStep; + Pos1 = highPosStep; + } + } + } + + // inverse the scaling + Pos0 = Pos0 * (Scl1 - Scl0) + Scl0; + Pos1 = Pos1 * (Scl1 - Scl0) + Scl0; + + // did we find somthing better from the previous run? + if (StepErr + 0.001 < ErrG) { + // yes, remember it + ErrG = StepErr; + LineDirG = LineDir; + + PosG0.x = Pos0; + PosG0.y = Pos0; + PosG0.z = Pos0; + PosG1.x = Pos1; + PosG1.y = Pos1; + PosG1.z = Pos1; + + // 3. Compute the vector of indexes (or clusters) for the current + // approximate ramp. + // indexes + const CGU_FLOAT step = (Pos1 - Pos0) / 3.0f; // (dwNumChannels=4 - 1); + const CGU_FLOAT step_h = step * (CGU_FLOAT)0.5; + const CGU_FLOAT rstep = (CGU_FLOAT)1.0f / step; + const CGU_FLOAT overBlkTp = 1.f / 3.0f; // (dwNumChannels=4 - 1); + + // here the index vector is computed, + // shifted and normalized + CGU_FLOAT indxAvrg = 3.0f / 2.0f; // (dwNumChannels=4 - 1); + + for (i = 0; i < dwUniqueColors; i++) { + CGU_FLOAT del; + // CGU_UINT32 n = (CGU_UINT32)((b - _min_ex + (step*0.5f)) * rstep); + if ((del = Prj0[i] - Pos0) <= 0) + RmpIndxs[i] = 0.f; + else if (Prj0[i] - Pos1 >= 0) + RmpIndxs[i] = 3.0f; // (dwNumChannels=4 - 1); + else + RmpIndxs[i] = floor((del + step_h) * rstep); + // shift and normalization + RmpIndxs[i] = (RmpIndxs[i] - indxAvrg) * overBlkTp; + } + + // 4. Present our color channels as 3 16 DIM vectors. + // 5. Find closest aproximation of each of 16DIM color vector with the + // pojection of the 16DIM index vector. + CGU_Vec3f Crs = {0.0f,0.0f,0.0f}; + CGU_FLOAT Len = 0.0f; + + for (i = 0; i < dwUniqueColors; i++) { + const CGU_FLOAT PreMlt = RmpIndxs[i] * Rpt[i]; + Len += RmpIndxs[i] * PreMlt; + Crs.x += BlkSh[i].x * PreMlt; + Crs.y += BlkSh[i].y * PreMlt; + Crs.z += BlkSh[i].z * PreMlt; + } + + LineDir.x = LineDir.y = LineDir.z = 0.0f; + if (Len > 0.0f) { + CGU_FLOAT Len2; + LineDir = Crs / Len; + // 6. Plug the projections as a new directional vector for the axis. + // 7. Goto 1. + Len2 = dot(LineDir,LineDir); // LineDir.x * LineDir.x + LineDir.y * LineDir.y + LineDir.z * LineDir.z; + Len2 = sqrt(Len2); + LineDir /= Len2; + } + } + else // We was not able to find anything better. Drop out. + break; + } + + // inverse transform to find end-points of 3-color ramp + rsltC0 = (PosG0 * LineDirG + Mdl) * 255.f; + rsltC1 = (PosG1 * LineDirG + Mdl) * 255.f; + } // !isDone + + // We've dealt with (almost) unrestricted full precision realm. + // Now back digital world. + + // round the end points to make them look like compressed ones + CGU_Vec3f inpRmpEndPts0 = {0.0f,255.0f,0.0f}; + CGU_Vec3f inpRmpEndPts1 = {0.0f,255.0f,0.0f}; + CGU_Vec3f Fctrs0 = {8.0f,4.0f,8.0f}; //(1 << (PIX_GRID - BG)); x (1 << (PIX_GRID - GG)); y (1 << (PIX_GRID - RG)); z + CGU_Vec3f Fctrs1 = {32.0f,64.0f,32.0f}; //(CGU_FLOAT)(1 << RG); z (CGU_FLOAT)(1 << GG); y (CGU_FLOAT)(1 << BG); x + CGU_FLOAT _Min = 0.0f; + CGU_FLOAT _Max = 255.0f; + + { // MkRmpOnGrid(inpRmpEndPts, rsltC, _Min, _Max); + + inpRmpEndPts0 = floor(rsltC0); + + if (inpRmpEndPts0.x <= _Min) inpRmpEndPts0.x = _Min; + else { + inpRmpEndPts0.x += floor(128.f / Fctrs1.x) - floor(inpRmpEndPts0.x / Fctrs1.x); + inpRmpEndPts0.x = min(inpRmpEndPts0.x, _Max); + } + if (inpRmpEndPts0.y <= _Min) inpRmpEndPts0.y = _Min; + else { + inpRmpEndPts0.y += floor(128.f / Fctrs1.y) - floor(inpRmpEndPts0.y / Fctrs1.y); + inpRmpEndPts0.y = min(inpRmpEndPts0.y, _Max); + } + if (inpRmpEndPts0.z <= _Min) inpRmpEndPts0.z = _Min; + else { + inpRmpEndPts0.z += floor(128.f / Fctrs1.z) - floor(inpRmpEndPts0.z / Fctrs1.z); + inpRmpEndPts0.z = min(inpRmpEndPts0.z, _Max); + } + + inpRmpEndPts0 = floor(inpRmpEndPts0 / Fctrs0) * Fctrs0; + + inpRmpEndPts1 = floor(rsltC1); + if (inpRmpEndPts1.x <= _Min) inpRmpEndPts1.x = _Min; + else { + inpRmpEndPts1.x += floor(128.f / Fctrs1.x) - floor(inpRmpEndPts1.x / Fctrs1.x); + inpRmpEndPts1.x = min(inpRmpEndPts1.x, _Max); + } + if (inpRmpEndPts1.y <= _Min) inpRmpEndPts1.y = _Min; + else { + inpRmpEndPts1.y += floor(128.f / Fctrs1.y) - floor(inpRmpEndPts1.y / Fctrs1.y); + inpRmpEndPts1.y = min(inpRmpEndPts1.y, _Max); + } + if (inpRmpEndPts1.z <= _Min) inpRmpEndPts1.z = _Min; + else { + inpRmpEndPts1.z += floor(128.f / Fctrs1.z) - floor(inpRmpEndPts1.z / Fctrs1.z); + inpRmpEndPts1.z = min(inpRmpEndPts1.z, _Max); + } + + inpRmpEndPts1 = floor(inpRmpEndPts1 / Fctrs0) * Fctrs0; + } // MkRmpOnGrid + + CMP_EndPoints EndPoints; + EndPoints.Color0 = inpRmpEndPts0; + EndPoints.Color1 = inpRmpEndPts1; + + return EndPoints; +} +#endif + + +// Process a rgbBlock which is normalized (0.0f ... 1.0f), signed normal is not implemented +static CGU_Vec2ui CompressBlockBC1_RGBA_Internal( + const CGU_Vec3f rgbBlockUVf[BLOCK_SIZE_4X4], + const CGU_FLOAT BlockA[BLOCK_SIZE_4X4], + CGU_Vec3f channelWeights, + CGU_UINT32 dwAlphaThreshold, + CGU_UINT32 m_nRefinementSteps, + CMP_IN CGU_FLOAT fquality, + CGU_BOOL isSRGB ) +{ + CGU_Vec2ui cmpBlock = {0,0}; + CGU_FLOAT errLQ = 1e6f; + + cmpBlock = CompressRGBBlock_FM(rgbBlockUVf,fquality,isSRGB,CMP_REFINOUT errLQ); + +#ifndef CMP_USE_LOWQUALITY + //------------------------------------------------------------------ + // Processing is in 0..255 range, code needs to be normized to 0..1 + //------------------------------------------------------------------ + if ((errLQ > 0.0f)&&(fquality > CMP_QUALITY2)) { + + CGU_Vec3f rgbBlock_normal[BLOCK_SIZE_4X4]; + CGU_UINT32 nCmpIndices = 0; + CGU_UINT32 c0, c1; + // High Quality + CMP_EndPoints EndPoints = {{0,0,0xFF},{0,0,0xFF}}; + // Hold a err ref to lowest quality compression, to check if new compression is any better + CGU_Vec2ui Q1CompData = cmpBlock; + // High Quality + CGU_UINT32 i; + + ALIGN_16 CGU_FLOAT Rpt[BLOCK_SIZE_4X4]; + CGU_UINT32 pcIndices = 0; + + m_nRefinementSteps = 0; + + CGU_Vec3f BlkInBGRf_UV[BLOCK_SIZE_4X4]; // Normalized Block Input (0..1) in BGR channel format + // Default inidices & endpoints for Transparent Block + CGU_Vec3ui nEndpoints0 = {0,0,0}; // Endpoints are stored BGR as x,y,z + CGU_Vec3ui nEndpoints1 = {0xFF,0xFF,0xFF}; // Endpoints are stored BGR as x,y,z + + for (i = 0; i < BLOCK_SIZE_4X4; i++) + { + Rpt[i] = 0.0f; + } + + //=============================================================== + // Check if we have more then 2 colors and process Alpha block + CGU_UINT32 dwColors = 0; + CGU_UINT32 dwBlk[BLOCK_SIZE_4X4]; + CGU_UINT32 R,G,B,A; + for (i = 0; i < BLOCK_SIZE_4X4; i++) + { + // Do any color conversion prior to processing the block + rgbBlock_normal[i] = isSRGB?cmp_linearToSrgb(rgbBlockUVf[i]):rgbBlockUVf[i]; + + R = (CGU_UINT32)(rgbBlock_normal[i].x*255.0f); + G = (CGU_UINT32)(rgbBlock_normal[i].y*255.0f); + B = (CGU_UINT32)(rgbBlock_normal[i].z*255.0f); + + if (dwAlphaThreshold > 0) + A = (CGU_UINT32)BlockA[i]; + else + A = 255; + + // Punch Through Alpha in BC1 Codec (1 bit alpha) + if ((dwAlphaThreshold == 0) || (A >= dwAlphaThreshold)) + { + // copy to local RGB data and have alpha set to 0xFF + dwBlk[dwColors++] = A << 24 | R << 16 | G << 8 | B; + } + } + + if (!dwColors) + { + // All are colors transparent + EndPoints.Color0.x = EndPoints.Color0.y = EndPoints.Color0.z = 0.0f; + EndPoints.Color1.x = EndPoints.Color1.y = EndPoints.Color0.z = 255.0f; + nCmpIndices = 0xFFFFFFFF; + } + else { // We have colors to process + nCmpIndices = 0; + // Punch Through Alpha Support ToDo + // CGU_BOOL bHasAlpha = (dwColors != BLOCK_SIZE_4X4); + // bHasAlpha = bHasAlpha && (dwAlphaThreshold > 0); // valid for (dwNumChannels=4); + // if (bHasAlpha) { + // CGU_Vec2ui compBlock = {0xf800f800,0}; + // return compBlock; + // } + + // Here we are computing an unique number of sorted colors. + // For each unique value we compute the number of it appearences. + // qsort((void *)dwBlk, (size_t)dwColors, sizeof(CGU_UINT32), QSortIntCmp); + #ifndef ASPM_GPU + std::sort(dwBlk, dwBlk+15); + #else + { + CGU_UINT32 j; + CMP_di what[BLOCK_SIZE_4X4]; + + for (i = 0; i < dwColors; i++) { + what[i].index = i; + what[i].data = dwBlk[i]; + } + + CGU_UINT32 tmp_index; + CGU_UINT32 tmp_data; + + for (i = 1; i < dwColors; i++) { + for (j = i; j > 0; j--) { + if (what[j - 1].data > what[j].data) { + tmp_index = what[j].index; + tmp_data = what[j].data; + what[j].index = what[j - 1].index; + what[j].data = what[j - 1].data; + what[j - 1].index = tmp_index; + what[j - 1].data = tmp_data; + } + } + } + for (i = 0; i < dwColors; i++) dwBlk[i] = what[i].data; + } + #endif + CGU_UINT32 new_p; + CGU_UINT32 dwBlkU[BLOCK_SIZE_4X4]; + CGU_UINT32 dwUniqueColors = 0; + new_p = dwBlkU[0] = dwBlk[0]; + Rpt[dwUniqueColors] = 1.f; + for (i = 1; i < dwColors; i++) { + if (new_p != dwBlk[i]) { + dwUniqueColors++; + new_p = dwBlkU[dwUniqueColors] = dwBlk[i]; + Rpt[dwUniqueColors] = 1.f; + } else + Rpt[dwUniqueColors] += 1.f; + } + dwUniqueColors++; + + // Simple case of only 2 colors to process + // no need for futher processing as lowest quality methods work best for this case + if (dwUniqueColors <= 2) { + return Q1CompData; + } + else + { + // switch from int range back to UV floats + for (i = 0; i < dwUniqueColors; i++) + { + R = (dwBlkU[i] >> 16) & 0xff; + G = (dwBlkU[i] >> 8) & 0xff; + B = (dwBlkU[i] >> 0) & 0xff; + BlkInBGRf_UV[i].z = (CGU_FLOAT)R/255.0f; + BlkInBGRf_UV[i].y = (CGU_FLOAT)G/255.0f; + BlkInBGRf_UV[i].x = (CGU_FLOAT)B/255.0f; + } + + CGU_Vec3f channelWeightsBGR; + channelWeightsBGR.x = channelWeights.z; + channelWeightsBGR.y = channelWeights.y; + channelWeightsBGR.z = channelWeights.x; + + EndPoints = CompressRGBBlock_Slow( + BlkInBGRf_UV, + Rpt, + dwUniqueColors, + channelWeightsBGR, + m_nRefinementSteps + ); + + + } + } // colors + + //=================================================================== + // Process Cluster INPUT is constant EndPointsf OUTPUT is pcIndices + //=================================================================== + if (nCmpIndices == 0) + { + R = (CGU_UINT32)(EndPoints.Color0.z); + G = (CGU_UINT32)(EndPoints.Color0.y); + B = (CGU_UINT32)(EndPoints.Color0.x); + CGU_INT32 cluster0 = cmp_constructColor(R,G,B); + + R = (CGU_UINT32)(EndPoints.Color1.z); + G = (CGU_UINT32)(EndPoints.Color1.y); + B = (CGU_UINT32)(EndPoints.Color1.x); + CGU_INT32 cluster1 = cmp_constructColor(R,G,B); + + CGU_Vec3f InpRmp[NUM_ENDPOINTS]; + if ((cluster0 <= cluster1) // valid for 4 channels + // || (cluster0 > cluster1) // valid for 3 channels + ) + { + // inverse endpoints + InpRmp[0] = EndPoints.Color1; + InpRmp[1] = EndPoints.Color0; + } + else + { + InpRmp[0] = EndPoints.Color0; + InpRmp[1] = EndPoints.Color1; + } + + CGU_Vec3f srcblockBGR[BLOCK_SIZE_4X4]; + CGU_FLOAT srcblockA[BLOCK_SIZE_4X4]; + + // Swizzle the source RGB to BGR for processing + for (i = 0; i < BLOCK_SIZE_4X4; i++) { + srcblockBGR[i].z = rgbBlock_normal[i].x*255.0f; + srcblockBGR[i].y = rgbBlock_normal[i].y*255.0f; + srcblockBGR[i].x = rgbBlock_normal[i].z*255.0f; + srcblockA[i] = 0.0f; + if (dwAlphaThreshold > 0) { + CGU_UINT32 alpha = (CGU_UINT32)BlockA[i]; + if (alpha >= dwAlphaThreshold) + srcblockA[i] = BlockA[i]; + } + } + + // input ramp is on the coarse grid + // make ramp endpoints the way they'll going to be decompressed + CGU_Vec3f InpRmpL[NUM_ENDPOINTS]; + CGU_Vec3f Fctrs = {32.0F,64.0F,32.0F}; // 1 << RG,1 << GG,1 << BG + + { // ConstantRamp = MkWkRmpPts(InpRmpL, InpRmp); + InpRmpL[0] = InpRmp[0] + floor(InpRmp[0] / Fctrs); + InpRmpL[0] = cmp_clamp3f(InpRmpL[0],0.0f,255.0f); + InpRmpL[1] = InpRmp[1] + floor(InpRmp[1] / Fctrs); + InpRmpL[1] = cmp_clamp3f(InpRmpL[1],0.0f,255.0f); + } // MkWkRmpPts + + // build ramp + CGU_Vec3f LerpRmp[4]; + CGU_Vec3f offset = {1.0f,1.0f,1.0f}; + { //BldRmp(Rmp, InpRmpL, dwNumChannels); + // linear interpolate end points to get the ramp + LerpRmp[0] = InpRmpL[0]; + LerpRmp[3] = InpRmpL[1]; + LerpRmp[1] = floor((InpRmpL[0]*2.0f + LerpRmp[3] + offset) / 3.0f); + LerpRmp[2] = floor((InpRmpL[0] + LerpRmp[3]*2.0f + offset) / 3.0f); + } // BldRmp + + //========================================================================= + // Clusterize, Compute error and find DXTC indexes for the current cluster + //========================================================================= + { // Clusterize + CGU_UINT32 alpha; + + // For each colour in the original block assign it + // to the closest cluster and compute the cumulative error + for (i = 0; i < BLOCK_SIZE_4X4; i++) { + alpha = (CGU_UINT32)srcblockA[i]; + if ((dwAlphaThreshold > 0) && alpha == 0) //*((CGU_DWORD *)&_Blk[i][AC]) == 0) + { + pcIndices |= cmp_set2Bit32(4,i); // dwNumChannels 3 or 4 (default is 4) + } + else + { + CGU_FLOAT shortest = 99999999999.f; + CGU_UINT8 shortestIndex = 0; + + CGU_Vec3f channelWeightsBGR; + channelWeightsBGR.x = channelWeights.z; + channelWeightsBGR.y = channelWeights.y; + channelWeightsBGR.z = channelWeights.x; + + for (CGU_UINT8 rampindex = 0; rampindex < 4; rampindex++) { // r is either 1 or 4 + // calculate the distance for each component + CGU_FLOAT distance = dot(((srcblockBGR[i]- LerpRmp[rampindex])* channelWeightsBGR), + ((srcblockBGR[i]- LerpRmp[rampindex])* channelWeightsBGR)); + if (distance < shortest) { + shortest = distance; + shortestIndex = rampindex; + } + } + + // The total is a sum of (error += shortest) + // We have the index of the best cluster, so assign this in the block + // Reorder indices to match correct DXTC ordering + if (shortestIndex == 3) // dwNumChannels - 1 + shortestIndex = 1; + else if (shortestIndex) + shortestIndex++; + pcIndices |= cmp_set2Bit32(shortestIndex,i); + } + } // BLOCK_SIZE_4X4 + } // Clusterize + }// Process Cluster + + //============================================================== + // Generate Compressed Result from nEndpoints & pcIndices + //============================================================== + R = (CGU_UINT32)(EndPoints.Color0.z); + G = (CGU_UINT32)(EndPoints.Color0.y); + B = (CGU_UINT32)(EndPoints.Color0.x); + c0 = cmp_constructColor(R,G,B); + + R = (CGU_UINT32)(EndPoints.Color1.z); + G = (CGU_UINT32)(EndPoints.Color1.y); + B = (CGU_UINT32)(EndPoints.Color1.x); + c1 = cmp_constructColor(R,G,B); + + // Get Processed indices if not set + if (nCmpIndices == 0) + nCmpIndices = pcIndices; + + if (c0 <= c1) + { + cmpBlock.x = c1 | (c0 << 16); + } + else + cmpBlock.x = c0 | (c1 << 16); + + cmpBlock.y = nCmpIndices; + + // Select best compression + CGU_FLOAT CompErr = CMP_RGBBlockError(rgbBlockUVf,cmpBlock,isSRGB); + if (CompErr > errLQ) + cmpBlock = Q1CompData; + } +#endif + return cmpBlock; +} + +//============================= Alpha: New single header interfaces: supports GPU shader interface ================================================== + +// Compress a BC1 block +static CGU_Vec2ui CompressBlockBC1_UNORM(CGU_Vec3f rgbablockf[BLOCK_SIZE_4X4],CMP_IN CGU_FLOAT fquality,CGU_BOOL isSRGB) +{ + CGU_FLOAT BlockA[BLOCK_SIZE_4X4]; // Not used but required + CGU_Vec3f channelWeights = {1.0f,1.0f,1.0f}; + + return CompressBlockBC1_RGBA_Internal( + rgbablockf, + BlockA, // ToDo support nullptr + channelWeights, + 0,1, + fquality, + isSRGB); +} + +// Compress a BC2 block +static CGU_Vec4ui CompressBlockBC2_UNORM( CMP_IN CGU_Vec3f BlockRGB[16], CMP_IN CGU_FLOAT BlockA[16], CGU_FLOAT fquality, CGU_BOOL isSRGB) +{ + CGU_Vec2ui compressedBlocks; + CGU_Vec4ui compBlock; + compressedBlocks = cmp_compressExplicitAlphaBlock(BlockA); + compBlock.x = compressedBlocks.x; + compBlock.y = compressedBlocks.y; + + CGU_Vec3f channelWeights = {1.0f,1.0f,1.0f}; + compressedBlocks = CompressBlockBC1_RGBA_Internal( + BlockRGB, + BlockA, + channelWeights, + 0,1, + fquality, + isSRGB); + compBlock.z = compressedBlocks.x; + compBlock.w = compressedBlocks.y; + return compBlock; +} + +// Compress a BC3 block +static CGU_Vec4ui CompressBlockBC3_UNORM( CMP_IN CGU_Vec3f BlockRGB[16], CMP_IN CGU_FLOAT BlockA[16], CGU_FLOAT fquality,CGU_BOOL isSRGB) +{ + CGU_Vec4ui compBlock; + CGU_Vec2ui cmpBlock; + + cmpBlock = cmp_compressAlphaBlock(BlockA,fquality); + compBlock.x = cmpBlock.x; + compBlock.y = cmpBlock.y; + + CGU_Vec2ui compressedBlocks; + compressedBlocks = CompressBlockBC1_UNORM(BlockRGB, fquality,isSRGB); + compBlock.z = compressedBlocks.x; + compBlock.w = compressedBlocks.y; + return compBlock; +} + +// Compress a BC4 block +static CGU_Vec2ui CompressBlockBC4_UNORM( CMP_IN CGU_FLOAT Block[16], CGU_FLOAT fquality) +{ + CGU_Vec2ui cmpBlock; + cmpBlock = cmp_compressAlphaBlock(Block,fquality); + return cmpBlock; +} + +// Compress a BC5 block +static CGU_Vec4ui CompressBlockBC5_UNORM( CMP_IN CGU_FLOAT BlockU[16], CMP_IN CGU_FLOAT BlockV[16], CGU_FLOAT fquality) +{ + CGU_Vec4ui compressedBlock = {0,0,0,0}; + CGU_Vec2ui cmpBlock; + cmpBlock = cmp_compressAlphaBlock(BlockU,fquality); + compressedBlock.x = cmpBlock.x; + compressedBlock.y = cmpBlock.y; + + cmpBlock = cmp_compressAlphaBlock(BlockV,fquality); + compressedBlock.z = cmpBlock.x; + compressedBlock.w = cmpBlock.y; + + return compressedBlock; +} + +// Compress a BC6 & BC7 UNORM block ToDo + +#endif diff --git a/extern/CMP_Core/shaders/Common_Def.h b/extern/CMP_Core/shaders/Common_Def.h new file mode 100644 index 00000000..b9df7a5c --- /dev/null +++ b/extern/CMP_Core/shaders/Common_Def.h @@ -0,0 +1,454 @@ +//=============================================================================== +// Copyright (c) 2007-2020 Advanced Micro Devices, Inc. All rights reserved. +// Copyright (c) 2004-2006 ATI Technologies Inc. +//=============================================================================== +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// +// File Name: Common_Def +// Description: common definitions used for CPU/HPC/GPU +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef _COMMON_DEFINITIONS_H +#define _COMMON_DEFINITIONS_H + +// The shaders for UE4 require extension in the form of .ush in place of standard .h +// this directive is used to make the change without users requiring to modify all of the include extensions +// specific to UE4 + +#ifdef ASPM_HLSL_UE4 +#pragma once +#define INC_cmp_math_vec4 "cmp_math_vec4.ush" +#define INC_cmp_math_func "cmp_math_func.ush" +#else +#define INC_cmp_math_vec4 "cmp_math_vec4.h" +#define INC_cmp_math_func "cmp_math_func.h" +#endif + +// Features +#ifdef _WIN32 +//#define USE_ASPM_CODE +#endif + +// Proxy ISPC compiler (Warning! Not all ASPM features will be available : expect build errors for specialized ASPM code! +#ifdef ISPC +#define ASPM +#endif + +// Using OpenCL Compiler +#ifdef __OPENCL_VERSION__ +#define ASPM_GPU +#define ASPM_OPENCL +#endif + +// Using DirectX fxc Compiler +// Note use the /DASPM_HLSL command line to define this +#ifdef ASPM_HLSL +#define ASPM_GPU +#endif + +#ifdef _LINUX +#undef ASPM_GPU +#undef ASPM_OPENCL +#ifndef ASPM_HLSL +#include +#include +#include +#include INC_cmp_math_vec4 +#endif +#endif + +#ifndef CMP_MAX +#define CMP_MAX(x, y) (((x) > (y)) ? (x) : (y)) +#endif + +#ifndef CMP_MIN +#define CMP_MIN(x, y) (((x) < (y)) ? (x) : (y)) +#endif + +#ifndef ASPM_GPU +#define CMP_STATIC_CAST(x,y) static_cast(y) +#else +#define CMP_STATIC_CAST(x,y) (x)(y) +#endif + + +#define CMP_SET_BC13_DECODER_RGBA // Sets mapping BC1, BC2 & BC3 to decode Red,Green,Blue and Alpha + // RGBA to channels [0,1,2,3] else BGRA maps to [0,1,2,3] + // BC4 alpha always maps as AAAA to channels [0,1,2,3] + // BC5 decoded (Red&Green) maps R,G,B=0,A=255 to [0,1,2,3] else maps [B=0,G,R,A=255] to [0,1,2,3] + +//#define USE_BLOCK_LINEAR + +#define CMP_FLOAT_MAX 3.402823466e+38F // max value used to detect an Error in processing +#define CMP_FLOAT_MAX_EXP 38 +#define USE_PROCESS_SEPERATE_ALPHA // Enable this to use higher quality code using CompressDualIndexBlock +#define COMPRESSED_BLOCK_SIZE 16 // Size of a compressed block in bytes +#define MAX_DIMENSION_BIG 4 // Max number of channels (RGBA) +#define MAX_SUBSETS 3 // Maximum number of possible subsets +#define MAX_SUBSET_SIZE 16 // Largest possible size for an individual subset +#define BLOCK_SIZE_4X4X4 64 +#define BLOCK_SIZE_4X4 16 +#define BlockX 4 +#define BlockY 4 +//#define USE_BLOCK_LINEAR // Source Data is organized in linear form for each block : Experimental Code not fully developed +//#define USE_DOUBLE // Default is to use float, enable to use double data types only for float definitions + +//--------------------------------------------- +// Predefinitions for GPU and CPU compiled code +//--------------------------------------------- + +#ifdef ASPM_HLSL + // ==== Vectors ==== + typedef float2 CGU_Vec2f; + typedef float2 CGV_Vec2f; + typedef float3 CGU_Vec3f; + typedef float3 CGV_Vec3f; + typedef float4 CGU_Vec4f; + typedef float4 CGV_Vec4f; + + typedef int2 CGU_Vec2i; + typedef int2 CGV_Vec2i; + typedef uint2 CGU_Vec2ui; + typedef uint2 CGV_Vec2ui; + + typedef int3 CGU_Vec3i; + typedef int3 CGV_Vec3i; + typedef uint3 CGU_Vec3ui; + typedef uint3 CGV_Vec3ui; + + typedef uint4 CGU_Vec4ui; + typedef uint4 CGV_Vec4ui; + + // ==== Scalar Types ==== to remove from code + typedef int CGU_INT8; + typedef uint CGU_INT; + typedef int CGV_INT; + typedef uint CGU_UINT8; + typedef uint CGU_UINT; + + // ==== Scalar Types ==== + typedef int CGU_BOOL; + typedef int CGV_BOOL; + typedef int CGU_INT32; + typedef int CGV_INT32; + typedef uint CGU_UINT32; + typedef uint CGV_UINT32; + typedef float CGV_FLOAT; + typedef float CGU_FLOAT; + typedef min16float CGU_MIN16_FLOAT; // FP16 GPU support defaults to 32 bit if no HW support + + #define TRUE 1 + #define FALSE 0 + #define CMP_CDECL + + #define BC7_ENCODECLASS + #define CMP_EXPORT + #define INLINE + #define uniform + #define varying + #define CMP_GLOBAL + #define CMP_KERNEL + #define CMP_CONSTANT + #define CMP_STATIC + #define CMP_REFINOUT + #define CMP_PTRINOUT + #define CMP_INOUT inout + #define CMP_OUT out + #define CMP_IN in + #define CMP_UNUSED(x) (x); + #define CMP_UNROLL [unroll] + + + +#else + +typedef enum { + CGU_CORE_OK = 0, // No errors, call was successfull + CGU_CORE_ERR_UNKOWN, // An unknown error occurred + CGU_CORE_ERR_NEWMEM, // New Memory Allocation Failed + CGU_CORE_ERR_INVALIDPTR, // The pointer value used is invalid or null + CGU_CORE_ERR_RANGERED, // values for Red Channel is out of range (too high or too low) + CGU_CORE_ERR_RANGEGREEN, // values for Green Channel is out of range (too high or too low) + CGU_CORE_ERR_RANGEBLUE, // values for Blue Channel is out of range (too high or too low) +} CGU_ERROR_CODES; + + +#ifdef ASPM_OPENCL // GPU Based code using OpenCL + // ==== Vectors ==== + typedef float2 CGU_Vec2f; + typedef float2 CGV_Vec2f; + typedef float3 CMP_Vec3f; + typedef float3 CGU_Vec3f; + typedef float3 CGV_Vec3f; + typedef float4 CGU_Vec4f; + typedef float4 CGV_Vec4f; + + typedef uchar3 CGU_Vec3uc; + typedef uchar3 CGV_Vec3uc; + + typedef uchar4 CMP_Vec4uc; + typedef uchar4 CGU_Vec4uc; + typedef uchar4 CGV_Vec4uc; + + typedef int2 CGU_Vec2i; + typedef int2 CGV_Vec2i; + typedef int3 CGU_Vec3i; + typedef int3 CGV_Vec3i; + typedef int4 CGU_Vec4i; + typedef int4 CGV_Vec4i; + + typedef uint2 CGU_Vec2ui; + typedef uint2 CGV_Vec2ui; + typedef uint3 CGU_Vec3ui; + typedef uint3 CGV_Vec3ui; + typedef uint4 CGU_Vec4ui; + typedef uint4 CGV_Vec4ui; + + + #define USE_BC7_SP_ERR_IDX + #define BC7_ENCODECLASS + #define ASPM_PRINT(args) printf args + + #define CMP_EXPORT + #define INLINE + #define uniform + #define varying + #define CMP_GLOBAL __global + #define CMP_KERNEL __kernel + #define CMP_CONSTANT __constant + #define CMP_STATIC + #define CMP_REFINOUT & + #define CMP_PTRINOUT * + #define CMP_INOUT + #define CMP_OUT + #define CMP_IN + #define CMP_UNUSED(x) + #define CMP_UNROLL + + typedef unsigned int CGU_DWORD; //32bits + typedef int CGU_INT; //32bits + typedef bool CGU_BOOL; + typedef unsigned short CGU_SHORT; //16bits + typedef float CGU_FLOAT; + typedef half CGU_MIN16_FLOAT; // FP16 GPU support defaults to 32 bit if no HW support + typedef unsigned int uint32; // need to remove this def + + typedef int CGV_INT; + typedef unsigned int CGU_UINT; + typedef int CGUV_INT; + typedef int CGV_BOOL; + + typedef char CGU_INT8; + typedef unsigned char CGU_UINT8; + typedef short CGU_INT16; + typedef unsigned short CGU_UINT16; + typedef int CGU_INT32; + typedef unsigned int CGU_UINT32; + typedef unsigned long CGU_UINT64; + + typedef char CGV_INT8; + typedef unsigned char CGV_UINT8; + typedef short CGV_INT16; + typedef unsigned short CGV_UINT16; + typedef int CGV_INT32; + typedef unsigned int CGV_UINT32; + typedef unsigned long CGV_UINT64; + + typedef float CGV_FLOAT; + + #define TRUE 1 + #define FALSE 0 + #define CMP_CDECL + +#else + // CPU & ASPM definitions + + #define CMP_REFINOUT & + #define CMP_PTRINOUT * + #define CMP_INOUT + #define CMP_OUT + #define CMP_IN + #define CMP_UNUSED(x) (void)(x); + #define CMP_UNROLL + + + #ifdef ASPM // SPMD ,SIMD CPU code + // using hybrid (CPU/GPU) aspm compiler + #define ASPM_PRINT(args) print args + #define CMP_USE_FOREACH_ASPM + #define __ASPM__ + #define BC7_ENCODECLASS + + #define USE_BC7_SP_ERR_IDX + //#define USE_BC7_RAMP + + #define CMP_EXPORT export + #define TRUE true + #define FALSE false + typedef uniform bool CGU_BOOL; + typedef bool CGV_BOOL; + + typedef unsigned int8 uint8; + typedef unsigned int16 uint16; + typedef unsigned int32 uint32; + typedef unsigned int64 uint64; + typedef uniform float CGU_FLOAT; + typedef varying float CGV_FLOAT; + typedef uniform float CGU_MIN16_FLOAT; + + typedef uniform uint8 CGU_UINT8; + typedef varying uint8 CGV_UINT8; + + + typedef CGV_UINT8<4> CGV_Vec4uc; + typedef CGU_UINT8<4> CGU_Vec4uc; + + typedef CGU_FLOAT<2> CGU_Vec2f; + typedef CGV_FLOAT<2> CGV_Vec2f; + typedef CGU_FLOAT<3> CGU_Vec3f; + typedef CGV_FLOAT<3> CGV_Vec3f; + typedef CGU_FLOAT<4> CGU_Vec4f; + typedef CGV_FLOAT<4> CGV_Vec4f; + + typedef CGU_UINT32<3> CGU_Vec3ui; + typedef CGV_UINT32<3> CGV_Vec3ui; + + typedef CGU_UINT32<4> CGU_Vec4ui; + typedef CGV_UINT32<4> CGV_Vec4ui; + + #define CMP_CDECL + #else // standard CPU code + #include + #include + #include INC_cmp_math_vec4 + + // using CPU compiler + #define ASPM_PRINT(args) printf args + #define USE_BC7_RAMP + #define USE_BC7_SP_ERR_IDX + + #define CMP_EXPORT + #define BC7_ENCODECLASS BC7_EncodeClass:: + #define TRUE 1 + #define FALSE 0 + #define uniform + #define varying + + typedef char int8; + typedef short int16; + typedef int int32; + typedef long int64; + typedef unsigned char uint8; + typedef unsigned short uint16; + typedef unsigned int uint32; + typedef unsigned long uint64; + + typedef int8 CGV_BOOL; + typedef bool CGU_BOOL; + typedef int16 CGU_WORD; + typedef uint8 CGU_SHORT; + typedef int64 CGU_LONG; + typedef uint64 CGU_ULONG; + + typedef uniform float CGU_FLOAT; + typedef varying float CGV_FLOAT; + typedef uniform float CGU_MIN16_FLOAT; + + typedef uniform uint8 CGU_UINT8; + typedef varying uint8 CGV_UINT8; + + typedef CMP_Vec3ui CGU_Vec3ui; + typedef CMP_Vec3ui CGV_Vec3ui; + + typedef CMP_Vec4ui CGU_Vec4ui; + typedef CMP_Vec4ui CGV_Vec4ui; + typedef CMP_Vec4f CGU_Vec4f; + typedef CMP_Vec4f CGV_Vec4f; + + #if defined(WIN32) || defined(_WIN64) + #define CMP_CDECL __cdecl + #else + #define CMP_CDECL + #endif + #endif + + // Common CPU & ASPM definitions + #define CMP_ASSERT(arg) + + #define CMP_GLOBAL + + #define CMP_KERNEL + #define __local const + #define __constant const + #define CMP_CONSTANT const + #define INLINE inline + #define CMP_STATIC static + + + typedef uniform int32 CGU_DWORD; + typedef uniform uint8 CGU_UBYTE; + typedef uniform int CGU_INT; + typedef uniform int8 CGU_INT8; + + typedef uniform int16 CGU_INT16; + typedef uniform uint16 CGU_UINT16; + typedef uniform int32 CGU_INT32; + typedef uniform uint32 CGU_UINT32; + typedef uniform uint64 CGU_UINT64; + + typedef int CGV_INT; + typedef int8 CGV_INT8; + typedef int16 CGV_INT16; + typedef int32 CGV_INT32; + typedef uint16 CGV_UINT16; + typedef uint32 CGV_UINT32; + typedef uint64 CGV_UINT64; + + +#endif // else ASPM_GPU + +typedef struct +{ + CGU_UINT32 m_src_width; + CGU_UINT32 m_src_height; + CGU_UINT32 m_width_in_blocks; + CGU_UINT32 m_height_in_blocks; + CGU_FLOAT m_fquality; +} Source_Info; + +typedef unsigned char* CGU_PTR; + +// Ref Compute_CPU_HPC +struct texture_surface +{ + CGU_PTR ptr; + CGU_INT width, + height, + stride; + CGU_INT channels; +}; + + +#endif // else ASPM_HLSL + +#endif // Common_Def.h + \ No newline at end of file diff --git a/extern/CMP_Core/shaders/CopyFiles.bat b/extern/CMP_Core/shaders/CopyFiles.bat new file mode 100644 index 00000000..e31392c7 --- /dev/null +++ b/extern/CMP_Core/shaders/CopyFiles.bat @@ -0,0 +1,69 @@ +REM ==================================== +REM Hybrid Codecs: Full support in v4.0 +REM ==================================== + +REM gets the output dir +set BUILD_OUTDIR=%1 + +REM get the batch files dir +SET mypath=%~dp0 +echo %mypath:~0,-1% + +IF NOT EXIST "%outpath%"\Plugins mkdir %BUILD_OUTDIR%Plugins +IF NOT EXIST "%outpath%"\Plugins\Compute mkdir %BUILD_OUTDIR%Plugins\Compute + +REM ToDo: Build Vulkan based shaders +REM "%VULKAN_SDK%"\bin\glslangvalidator -V %mypath:~0,-1%\BC1... -o %BUILD_OUTDIR%\Plugins\Compute\BC1....spv +REM IF %ERRORLEVEL% GTR 0 exit 123 + +REM Remove any OpenCL compiled Binaries +REM +del %BUILD_OUTDIR%Plugins\Compute\BC1_Encode_kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC1_Encode_kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC2_Encode_kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC2_Encode_kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC3_Encode_kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC3_Encode_kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC4_Encode_kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC4_Encode_kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC5_Encode_kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC5_Encode_kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC6_Encode_kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC6_Encode_kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC6_Encode_kernel.hlsl.0.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC6_Encode_kernel.hlsl.1.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC7_Encode_Kernel.cpp.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC7_Encode_Kernel.hlsl.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC7_Encode_Kernel.hlsl.0.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC7_Encode_Kernel.hlsl.1.cmp +del %BUILD_OUTDIR%Plugins\Compute\BC7_Encode_Kernel.hlsl.2.cmp + +XCopy /r /d /y "%mypath:~0,-1%\Common_Def.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BCn_Common_Kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC1_Encode_kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC1_Encode_kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC1_Encode_kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC2_Encode_kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC2_Encode_kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC2_Encode_kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC3_Encode_kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC3_Encode_kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC3_Encode_kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC4_Encode_kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC4_Encode_kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC4_Encode_kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC5_Encode_kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC5_Encode_kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC5_Encode_kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC6_Encode_kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC6_Encode_kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC6_Encode_kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC7_Encode_Kernel.h" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC7_Encode_Kernel.hlsl" %BUILD_OUTDIR%Plugins\Compute\ +XCopy /r /d /y "%mypath:~0,-1%\BC7_Encode_Kernel.cpp" %BUILD_OUTDIR%Plugins\Compute\ + +echo "Dependencies copied done" + + + + diff --git a/extern/CMP_Core/source/CMP_Core.h b/extern/CMP_Core/source/CMP_Core.h new file mode 100644 index 00000000..d794a8c8 --- /dev/null +++ b/extern/CMP_Core/source/CMP_Core.h @@ -0,0 +1,153 @@ +//===================================================================== +// Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +/// \file CMP_Core.h CPU User Interface +// +//===================================================================== + +#ifndef CMP_CORE_H +#define CMP_CORE_H + +#include +#ifdef _WIN32 +#define CMP_CDECL __cdecl +#else +#define CMP_CDECL +#endif + +//==================================================================================== +// API Definitions for Core API +//------------------------------------------------------------------------------------ +// All API return 0 on success else error codes > 0 +// See Common_Def.h CGU_CORE_ values for the error codes +//===================================================================================== + +//====================================================================================================== +// Block level setting option: Create and Destroy Reference Pointers +//====================================================================================================== +// Context create and destroy to use for BCn codec settings, where n is the set [1,2,3,4,5,6,7] +// All codecs will use default max quality settings, users can create multiple contexts to +// set quality levels, masks , channel mapping, etc... + +int CMP_CDECL CreateOptionsBC1(void **optionsBC1); +int CMP_CDECL CreateOptionsBC2(void **optionsBC2); +int CMP_CDECL CreateOptionsBC3(void **optionsBC3); +int CMP_CDECL CreateOptionsBC4(void **optionsBC4); +int CMP_CDECL CreateOptionsBC5(void **optionsBC5); +int CMP_CDECL CreateOptionsBC6(void **optionsBC6); +int CMP_CDECL CreateOptionsBC7(void **optionsBC7); + +int CMP_CDECL DestroyOptionsBC1(void *optionsBC1); +int CMP_CDECL DestroyOptionsBC2(void *optionsBC2); +int CMP_CDECL DestroyOptionsBC3(void *optionsBC3); +int CMP_CDECL DestroyOptionsBC4(void *optionsBC4); +int CMP_CDECL DestroyOptionsBC5(void *optionsBC5); +int CMP_CDECL DestroyOptionsBC6(void *optionsBC6); +int CMP_CDECL DestroyOptionsBC7(void *optionsBC7); + + +//====================================================================================================== +// Block level settings using the options Reference Pointers +//====================================================================================================== + +// Setting channel Weights : Applies to BC1, BC2 and BC3 valid ranges are [0..1.0f] Default is {1.0f, 1.0f , 1.0f} +// Use channel weightings. With swizzled formats the weighting applies to the data within the specified channel not the channel itself. +int CMP_CDECL SetChannelWeightsBC1(void *options, float WeightRed, float WeightGreen, float WeightBlue); +int CMP_CDECL SetChannelWeightsBC2(void *options, float WeightRed, float WeightGreen, float WeightBlue); +int CMP_CDECL SetChannelWeightsBC3(void *options, float WeightRed, float WeightGreen, float WeightBlue); + + +// True sets mapping CMP_Core BC1, BC2 & BC3 to decode Red,Green,Blue and Alpha as +// RGBA to channels [0,1,2,3] else BGRA maps to [0,1,2,3] +// Default is set to true. +int CMP_CDECL SetDecodeChannelMapping(void *options, bool mapRGBA); + +int CMP_CDECL SetQualityBC1(void *options, float fquality); +int CMP_CDECL SetQualityBC2(void *options, float fquality); +int CMP_CDECL SetQualityBC3(void *options, float fquality); +int CMP_CDECL SetQualityBC4(void *options, float fquality); +int CMP_CDECL SetQualityBC5(void *options, float fquality); +int CMP_CDECL SetQualityBC6(void *options, float fquality); +int CMP_CDECL SetQualityBC7(void *options, float fquality); + + +int CMP_CDECL SetAlphaThresholdBC1(void *options, unsigned char alphaThreshold); + +int CMP_CDECL SetMaskBC6(void *options, unsigned int mask); +int CMP_CDECL SetMaskBC7(void *options, unsigned char mask); + +int CMP_CDECL SetAlphaOptionsBC7(void *options, bool imageNeedsAlpha, bool colourRestrict, bool alphaRestrict); +int CMP_CDECL SetErrorThresholdBC7(void *options, float minThreshold, float maxThreshold); + +//====================================================================================================== +// (4x4) Block level 4 channel source CompressBlock and DecompressBlock API for BCn Codecs +//====================================================================================================== +// The options parameter for these API can be set to null in the calls if defaults settings is sufficient +// Example: CompressBlockBC1(srcBlock,16,cmpBlock,NULL); For "C" call +// CompressBlockBC1(srcBlock,16,cmpBlock); For "C++" calls +// +// To use this parameter first create the options context using the CreateOptions call +// then use the Set Options to set various codec settings and pass them to the appropriate +// Compress or Decompress API. +// The source (srcBlock) channel format is expected to be RGBA:8888 by default for LDR Codecs +// for BC6H the format is RGBA Half float (16 bits per channel) +//------------------------------------------------------------------------------------------------------ +#ifdef __cplusplus +#define CMP_DEFAULTNULL =NULL +#else +#define CMP_DEFAULTNULL +#endif + +//========================================================================================================= +// 4 channel Sources, default format RGBA:8888 is processed as a 4x4 block starting at srcBlock location +// where each row of the block is calculated from srcStride +//========================================================================================================= +int CMP_CDECL CompressBlockBC1(const unsigned char *srcBlock, unsigned int srcStrideInBytes, unsigned char cmpBlock[8 ], const void *options CMP_DEFAULTNULL); +int CMP_CDECL CompressBlockBC2(const unsigned char *srcBlock, unsigned int srcStrideInBytes, unsigned char cmpBlock[16], const void *options CMP_DEFAULTNULL); +int CMP_CDECL CompressBlockBC3(const unsigned char *srcBlock, unsigned int srcStrideInBytes, unsigned char cmpBlock[16], const void *options CMP_DEFAULTNULL); +int CMP_CDECL CompressBlockBC7(const unsigned char *srcBlock, unsigned int srcStrideInBytes, unsigned char cmpBlock[16], const void *options CMP_DEFAULTNULL); + +int CMP_CDECL DecompressBlockBC1(const unsigned char cmpBlock[8 ], unsigned char srcBlock[64], const void *options CMP_DEFAULTNULL); +int CMP_CDECL DecompressBlockBC2(const unsigned char cmpBlock[16], unsigned char srcBlock[64], const void *options CMP_DEFAULTNULL); +int CMP_CDECL DecompressBlockBC3(const unsigned char cmpBlock[16], unsigned char srcBlock[64], const void *options CMP_DEFAULTNULL); +int CMP_CDECL DecompressBlockBC7(const unsigned char cmpBlock[16], unsigned char srcBlock[64], const void *options CMP_DEFAULTNULL); + +//================================================ +// 1 channel Source 4x4 8 bits per block +//================================================ +int CMP_CDECL CompressBlockBC4(const unsigned char *srcBlock, unsigned int srcStrideInBytes, unsigned char cmpBlock[8], const void *options CMP_DEFAULTNULL); +int CMP_CDECL DecompressBlockBC4(const unsigned char cmpBlock[8], unsigned char srcBlock[16], const void *options CMP_DEFAULTNULL); + +//================================================ +// 2 channel Source 2x(4x4 8 bits) +//================================================ +int CMP_CDECL CompressBlockBC5(const unsigned char *srcBlock1, unsigned int srcStrideInBytes1, + const unsigned char *srcBlock2, unsigned int srcStrideInBytes2, + unsigned char cmpBlock[16], const void *options CMP_DEFAULTNULL); +int CMP_CDECL DecompressBlockBC5(const unsigned char cmpBlock[16], unsigned char srcBlock1[16], unsigned char srcBlock2[16], const void *options CMP_DEFAULTNULL); + +//======================================================================================== +// For 3 channel Source RGB_16, Note srcStride is in unsigned short steps (2 bytes each) +//======================================================================================== +int CMP_CDECL CompressBlockBC6(const unsigned short *srcBlock, unsigned int srcStrideInShorts, unsigned char cmpBlock[16], const void *options CMP_DEFAULTNULL); +int CMP_CDECL DecompressBlockBC6(const unsigned char cmpBlock[16], unsigned short srcBlock[48], const void *options CMP_DEFAULTNULL); + +#endif // CMP_CORE diff --git a/extern/CMP_Core/source/cmp_math_func.h b/extern/CMP_Core/source/cmp_math_func.h new file mode 100644 index 00000000..c2f89083 --- /dev/null +++ b/extern/CMP_Core/source/cmp_math_func.h @@ -0,0 +1,143 @@ +//===================================================================== +// Copyright 2020 (c), Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef CMP_MATH_FUNC_H +#define CMP_MATH_FUNC_H + + +#include "Common_Def.h" + +#ifndef ASPM_GPU + +//============================================================================ +// Core API which have have GPU equivalents, defined here for HPC_CPU usage +//============================================================================ + +#include +using namespace std; + +static CGU_INT QSortFCmp(const void *Elem1, const void *Elem2) { + CGU_INT ret = 0; + + if (*(CGU_FLOAT *)Elem1 - *(CGU_FLOAT *)Elem2 < 0.) + ret = -1; + else if (*(CGU_FLOAT *)Elem1 - *(CGU_FLOAT *)Elem2 > 0.) + ret = 1; + return ret; +} + +static int QSortIntCmp(const void *Elem1, const void *Elem2) +{ + return (*(CGU_INT32 *)Elem1 - *(CGU_INT32 *)Elem2); +} + +static CGU_FLOAT dot(CMP_IN CGU_Vec3f Color,CMP_IN CGU_Vec3f Color2) +{ + CGU_FLOAT ColorDot; + ColorDot = (Color.x * Color2.x) + (Color.y * Color2.y) + (Color.z * Color2.z); + return ColorDot; +} + +static CGU_FLOAT dot(CMP_IN CGU_Vec2f Color,CMP_IN CGU_Vec2f Color2) +{ + CGU_FLOAT ColorDot; + ColorDot = Color.x * Color2.x + Color.y * Color2.y; + return ColorDot; +} + +static CGU_Vec2f abs(CMP_IN CGU_Vec2f Color) +{ + CGU_Vec2f ColorAbs; + ColorAbs.x = std::abs(Color.x); + ColorAbs.y = std::abs(Color.y); + return ColorAbs; +} + +static CGU_Vec3f fabs(CMP_IN CGU_Vec3f Color) +{ + CGU_Vec3f ColorAbs; + ColorAbs.x = std::abs(Color.x); + ColorAbs.y = std::abs(Color.y); + ColorAbs.z = std::abs(Color.z); + return ColorAbs; +} + +static CGU_Vec3f round(CMP_IN CGU_Vec3f Color) +{ + CGU_Vec3f ColorRound; + ColorRound.x = std::round(Color.x); + ColorRound.y = std::round(Color.y); + ColorRound.z = std::round(Color.z); + return ColorRound; +} + +static CGU_Vec2f round(CMP_IN CGU_Vec2f Color) +{ + CGU_Vec2f ColorRound; + ColorRound.x = std::round(Color.x); + ColorRound.y = std::round(Color.y); + return ColorRound; +} + +static CGU_Vec3f ceil(CMP_IN CGU_Vec3f Color) +{ + CGU_Vec3f ColorCeil; + ColorCeil.x = std::ceil(Color.x); + ColorCeil.y = std::ceil(Color.y); + ColorCeil.z = std::ceil(Color.z); + return ColorCeil; +} + +static CGU_Vec3f floor(CMP_IN CGU_Vec3f Color) +{ + CGU_Vec3f Colorfloor; + Colorfloor.x = std::floor(Color.x); + Colorfloor.y = std::floor(Color.y); + Colorfloor.z = std::floor(Color.z); + return Colorfloor; +} + +static CGU_Vec3f saturate(CGU_Vec3f value) +{ + if (value.x > 1.0f) value.x = 1.0f; + else + if (value.x < 0.0f) value.x = 0.0f; + + if (value.y > 1.0f) value.y = 1.0f; + else + if (value.y < 0.0f) value.y = 0.0f; + + if (value.z > 1.0f) value.z = 1.0f; + else + if (value.z < 0.0f) value.z = 0.0f; + + return value; +} + +#endif + +//============================================================================ +// Core API which are shared between GPU & CPU +//============================================================================ + +#endif // Header Guard + diff --git a/extern/CMP_Core/source/cmp_math_vec4.h b/extern/CMP_Core/source/cmp_math_vec4.h new file mode 100644 index 00000000..4467deb7 --- /dev/null +++ b/extern/CMP_Core/source/cmp_math_vec4.h @@ -0,0 +1,435 @@ +//===================================================================== +// Copyright 2019 (c), Advanced Micro Devices, Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +//===================================================================== +#ifndef CMP_MATH_VEC4_H +#define CMP_MATH_VEC4_H + +//==================================================== +// Vector Class definitions for CPU & Intrinsics +//==================================================== + +#if defined (_LINUX) || defined (_WIN32) + +//============================================= VEC2 ================================================== +template class vec3; + +template +class Vec2 +{ +public: + T x; + T y; + + + // ***************************************** + // Constructors + // ***************************************** + + /// Default constructor + Vec2() : x((T)0), y((T)0) {}; + + /// Value constructor + Vec2(const T& vx, const T& vy) : x(vx), y(vy) {}; + + /// Copy constructor + Vec2(const Vec2& val) : x(val.x), y(val.y) {}; + + /// Single value constructor. Sets all components to the given value + Vec2(const T& v) : x(v), y(v) {}; + + // ***************************************** + // Conversions/Assignment/Indexing + // ***************************************** + + /// cast to T* + operator const T* () const { return (const T*)this; }; + + /// cast to T* + operator T* () { return (T*)this; }; + + /// Indexing + const T& operator[](int i) const { return ((const T*)this)[i]; }; + T& operator[](int i) { return ((T*)this)[i]; }; + + /// Assignment + const Vec2& operator=(const Vec2& rhs) { x = rhs.x; y = rhs.y; return *this; }; + + // ***************************************** + // Comparison + // ***************************************** + + /// Equality comparison + bool operator==(const Vec2& rhs) const { return (x == rhs.x && y == rhs.y); }; + + /// Inequality comparision + bool operator!=(const Vec2& rhs) const { return (x != rhs.x || y != rhs.y); }; + + // ***************************************** + // Arithmetic + // ***************************************** + + /// Addition + const Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }; + + /// Subtraction + const Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }; + + /// Multiply + const Vec2 operator*(const Vec2& rhs) const { return Vec2(x * rhs.x, y * rhs.y); }; + + /// Divide + const Vec2 operator/(const Vec2& rhs) const { return Vec2(x / rhs.x, y / rhs.y); }; + + + /// Multiply by scalar + const Vec2 operator*(const T& v) const { return Vec2(x * v, y * v); }; + + /// Divide by scalar + const Vec2 operator/(const T& v) const { return Vec2(x / v, y / v); }; + + /// Addition in-place + Vec2& operator+= (const Vec2& rhs) { x += rhs.x; y += rhs.y; return *this; }; + + /// Subtract in-place + Vec2& operator-= (const Vec2& rhs) { x -= rhs.x; y -= rhs.y; return *this; }; + + /// Scalar multiply in-place + Vec2& operator*= (const T& v) { x *= v; y *= v; return *this; }; + + /// Scalar divide in-place + Vec2& operator/= (const T& v) { x /= v; y /= v; return *this; }; + + +}; + +typedef Vec2 CMP_Vec2f; +typedef Vec2 CGU_Vec2f; +typedef Vec2 CGV_Vec2f; +typedef Vec2 CMP_Vec2d; +typedef Vec2 CMP_Vec2i; +typedef Vec2 CGU_Vec2ui; + +//} + + + + +//============================================= VEC3 ================================================== +template +class Vec3 +{ +public: + + T x; + T y; + T z; + + + // ***************************************** + // Constructors + // ***************************************** + + /// Default constructor + Vec3() : x((T)0), y((T)0), z((T)0) {}; + + /// Value constructor + Vec3(const T& vx, const T& vy, const T& vz) : x(vx), y(vy), z(vz) {}; + + /// Copy constructor + Vec3(const Vec3& val) : x(val.x), y(val.y), z(val.z) {}; + + /// Single value constructor. Sets all components to the given value + Vec3(const T& v) : x(v), y(v), z(v) {}; + + /// Array constructor. Assumes a 3-component array + Vec3(const T* v) : x(v[0]), y(v[1]), z(v[2]) {}; + + // ***************************************** + // Conversions/Assignment/Indexing + // ***************************************** + + /// cast to T* + operator const T* () const { return (const T*)this; }; + + /// cast to T* + operator T* () { return (T*)this; }; + + /// Assignment + const Vec3& operator=(const Vec3& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; return *this; }; + + // ***************************************** + // Comparison + // ***************************************** + + /// Equality comparison + bool operator==(const Vec3& rhs) const { return (x == rhs.x && y == rhs.y && z == rhs.z); }; + + /// Inequality comparision + bool operator!=(const Vec3& rhs) const { return (x != rhs.x || y != rhs.y || z != rhs.z); }; + + // ***************************************** + // Arithmetic + // ***************************************** + + /// Addition by vector + const Vec3 operator+(const Vec3& rhs) const { return Vec3(x + rhs.x, y + rhs.y, z + rhs.z); }; + + /// Subtraction by vector + const Vec3 operator-(const Vec3& rhs) const { return Vec3(x - rhs.x, y - rhs.y, z - rhs.z); }; + + /// Multiply by vector + const Vec3 operator*(const Vec3& rhs) const { return Vec3(x * rhs.x, y * rhs.y, z * rhs.z); }; + + /// Divide by vector + const Vec3 operator/(const Vec3& rhs) const { return Vec3(x / rhs.x, y / rhs.y, z / rhs.z); }; + + /// Multiply by scalar + const Vec3 operator*(const T& v) const { return Vec3(x * v, y * v, z * v); }; + + /// Divide by scalar + const Vec3 operator/(const T& v) const { return Vec3(x / v, y / v, z / v); }; + + /// Addition in-place + Vec3& operator+= (const Vec3& rhs) { x += rhs.x; y += rhs.y; z += rhs.z; return *this; }; + + /// Subtract in-place + Vec3& operator-= (const Vec3& rhs) { x -= rhs.x; y -= rhs.y; z -= rhs.z; return *this; }; + + /// Scalar multiply in-place + Vec3& operator*= (const T& v) { x *= v; y *= v; z *= v; return *this; }; + + /// Scalar divide in-place + Vec3& operator/= (const T& v) { x /= v; y /= v; z /= v; return *this; }; +}; + +typedef Vec3 CGU_Vec3bool; +typedef Vec3 CGU_Vec3f; +typedef Vec3 CGV_Vec3f; +typedef Vec3 CGU_Vec3uc; +typedef Vec3 CGV_Vec3uc; + +typedef Vec3 CMP_Vec3f; +typedef Vec3 CMP_Vec3d; +typedef Vec3 CMP_Vec3i; +typedef Vec3 CMP_Vec3uc; +typedef Vec3 CMP_Vec3ui; + +//============================================= VEC4 ================================================== +template +class Vec4 +{ +public: + + T x; + T y; + T z; + T w; + + // ***************************************** + // Constructors + // ***************************************** + + /// Default constructor + Vec4() : x((T)0), y((T)0), z((T)0), w((T)0) {}; + + /// Value constructor + Vec4(const T& vx, const T& vy, const T& vz, const T& vw) : x(vx), y(vy), z(vz), w(vw) {}; + + /// Copy constructor + Vec4(const Vec4& val) : x(val.x), y(val.y), z(val.z), w(val.w) {}; + + /// Single value constructor. Sets all components to the given value + Vec4(const T& v) : x(v), y(v), z(v), w(v) {}; + + /// Array constructor. Assumes a 4-component array + Vec4(const T* v) : x(v[0]), y(v[1]), z(v[2]), w(v[3]) {}; + + // ***************************************** + // Conversions/Assignment/Indexing + // ***************************************** + + /// cast to T* + operator const T* () const { return (const T*)this; }; + + /// cast to T* + operator T* () { return (T*)this; }; + + /// Assignment + const Vec4& operator=(const Vec4& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; w = rhs.w; return *this; }; + + // ***************************************** + // Comparison + // ***************************************** + + /// Equality comparison + bool operator==(const Vec4& rhs) const { return (x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w); }; + + /// Inequality comparision + bool operator!=(const Vec4& rhs) const { return (x != rhs.x || y != rhs.y || z != rhs.z || w != rhs.w); }; + + // ***************************************** + // Arithmetic + // ***************************************** + + /// Addition by vector + const Vec4 operator+(const Vec4& rhs) const { return Vec4(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w); }; + + /// Subtraction by vector + const Vec4 operator-(const Vec4& rhs) const { return Vec4(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w); }; + + /// Multiply by vector + const Vec4 operator*(const Vec4& rhs) const { return Vec4(x * rhs.x, y * rhs.y, z * rhs.z, w * rhs.w); }; + + /// Divide by vector + const Vec4 operator/(const Vec4& rhs) const { return Vec4(x / rhs.x, y / rhs.y, z / rhs.z, w / rhs.w); }; + + /// Multiply by scalar + const Vec4 operator*(const T& v) const { return Vec4(x * v, y * v, z * v, w * v); }; + + /// Divide by scalar + const Vec4 operator/(const T& v) const { return Vec4(x / v, y / v, z / v, w / v); }; + + /// Addition in-place + Vec4& operator+= (const Vec4& rhs) { x += rhs.x; y += rhs.y; z += rhs.z; w += rhs.w; return *this; }; + + /// Subtract in-place + Vec4& operator-= (const Vec4& rhs) { x -= rhs.x; y -= rhs.y; z -= rhs.z; w -= rhs.w; return *this; }; + + /// Scalar multiply in-place + Vec4& operator*= (const T& v) { x *= v; y *= v; z *= v; w *= v; return *this; }; + + /// Scalar divide in-place + Vec4& operator/= (const T& v) { x /= v; y /= v; z /= v; w /= v; return *this; }; +}; + +#include +#include "xmmintrin.h" +#include +#include + +// SSE Vec4 +#ifdef _LINUX +class CMP_SSEVec4f +#else +#include "intrin.h" +class __declspec(align(16)) CMP_SSEVec4f +#endif +{ +public: + + union + { + __m128 vec128; // float Vector 128 bits in total (16 Bytes) = array of 4 floats +#ifdef _LINUX + float f32[4]; +#endif + }; + + // constructors + inline CMP_SSEVec4f() {}; + inline CMP_SSEVec4f(float x, float y, float z, float w) : vec128(_mm_setr_ps(x, y, z, w)) {}; + inline CMP_SSEVec4f(__m128 vec) : vec128(vec) {} + inline CMP_SSEVec4f(const float* data) : vec128(_mm_load_ps(data)) {}; + inline CMP_SSEVec4f(float scalar) : vec128(_mm_load1_ps(&scalar)) {}; + + // copy and assignment + inline CMP_SSEVec4f(const CMP_SSEVec4f& init) : vec128(init.vec128) {}; + inline const CMP_SSEVec4f& operator=(const CMP_SSEVec4f& lhs) { vec128 = lhs.vec128; return *this; }; + + // conversion to m128 type for direct use in _mm intrinsics + inline operator __m128() { return vec128; }; + inline operator const __m128() const { return vec128; }; + + // indexing +#ifdef _LINUX + inline const float& operator[](int i) const { return f32[i]; }; + inline float& operator[](int i) { return f32[i]; }; +#else + inline const float& operator[](int i) const { return vec128.m128_f32[i]; }; + inline float& operator[](int i) { return vec128.m128_f32[i]; }; +#endif + + // addition + inline CMP_SSEVec4f operator+(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_add_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f& operator+=(const CMP_SSEVec4f& rhs) { vec128 = _mm_add_ps(vec128, rhs.vec128); return *this; }; + + // multiplication + inline CMP_SSEVec4f operator*(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_mul_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f& operator*=(const CMP_SSEVec4f& rhs) { vec128 = _mm_mul_ps(vec128, rhs.vec128); return *this; }; + + // scalar multiplication + //inline CMP_SSEVec4f operator*( float rhs ) const { return CMP_SSEVec4f( _mm_mul_ps(vec128, _mm_load1_ps(&rhs)) ); }; + //inline CMP_SSEVec4f& operator*=( float rhs ) { vec128 = _mm_mul_ps(vec128, _mm_load1_ps(&rhs)); return *this; }; + + + // subtraction + inline CMP_SSEVec4f operator-(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_sub_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f& operator-= (const CMP_SSEVec4f& rhs) { vec128 = _mm_sub_ps(vec128, rhs.vec128); return *this; }; + + // division + inline CMP_SSEVec4f operator/(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_div_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f& operator/= (const CMP_SSEVec4f& rhs) { vec128 = _mm_div_ps(vec128, rhs.vec128); return *this; }; + + // scalar division + inline CMP_SSEVec4f operator/(float rhs) const { return CMP_SSEVec4f(_mm_div_ps(vec128, _mm_load1_ps(&rhs))); }; + inline CMP_SSEVec4f& operator/=(float rhs) { vec128 = _mm_div_ps(vec128, _mm_load1_ps(&rhs)); return *this; }; + + // comparison + // these return 0 or 0xffffffff in each component + inline CMP_SSEVec4f operator< (const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_cmplt_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f operator> (const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_cmpgt_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f operator<=(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_cmple_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f operator>=(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_cmpge_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f operator==(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_cmpeq_ps(vec128, rhs.vec128)); }; + + // bitwise operators + inline CMP_SSEVec4f operator|(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_or_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f operator&(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_and_ps(vec128, rhs.vec128)); }; + inline CMP_SSEVec4f operator^(const CMP_SSEVec4f& rhs) const { return CMP_SSEVec4f(_mm_xor_ps(vec128, rhs.vec128)); }; + inline const CMP_SSEVec4f& operator|=(const CMP_SSEVec4f& rhs) { vec128 = _mm_or_ps(vec128, rhs.vec128); return *this; }; + inline const CMP_SSEVec4f& operator&=(const CMP_SSEVec4f& rhs) { vec128 = _mm_and_ps(vec128, rhs.vec128); return *this; }; + + // for some horrible reason,there's no bitwise not instruction for SSE, + // so we have to do xor with 0xfffffff in order to fake it. + // TO get a 0xffffffff, we execute 0=0 + inline CMP_SSEVec4f operator~() const + { + __m128 zero = _mm_setzero_ps(); + __m128 is_true = _mm_cmpeq_ps(zero, zero); + return _mm_xor_ps(is_true, vec128); + }; + +}; + +typedef Vec4 CMP_Vec4f; +typedef Vec4 CMP_Vec4d; +typedef Vec4 CMP_Vec4i; +typedef Vec4 CMP_Vec4ui; // unsigned 16 bit x,y,x,w +typedef Vec4 CMP_Vec4uc; // unsigned 8 bit x,y,x,w + +typedef Vec4 CGU_Vec4uc; // unsigned 8 bit x,y,x,w +typedef Vec4 CGV_Vec4uc; // unsigned 8 bit x,y,x,w + +#endif // not ASPM_GPU + +#endif // Header Guard + diff --git a/extern/CMP_Core/test/BlockConstants.h b/extern/CMP_Core/test/BlockConstants.h new file mode 100644 index 00000000..389cd834 --- /dev/null +++ b/extern/CMP_Core/test/BlockConstants.h @@ -0,0 +1,520 @@ +#ifndef BLOCKCONSTANTS_H +#define BLOCKCONSTANTS_H +#include +#include +struct Block { const unsigned char* data; const unsigned char* color; }; +struct BlockBC6 { const unsigned char* data; const float* color; }; + +static const unsigned char BC1_Red_Ignore_Alpha [] {0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Blue_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_White_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Black_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Red_Blue_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Red_Green_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Green_Blue_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Red_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Green_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Blue_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_White_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Green_Ignore_Alpha [] {0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Black_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Red_Blue_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Red_Green_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Green_Blue_Full_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Blue_Ignore_Alpha [] {0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_White_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Black_Ignore_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Red_Blue_Ignore_Alpha [] {0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Red_Green_Ignore_Alpha [] {0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Green_Blue_Ignore_Alpha [] {0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC1_Red_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC1_Green_Half_Alpha [] {0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const unsigned char BC2_Red_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Blue_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_White_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Black_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Blue_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Green_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Green_Blue_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Green_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Blue_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_White_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Green_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Black_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Blue_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Green_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Green_Blue_Full_Alpha [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Blue_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_White_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Black_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Blue_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Green_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Green_Blue_Ignore_Alpha [] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Red_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC2_Green_Half_Alpha [] {0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Blue_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_White_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Black_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Blue_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Green_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Green_Blue_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Green_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_White_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Green_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Black_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Green_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Green_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Blue_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f, 0x0 , 0x1f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_White_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0xff, 0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Black_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Blue_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x1f, 0xf8, 0x1f, 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Green_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xe0, 0xff, 0xe0, 0xff, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Green_Blue_Ignore_Alpha [] {0xff, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x7 , 0xff, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Red_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xf8, 0x0 , 0xf8, 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC3_Green_Half_Alpha [] {0x7b, 0x7b, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xe0, 0x7 , 0xe0, 0x7 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Red_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Blue_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_White_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Black_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Red_Blue_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Red_Green_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Green_Blue_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Red_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Green_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_White_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Green_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Black_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Red_Blue_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Red_Green_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Green_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Blue_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_White_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Black_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Red_Blue_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Red_Green_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Green_Blue_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC4_Red_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC4_Green_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Blue_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_White_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Black_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Blue_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Green_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Green_Blue_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Red_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Green_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_White_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Green_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Black_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Blue_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Green_Full_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Green_Blue_Full_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Blue_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_White_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Black_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Blue_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Red_Green_Ignore_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Green_Blue_Ignore_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC5_Red_Half_Alpha [] {0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24}; +static const unsigned char BC5_Green_Half_Alpha [] {0xff, 0x0 , 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xff, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Ignore_Alpha [] {0xe3, 0x3d, 0x0 , 0x0 , 0x78, 0xf , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Blue_Half_Alpha [] {0x3 , 0x0 , 0x0 , 0xde, 0x3 , 0x0 , 0x80, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_White_Half_Alpha [] {0xe3, 0xbd, 0xf7, 0xde, 0x7b, 0xef, 0xbd, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Black_Half_Alpha [] {0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Blue_Half_Alpha [] {0xe3, 0x3d, 0x0 , 0xde, 0x7b, 0xf , 0x80, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Green_Half_Alpha [] {0xe3, 0xbd, 0xf7, 0x0 , 0x78, 0xef, 0x3d, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Green_Blue_Half_Alpha [] {0x3 , 0x80, 0xf7, 0xde, 0x3 , 0xe0, 0xbd, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Full_Alpha [] {0xe3, 0x3d, 0x0 , 0x0 , 0x78, 0xf , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Green_Full_Alpha [] {0x3 , 0x80, 0xf7, 0x0 , 0x0 , 0xe0, 0x3d, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Blue_Full_Alpha [] {0x3 , 0x0 , 0x0 , 0xde, 0x3 , 0x0 , 0x80, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_White_Full_Alpha [] {0xe3, 0xbd, 0xf7, 0xde, 0x7b, 0xef, 0xbd, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Green_Ignore_Alpha [] {0x3 , 0x80, 0xf7, 0x0 , 0x0 , 0xe0, 0x3d, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Black_Full_Alpha [] {0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Blue_Full_Alpha [] {0xe3, 0x3d, 0x0 , 0xde, 0x7b, 0xf , 0x80, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Green_Full_Alpha [] {0xe3, 0xbd, 0xf7, 0x0 , 0x78, 0xef, 0x3d, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Green_Blue_Full_Alpha [] {0x3 , 0x80, 0xf7, 0xde, 0x3 , 0xe0, 0xbd, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Blue_Ignore_Alpha [] {0x3 , 0x0 , 0x0 , 0xde, 0x3 , 0x0 , 0x80, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_White_Ignore_Alpha [] {0xe3, 0xbd, 0xf7, 0xde, 0x7b, 0xef, 0xbd, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Black_Ignore_Alpha [] {0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Blue_Ignore_Alpha [] {0xe3, 0x3d, 0x0 , 0xde, 0x7b, 0xf , 0x80, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Green_Ignore_Alpha [] {0xe3, 0xbd, 0xf7, 0x0 , 0x78, 0xef, 0x3d, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Green_Blue_Ignore_Alpha [] {0x3 , 0x80, 0xf7, 0xde, 0x3 , 0xe0, 0xbd, 0xf7, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Red_Half_Alpha [] {0xe3, 0x3d, 0x0 , 0x0 , 0x78, 0xf , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC6_Green_Half_Alpha [] {0x3 , 0x80, 0xf7, 0x0 , 0x0 , 0xe0, 0x3d, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Ignore_Alpha [] {0x10, 0xff, 0x3 , 0x0 , 0xc0, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Blue_Half_Alpha [] {0x20, 0x0 , 0x0 , 0x0 , 0xf0, 0xff, 0xef, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_White_Half_Alpha [] {0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Black_Half_Alpha [] {0x20, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0xec, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Blue_Half_Alpha [] {0x20, 0xff, 0x3f, 0x0 , 0xf0, 0xff, 0xef, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Green_Half_Alpha [] {0x20, 0xff, 0xff, 0xff, 0xf , 0x0 , 0xec, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Green_Blue_Half_Alpha [] {0x20, 0x0 , 0xc0, 0xff, 0xff, 0xff, 0xef, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Full_Alpha [] {0x10, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Green_Full_Alpha [] {0x10, 0x0 , 0xfc, 0xf , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Blue_Full_Alpha [] {0x10, 0x0 , 0x0 , 0xf0, 0x3f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_White_Full_Alpha [] {0x10, 0xff, 0xff, 0xff, 0x3f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Green_Ignore_Alpha [] {0x10, 0x0 , 0xfc, 0xf , 0xc0, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Black_Full_Alpha [] {0x10, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Blue_Full_Alpha [] {0x10, 0xff, 0x3 , 0xf0, 0x3f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Green_Full_Alpha [] {0x10, 0xff, 0xff, 0xf , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Green_Blue_Full_Alpha [] {0x10, 0x0 , 0xfc, 0xff, 0x3f, 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Blue_Ignore_Alpha [] {0x10, 0x0 , 0x0 , 0xf0, 0xff, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_White_Ignore_Alpha [] {0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Black_Ignore_Alpha [] {0x10, 0x0 , 0x0 , 0x0 , 0xc0, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Blue_Ignore_Alpha [] {0x10, 0xff, 0x3 , 0xf0, 0xff, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Green_Ignore_Alpha [] {0x10, 0xff, 0xff, 0xf , 0xc0, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Green_Blue_Ignore_Alpha [] {0x10, 0x0 , 0xfc, 0xff, 0xff, 0xff, 0x3 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Red_Half_Alpha [] {0x20, 0xff, 0x3f, 0x0 , 0x0 , 0x0 , 0xec, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; +static const unsigned char BC7_Green_Half_Alpha [] {0x20, 0x0 , 0xc0, 0xff, 0xf , 0x0 , 0xec, 0xed, 0x1 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 }; + +Block BC1_Red_Ignore_Alpha_Block = {BC1_Red_Ignore_Alpha, nullptr}; +Block BC1_Blue_Half_Alpha_Block = {BC1_Blue_Half_Alpha, nullptr}; +Block BC1_White_Half_Alpha_Block = {BC1_White_Half_Alpha, nullptr}; +Block BC1_Black_Half_Alpha_Block = {BC1_Black_Half_Alpha, nullptr}; +Block BC1_Red_Blue_Half_Alpha_Block = {BC1_Red_Blue_Half_Alpha, nullptr}; +Block BC1_Red_Green_Half_Alpha_Block = {BC1_Red_Green_Half_Alpha, nullptr}; +Block BC1_Green_Blue_Half_Alpha_Block = {BC1_Green_Blue_Half_Alpha, nullptr}; +Block BC1_Red_Full_Alpha_Block = {BC1_Red_Full_Alpha, nullptr}; +Block BC1_Green_Full_Alpha_Block = {BC1_Green_Full_Alpha, nullptr}; +Block BC1_Blue_Full_Alpha_Block = {BC1_Blue_Full_Alpha, nullptr}; +Block BC1_White_Full_Alpha_Block = {BC1_White_Full_Alpha, nullptr}; +Block BC1_Green_Ignore_Alpha_Block = {BC1_Green_Ignore_Alpha, nullptr}; +Block BC1_Black_Full_Alpha_Block = {BC1_Black_Full_Alpha, nullptr}; +Block BC1_Red_Blue_Full_Alpha_Block = {BC1_Red_Blue_Full_Alpha, nullptr}; +Block BC1_Red_Green_Full_Alpha_Block = {BC1_Red_Green_Full_Alpha, nullptr}; +Block BC1_Green_Blue_Full_Alpha_Block = {BC1_Green_Blue_Full_Alpha, nullptr}; +Block BC1_Blue_Ignore_Alpha_Block = {BC1_Blue_Ignore_Alpha, nullptr}; +Block BC1_White_Ignore_Alpha_Block = {BC1_White_Ignore_Alpha, nullptr}; +Block BC1_Black_Ignore_Alpha_Block = {BC1_Black_Ignore_Alpha, nullptr}; +Block BC1_Red_Blue_Ignore_Alpha_Block = {BC1_Red_Blue_Ignore_Alpha, nullptr}; +Block BC1_Red_Green_Ignore_Alpha_Block = {BC1_Red_Green_Ignore_Alpha, nullptr}; +Block BC1_Green_Blue_Ignore_Alpha_Block = {BC1_Green_Blue_Ignore_Alpha, nullptr}; +Block BC1_Red_Half_Alpha_Block = {BC1_Red_Half_Alpha, nullptr}; +Block BC1_Green_Half_Alpha_Block = {BC1_Green_Half_Alpha, nullptr}; +Block BC2_Red_Ignore_Alpha_Block = {BC2_Red_Ignore_Alpha, nullptr}; +Block BC2_Blue_Half_Alpha_Block = {BC2_Blue_Half_Alpha, nullptr}; +Block BC2_White_Half_Alpha_Block = {BC2_White_Half_Alpha, nullptr}; +Block BC2_Black_Half_Alpha_Block = {BC2_Black_Half_Alpha, nullptr}; +Block BC2_Red_Blue_Half_Alpha_Block = {BC2_Red_Blue_Half_Alpha, nullptr}; +Block BC2_Red_Green_Half_Alpha_Block = {BC2_Red_Green_Half_Alpha, nullptr}; +Block BC2_Green_Blue_Half_Alpha_Block = {BC2_Green_Blue_Half_Alpha, nullptr}; +Block BC2_Red_Full_Alpha_Block = {BC2_Red_Full_Alpha, nullptr}; +Block BC2_Green_Full_Alpha_Block = {BC2_Green_Full_Alpha, nullptr}; +Block BC2_Blue_Full_Alpha_Block = {BC2_Blue_Full_Alpha, nullptr}; +Block BC2_White_Full_Alpha_Block = {BC2_White_Full_Alpha, nullptr}; +Block BC2_Green_Ignore_Alpha_Block = {BC2_Green_Ignore_Alpha, nullptr}; +Block BC2_Black_Full_Alpha_Block = {BC2_Black_Full_Alpha, nullptr}; +Block BC2_Red_Blue_Full_Alpha_Block = {BC2_Red_Blue_Full_Alpha, nullptr}; +Block BC2_Red_Green_Full_Alpha_Block = {BC2_Red_Green_Full_Alpha, nullptr}; +Block BC2_Green_Blue_Full_Alpha_Block = {BC2_Green_Blue_Full_Alpha, nullptr}; +Block BC2_Blue_Ignore_Alpha_Block = {BC2_Blue_Ignore_Alpha, nullptr}; +Block BC2_White_Ignore_Alpha_Block = {BC2_White_Ignore_Alpha, nullptr}; +Block BC2_Black_Ignore_Alpha_Block = {BC2_Black_Ignore_Alpha, nullptr}; +Block BC2_Red_Blue_Ignore_Alpha_Block = {BC2_Red_Blue_Ignore_Alpha, nullptr}; +Block BC2_Red_Green_Ignore_Alpha_Block = {BC2_Red_Green_Ignore_Alpha, nullptr}; +Block BC2_Green_Blue_Ignore_Alpha_Block = {BC2_Green_Blue_Ignore_Alpha, nullptr}; +Block BC2_Red_Half_Alpha_Block = {BC2_Red_Half_Alpha, nullptr}; +Block BC2_Green_Half_Alpha_Block = {BC2_Green_Half_Alpha, nullptr}; +Block BC3_Red_Ignore_Alpha_Block = {BC3_Red_Ignore_Alpha, nullptr}; +Block BC3_Blue_Half_Alpha_Block = {BC3_Blue_Half_Alpha, nullptr}; +Block BC3_White_Half_Alpha_Block = {BC3_White_Half_Alpha, nullptr}; +Block BC3_Black_Half_Alpha_Block = {BC3_Black_Half_Alpha, nullptr}; +Block BC3_Red_Blue_Half_Alpha_Block = {BC3_Red_Blue_Half_Alpha, nullptr}; +Block BC3_Red_Green_Half_Alpha_Block = {BC3_Red_Green_Half_Alpha, nullptr}; +Block BC3_Green_Blue_Half_Alpha_Block = {BC3_Green_Blue_Half_Alpha, nullptr}; +Block BC3_Red_Full_Alpha_Block = {BC3_Red_Full_Alpha, nullptr}; +Block BC3_Green_Full_Alpha_Block = {BC3_Green_Full_Alpha, nullptr}; +Block BC3_Blue_Full_Alpha_Block = {BC3_Blue_Full_Alpha, nullptr}; +Block BC3_White_Full_Alpha_Block = {BC3_White_Full_Alpha, nullptr}; +Block BC3_Green_Ignore_Alpha_Block = {BC3_Green_Ignore_Alpha, nullptr}; +Block BC3_Black_Full_Alpha_Block = {BC3_Black_Full_Alpha, nullptr}; +Block BC3_Red_Blue_Full_Alpha_Block = {BC3_Red_Blue_Full_Alpha, nullptr}; +Block BC3_Red_Green_Full_Alpha_Block = {BC3_Red_Green_Full_Alpha, nullptr}; +Block BC3_Green_Blue_Full_Alpha_Block = {BC3_Green_Blue_Full_Alpha, nullptr}; +Block BC3_Blue_Ignore_Alpha_Block = {BC3_Blue_Ignore_Alpha, nullptr}; +Block BC3_White_Ignore_Alpha_Block = {BC3_White_Ignore_Alpha, nullptr}; +Block BC3_Black_Ignore_Alpha_Block = {BC3_Black_Ignore_Alpha, nullptr}; +Block BC3_Red_Blue_Ignore_Alpha_Block = {BC3_Red_Blue_Ignore_Alpha, nullptr}; +Block BC3_Red_Green_Ignore_Alpha_Block = {BC3_Red_Green_Ignore_Alpha, nullptr}; +Block BC3_Green_Blue_Ignore_Alpha_Block = {BC3_Green_Blue_Ignore_Alpha, nullptr}; +Block BC3_Red_Half_Alpha_Block = {BC3_Red_Half_Alpha, nullptr}; +Block BC3_Green_Half_Alpha_Block = {BC3_Green_Half_Alpha, nullptr}; +Block BC4_Red_Ignore_Alpha_Block = {BC4_Red_Ignore_Alpha, nullptr}; +Block BC4_Blue_Half_Alpha_Block = {BC4_Blue_Half_Alpha, nullptr}; +Block BC4_White_Half_Alpha_Block = {BC4_White_Half_Alpha, nullptr}; +Block BC4_Black_Half_Alpha_Block = {BC4_Black_Half_Alpha, nullptr}; +Block BC4_Red_Blue_Half_Alpha_Block = {BC4_Red_Blue_Half_Alpha, nullptr}; +Block BC4_Red_Green_Half_Alpha_Block = {BC4_Red_Green_Half_Alpha, nullptr}; +Block BC4_Green_Blue_Half_Alpha_Block = {BC4_Green_Blue_Half_Alpha, nullptr}; +Block BC4_Red_Full_Alpha_Block = {BC4_Red_Full_Alpha, nullptr}; +Block BC4_Green_Full_Alpha_Block = {BC4_Green_Full_Alpha, nullptr}; +Block BC4_Blue_Full_Alpha_Block = {BC4_Blue_Full_Alpha, nullptr}; +Block BC4_White_Full_Alpha_Block = {BC4_White_Full_Alpha, nullptr}; +Block BC4_Green_Ignore_Alpha_Block = {BC4_Green_Ignore_Alpha, nullptr}; +Block BC4_Black_Full_Alpha_Block = {BC4_Black_Full_Alpha, nullptr}; +Block BC4_Red_Blue_Full_Alpha_Block = {BC4_Red_Blue_Full_Alpha, nullptr}; +Block BC4_Red_Green_Full_Alpha_Block = {BC4_Red_Green_Full_Alpha, nullptr}; +Block BC4_Green_Blue_Full_Alpha_Block = {BC4_Green_Blue_Full_Alpha, nullptr}; +Block BC4_Blue_Ignore_Alpha_Block = {BC4_Blue_Ignore_Alpha, nullptr}; +Block BC4_White_Ignore_Alpha_Block = {BC4_White_Ignore_Alpha, nullptr}; +Block BC4_Black_Ignore_Alpha_Block = {BC4_Black_Ignore_Alpha, nullptr}; +Block BC4_Red_Blue_Ignore_Alpha_Block = {BC4_Red_Blue_Ignore_Alpha, nullptr}; +Block BC4_Red_Green_Ignore_Alpha_Block = {BC4_Red_Green_Ignore_Alpha, nullptr}; +Block BC4_Green_Blue_Ignore_Alpha_Block = {BC4_Green_Blue_Ignore_Alpha, nullptr}; +Block BC4_Red_Half_Alpha_Block = {BC4_Red_Half_Alpha, nullptr}; +Block BC4_Green_Half_Alpha_Block = {BC4_Green_Half_Alpha, nullptr}; +Block BC5_Red_Ignore_Alpha_Block = {BC5_Red_Ignore_Alpha, nullptr}; +Block BC5_Blue_Half_Alpha_Block = {BC5_Blue_Half_Alpha, nullptr}; +Block BC5_White_Half_Alpha_Block = {BC5_White_Half_Alpha, nullptr}; +Block BC5_Black_Half_Alpha_Block = {BC5_Black_Half_Alpha, nullptr}; +Block BC5_Red_Blue_Half_Alpha_Block = {BC5_Red_Blue_Half_Alpha, nullptr}; +Block BC5_Red_Green_Half_Alpha_Block = {BC5_Red_Green_Half_Alpha, nullptr}; +Block BC5_Green_Blue_Half_Alpha_Block = {BC5_Green_Blue_Half_Alpha, nullptr}; +Block BC5_Red_Full_Alpha_Block = {BC5_Red_Full_Alpha, nullptr}; +Block BC5_Green_Full_Alpha_Block = {BC5_Green_Full_Alpha, nullptr}; +Block BC5_Blue_Full_Alpha_Block = {BC5_Blue_Full_Alpha, nullptr}; +Block BC5_White_Full_Alpha_Block = {BC5_White_Full_Alpha, nullptr}; +Block BC5_Green_Ignore_Alpha_Block = {BC5_Green_Ignore_Alpha, nullptr}; +Block BC5_Black_Full_Alpha_Block = {BC5_Black_Full_Alpha, nullptr}; +Block BC5_Red_Blue_Full_Alpha_Block = {BC5_Red_Blue_Full_Alpha, nullptr}; +Block BC5_Red_Green_Full_Alpha_Block = {BC5_Red_Green_Full_Alpha, nullptr}; +Block BC5_Green_Blue_Full_Alpha_Block = {BC5_Green_Blue_Full_Alpha, nullptr}; +Block BC5_Blue_Ignore_Alpha_Block = {BC5_Blue_Ignore_Alpha, nullptr}; +Block BC5_White_Ignore_Alpha_Block = {BC5_White_Ignore_Alpha, nullptr}; +Block BC5_Black_Ignore_Alpha_Block = {BC5_Black_Ignore_Alpha, nullptr}; +Block BC5_Red_Blue_Ignore_Alpha_Block = {BC5_Red_Blue_Ignore_Alpha, nullptr}; +Block BC5_Red_Green_Ignore_Alpha_Block = {BC5_Red_Green_Ignore_Alpha, nullptr}; +Block BC5_Green_Blue_Ignore_Alpha_Block = {BC5_Green_Blue_Ignore_Alpha, nullptr}; +Block BC5_Red_Half_Alpha_Block = {BC5_Red_Half_Alpha, nullptr}; +Block BC5_Green_Half_Alpha_Block = {BC5_Green_Half_Alpha, nullptr}; +BlockBC6 BC6_Red_Ignore_Alpha_Block = {BC6_Red_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Blue_Half_Alpha_Block = {BC6_Blue_Half_Alpha, nullptr}; +BlockBC6 BC6_White_Half_Alpha_Block = {BC6_White_Half_Alpha, nullptr}; +BlockBC6 BC6_Black_Half_Alpha_Block = {BC6_Black_Half_Alpha, nullptr}; +BlockBC6 BC6_Red_Blue_Half_Alpha_Block = {BC6_Red_Blue_Half_Alpha, nullptr}; +BlockBC6 BC6_Red_Green_Half_Alpha_Block = {BC6_Red_Green_Half_Alpha, nullptr}; +BlockBC6 BC6_Green_Blue_Half_Alpha_Block = {BC6_Green_Blue_Half_Alpha, nullptr}; +BlockBC6 BC6_Red_Full_Alpha_Block = {BC6_Red_Full_Alpha, nullptr}; +BlockBC6 BC6_Green_Full_Alpha_Block = {BC6_Green_Full_Alpha, nullptr}; +BlockBC6 BC6_Blue_Full_Alpha_Block = {BC6_Blue_Full_Alpha, nullptr}; +BlockBC6 BC6_White_Full_Alpha_Block = {BC6_White_Full_Alpha, nullptr}; +BlockBC6 BC6_Green_Ignore_Alpha_Block = {BC6_Green_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Black_Full_Alpha_Block = {BC6_Black_Full_Alpha, nullptr}; +BlockBC6 BC6_Red_Blue_Full_Alpha_Block = {BC6_Red_Blue_Full_Alpha, nullptr}; +BlockBC6 BC6_Red_Green_Full_Alpha_Block = {BC6_Red_Green_Full_Alpha, nullptr}; +BlockBC6 BC6_Green_Blue_Full_Alpha_Block = {BC6_Green_Blue_Full_Alpha, nullptr}; +BlockBC6 BC6_Blue_Ignore_Alpha_Block = {BC6_Blue_Ignore_Alpha, nullptr}; +BlockBC6 BC6_White_Ignore_Alpha_Block = {BC6_White_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Black_Ignore_Alpha_Block = {BC6_Black_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Red_Blue_Ignore_Alpha_Block = {BC6_Red_Blue_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Red_Green_Ignore_Alpha_Block = {BC6_Red_Green_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Green_Blue_Ignore_Alpha_Block = {BC6_Green_Blue_Ignore_Alpha, nullptr}; +BlockBC6 BC6_Red_Half_Alpha_Block = {BC6_Red_Half_Alpha, nullptr}; +BlockBC6 BC6_Green_Half_Alpha_Block = {BC6_Green_Half_Alpha, nullptr}; +Block BC7_Red_Ignore_Alpha_Block = {BC7_Red_Ignore_Alpha, nullptr}; +Block BC7_Blue_Half_Alpha_Block = {BC7_Blue_Half_Alpha, nullptr}; +Block BC7_White_Half_Alpha_Block = {BC7_White_Half_Alpha, nullptr}; +Block BC7_Black_Half_Alpha_Block = {BC7_Black_Half_Alpha, nullptr}; +Block BC7_Red_Blue_Half_Alpha_Block = {BC7_Red_Blue_Half_Alpha, nullptr}; +Block BC7_Red_Green_Half_Alpha_Block = {BC7_Red_Green_Half_Alpha, nullptr}; +Block BC7_Green_Blue_Half_Alpha_Block = {BC7_Green_Blue_Half_Alpha, nullptr}; +Block BC7_Red_Full_Alpha_Block = {BC7_Red_Full_Alpha, nullptr}; +Block BC7_Green_Full_Alpha_Block = {BC7_Green_Full_Alpha, nullptr}; +Block BC7_Blue_Full_Alpha_Block = {BC7_Blue_Full_Alpha, nullptr}; +Block BC7_White_Full_Alpha_Block = {BC7_White_Full_Alpha, nullptr}; +Block BC7_Green_Ignore_Alpha_Block = {BC7_Green_Ignore_Alpha, nullptr}; +Block BC7_Black_Full_Alpha_Block = {BC7_Black_Full_Alpha, nullptr}; +Block BC7_Red_Blue_Full_Alpha_Block = {BC7_Red_Blue_Full_Alpha, nullptr}; +Block BC7_Red_Green_Full_Alpha_Block = {BC7_Red_Green_Full_Alpha, nullptr}; +Block BC7_Green_Blue_Full_Alpha_Block = {BC7_Green_Blue_Full_Alpha, nullptr}; +Block BC7_Blue_Ignore_Alpha_Block = {BC7_Blue_Ignore_Alpha, nullptr}; +Block BC7_White_Ignore_Alpha_Block = {BC7_White_Ignore_Alpha, nullptr}; +Block BC7_Black_Ignore_Alpha_Block = {BC7_Black_Ignore_Alpha, nullptr}; +Block BC7_Red_Blue_Ignore_Alpha_Block = {BC7_Red_Blue_Ignore_Alpha, nullptr}; +Block BC7_Red_Green_Ignore_Alpha_Block = {BC7_Red_Green_Ignore_Alpha, nullptr}; +Block BC7_Green_Blue_Ignore_Alpha_Block = {BC7_Green_Blue_Ignore_Alpha, nullptr}; +Block BC7_Red_Half_Alpha_Block = {BC7_Red_Half_Alpha, nullptr}; +Block BC7_Green_Half_Alpha_Block = {BC7_Green_Half_Alpha, nullptr}; + +static std::unordered_map blocks { + { "BC1_Red_Ignore_Alpha", BC1_Red_Ignore_Alpha_Block}, + { "BC1_Blue_Half_Alpha", BC1_Blue_Half_Alpha_Block}, + { "BC1_White_Half_Alpha", BC1_White_Half_Alpha_Block}, + { "BC1_Black_Half_Alpha", BC1_Black_Half_Alpha_Block}, + { "BC1_Red_Blue_Half_Alpha", BC1_Red_Blue_Half_Alpha_Block}, + { "BC1_Red_Green_Half_Alpha", BC1_Red_Green_Half_Alpha_Block}, + { "BC1_Green_Blue_Half_Alpha", BC1_Green_Blue_Half_Alpha_Block}, + { "BC1_Red_Full_Alpha", BC1_Red_Full_Alpha_Block}, + { "BC1_Green_Full_Alpha", BC1_Green_Full_Alpha_Block}, + { "BC1_Blue_Full_Alpha", BC1_Blue_Full_Alpha_Block}, + { "BC1_White_Full_Alpha", BC1_White_Full_Alpha_Block}, + { "BC1_Green_Ignore_Alpha", BC1_Green_Ignore_Alpha_Block}, + { "BC1_Black_Full_Alpha", BC1_Black_Full_Alpha_Block}, + { "BC1_Red_Blue_Full_Alpha", BC1_Red_Blue_Full_Alpha_Block}, + { "BC1_Red_Green_Full_Alpha", BC1_Red_Green_Full_Alpha_Block}, + { "BC1_Green_Blue_Full_Alpha", BC1_Green_Blue_Full_Alpha_Block}, + { "BC1_Blue_Ignore_Alpha", BC1_Blue_Ignore_Alpha_Block}, + { "BC1_White_Ignore_Alpha", BC1_White_Ignore_Alpha_Block}, + { "BC1_Black_Ignore_Alpha", BC1_Black_Ignore_Alpha_Block}, + { "BC1_Red_Blue_Ignore_Alpha", BC1_Red_Blue_Ignore_Alpha_Block}, + { "BC1_Red_Green_Ignore_Alpha", BC1_Red_Green_Ignore_Alpha_Block}, + { "BC1_Green_Blue_Ignore_Alpha", BC1_Green_Blue_Ignore_Alpha_Block}, + { "BC1_Red_Half_Alpha", BC1_Red_Half_Alpha_Block}, + { "BC1_Green_Half_Alpha", BC1_Green_Half_Alpha_Block}, + { "BC2_Red_Ignore_Alpha", BC2_Red_Ignore_Alpha_Block}, + { "BC2_Blue_Half_Alpha", BC2_Blue_Half_Alpha_Block}, + { "BC2_White_Half_Alpha", BC2_White_Half_Alpha_Block}, + { "BC2_Black_Half_Alpha", BC2_Black_Half_Alpha_Block}, + { "BC2_Red_Blue_Half_Alpha", BC2_Red_Blue_Half_Alpha_Block}, + { "BC2_Red_Green_Half_Alpha", BC2_Red_Green_Half_Alpha_Block}, + { "BC2_Green_Blue_Half_Alpha", BC2_Green_Blue_Half_Alpha_Block}, + { "BC2_Red_Full_Alpha", BC2_Red_Full_Alpha_Block}, + { "BC2_Green_Full_Alpha", BC2_Green_Full_Alpha_Block}, + { "BC2_Blue_Full_Alpha", BC2_Blue_Full_Alpha_Block}, + { "BC2_White_Full_Alpha", BC2_White_Full_Alpha_Block}, + { "BC2_Green_Ignore_Alpha", BC2_Green_Ignore_Alpha_Block}, + { "BC2_Black_Full_Alpha", BC2_Black_Full_Alpha_Block}, + { "BC2_Red_Blue_Full_Alpha", BC2_Red_Blue_Full_Alpha_Block}, + { "BC2_Red_Green_Full_Alpha", BC2_Red_Green_Full_Alpha_Block}, + { "BC2_Green_Blue_Full_Alpha", BC2_Green_Blue_Full_Alpha_Block}, + { "BC2_Blue_Ignore_Alpha", BC2_Blue_Ignore_Alpha_Block}, + { "BC2_White_Ignore_Alpha", BC2_White_Ignore_Alpha_Block}, + { "BC2_Black_Ignore_Alpha", BC2_Black_Ignore_Alpha_Block}, + { "BC2_Red_Blue_Ignore_Alpha", BC2_Red_Blue_Ignore_Alpha_Block}, + { "BC2_Red_Green_Ignore_Alpha", BC2_Red_Green_Ignore_Alpha_Block}, + { "BC2_Green_Blue_Ignore_Alpha", BC2_Green_Blue_Ignore_Alpha_Block}, + { "BC2_Red_Half_Alpha", BC2_Red_Half_Alpha_Block}, + { "BC2_Green_Half_Alpha", BC2_Green_Half_Alpha_Block}, + { "BC3_Red_Ignore_Alpha", BC3_Red_Ignore_Alpha_Block}, + { "BC3_Blue_Half_Alpha", BC3_Blue_Half_Alpha_Block}, + { "BC3_White_Half_Alpha", BC3_White_Half_Alpha_Block}, + { "BC3_Black_Half_Alpha", BC3_Black_Half_Alpha_Block}, + { "BC3_Red_Blue_Half_Alpha", BC3_Red_Blue_Half_Alpha_Block}, + { "BC3_Red_Green_Half_Alpha", BC3_Red_Green_Half_Alpha_Block}, + { "BC3_Green_Blue_Half_Alpha", BC3_Green_Blue_Half_Alpha_Block}, + { "BC3_Red_Full_Alpha", BC3_Red_Full_Alpha_Block}, + { "BC3_Green_Full_Alpha", BC3_Green_Full_Alpha_Block}, + { "BC3_Blue_Full_Alpha", BC3_Blue_Full_Alpha_Block}, + { "BC3_White_Full_Alpha", BC3_White_Full_Alpha_Block}, + { "BC3_Green_Ignore_Alpha", BC3_Green_Ignore_Alpha_Block}, + { "BC3_Black_Full_Alpha", BC3_Black_Full_Alpha_Block}, + { "BC3_Red_Blue_Full_Alpha", BC3_Red_Blue_Full_Alpha_Block}, + { "BC3_Red_Green_Full_Alpha", BC3_Red_Green_Full_Alpha_Block}, + { "BC3_Green_Blue_Full_Alpha", BC3_Green_Blue_Full_Alpha_Block}, + { "BC3_Blue_Ignore_Alpha", BC3_Blue_Ignore_Alpha_Block}, + { "BC3_White_Ignore_Alpha", BC3_White_Ignore_Alpha_Block}, + { "BC3_Black_Ignore_Alpha", BC3_Black_Ignore_Alpha_Block}, + { "BC3_Red_Blue_Ignore_Alpha", BC3_Red_Blue_Ignore_Alpha_Block}, + { "BC3_Red_Green_Ignore_Alpha", BC3_Red_Green_Ignore_Alpha_Block}, + { "BC3_Green_Blue_Ignore_Alpha", BC3_Green_Blue_Ignore_Alpha_Block}, + { "BC3_Red_Half_Alpha", BC3_Red_Half_Alpha_Block}, + { "BC3_Green_Half_Alpha", BC3_Green_Half_Alpha_Block}, + { "BC4_Red_Ignore_Alpha", BC4_Red_Ignore_Alpha_Block}, + { "BC4_Blue_Half_Alpha", BC4_Blue_Half_Alpha_Block}, + { "BC4_White_Half_Alpha", BC4_White_Half_Alpha_Block}, + { "BC4_Black_Half_Alpha", BC4_Black_Half_Alpha_Block}, + { "BC4_Red_Blue_Half_Alpha", BC4_Red_Blue_Half_Alpha_Block}, + { "BC4_Red_Green_Half_Alpha", BC4_Red_Green_Half_Alpha_Block}, + { "BC4_Green_Blue_Half_Alpha", BC4_Green_Blue_Half_Alpha_Block}, + { "BC4_Red_Full_Alpha", BC4_Red_Full_Alpha_Block}, + { "BC4_Green_Full_Alpha", BC4_Green_Full_Alpha_Block}, + { "BC4_Blue_Full_Alpha", BC4_Blue_Full_Alpha_Block}, + { "BC4_White_Full_Alpha", BC4_White_Full_Alpha_Block}, + { "BC4_Green_Ignore_Alpha", BC4_Green_Ignore_Alpha_Block}, + { "BC4_Black_Full_Alpha", BC4_Black_Full_Alpha_Block}, + { "BC4_Red_Blue_Full_Alpha", BC4_Red_Blue_Full_Alpha_Block}, + { "BC4_Red_Green_Full_Alpha", BC4_Red_Green_Full_Alpha_Block}, + { "BC4_Green_Blue_Full_Alpha", BC4_Green_Blue_Full_Alpha_Block}, + { "BC4_Blue_Ignore_Alpha", BC4_Blue_Ignore_Alpha_Block}, + { "BC4_White_Ignore_Alpha", BC4_White_Ignore_Alpha_Block}, + { "BC4_Black_Ignore_Alpha", BC4_Black_Ignore_Alpha_Block}, + { "BC4_Red_Blue_Ignore_Alpha", BC4_Red_Blue_Ignore_Alpha_Block}, + { "BC4_Red_Green_Ignore_Alpha", BC4_Red_Green_Ignore_Alpha_Block}, + { "BC4_Green_Blue_Ignore_Alpha", BC4_Green_Blue_Ignore_Alpha_Block}, + { "BC4_Red_Half_Alpha", BC4_Red_Half_Alpha_Block}, + { "BC4_Green_Half_Alpha", BC4_Green_Half_Alpha_Block}, + { "BC5_Red_Ignore_Alpha", BC5_Red_Ignore_Alpha_Block}, + { "BC5_Blue_Half_Alpha", BC5_Blue_Half_Alpha_Block}, + { "BC5_White_Half_Alpha", BC5_White_Half_Alpha_Block}, + { "BC5_Black_Half_Alpha", BC5_Black_Half_Alpha_Block}, + { "BC5_Red_Blue_Half_Alpha", BC5_Red_Blue_Half_Alpha_Block}, + { "BC5_Red_Green_Half_Alpha", BC5_Red_Green_Half_Alpha_Block}, + { "BC5_Green_Blue_Half_Alpha", BC5_Green_Blue_Half_Alpha_Block}, + { "BC5_Red_Full_Alpha", BC5_Red_Full_Alpha_Block}, + { "BC5_Green_Full_Alpha", BC5_Green_Full_Alpha_Block}, + { "BC5_Blue_Full_Alpha", BC5_Blue_Full_Alpha_Block}, + { "BC5_White_Full_Alpha", BC5_White_Full_Alpha_Block}, + { "BC5_Green_Ignore_Alpha", BC5_Green_Ignore_Alpha_Block}, + { "BC5_Black_Full_Alpha", BC5_Black_Full_Alpha_Block}, + { "BC5_Red_Blue_Full_Alpha", BC5_Red_Blue_Full_Alpha_Block}, + { "BC5_Red_Green_Full_Alpha", BC5_Red_Green_Full_Alpha_Block}, + { "BC5_Green_Blue_Full_Alpha", BC5_Green_Blue_Full_Alpha_Block}, + { "BC5_Blue_Ignore_Alpha", BC5_Blue_Ignore_Alpha_Block}, + { "BC5_White_Ignore_Alpha", BC5_White_Ignore_Alpha_Block}, + { "BC5_Black_Ignore_Alpha", BC5_Black_Ignore_Alpha_Block}, + { "BC5_Red_Blue_Ignore_Alpha", BC5_Red_Blue_Ignore_Alpha_Block}, + { "BC5_Red_Green_Ignore_Alpha", BC5_Red_Green_Ignore_Alpha_Block}, + { "BC5_Green_Blue_Ignore_Alpha", BC5_Green_Blue_Ignore_Alpha_Block}, + { "BC5_Red_Half_Alpha", BC5_Red_Half_Alpha_Block}, + { "BC5_Green_Half_Alpha", BC5_Green_Half_Alpha_Block}, + { "BC7_Red_Ignore_Alpha", BC7_Red_Ignore_Alpha_Block}, + { "BC7_Blue_Half_Alpha", BC7_Blue_Half_Alpha_Block}, + { "BC7_White_Half_Alpha", BC7_White_Half_Alpha_Block}, + { "BC7_Black_Half_Alpha", BC7_Black_Half_Alpha_Block}, + { "BC7_Red_Blue_Half_Alpha", BC7_Red_Blue_Half_Alpha_Block}, + { "BC7_Red_Green_Half_Alpha", BC7_Red_Green_Half_Alpha_Block}, + { "BC7_Green_Blue_Half_Alpha", BC7_Green_Blue_Half_Alpha_Block}, + { "BC7_Red_Full_Alpha", BC7_Red_Full_Alpha_Block}, + { "BC7_Green_Full_Alpha", BC7_Green_Full_Alpha_Block}, + { "BC7_Blue_Full_Alpha", BC7_Blue_Full_Alpha_Block}, + { "BC7_White_Full_Alpha", BC7_White_Full_Alpha_Block}, + { "BC7_Green_Ignore_Alpha", BC7_Green_Ignore_Alpha_Block}, + { "BC7_Black_Full_Alpha", BC7_Black_Full_Alpha_Block}, + { "BC7_Red_Blue_Full_Alpha", BC7_Red_Blue_Full_Alpha_Block}, + { "BC7_Red_Green_Full_Alpha", BC7_Red_Green_Full_Alpha_Block}, + { "BC7_Green_Blue_Full_Alpha", BC7_Green_Blue_Full_Alpha_Block}, + { "BC7_Blue_Ignore_Alpha", BC7_Blue_Ignore_Alpha_Block}, + { "BC7_White_Ignore_Alpha", BC7_White_Ignore_Alpha_Block}, + { "BC7_Black_Ignore_Alpha", BC7_Black_Ignore_Alpha_Block}, + { "BC7_Red_Blue_Ignore_Alpha", BC7_Red_Blue_Ignore_Alpha_Block}, + { "BC7_Red_Green_Ignore_Alpha", BC7_Red_Green_Ignore_Alpha_Block}, + { "BC7_Green_Blue_Ignore_Alpha", BC7_Green_Blue_Ignore_Alpha_Block}, + { "BC7_Red_Half_Alpha", BC7_Red_Half_Alpha_Block}, + { "BC7_Green_Half_Alpha", BC7_Green_Half_Alpha_Block} +}; + +static std::unordered_map blocksBC6 { + { "BC6_Red_Ignore_Alpha", BC6_Red_Ignore_Alpha_Block}, + { "BC6_Blue_Half_Alpha", BC6_Blue_Half_Alpha_Block}, + { "BC6_White_Half_Alpha", BC6_White_Half_Alpha_Block}, + { "BC6_Black_Half_Alpha", BC6_Black_Half_Alpha_Block}, + { "BC6_Red_Blue_Half_Alpha", BC6_Red_Blue_Half_Alpha_Block}, + { "BC6_Red_Green_Half_Alpha", BC6_Red_Green_Half_Alpha_Block}, + { "BC6_Green_Blue_Half_Alpha", BC6_Green_Blue_Half_Alpha_Block}, + { "BC6_Red_Full_Alpha", BC6_Red_Full_Alpha_Block}, + { "BC6_Green_Full_Alpha", BC6_Green_Full_Alpha_Block}, + { "BC6_Blue_Full_Alpha", BC6_Blue_Full_Alpha_Block}, + { "BC6_White_Full_Alpha", BC6_White_Full_Alpha_Block}, + { "BC6_Green_Ignore_Alpha", BC6_Green_Ignore_Alpha_Block}, + { "BC6_Black_Full_Alpha", BC6_Black_Full_Alpha_Block}, + { "BC6_Red_Blue_Full_Alpha", BC6_Red_Blue_Full_Alpha_Block}, + { "BC6_Red_Green_Full_Alpha", BC6_Red_Green_Full_Alpha_Block}, + { "BC6_Green_Blue_Full_Alpha", BC6_Green_Blue_Full_Alpha_Block}, + { "BC6_Blue_Ignore_Alpha", BC6_Blue_Ignore_Alpha_Block}, + { "BC6_White_Ignore_Alpha", BC6_White_Ignore_Alpha_Block}, + { "BC6_Black_Ignore_Alpha", BC6_Black_Ignore_Alpha_Block}, + { "BC6_Red_Blue_Ignore_Alpha", BC6_Red_Blue_Ignore_Alpha_Block}, + { "BC6_Red_Green_Ignore_Alpha", BC6_Red_Green_Ignore_Alpha_Block}, + { "BC6_Green_Blue_Ignore_Alpha", BC6_Green_Blue_Ignore_Alpha_Block}, + { "BC6_Red_Half_Alpha", BC6_Red_Half_Alpha_Block}, + { "BC6_Green_Half_Alpha", BC6_Green_Half_Alpha_Block} +}; + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/test/CMakeLists.txt b/extern/CMP_Core/test/CMakeLists.txt new file mode 100644 index 00000000..f01de34a --- /dev/null +++ b/extern/CMP_Core/test/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.5) +project(CMP_Core_Tests) + +add_executable(Tests TestsMain.cpp) +add_subdirectory(../../../Common/Lib/Ext/Catch2 + Common/Lib/Ext/Catch2/bin) +target_sources(Tests + PRIVATE + CompressonatorTests.cpp + CompressonatorTests.h + BlockConstants.h + ../../Applications/_Plugins/Common/UtilFuncs.cpp + ../../Applications/_Plugins/Common/UtilFuncs.h + ) +target_link_libraries(Tests Catch2::Catch2 CMP_Core) diff --git a/extern/CMP_Core/test/CompressonatorTests.cpp b/extern/CMP_Core/test/CompressonatorTests.cpp new file mode 100644 index 00000000..bb891ea2 --- /dev/null +++ b/extern/CMP_Core/test/CompressonatorTests.cpp @@ -0,0 +1,2608 @@ +#include +#include +#include "../../../Common/Lib/Ext/Catch2/catch.hpp" +#include "../source/CMP_Core.h" +#include "../../Applications/_Plugins/Common/UtilFuncs.h" +// incudes all compressed 4x4 blocks +#include "BlockConstants.h" +#include "CompressonatorTests.h" + +static const int BC1_BLOCK_SIZE = 8; +static const int BC2_BLOCK_SIZE = 16; +static const int BC3_BLOCK_SIZE = 16; +static const int DECOMPRESSED_BLOCK_SIZE = 64; +static const int STRIDE_DECOMPRESSED = 16; + +static const std::map> colorValues{ + { "Red_Ignore_Alpha", { 0xff, 0x0, 0x0, 0xff }}, + { "Green_Ignore_Alpha" , { 0x0, 0xff, 0x0, 0xff }}, + { "Blue_Ignore_Alpha" , { 0x0, 0x0, 0xff, 0xff }}, + { "White_Ignore_Alpha" , { 0xff, 0xff, 0xff, 0xff }}, + { "Black_Ignore_Alpha" , { 0x0, 0x0, 0x0, 0xff }}, + { "Red_Blue_Ignore_Alpha" , { 0xff, 0x0, 0xff, 0xff }}, + { "Red_Green_Ignore_Alpha" , { 0xff, 0xff, 0x0, 0xff }}, + { "Green_Blue_Ignore_Alpha", { 0x0, 0xff, 0xff, 0xff }}, + + { "Red_Half_Alpha" , { 0xff, 0x0, 0x0, 0x7b }}, + { "Green_Half_Alpha" , { 0x0, 0xff, 0x0, 0x7b }}, + { "Blue_Half_Alpha" , { 0x0, 0x0, 0xff, 0x7b }}, + { "White_Half_Alpha" , { 0xff, 0xff, 0xff, 0x7b }}, + { "Black_Half_Alpha" , { 0x0, 0x0, 0x0, 0x7b }}, + { "Red_Blue_Half_Alpha" , { 0xff, 0x0, 0xff, 0x7b }}, + { "Red_Green_Half_Alpha", { 0xff, 0xff, 0x0, 0x7b }}, + { "Green_Blue_Half_Alpha" , { 0x0, 0xff, 0xff, 0x7b }}, + + { "Red_Full_Alpha" , { 0xff, 0x0, 0x0, 0x0 }}, + { "Green_Full_Alpha" , { 0x0, 0xff, 0x0, 0x0 }}, + { "Blue_Full_Alpha" , { 0x0, 0x0, 0xff, 0x0 }}, + { "White_Full_Alpha" , { 0xff, 0xff, 0xff, 0x0 }}, + { "Black_Full_Alpha" , { 0x0, 0x0, 0x0, 0x0 }}, + { "Red_Blue_Full_Alpha" , { 0xff, 0x0, 0xff, 0x0 }}, + { "Red_Green_Full_Alpha", { 0xff, 0xff, 0x0, 0x0 }}, + { "Green_Blue_Full_Alpha" , { 0x0, 0xff, 0xff, 0x0 }} +}; + +const std::map> colorValuesBC6{ + { "Red_Ignore_Alpha", { 1.0f, 0.0f, 0.0f}}, + { "Green_Ignore_Alpha" , { 0.0f, 01.0f, 0.0f}}, + { "Blue_Ignore_Alpha" , { 0.0f, 0.0f, 1.0f}}, + { "White_Ignore_Alpha" , { 1.0f, 1.0f, 1.0f}}, + { "Black_Ignore_Alpha" , { 0.0f, 0.0f, 0.0f}}, + { "Red_Blue_Ignore_Alpha" , { 1.0f, 0.0f, 1.0f}}, + { "Red_Green_Ignore_Alpha" , { 1.0f, 1.0f, 0.0f}}, + { "Green_Blue_Ignore_Alpha", { 0.0f, 1.0f, 1.0f }}, +}; + +//block storage format: [R, G, B, W, Black, RB, RG, GB]. Alpha: 100%, 50%, 0% +enum ColorEnum { + Red, Green, Blue, White, Black, Red_Blue, Red_Green, Green_Blue +}; +enum AlphaEnum { + Ignore_Alpha, Half_Alpha, Full_Alpha +}; +enum CompEnum { + BC1, BC2, BC3, BC4, BC5, BC7, BC6 +}; + +std::string BlockKeyName(CompEnum compression, ColorEnum color, AlphaEnum alpha) { + std::string result = ""; + switch (compression) { + case BC1: result += "BC1"; break; + case BC2: result += "BC2"; break; + case BC3: result += "BC3"; break; + case BC4: result += "BC4"; break; + case BC5: result += "BC5"; break; + case BC6: result += "BC6"; break; + case BC7: result += "BC7"; break; + } + switch (color) { + case Red: result += "_Red_"; break; + case Green: result += "_Green_"; break; + case Blue: result += "_Blue_"; break; + case White: result += "_White_"; break; + case Black: result += "_Black_"; break; + case Red_Blue: result += "_Red_Blue_"; break; + case Red_Green: result += "_Red_Green_"; break; + case Green_Blue: result += "_Green_Blue_"; break; + } + switch (alpha) { + case Ignore_Alpha: result += "Ignore_Alpha"; break; + case Half_Alpha: result += "Half_Alpha"; break; + case Full_Alpha: result += "Full_Alpha"; break; + } + return result; +} + +void AssignExpectedColorsToBlocks() { + ColorEnum color = Red; + CompEnum comp = BC1; + AlphaEnum alpha = Ignore_Alpha; + for (int i = 0; i < blocks.size(); ++i) { + if (i % 24 == 0 && i > 0) { + comp = static_cast(comp + 1); + } + if (comp == CompEnum::BC6) //Bc6 blocks are stored in its own blocks map. + continue; + + if (i % 8 == 0 && i > 0) { + alpha = static_cast((alpha + 1) % 3); + } + const std::string keyBlocks = BlockKeyName(comp, color, alpha); + std::string keyColor = keyBlocks; + keyColor.erase(0, 4); + auto it = (blocks.find(keyBlocks)); + it->second.color = ((colorValues.find(keyColor))->second).data(); + color = static_cast((color + 1) % 8); + } + // BC6 list + comp = CompEnum::BC6; + for (int i = 0; i < blocksBC6.size(); ++i){ + if (i % 8 == 0 && i > 0) { + alpha = static_cast((alpha + 1) % 3); + } + const std::string keyBlocks = BlockKeyName(comp, color, alpha); + std::string keyColor = BlockKeyName(comp, color, AlphaEnum::Ignore_Alpha); + // string keyColor is in format BCn_color_alpha. To use it as key to access colorValues, delete the BCn_ part. + keyColor.erase(0, 4); + ((blocksBC6.find(keyBlocks))->second).color = ((colorValuesBC6.find(keyColor))->second).data(); + color = static_cast((color + 1) % 8); + } +} + +bool ColorMatches(unsigned char* buffer, const unsigned char* expectedColor, bool ignoreAlpha) +{ + unsigned char expectedColorBuffer[64]; + // handle formats that do not support alpha. + if (ignoreAlpha) { + // if alpha is ignored, BC should set all values to 0. exept the alpha value which can be 0 or 0xff only. + // Since all blocks have the same color, there should always be the same alpha. + if (buffer[3] != 0 && buffer[3] != 255) { + return false; + } + unsigned char expColorWithoutAlpha[4] = { 0 }; + // Only when the alpha value is 0xff colors are stored. Otherwise the RGB colors were set to 0 by during compression. + if (expectedColor[3] == 0xff) { + memcpy(expColorWithoutAlpha, expectedColor, 4); + } + // Set alpha value to the alpha value in the first pixel of the decompressed buffer. + // The buffer contains only one color, so all pixels should have the same values. + expColorWithoutAlpha[3] = buffer[3]; + + for (int idx = 0; idx < DECOMPRESSED_BLOCK_SIZE / 4; ++idx) { + memcpy(expectedColorBuffer + (idx * 4), expColorWithoutAlpha, 4); + } + return memcmp(&expectedColorBuffer, buffer, DECOMPRESSED_BLOCK_SIZE) == 0; + } + + for (int idx = 0; idx < DECOMPRESSED_BLOCK_SIZE / 4; ++idx) { + memcpy(expectedColorBuffer + (idx * 4), expectedColor, 4); + } + return memcmp(&expectedColorBuffer, buffer, DECOMPRESSED_BLOCK_SIZE) == 0; +} + + +bool ColorMatchesBC4(unsigned char* buffer, const unsigned char* expectedColor) { + unsigned char expectedColorBuffer[16]; + for (int i = 0; i < 16; ++i) { + expectedColorBuffer[i] = expectedColor[0]; //Bc4 supports red channel only. + } + return memcmp(&expectedColorBuffer, buffer, sizeof(expectedColorBuffer)) == 0; +} + +bool ColorMatchesBC5(unsigned char* bufferR, unsigned char* bufferG, const unsigned char* expectedColor) { + unsigned char expectedColorR[16]; + unsigned char expectedColorG[16]; + for (int i = 0; i < 16; ++i) { + expectedColorR[i] = expectedColor[0]; //Bc5 supports red channel and green channel only. + expectedColorG[i] = expectedColor[1]; + } + return memcmp(&expectedColorR, bufferR, 16) == 0 && memcmp(&expectedColorG, bufferG, 16) == 0; +} + +bool ColorMatchesBC6(unsigned short* buffer, const float* expectedColor) +{ + float bufferInFloat[48]; + float expectedColorBuffer[48]; + for (int i = 0; i < 16; ++i) { + // SF16: 1:5:10 : 1bit signed, 5bit exponent, 10bit mantissa + // DecompressBC6 stores decompressed color as SF16 + // BC6 stores RGB channels only + for (int channel = 0; channel < 3; ++channel) { + // convert expcolor float to half-float with intrinsic + //__m128 val = _mm_load_ps1(&expColor); + //__m128i half = _mm_cvtps_ph(val, 0); + //unsigned short expColorSh = _mm_extract_epi32(half, 0); + unsigned short color = buffer[i * 3 + channel]; + bufferInFloat[i * 3 + channel] = HalfToFloat(color); + + expectedColorBuffer[i * 3 + channel] = expectedColor[channel]; + } + } + return memcmp(&expectedColorBuffer, bufferInFloat, sizeof(expectedColorBuffer)) == 0; +} + +//*************************************************************************************** + +TEST_CASE("BC1_Red_Ignore_Alpha", "[BC1_Red_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Blue_Half_Alpha", "[BC1_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_White_Half_Alpha", "[BC1_White_Half_Alpha]") +{ + const auto block = blocks.find("BC1_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Black_Half_Alpha", "[BC1_Black_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Blue_Half_Alpha", "[BC1_Red_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Green_Half_Alpha", "[BC1_Red_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Green_Blue_Half_Alpha", "[BC1_Green_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Full_Alpha", "[BC1_Red_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Green_Full_Alpha", "[BC1_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Blue_Full_Alpha", "[BC1_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_White_Full_Alpha", "[BC1_White_Full_Alpha]") +{ + const auto block = blocks.find("BC1_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Green_Ignore_Alpha", "[BC1_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Black_Full_Alpha", "[BC1_Black_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Blue_Full_Alpha", "[BC1_Red_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Green_Full_Alpha", "[BC1_Red_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Green_Blue_Full_Alpha", "[BC1_Green_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC1_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Blue_Ignore_Alpha", "[BC1_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_White_Ignore_Alpha", "[BC1_White_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Black_Ignore_Alpha", "[BC1_Black_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Blue_Ignore_Alpha", "[BC1_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Green_Ignore_Alpha", "[BC1_Red_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Green_Blue_Ignore_Alpha", "[BC1_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC1_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Red_Half_Alpha", "[BC1_Red_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC1_Green_Half_Alpha", "[BC1_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC1_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC1(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, true)); + unsigned char compBlock[8]; + unsigned char decompCompBlock[64]; + CompressBlockBC1(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC1(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, true)); +} +TEST_CASE("BC2_Red_Ignore_Alpha", "[BC2_Red_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Blue_Half_Alpha", "[BC2_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_White_Half_Alpha", "[BC2_White_Half_Alpha]") +{ + const auto block = blocks.find("BC2_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Black_Half_Alpha", "[BC2_Black_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Blue_Half_Alpha", "[BC2_Red_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Green_Half_Alpha", "[BC2_Red_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Green_Blue_Half_Alpha", "[BC2_Green_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Full_Alpha", "[BC2_Red_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Green_Full_Alpha", "[BC2_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Blue_Full_Alpha", "[BC2_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_White_Full_Alpha", "[BC2_White_Full_Alpha]") +{ + const auto block = blocks.find("BC2_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Green_Ignore_Alpha", "[BC2_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Black_Full_Alpha", "[BC2_Black_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Blue_Full_Alpha", "[BC2_Red_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Green_Full_Alpha", "[BC2_Red_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Green_Blue_Full_Alpha", "[BC2_Green_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC2_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Blue_Ignore_Alpha", "[BC2_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_White_Ignore_Alpha", "[BC2_White_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Black_Ignore_Alpha", "[BC2_Black_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Blue_Ignore_Alpha", "[BC2_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Green_Ignore_Alpha", "[BC2_Red_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Green_Blue_Ignore_Alpha", "[BC2_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC2_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Red_Half_Alpha", "[BC2_Red_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC2_Green_Half_Alpha", "[BC2_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC2_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC2(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC2(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC2(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Ignore_Alpha", "[BC3_Red_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Blue_Half_Alpha", "[BC3_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_White_Half_Alpha", "[BC3_White_Half_Alpha]") +{ + const auto block = blocks.find("BC3_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Black_Half_Alpha", "[BC3_Black_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Blue_Half_Alpha", "[BC3_Red_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Green_Half_Alpha", "[BC3_Red_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Green_Blue_Half_Alpha", "[BC3_Green_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Full_Alpha", "[BC3_Red_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Green_Full_Alpha", "[BC3_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Blue_Full_Alpha", "[BC3_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_White_Full_Alpha", "[BC3_White_Full_Alpha]") +{ + const auto block = blocks.find("BC3_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Green_Ignore_Alpha", "[BC3_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Black_Full_Alpha", "[BC3_Black_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Blue_Full_Alpha", "[BC3_Red_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Green_Full_Alpha", "[BC3_Red_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Green_Blue_Full_Alpha", "[BC3_Green_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC3_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Blue_Ignore_Alpha", "[BC3_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_White_Ignore_Alpha", "[BC3_White_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Black_Ignore_Alpha", "[BC3_Black_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Blue_Ignore_Alpha", "[BC3_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Green_Ignore_Alpha", "[BC3_Red_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Green_Blue_Ignore_Alpha", "[BC3_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC3_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Red_Half_Alpha", "[BC3_Red_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC3_Green_Half_Alpha", "[BC3_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC3_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC3(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC3(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC3(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC4_Red_Ignore_Alpha", "[BC4_Red_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Blue_Half_Alpha", "[BC4_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_White_Half_Alpha", "[BC4_White_Half_Alpha]") +{ + const auto block = blocks.find("BC4_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Black_Half_Alpha", "[BC4_Black_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Blue_Half_Alpha", "[BC4_Red_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Green_Half_Alpha", "[BC4_Red_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Green_Blue_Half_Alpha", "[BC4_Green_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Full_Alpha", "[BC4_Red_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Green_Full_Alpha", "[BC4_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Blue_Full_Alpha", "[BC4_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_White_Full_Alpha", "[BC4_White_Full_Alpha]") +{ + const auto block = blocks.find("BC4_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Green_Ignore_Alpha", "[BC4_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Black_Full_Alpha", "[BC4_Black_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Blue_Full_Alpha", "[BC4_Red_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Green_Full_Alpha", "[BC4_Red_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Green_Blue_Full_Alpha", "[BC4_Green_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC4_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Blue_Ignore_Alpha", "[BC4_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_White_Ignore_Alpha", "[BC4_White_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Black_Ignore_Alpha", "[BC4_Black_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Blue_Ignore_Alpha", "[BC4_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Green_Ignore_Alpha", "[BC4_Red_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Green_Blue_Ignore_Alpha", "[BC4_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC4_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Red_Half_Alpha", "[BC4_Red_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC4_Green_Half_Alpha", "[BC4_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC4_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[16]; + DecompressBlockBC4(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC4(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[16]; + CompressBlockBC4(decompBlock, 4, compBlock, nullptr); + DecompressBlockBC4(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC4(decompCompBlock, blockColor)); +} +TEST_CASE("BC5_Red_Ignore_Alpha", "[BC5_Red_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Blue_Half_Alpha", "[BC5_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_White_Half_Alpha", "[BC5_White_Half_Alpha]") +{ + const auto block = blocks.find("BC5_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Black_Half_Alpha", "[BC5_Black_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Blue_Half_Alpha", "[BC5_Red_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Green_Half_Alpha", "[BC5_Red_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Green_Blue_Half_Alpha", "[BC5_Green_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Full_Alpha", "[BC5_Red_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Green_Full_Alpha", "[BC5_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Blue_Full_Alpha", "[BC5_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_White_Full_Alpha", "[BC5_White_Full_Alpha]") +{ + const auto block = blocks.find("BC5_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Green_Ignore_Alpha", "[BC5_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Black_Full_Alpha", "[BC5_Black_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Blue_Full_Alpha", "[BC5_Red_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Green_Full_Alpha", "[BC5_Red_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Green_Blue_Full_Alpha", "[BC5_Green_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC5_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Blue_Ignore_Alpha", "[BC5_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_White_Ignore_Alpha", "[BC5_White_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Black_Ignore_Alpha", "[BC5_Black_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Blue_Ignore_Alpha", "[BC5_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Green_Ignore_Alpha", "[BC5_Red_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Green_Blue_Ignore_Alpha", "[BC5_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC5_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Red_Half_Alpha", "[BC5_Red_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC5_Green_Half_Alpha", "[BC5_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC5_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlockR[16]; + unsigned char decompBlockG[16]; + DecompressBlockBC5(blockData, decompBlockR, decompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompBlockR, decompBlockG, blockColor)); + unsigned char compBlock[16]; + unsigned char decompCompBlockR[16]; + unsigned char decompCompBlockG[16]; + CompressBlockBC5(decompBlockR, 4, decompBlockG, 4, compBlock, nullptr); + DecompressBlockBC5(compBlock, decompCompBlockR, decompCompBlockG, nullptr); + CHECK(ColorMatchesBC5(decompCompBlockR, decompCompBlockG, blockColor)); +} +TEST_CASE("BC6_Red_Ignore_Alpha", "[BC6_Red_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Blue_Half_Alpha", "[BC6_Blue_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_White_Half_Alpha", "[BC6_White_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Black_Half_Alpha", "[BC6_Black_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Blue_Half_Alpha", "[BC6_Red_Blue_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Green_Half_Alpha", "[BC6_Red_Green_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Green_Blue_Half_Alpha", "[BC6_Green_Blue_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Full_Alpha", "[BC6_Red_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Green_Full_Alpha", "[BC6_Green_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Blue_Full_Alpha", "[BC6_Blue_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_White_Full_Alpha", "[BC6_White_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Green_Ignore_Alpha", "[BC6_Green_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Black_Full_Alpha", "[BC6_Black_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Blue_Full_Alpha", "[BC6_Red_Blue_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Green_Full_Alpha", "[BC6_Red_Green_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Green_Blue_Full_Alpha", "[BC6_Green_Blue_Full_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Blue_Ignore_Alpha", "[BC6_Blue_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_White_Ignore_Alpha", "[BC6_White_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Black_Ignore_Alpha", "[BC6_Black_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Blue_Ignore_Alpha", "[BC6_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Green_Ignore_Alpha", "[BC6_Red_Green_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Green_Blue_Ignore_Alpha", "[BC6_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Red_Half_Alpha", "[BC6_Red_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC6_Green_Half_Alpha", "[BC6_Green_Half_Alpha]") +{ + const auto block = blocksBC6.find("BC6_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned short decompBlock[64]; + DecompressBlockBC6(blockData, decompBlock, nullptr); + CHECK(ColorMatchesBC6(decompBlock, blockColor)); + unsigned char compBlock[16]; + unsigned short decompCompBlock[48]; + CompressBlockBC6(decompBlock, 12, compBlock, nullptr); + DecompressBlockBC6(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatchesBC6(decompCompBlock, blockColor)); +} +TEST_CASE("BC7_Red_Ignore_Alpha", "[BC7_Red_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Blue_Half_Alpha", "[BC7_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_White_Half_Alpha", "[BC7_White_Half_Alpha]") +{ + const auto block = blocks.find("BC7_White_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Black_Half_Alpha", "[BC7_Black_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Black_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Blue_Half_Alpha", "[BC7_Red_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Green_Half_Alpha", "[BC7_Red_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Green_Blue_Half_Alpha", "[BC7_Green_Blue_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Green_Blue_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Full_Alpha", "[BC7_Red_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Green_Full_Alpha", "[BC7_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Blue_Full_Alpha", "[BC7_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_White_Full_Alpha", "[BC7_White_Full_Alpha]") +{ + const auto block = blocks.find("BC7_White_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Green_Ignore_Alpha", "[BC7_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Black_Full_Alpha", "[BC7_Black_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Black_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Blue_Full_Alpha", "[BC7_Red_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Green_Full_Alpha", "[BC7_Red_Green_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Green_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Green_Blue_Full_Alpha", "[BC7_Green_Blue_Full_Alpha]") +{ + const auto block = blocks.find("BC7_Green_Blue_Full_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Blue_Ignore_Alpha", "[BC7_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_White_Ignore_Alpha", "[BC7_White_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_White_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Black_Ignore_Alpha", "[BC7_Black_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Black_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Blue_Ignore_Alpha", "[BC7_Red_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Green_Ignore_Alpha", "[BC7_Red_Green_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Green_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Green_Blue_Ignore_Alpha", "[BC7_Green_Blue_Ignore_Alpha]") +{ + const auto block = blocks.find("BC7_Green_Blue_Ignore_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Red_Half_Alpha", "[BC7_Red_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Red_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} +TEST_CASE("BC7_Green_Half_Alpha", "[BC7_Green_Half_Alpha]") +{ + const auto block = blocks.find("BC7_Green_Half_Alpha")->second; + const auto blockData = block.data; + const auto blockColor = block.color; + unsigned char decompBlock[64]; + DecompressBlockBC7(blockData, decompBlock, nullptr); + CHECK(ColorMatches(decompBlock, blockColor, false)); + unsigned char compBlock[16]; + unsigned char decompCompBlock[64]; + CompressBlockBC7(decompBlock, 16, compBlock, nullptr); + DecompressBlockBC7(compBlock, decompCompBlock, nullptr); + CHECK(ColorMatches(decompCompBlock, blockColor, false)); +} + + +//*************************************************************************************** \ No newline at end of file diff --git a/extern/CMP_Core/test/CompressonatorTests.h b/extern/CMP_Core/test/CompressonatorTests.h new file mode 100644 index 00000000..f070a4f2 --- /dev/null +++ b/extern/CMP_Core/test/CompressonatorTests.h @@ -0,0 +1,6 @@ +#ifndef COMPRESSONATOR_TESTS_H +#define COMPRESSONATOR_TESTS_H + +void AssignExpectedColorsToBlocks(); + +#endif \ No newline at end of file diff --git a/extern/CMP_Core/test/TestsMain.cpp b/extern/CMP_Core/test/TestsMain.cpp new file mode 100644 index 00000000..99f12a58 --- /dev/null +++ b/extern/CMP_Core/test/TestsMain.cpp @@ -0,0 +1,10 @@ +#define CATCH_CONFIG_RUNNER +#include "../../../Common/Lib/Ext/Catch2/catch.hpp" +#include "CompressonatorTests.h" + +int main(int argc, char* argv[]) { + AssignExpectedColorsToBlocks(); + int result = Catch::Session().run(argc, argv); + + return result; +} \ No newline at end of file diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 7e419867..911c19e2 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -1,13 +1,11 @@ -IF(WIN32) - ADD_SUBDIRECTORY(gnuwin32) -ENDIF(WIN32) - ADD_SUBDIRECTORY(poshlib) ADD_SUBDIRECTORY(EtcLib) ADD_SUBDIRECTORY(rg_etc1_v104) #ADD_SUBDIRECTORY(etcpack) -ADD_SUBDIRECTORY(butteraugli) +ADD_SUBDIRECTORY(libsquish-1.15) + +ADD_SUBDIRECTORY(CMP_Core) diff --git a/extern/FreeImage/FreeImage.def b/extern/FreeImage/FreeImage.def deleted file mode 100755 index 935d8362..00000000 --- a/extern/FreeImage/FreeImage.def +++ /dev/null @@ -1,227 +0,0 @@ -LIBRARY FreeImage.dll -EXPORTS -FreeImage_OutputMessageProc -FreeImage_AcquireMemory@12 -FreeImage_AdjustBrightness@12 -FreeImage_AdjustColors@32 -FreeImage_AdjustContrast@12 -FreeImage_AdjustCurve@12 -FreeImage_AdjustGamma@12 -FreeImage_Allocate@24 -FreeImage_AllocateEx@36 -FreeImage_AllocateExT@40 -FreeImage_AllocateT@28 -FreeImage_AppendPage@8 -FreeImage_ApplyColorMapping@24 -FreeImage_ApplyPaletteIndexMapping@20 -FreeImage_Clone@4 -FreeImage_CloneMetadata@8 -FreeImage_CloneTag@4 -FreeImage_CloseMemory@4 -FreeImage_CloseMultiBitmap@8 -FreeImage_ColorQuantize@8 -FreeImage_ColorQuantizeEx@20 -FreeImage_Composite@16 -FreeImage_ConvertFromRawBits@36 -FreeImage_ConvertLine16To24_555@12 -FreeImage_ConvertLine16To24_565@12 -FreeImage_ConvertLine16To32_555@12 -FreeImage_ConvertLine16To32_565@12 -FreeImage_ConvertLine16To4_555@12 -FreeImage_ConvertLine16To4_565@12 -FreeImage_ConvertLine16To8_555@12 -FreeImage_ConvertLine16To8_565@12 -FreeImage_ConvertLine16_555_To16_565@12 -FreeImage_ConvertLine16_565_To16_555@12 -FreeImage_ConvertLine1To16_555@16 -FreeImage_ConvertLine1To16_565@16 -FreeImage_ConvertLine1To24@16 -FreeImage_ConvertLine1To32@16 -FreeImage_ConvertLine1To4@12 -FreeImage_ConvertLine1To8@12 -FreeImage_ConvertLine24To16_555@12 -FreeImage_ConvertLine24To16_565@12 -FreeImage_ConvertLine24To32@12 -FreeImage_ConvertLine24To4@12 -FreeImage_ConvertLine24To8@12 -FreeImage_ConvertLine32To16_555@12 -FreeImage_ConvertLine32To16_565@12 -FreeImage_ConvertLine32To24@12 -FreeImage_ConvertLine32To4@12 -FreeImage_ConvertLine32To8@12 -FreeImage_ConvertLine4To16_555@16 -FreeImage_ConvertLine4To16_565@16 -FreeImage_ConvertLine4To24@16 -FreeImage_ConvertLine4To32@16 -FreeImage_ConvertLine4To8@12 -FreeImage_ConvertLine8To16_555@16 -FreeImage_ConvertLine8To16_565@16 -FreeImage_ConvertLine8To24@16 -FreeImage_ConvertLine8To32@16 -FreeImage_ConvertLine8To4@16 -FreeImage_ConvertTo16Bits555@4 -FreeImage_ConvertTo16Bits565@4 -FreeImage_ConvertTo24Bits@4 -FreeImage_ConvertTo32Bits@4 -FreeImage_ConvertTo4Bits@4 -FreeImage_ConvertTo8Bits@4 -FreeImage_ConvertToGreyscale@4 -FreeImage_ConvertToRGBF@4 -FreeImage_ConvertToRawBits@32 -FreeImage_ConvertToStandardType@8 -FreeImage_ConvertToType@12 -FreeImage_Copy@20 -FreeImage_CreateICCProfile@12 -FreeImage_CreateTag@0 -FreeImage_DeInitialise@0 -FreeImage_DeletePage@8 -FreeImage_DeleteTag@4 -FreeImage_DestroyICCProfile@4 -FreeImage_Dither@8 -FreeImage_EnlargeCanvas@28 -FreeImage_FIFSupportsExportBPP@8 -FreeImage_FIFSupportsExportType@8 -FreeImage_FIFSupportsICCProfiles@4 -FreeImage_FIFSupportsReading@4 -FreeImage_FIFSupportsWriting@4 -FreeImage_FillBackground@12 -FreeImage_FindCloseMetadata@4 -FreeImage_FindFirstMetadata@12 -FreeImage_FindNextMetadata@8 -FreeImage_FlipHorizontal@4 -FreeImage_FlipVertical@4 -FreeImage_GetAdjustColorsLookupTable@32 -FreeImage_GetBPP@4 -FreeImage_GetBackgroundColor@8 -FreeImage_GetBits@4 -FreeImage_GetBlueMask@4 -FreeImage_GetChannel@8 -FreeImage_GetColorType@4 -FreeImage_GetColorsUsed@4 -FreeImage_GetComplexChannel@8 -FreeImage_GetCopyrightMessage@0 -FreeImage_GetDIBSize@4 -FreeImage_GetDotsPerMeterX@4 -FreeImage_GetDotsPerMeterY@4 -FreeImage_GetFIFCount@0 -FreeImage_GetFIFDescription@4 -FreeImage_GetFIFExtensionList@4 -FreeImage_GetFIFFromFilename@4 -FreeImage_GetFIFFromFilenameU@4 -FreeImage_GetFIFFromFormat@4 -FreeImage_GetFIFFromMime@4 -FreeImage_GetFIFMimeType@4 -FreeImage_GetFIFRegExpr@4 -FreeImage_GetFileType@8 -FreeImage_GetFileTypeFromHandle@12 -FreeImage_GetFileTypeFromMemory@8 -FreeImage_GetFileTypeU@8 -FreeImage_GetFormatFromFIF@4 -FreeImage_GetGreenMask@4 -FreeImage_GetHeight@4 -FreeImage_GetHistogram@12 -FreeImage_GetICCProfile@4 -FreeImage_GetImageType@4 -FreeImage_GetInfo@4 -FreeImage_GetInfoHeader@4 -FreeImage_GetLine@4 -FreeImage_GetLockedPageNumbers@12 -FreeImage_GetMetadata@16 -FreeImage_GetMetadataCount@8 -FreeImage_GetPageCount@4 -FreeImage_GetPalette@4 -FreeImage_GetPitch@4 -FreeImage_GetPixelColor@16 -FreeImage_GetPixelIndex@16 -FreeImage_GetRedMask@4 -FreeImage_GetScanLine@8 -FreeImage_GetTagCount@4 -FreeImage_GetTagDescription@4 -FreeImage_GetTagID@4 -FreeImage_GetTagKey@4 -FreeImage_GetTagLength@4 -FreeImage_GetTagType@4 -FreeImage_GetTagValue@4 -FreeImage_GetTransparencyCount@4 -FreeImage_GetTransparencyTable@4 -FreeImage_GetTransparentIndex@4 -FreeImage_GetVersion@0 -FreeImage_GetWidth@4 -FreeImage_HasBackgroundColor@4 -FreeImage_Initialise@4 -FreeImage_InsertPage@12 -FreeImage_Invert@4 -FreeImage_IsLittleEndian@0 -FreeImage_IsPluginEnabled@4 -FreeImage_IsTransparent@4 -FreeImage_JPEGCrop@24 -FreeImage_JPEGCropU@24 -FreeImage_JPEGTransform@16 -FreeImage_JPEGTransformU@16 -FreeImage_Load@12 -FreeImage_LoadFromHandle@16 -FreeImage_LoadFromMemory@12 -FreeImage_LoadMultiBitmapFromMemory@12 -FreeImage_LoadU@12 -FreeImage_LockPage@8 -FreeImage_LookupSVGColor@16 -FreeImage_LookupX11Color@16 -FreeImage_MakeThumbnail@12 -FreeImage_MovePage@12 -FreeImage_MultigridPoissonSolver@8 -FreeImage_OpenMemory@8 -FreeImage_OpenMultiBitmap@24 -FreeImage_OpenMultiBitmapFromHandle@16 -FreeImage_Paste@20 -FreeImage_PreMultiplyWithAlpha@4 -FreeImage_ReadMemory@16 -FreeImage_RegisterExternalPlugin@20 -FreeImage_RegisterLocalPlugin@20 -FreeImage_Rescale@16 -FreeImage_Rotate@16 -FreeImage_RotateClassic@12 -FreeImage_RotateEx@48 -FreeImage_Save@16 -FreeImage_SaveToHandle@20 -FreeImage_SaveToMemory@16 -FreeImage_SaveU@16 -FreeImage_SeekMemory@12 -FreeImage_SetBackgroundColor@8 -FreeImage_SetChannel@12 -FreeImage_SetComplexChannel@12 -FreeImage_SetDotsPerMeterX@8 -FreeImage_SetDotsPerMeterY@8 -FreeImage_SetMetadata@16 -FreeImage_SetOutputMessage@4 -FreeImage_SetOutputMessageStdCall@4 -FreeImage_SetPixelColor@16 -FreeImage_SetPixelIndex@16 -FreeImage_SetPluginEnabled@8 -FreeImage_SetTagCount@8 -FreeImage_SetTagDescription@8 -FreeImage_SetTagID@8 -FreeImage_SetTagKey@8 -FreeImage_SetTagLength@8 -FreeImage_SetTagType@8 -FreeImage_SetTagValue@8 -FreeImage_SetTransparencyTable@12 -FreeImage_SetTransparent@8 -FreeImage_SetTransparentIndex@8 -FreeImage_SwapColors@16 -FreeImage_SwapPaletteIndices@12 -FreeImage_TagToString@12 -FreeImage_TellMemory@4 -FreeImage_Threshold@8 -FreeImage_TmoDrago03@20 -FreeImage_TmoFattal02@20 -FreeImage_TmoReinhard05@20 -FreeImage_TmoReinhard05Ex@36 -FreeImage_ToneMapping@24 -FreeImage_Unload@4 -FreeImage_UnlockPage@12 -FreeImage_WriteMemory@16 -FreeImage_ZLibCRC32@12 -FreeImage_ZLibCompress@16 -FreeImage_ZLibGUnzip@16 -FreeImage_ZLibGZip@16 -FreeImage_ZLibUncompress@16 diff --git a/extern/FreeImage/FreeImage.dll b/extern/FreeImage/FreeImage.dll deleted file mode 100755 index d6fbf5d4..00000000 Binary files a/extern/FreeImage/FreeImage.dll and /dev/null differ diff --git a/extern/FreeImage/FreeImage.h b/extern/FreeImage/FreeImage.h deleted file mode 100644 index b61f1e1d..00000000 --- a/extern/FreeImage/FreeImage.h +++ /dev/null @@ -1,1090 +0,0 @@ -// ========================================================== -// FreeImage 3 -// -// Design and implementation by -// - Floris van den Berg (flvdberg@wxs.nl) -// - Hervé Drolon (drolon@infonie.fr) -// -// Contributors: -// - Adam Gates (radad@xoasis.com) -// - Alex Kwak -// - Alexander Dymerets (sashad@te.net.ua) -// - Detlev Vendt (detlev.vendt@brillit.de) -// - Jan L. Nauta (jln@magentammt.com) -// - Jani Kajala (janik@remedy.fi) -// - Juergen Riecker (j.riecker@gmx.de) -// - Karl-Heinz Bussian (khbussian@moss.de) -// - Laurent Rocher (rocherl@club-internet.fr) -// - Luca Piergentili (l.pierge@terra.es) -// - Machiel ten Brinke (brinkem@uni-one.nl) -// - Markus Loibl (markus.loibl@epost.de) -// - Martin Weber (martweb@gmx.net) -// - Matthias Wandel (mwandel@rim.net) -// - Michal Novotny (michal@etc.cz) -// - Petr Pytelka (pyta@lightcomp.com) -// - Riley McNiff (rmcniff@marexgroup.com) -// - Ryan Rubley (ryan@lostreality.org) -// - Volker Gärtner (volkerg@gmx.at) -// -// This file is part of FreeImage 3 -// -// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY -// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES -// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE -// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED -// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT -// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY -// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL -// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER -// THIS DISCLAIMER. -// -// Use at your own risk! -// ========================================================== - -#ifndef FREEIMAGE_H -#define FREEIMAGE_H - -// Version information ------------------------------------------------------ - -#define FREEIMAGE_MAJOR_VERSION 3 -#define FREEIMAGE_MINOR_VERSION 13 -#define FREEIMAGE_RELEASE_SERIAL 1 - -// Compiler options --------------------------------------------------------- - -#include // needed for UNICODE functions - -#if defined(FREEIMAGE_LIB) - #define DLL_API - #define DLL_CALLCONV -#else - #if defined(_WIN32) || defined(__WIN32__) - #define DLL_CALLCONV __stdcall - // The following ifdef block is the standard way of creating macros which make exporting - // from a DLL simpler. All files within this DLL are compiled with the FREEIMAGE_EXPORTS - // symbol defined on the command line. this symbol should not be defined on any project - // that uses this DLL. This way any other project whose source files include this file see - // DLL_API functions as being imported from a DLL, wheras this DLL sees symbols - // defined with this macro as being exported. - #ifdef FREEIMAGE_EXPORTS - #define DLL_API __declspec(dllexport) - #else - #define DLL_API __declspec(dllimport) - #endif // FREEIMAGE_EXPORTS - #else - // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) - #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) - #ifndef GCC_HASCLASSVISIBILITY - #define GCC_HASCLASSVISIBILITY - #endif - #endif // __GNUC__ - #define DLL_CALLCONV - #if defined(GCC_HASCLASSVISIBILITY) - #define DLL_API __attribute__ ((visibility("default"))) - #else - #define DLL_API - #endif - #endif // WIN32 / !WIN32 -#endif // FREEIMAGE_LIB - -// Some versions of gcc may have BYTE_ORDER or __BYTE_ORDER defined -// If your big endian system isn't being detected, add an OS specific check -#if (defined(BYTE_ORDER) && BYTE_ORDER==BIG_ENDIAN) || \ - (defined(__BYTE_ORDER) && __BYTE_ORDER==__BIG_ENDIAN) || \ - defined(__BIG_ENDIAN__) -#define FREEIMAGE_BIGENDIAN -#endif // BYTE_ORDER - -// This really only affects 24 and 32 bit formats, the rest are always RGB order. -#define FREEIMAGE_COLORORDER_BGR 0 -#define FREEIMAGE_COLORORDER_RGB 1 -#if defined(FREEIMAGE_BIGENDIAN) -#define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_RGB -#else -#define FREEIMAGE_COLORORDER FREEIMAGE_COLORORDER_BGR -#endif - -// Ensure 4-byte enums if we're using Borland C++ compilers -#if defined(__BORLANDC__) -#pragma option push -b -#endif - -// For C compatibility -------------------------------------------------------- - -#ifdef __cplusplus -#define FI_DEFAULT(x) = x -#define FI_ENUM(x) enum x -#define FI_STRUCT(x) struct x -#else -#define FI_DEFAULT(x) -#define FI_ENUM(x) typedef int x; enum x -#define FI_STRUCT(x) typedef struct x x; struct x -#endif - -// Bitmap types ------------------------------------------------------------- - -FI_STRUCT (FIBITMAP) { void *data; }; -FI_STRUCT (FIMULTIBITMAP) { void *data; }; - -// Types used in the library (directly copied from Windows) ----------------- - -#if defined(__MINGW32__) && defined(_WINDOWS_H) -#define _WINDOWS_ // prevent a bug in MinGW32 -#endif // __MINGW32__ - -#ifndef _WINDOWS_ -#define _WINDOWS_ - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef NULL -#define NULL 0 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 -#endif - -#ifndef _MSC_VER -// define portable types for 32-bit / 64-bit OS -#include -typedef int32_t BOOL; -typedef uint8_t BYTE; -typedef uint16_t WORD; -typedef uint32_t DWORD; -typedef int32_t LONG; -#else -// MS is not C99 ISO compliant -typedef long BOOL; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef long LONG; -#endif // _MSC_VER - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif // WIN32 - -typedef struct tagRGBQUAD { -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR - BYTE rgbBlue; - BYTE rgbGreen; - BYTE rgbRed; -#else - BYTE rgbRed; - BYTE rgbGreen; - BYTE rgbBlue; -#endif // FREEIMAGE_COLORORDER - BYTE rgbReserved; -} RGBQUAD; - -typedef struct tagRGBTRIPLE { -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR - BYTE rgbtBlue; - BYTE rgbtGreen; - BYTE rgbtRed; -#else - BYTE rgbtRed; - BYTE rgbtGreen; - BYTE rgbtBlue; -#endif // FREEIMAGE_COLORORDER -} RGBTRIPLE; - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(pop) -#else -#pragma pack() -#endif // WIN32 - -typedef struct tagBITMAPINFOHEADER{ - DWORD biSize; - LONG biWidth; - LONG biHeight; - WORD biPlanes; - WORD biBitCount; - DWORD biCompression; - DWORD biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - DWORD biClrUsed; - DWORD biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; - -typedef struct tagBITMAPINFO { - BITMAPINFOHEADER bmiHeader; - RGBQUAD bmiColors[1]; -} BITMAPINFO, *PBITMAPINFO; - -#endif // _WINDOWS_ - -// Types used in the library (specific to FreeImage) ------------------------ - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif // WIN32 - -/** 48-bit RGB -*/ -typedef struct tagFIRGB16 { - WORD red; - WORD green; - WORD blue; -} FIRGB16; - -/** 64-bit RGBA -*/ -typedef struct tagFIRGBA16 { - WORD red; - WORD green; - WORD blue; - WORD alpha; -} FIRGBA16; - -/** 96-bit RGB Float -*/ -typedef struct tagFIRGBF { - float red; - float green; - float blue; -} FIRGBF; - -/** 128-bit RGBA Float -*/ -typedef struct tagFIRGBAF { - float red; - float green; - float blue; - float alpha; -} FIRGBAF; - -/** Data structure for COMPLEX type (complex number) -*/ -typedef struct tagFICOMPLEX { - /// real part - double r; - /// imaginary part - double i; -} FICOMPLEX; - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(pop) -#else -#pragma pack() -#endif // WIN32 - -// Indexes for byte arrays, masks and shifts for treating pixels as words --- -// These coincide with the order of RGBQUAD and RGBTRIPLE ------------------- - -#ifndef FREEIMAGE_BIGENDIAN -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR -// Little Endian (x86 / MS Windows, Linux) : BGR(A) order -#define FI_RGBA_RED 2 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 0 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0x00FF0000 -#define FI_RGBA_GREEN_MASK 0x0000FF00 -#define FI_RGBA_BLUE_MASK 0x000000FF -#define FI_RGBA_ALPHA_MASK 0xFF000000 -#define FI_RGBA_RED_SHIFT 16 -#define FI_RGBA_GREEN_SHIFT 8 -#define FI_RGBA_BLUE_SHIFT 0 -#define FI_RGBA_ALPHA_SHIFT 24 -#else -// Little Endian (x86 / MaxOSX) : RGB(A) order -#define FI_RGBA_RED 0 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 2 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0x000000FF -#define FI_RGBA_GREEN_MASK 0x0000FF00 -#define FI_RGBA_BLUE_MASK 0x00FF0000 -#define FI_RGBA_ALPHA_MASK 0xFF000000 -#define FI_RGBA_RED_SHIFT 0 -#define FI_RGBA_GREEN_SHIFT 8 -#define FI_RGBA_BLUE_SHIFT 16 -#define FI_RGBA_ALPHA_SHIFT 24 -#endif // FREEIMAGE_COLORORDER -#else -#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR -// Big Endian (PPC / none) : BGR(A) order -#define FI_RGBA_RED 2 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 0 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0x0000FF00 -#define FI_RGBA_GREEN_MASK 0x00FF0000 -#define FI_RGBA_BLUE_MASK 0xFF000000 -#define FI_RGBA_ALPHA_MASK 0x000000FF -#define FI_RGBA_RED_SHIFT 8 -#define FI_RGBA_GREEN_SHIFT 16 -#define FI_RGBA_BLUE_SHIFT 24 -#define FI_RGBA_ALPHA_SHIFT 0 -#else -// Big Endian (PPC / Linux, MaxOSX) : RGB(A) order -#define FI_RGBA_RED 0 -#define FI_RGBA_GREEN 1 -#define FI_RGBA_BLUE 2 -#define FI_RGBA_ALPHA 3 -#define FI_RGBA_RED_MASK 0xFF000000 -#define FI_RGBA_GREEN_MASK 0x00FF0000 -#define FI_RGBA_BLUE_MASK 0x0000FF00 -#define FI_RGBA_ALPHA_MASK 0x000000FF -#define FI_RGBA_RED_SHIFT 24 -#define FI_RGBA_GREEN_SHIFT 16 -#define FI_RGBA_BLUE_SHIFT 8 -#define FI_RGBA_ALPHA_SHIFT 0 -#endif // FREEIMAGE_COLORORDER -#endif // FREEIMAGE_BIGENDIAN - -#define FI_RGBA_RGB_MASK (FI_RGBA_RED_MASK|FI_RGBA_GREEN_MASK|FI_RGBA_BLUE_MASK) - -// The 16bit macros only include masks and shifts, since each color element is not byte aligned - -#define FI16_555_RED_MASK 0x7C00 -#define FI16_555_GREEN_MASK 0x03E0 -#define FI16_555_BLUE_MASK 0x001F -#define FI16_555_RED_SHIFT 10 -#define FI16_555_GREEN_SHIFT 5 -#define FI16_555_BLUE_SHIFT 0 -#define FI16_565_RED_MASK 0xF800 -#define FI16_565_GREEN_MASK 0x07E0 -#define FI16_565_BLUE_MASK 0x001F -#define FI16_565_RED_SHIFT 11 -#define FI16_565_GREEN_SHIFT 5 -#define FI16_565_BLUE_SHIFT 0 - -// ICC profile support ------------------------------------------------------ - -#define FIICC_DEFAULT 0x00 -#define FIICC_COLOR_IS_CMYK 0x01 - -FI_STRUCT (FIICCPROFILE) { - WORD flags; // info flag - DWORD size; // profile's size measured in bytes - void *data; // points to a block of contiguous memory containing the profile -}; - -// Important enums ---------------------------------------------------------- - -/** I/O image format identifiers. -*/ -FI_ENUM(FREE_IMAGE_FORMAT) { - FIF_UNKNOWN = -1, - FIF_BMP = 0, - FIF_ICO = 1, - FIF_JPEG = 2, - FIF_JNG = 3, - FIF_KOALA = 4, - FIF_LBM = 5, - FIF_IFF = FIF_LBM, - FIF_MNG = 6, - FIF_PBM = 7, - FIF_PBMRAW = 8, - FIF_PCD = 9, - FIF_PCX = 10, - FIF_PGM = 11, - FIF_PGMRAW = 12, - FIF_PNG = 13, - FIF_PPM = 14, - FIF_PPMRAW = 15, - FIF_RAS = 16, - FIF_TARGA = 17, - FIF_TIFF = 18, - FIF_WBMP = 19, - FIF_PSD = 20, - FIF_CUT = 21, - FIF_XBM = 22, - FIF_XPM = 23, - FIF_DDS = 24, - FIF_GIF = 25, - FIF_HDR = 26, - FIF_FAXG3 = 27, - FIF_SGI = 28, - FIF_EXR = 29, - FIF_J2K = 30, - FIF_JP2 = 31, - FIF_PFM = 32, - FIF_PICT = 33, - FIF_RAW = 34 -}; - -/** Image type used in FreeImage. -*/ -FI_ENUM(FREE_IMAGE_TYPE) { - FIT_UNKNOWN = 0, // unknown type - FIT_BITMAP = 1, // standard image : 1-, 4-, 8-, 16-, 24-, 32-bit - FIT_UINT16 = 2, // array of unsigned short : unsigned 16-bit - FIT_INT16 = 3, // array of short : signed 16-bit - FIT_UINT32 = 4, // array of unsigned long : unsigned 32-bit - FIT_INT32 = 5, // array of long : signed 32-bit - FIT_FLOAT = 6, // array of float : 32-bit IEEE floating point - FIT_DOUBLE = 7, // array of double : 64-bit IEEE floating point - FIT_COMPLEX = 8, // array of FICOMPLEX : 2 x 64-bit IEEE floating point - FIT_RGB16 = 9, // 48-bit RGB image : 3 x 16-bit - FIT_RGBA16 = 10, // 64-bit RGBA image : 4 x 16-bit - FIT_RGBF = 11, // 96-bit RGB float image : 3 x 32-bit IEEE floating point - FIT_RGBAF = 12 // 128-bit RGBA float image : 4 x 32-bit IEEE floating point -}; - -/** Image color type used in FreeImage. -*/ -FI_ENUM(FREE_IMAGE_COLOR_TYPE) { - FIC_MINISWHITE = 0, // min value is white - FIC_MINISBLACK = 1, // min value is black - FIC_RGB = 2, // RGB color model - FIC_PALETTE = 3, // color map indexed - FIC_RGBALPHA = 4, // RGB color model with alpha channel - FIC_CMYK = 5 // CMYK color model -}; - -/** Color quantization algorithms. -Constants used in FreeImage_ColorQuantize. -*/ -FI_ENUM(FREE_IMAGE_QUANTIZE) { - FIQ_WUQUANT = 0, // Xiaolin Wu color quantization algorithm - FIQ_NNQUANT = 1 // NeuQuant neural-net quantization algorithm by Anthony Dekker -}; - -/** Dithering algorithms. -Constants used in FreeImage_Dither. -*/ -FI_ENUM(FREE_IMAGE_DITHER) { - FID_FS = 0, // Floyd & Steinberg error diffusion - FID_BAYER4x4 = 1, // Bayer ordered dispersed dot dithering (order 2 dithering matrix) - FID_BAYER8x8 = 2, // Bayer ordered dispersed dot dithering (order 3 dithering matrix) - FID_CLUSTER6x6 = 3, // Ordered clustered dot dithering (order 3 - 6x6 matrix) - FID_CLUSTER8x8 = 4, // Ordered clustered dot dithering (order 4 - 8x8 matrix) - FID_CLUSTER16x16= 5, // Ordered clustered dot dithering (order 8 - 16x16 matrix) - FID_BAYER16x16 = 6 // Bayer ordered dispersed dot dithering (order 4 dithering matrix) -}; - -/** Lossless JPEG transformations -Constants used in FreeImage_JPEGTransform -*/ -FI_ENUM(FREE_IMAGE_JPEG_OPERATION) { - FIJPEG_OP_NONE = 0, // no transformation - FIJPEG_OP_FLIP_H = 1, // horizontal flip - FIJPEG_OP_FLIP_V = 2, // vertical flip - FIJPEG_OP_TRANSPOSE = 3, // transpose across UL-to-LR axis - FIJPEG_OP_TRANSVERSE = 4, // transpose across UR-to-LL axis - FIJPEG_OP_ROTATE_90 = 5, // 90-degree clockwise rotation - FIJPEG_OP_ROTATE_180 = 6, // 180-degree rotation - FIJPEG_OP_ROTATE_270 = 7 // 270-degree clockwise (or 90 ccw) -}; - -/** Tone mapping operators. -Constants used in FreeImage_ToneMapping. -*/ -FI_ENUM(FREE_IMAGE_TMO) { - FITMO_DRAGO03 = 0, // Adaptive logarithmic mapping (F. Drago, 2003) - FITMO_REINHARD05 = 1, // Dynamic range reduction inspired by photoreceptor physiology (E. Reinhard, 2005) - FITMO_FATTAL02 = 2 // Gradient domain high dynamic range compression (R. Fattal, 2002) -}; - -/** Upsampling / downsampling filters. -Constants used in FreeImage_Rescale. -*/ -FI_ENUM(FREE_IMAGE_FILTER) { - FILTER_BOX = 0, // Box, pulse, Fourier window, 1st order (constant) b-spline - FILTER_BICUBIC = 1, // Mitchell & Netravali's two-param cubic filter - FILTER_BILINEAR = 2, // Bilinear filter - FILTER_BSPLINE = 3, // 4th order (cubic) b-spline - FILTER_CATMULLROM = 4, // Catmull-Rom spline, Overhauser spline - FILTER_LANCZOS3 = 5 // Lanczos3 filter -}; - -/** Color channels. -Constants used in color manipulation routines. -*/ -FI_ENUM(FREE_IMAGE_COLOR_CHANNEL) { - FICC_RGB = 0, // Use red, green and blue channels - FICC_RED = 1, // Use red channel - FICC_GREEN = 2, // Use green channel - FICC_BLUE = 3, // Use blue channel - FICC_ALPHA = 4, // Use alpha channel - FICC_BLACK = 5, // Use black channel - FICC_REAL = 6, // Complex images: use real part - FICC_IMAG = 7, // Complex images: use imaginary part - FICC_MAG = 8, // Complex images: use magnitude - FICC_PHASE = 9 // Complex images: use phase -}; - -// Metadata support --------------------------------------------------------- - -/** - Tag data type information (based on TIFF specifications) - - Note: RATIONALs are the ratio of two 32-bit integer values. -*/ -FI_ENUM(FREE_IMAGE_MDTYPE) { - FIDT_NOTYPE = 0, // placeholder - FIDT_BYTE = 1, // 8-bit unsigned integer - FIDT_ASCII = 2, // 8-bit bytes w/ last byte null - FIDT_SHORT = 3, // 16-bit unsigned integer - FIDT_LONG = 4, // 32-bit unsigned integer - FIDT_RATIONAL = 5, // 64-bit unsigned fraction - FIDT_SBYTE = 6, // 8-bit signed integer - FIDT_UNDEFINED = 7, // 8-bit untyped data - FIDT_SSHORT = 8, // 16-bit signed integer - FIDT_SLONG = 9, // 32-bit signed integer - FIDT_SRATIONAL = 10, // 64-bit signed fraction - FIDT_FLOAT = 11, // 32-bit IEEE floating point - FIDT_DOUBLE = 12, // 64-bit IEEE floating point - FIDT_IFD = 13, // 32-bit unsigned integer (offset) - FIDT_PALETTE = 14 // 32-bit RGBQUAD -}; - -/** - Metadata models supported by FreeImage -*/ -FI_ENUM(FREE_IMAGE_MDMODEL) { - FIMD_NODATA = -1, - FIMD_COMMENTS = 0, // single comment or keywords - FIMD_EXIF_MAIN = 1, // Exif-TIFF metadata - FIMD_EXIF_EXIF = 2, // Exif-specific metadata - FIMD_EXIF_GPS = 3, // Exif GPS metadata - FIMD_EXIF_MAKERNOTE = 4, // Exif maker note metadata - FIMD_EXIF_INTEROP = 5, // Exif interoperability metadata - FIMD_IPTC = 6, // IPTC/NAA metadata - FIMD_XMP = 7, // Abobe XMP metadata - FIMD_GEOTIFF = 8, // GeoTIFF metadata - FIMD_ANIMATION = 9, // Animation metadata - FIMD_CUSTOM = 10 // Used to attach other metadata types to a dib -}; - -/** - Handle to a metadata model -*/ -FI_STRUCT (FIMETADATA) { void *data; }; - -/** - Handle to a FreeImage tag -*/ -FI_STRUCT (FITAG) { void *data; }; - -// File IO routines --------------------------------------------------------- - -#ifndef FREEIMAGE_IO -#define FREEIMAGE_IO - -typedef void* fi_handle; -typedef unsigned (DLL_CALLCONV *FI_ReadProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef unsigned (DLL_CALLCONV *FI_WriteProc) (void *buffer, unsigned size, unsigned count, fi_handle handle); -typedef int (DLL_CALLCONV *FI_SeekProc) (fi_handle handle, long offset, int origin); -typedef long (DLL_CALLCONV *FI_TellProc) (fi_handle handle); - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(push, 1) -#else -#pragma pack(1) -#endif // WIN32 - -FI_STRUCT(FreeImageIO) { - FI_ReadProc read_proc; // pointer to the function used to read data - FI_WriteProc write_proc; // pointer to the function used to write data - FI_SeekProc seek_proc; // pointer to the function used to seek - FI_TellProc tell_proc; // pointer to the function used to aquire the current position -}; - -#if (defined(_WIN32) || defined(__WIN32__)) -#pragma pack(pop) -#else -#pragma pack() -#endif // WIN32 - -/** -Handle to a memory I/O stream -*/ -FI_STRUCT (FIMEMORY) { void *data; }; - -#endif // FREEIMAGE_IO - -// Plugin routines ---------------------------------------------------------- - -#ifndef PLUGINS -#define PLUGINS - -typedef const char *(DLL_CALLCONV *FI_FormatProc)(void); -typedef const char *(DLL_CALLCONV *FI_DescriptionProc)(void); -typedef const char *(DLL_CALLCONV *FI_ExtensionListProc)(void); -typedef const char *(DLL_CALLCONV *FI_RegExprProc)(void); -typedef void *(DLL_CALLCONV *FI_OpenProc)(FreeImageIO *io, fi_handle handle, BOOL read); -typedef void (DLL_CALLCONV *FI_CloseProc)(FreeImageIO *io, fi_handle handle, void *data); -typedef int (DLL_CALLCONV *FI_PageCountProc)(FreeImageIO *io, fi_handle handle, void *data); -typedef int (DLL_CALLCONV *FI_PageCapabilityProc)(FreeImageIO *io, fi_handle handle, void *data); -typedef FIBITMAP *(DLL_CALLCONV *FI_LoadProc)(FreeImageIO *io, fi_handle handle, int page, int flags, void *data); -typedef BOOL (DLL_CALLCONV *FI_SaveProc)(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data); -typedef BOOL (DLL_CALLCONV *FI_ValidateProc)(FreeImageIO *io, fi_handle handle); -typedef const char *(DLL_CALLCONV *FI_MimeProc)(void); -typedef BOOL (DLL_CALLCONV *FI_SupportsExportBPPProc)(int bpp); -typedef BOOL (DLL_CALLCONV *FI_SupportsExportTypeProc)(FREE_IMAGE_TYPE type); -typedef BOOL (DLL_CALLCONV *FI_SupportsICCProfilesProc)(void); - -FI_STRUCT (Plugin) { - FI_FormatProc format_proc; - FI_DescriptionProc description_proc; - FI_ExtensionListProc extension_proc; - FI_RegExprProc regexpr_proc; - FI_OpenProc open_proc; - FI_CloseProc close_proc; - FI_PageCountProc pagecount_proc; - FI_PageCapabilityProc pagecapability_proc; - FI_LoadProc load_proc; - FI_SaveProc save_proc; - FI_ValidateProc validate_proc; - FI_MimeProc mime_proc; - FI_SupportsExportBPPProc supports_export_bpp_proc; - FI_SupportsExportTypeProc supports_export_type_proc; - FI_SupportsICCProfilesProc supports_icc_profiles_proc; -}; - -typedef void (DLL_CALLCONV *FI_InitProc)(Plugin *plugin, int format_id); - -#endif // PLUGINS - - -// Load / Save flag constants ----------------------------------------------- - -#define BMP_DEFAULT 0 -#define BMP_SAVE_RLE 1 -#define CUT_DEFAULT 0 -#define DDS_DEFAULT 0 -#define EXR_DEFAULT 0 // save data as half with piz-based wavelet compression -#define EXR_FLOAT 0x0001 // save data as float instead of as half (not recommended) -#define EXR_NONE 0x0002 // save with no compression -#define EXR_ZIP 0x0004 // save with zlib compression, in blocks of 16 scan lines -#define EXR_PIZ 0x0008 // save with piz-based wavelet compression -#define EXR_PXR24 0x0010 // save with lossy 24-bit float compression -#define EXR_B44 0x0020 // save with lossy 44% float compression - goes to 22% when combined with EXR_LC -#define EXR_LC 0x0040 // save images with one luminance and two chroma channels, rather than as RGB (lossy compression) -#define FAXG3_DEFAULT 0 -#define GIF_DEFAULT 0 -#define GIF_LOAD256 1 // Load the image as a 256 color image with ununsed palette entries, if it's 16 or 2 color -#define GIF_PLAYBACK 2 // 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading -#define HDR_DEFAULT 0 -#define ICO_DEFAULT 0 -#define ICO_MAKEALPHA 1 // convert to 32bpp and create an alpha channel from the AND-mask when loading -#define IFF_DEFAULT 0 -#define J2K_DEFAULT 0 // save with a 16:1 rate -#define JP2_DEFAULT 0 // save with a 16:1 rate -#define JPEG_DEFAULT 0 // loading (see JPEG_FAST); saving (see JPEG_QUALITYGOOD|JPEG_SUBSAMPLING_420) -#define JPEG_FAST 0x0001 // load the file as fast as possible, sacrificing some quality -#define JPEG_ACCURATE 0x0002 // load the file with the best quality, sacrificing some speed -#define JPEG_CMYK 0x0004 // load separated CMYK "as is" (use | to combine with other load flags) -#define JPEG_EXIFROTATE 0x0008 // load and rotate according to Exif 'Orientation' tag if available -#define JPEG_QUALITYSUPERB 0x80 // save with superb quality (100:1) -#define JPEG_QUALITYGOOD 0x0100 // save with good quality (75:1) -#define JPEG_QUALITYNORMAL 0x0200 // save with normal quality (50:1) -#define JPEG_QUALITYAVERAGE 0x0400 // save with average quality (25:1) -#define JPEG_QUALITYBAD 0x0800 // save with bad quality (10:1) -#define JPEG_PROGRESSIVE 0x2000 // save as a progressive-JPEG (use | to combine with other save flags) -#define JPEG_SUBSAMPLING_411 0x1000 // save with high 4x1 chroma subsampling (4:1:1) -#define JPEG_SUBSAMPLING_420 0x4000 // save with medium 2x2 medium chroma subsampling (4:2:0) - default value -#define JPEG_SUBSAMPLING_422 0x8000 // save with low 2x1 chroma subsampling (4:2:2) -#define JPEG_SUBSAMPLING_444 0x10000 // save with no chroma subsampling (4:4:4) -#define KOALA_DEFAULT 0 -#define LBM_DEFAULT 0 -#define MNG_DEFAULT 0 -#define PCD_DEFAULT 0 -#define PCD_BASE 1 // load the bitmap sized 768 x 512 -#define PCD_BASEDIV4 2 // load the bitmap sized 384 x 256 -#define PCD_BASEDIV16 3 // load the bitmap sized 192 x 128 -#define PCX_DEFAULT 0 -#define PFM_DEFAULT 0 -#define PICT_DEFAULT 0 -#define PNG_DEFAULT 0 -#define PNG_IGNOREGAMMA 1 // loading: avoid gamma correction -#define PNG_Z_BEST_SPEED 0x0001 // save using ZLib level 1 compression flag (default value is 6) -#define PNG_Z_DEFAULT_COMPRESSION 0x0006 // save using ZLib level 6 compression flag (default recommended value) -#define PNG_Z_BEST_COMPRESSION 0x0009 // save using ZLib level 9 compression flag (default value is 6) -#define PNG_Z_NO_COMPRESSION 0x0100 // save without ZLib compression -#define PNG_INTERLACED 0x0200 // save using Adam7 interlacing (use | to combine with other save flags) -#define PNM_DEFAULT 0 -#define PNM_SAVE_RAW 0 // If set the writer saves in RAW format (i.e. P4, P5 or P6) -#define PNM_SAVE_ASCII 1 // If set the writer saves in ASCII format (i.e. P1, P2 or P3) -#define PSD_DEFAULT 0 -#define RAS_DEFAULT 0 -#define RAW_DEFAULT 0 // load the file as linear RGB 48-bit -#define RAW_PREVIEW 1 // try to load the embedded JPEG preview with included Exif Data or default to RGB 24-bit -#define RAW_DISPLAY 2 // load the file as RGB 24-bit -#define SGI_DEFAULT 0 -#define TARGA_DEFAULT 0 -#define TARGA_LOAD_RGB888 1 // If set the loader converts RGB555 and ARGB8888 -> RGB888. -#define TIFF_DEFAULT 0 -#define TIFF_CMYK 0x0001 // reads/stores tags for separated CMYK (use | to combine with compression flags) -#define TIFF_PACKBITS 0x0100 // save using PACKBITS compression -#define TIFF_DEFLATE 0x0200 // save using DEFLATE compression (a.k.a. ZLIB compression) -#define TIFF_ADOBE_DEFLATE 0x0400 // save using ADOBE DEFLATE compression -#define TIFF_NONE 0x0800 // save without any compression -#define TIFF_CCITTFAX3 0x1000 // save using CCITT Group 3 fax encoding -#define TIFF_CCITTFAX4 0x2000 // save using CCITT Group 4 fax encoding -#define TIFF_LZW 0x4000 // save using LZW compression -#define TIFF_JPEG 0x8000 // save using JPEG compression -#define WBMP_DEFAULT 0 -#define XBM_DEFAULT 0 -#define XPM_DEFAULT 0 - -// Background filling options --------------------------------------------------------- -// Constants used in FreeImage_FillBackground and FreeImage_EnlargeCanvas - -#define FI_COLOR_IS_RGB_COLOR 0x00 // RGBQUAD color is a RGB color (contains no valid alpha channel) -#define FI_COLOR_IS_RGBA_COLOR 0x01 // RGBQUAD color is a RGBA color (contains a valid alpha channel) -#define FI_COLOR_FIND_EQUAL_COLOR 0x02 // For palettized images: lookup equal RGB color from palette -#define FI_COLOR_ALPHA_IS_INDEX 0x04 // The color's rgbReserved member (alpha) contains the palette index to be used -#define FI_COLOR_PALETTE_SEARCH_MASK (FI_COLOR_FIND_EQUAL_COLOR | FI_COLOR_ALPHA_IS_INDEX) // No color lookup is performed - - -#ifdef __cplusplus -extern "C" { -#endif - -// Init / Error routines ---------------------------------------------------- - -DLL_API void DLL_CALLCONV FreeImage_Initialise(BOOL load_local_plugins_only FI_DEFAULT(FALSE)); -DLL_API void DLL_CALLCONV FreeImage_DeInitialise(void); - -// Version routines --------------------------------------------------------- - -DLL_API const char *DLL_CALLCONV FreeImage_GetVersion(void); -DLL_API const char *DLL_CALLCONV FreeImage_GetCopyrightMessage(void); - -// Message output functions ------------------------------------------------- - -typedef void (*FreeImage_OutputMessageFunction)(FREE_IMAGE_FORMAT fif, const char *msg); -typedef void (DLL_CALLCONV *FreeImage_OutputMessageFunctionStdCall)(FREE_IMAGE_FORMAT fif, const char *msg); - -DLL_API void DLL_CALLCONV FreeImage_SetOutputMessageStdCall(FreeImage_OutputMessageFunctionStdCall omf); -DLL_API void DLL_CALLCONV FreeImage_SetOutputMessage(FreeImage_OutputMessageFunction omf); -DLL_API void DLL_CALLCONV FreeImage_OutputMessageProc(int fif, const char *fmt, ...); - -// Allocate / Clone / Unload routines --------------------------------------- - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Allocate(int width, int height, int bpp, unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateT(FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); -DLL_API FIBITMAP * DLL_CALLCONV FreeImage_Clone(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_Unload(FIBITMAP *dib); - -// Load / Save routines ----------------------------------------------------- - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Load(FREE_IMAGE_FORMAT fif, const char *filename, int flags FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadU(FREE_IMAGE_FORMAT fif, const wchar_t *filename, int flags FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveU(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const wchar_t *filename, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); - -// Memory I/O stream routines ----------------------------------------------- - -DLL_API FIMEMORY *DLL_CALLCONV FreeImage_OpenMemory(BYTE *data FI_DEFAULT(0), DWORD size_in_bytes FI_DEFAULT(0)); -DLL_API void DLL_CALLCONV FreeImage_CloseMemory(FIMEMORY *stream); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_LoadFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0)); -DLL_API long DLL_CALLCONV FreeImage_TellMemory(FIMEMORY *stream); -DLL_API BOOL DLL_CALLCONV FreeImage_SeekMemory(FIMEMORY *stream, long offset, int origin); -DLL_API BOOL DLL_CALLCONV FreeImage_AcquireMemory(FIMEMORY *stream, BYTE **data, DWORD *size_in_bytes); -DLL_API unsigned DLL_CALLCONV FreeImage_ReadMemory(void *buffer, unsigned size, unsigned count, FIMEMORY *stream); -DLL_API unsigned DLL_CALLCONV FreeImage_WriteMemory(const void *buffer, unsigned size, unsigned count, FIMEMORY *stream); -DLL_API FIMULTIBITMAP *DLL_CALLCONV FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags FI_DEFAULT(0)); - -// Plugin Interface --------------------------------------------------------- - -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterLocalPlugin(FI_InitProc proc_address, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_RegisterExternalPlugin(const char *path, const char *format FI_DEFAULT(0), const char *description FI_DEFAULT(0), const char *extension FI_DEFAULT(0), const char *regexpr FI_DEFAULT(0)); -DLL_API int DLL_CALLCONV FreeImage_GetFIFCount(void); -DLL_API int DLL_CALLCONV FreeImage_SetPluginEnabled(FREE_IMAGE_FORMAT fif, BOOL enable); -DLL_API int DLL_CALLCONV FreeImage_IsPluginEnabled(FREE_IMAGE_FORMAT fif); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFormat(const char *format); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromMime(const char *mime); -DLL_API const char *DLL_CALLCONV FreeImage_GetFormatFromFIF(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFExtensionList(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFDescription(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFRegExpr(FREE_IMAGE_FORMAT fif); -DLL_API const char *DLL_CALLCONV FreeImage_GetFIFMimeType(FREE_IMAGE_FORMAT fif); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilename(const char *filename); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFIFFromFilenameU(const wchar_t *filename); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsReading(FREE_IMAGE_FORMAT fif); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportType(FREE_IMAGE_FORMAT fif, FREE_IMAGE_TYPE type); -DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsICCProfiles(FREE_IMAGE_FORMAT fif); - -// Multipaging interface ---------------------------------------------------- - -DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory FI_DEFAULT(FALSE), int flags FI_DEFAULT(0)); -DLL_API FIMULTIBITMAP * DLL_CALLCONV FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0)); -DLL_API BOOL DLL_CALLCONV FreeImage_CloseMultiBitmap(FIMULTIBITMAP *bitmap, int flags FI_DEFAULT(0)); -DLL_API int DLL_CALLCONV FreeImage_GetPageCount(FIMULTIBITMAP *bitmap); -DLL_API void DLL_CALLCONV FreeImage_AppendPage(FIMULTIBITMAP *bitmap, FIBITMAP *data); -DLL_API void DLL_CALLCONV FreeImage_InsertPage(FIMULTIBITMAP *bitmap, int page, FIBITMAP *data); -DLL_API void DLL_CALLCONV FreeImage_DeletePage(FIMULTIBITMAP *bitmap, int page); -DLL_API FIBITMAP * DLL_CALLCONV FreeImage_LockPage(FIMULTIBITMAP *bitmap, int page); -DLL_API void DLL_CALLCONV FreeImage_UnlockPage(FIMULTIBITMAP *bitmap, FIBITMAP *data, BOOL changed); -DLL_API BOOL DLL_CALLCONV FreeImage_MovePage(FIMULTIBITMAP *bitmap, int target, int source); -DLL_API BOOL DLL_CALLCONV FreeImage_GetLockedPageNumbers(FIMULTIBITMAP *bitmap, int *pages, int *count); - -// Filetype request routines ------------------------------------------------ - -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileType(const char *filename, int size FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeU(const wchar_t *filename, int size FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size FI_DEFAULT(0)); -DLL_API FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromMemory(FIMEMORY *stream, int size FI_DEFAULT(0)); - -// Image type request routine ----------------------------------------------- - -DLL_API FREE_IMAGE_TYPE DLL_CALLCONV FreeImage_GetImageType(FIBITMAP *dib); - -// FreeImage helper routines ------------------------------------------------ - -DLL_API BOOL DLL_CALLCONV FreeImage_IsLittleEndian(void); -DLL_API BOOL DLL_CALLCONV FreeImage_LookupX11Color(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); -DLL_API BOOL DLL_CALLCONV FreeImage_LookupSVGColor(const char *szColor, BYTE *nRed, BYTE *nGreen, BYTE *nBlue); - -// Pixel access routines ---------------------------------------------------- - -DLL_API BYTE *DLL_CALLCONV FreeImage_GetBits(FIBITMAP *dib); -DLL_API BYTE *DLL_CALLCONV FreeImage_GetScanLine(FIBITMAP *dib, int scanline); - -DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); -DLL_API BOOL DLL_CALLCONV FreeImage_GetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); -DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelIndex(FIBITMAP *dib, unsigned x, unsigned y, BYTE *value); -DLL_API BOOL DLL_CALLCONV FreeImage_SetPixelColor(FIBITMAP *dib, unsigned x, unsigned y, RGBQUAD *value); - -// DIB info routines -------------------------------------------------------- - -DLL_API unsigned DLL_CALLCONV FreeImage_GetColorsUsed(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetBPP(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetWidth(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetHeight(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetLine(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetPitch(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDIBSize(FIBITMAP *dib); -DLL_API RGBQUAD *DLL_CALLCONV FreeImage_GetPalette(FIBITMAP *dib); - -DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterX(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetDotsPerMeterY(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterX(FIBITMAP *dib, unsigned res); -DLL_API void DLL_CALLCONV FreeImage_SetDotsPerMeterY(FIBITMAP *dib, unsigned res); - -DLL_API BITMAPINFOHEADER *DLL_CALLCONV FreeImage_GetInfoHeader(FIBITMAP *dib); -DLL_API BITMAPINFO *DLL_CALLCONV FreeImage_GetInfo(FIBITMAP *dib); -DLL_API FREE_IMAGE_COLOR_TYPE DLL_CALLCONV FreeImage_GetColorType(FIBITMAP *dib); - -DLL_API unsigned DLL_CALLCONV FreeImage_GetRedMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetGreenMask(FIBITMAP *dib); -DLL_API unsigned DLL_CALLCONV FreeImage_GetBlueMask(FIBITMAP *dib); - -DLL_API unsigned DLL_CALLCONV FreeImage_GetTransparencyCount(FIBITMAP *dib); -DLL_API BYTE * DLL_CALLCONV FreeImage_GetTransparencyTable(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetTransparent(FIBITMAP *dib, BOOL enabled); -DLL_API void DLL_CALLCONV FreeImage_SetTransparencyTable(FIBITMAP *dib, BYTE *table, int count); -DLL_API BOOL DLL_CALLCONV FreeImage_IsTransparent(FIBITMAP *dib); -DLL_API void DLL_CALLCONV FreeImage_SetTransparentIndex(FIBITMAP *dib, int index); -DLL_API int DLL_CALLCONV FreeImage_GetTransparentIndex(FIBITMAP *dib); - -DLL_API BOOL DLL_CALLCONV FreeImage_HasBackgroundColor(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_GetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); -DLL_API BOOL DLL_CALLCONV FreeImage_SetBackgroundColor(FIBITMAP *dib, RGBQUAD *bkcolor); - - -// ICC profile routines ----------------------------------------------------- - -DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_GetICCProfile(FIBITMAP *dib); -DLL_API FIICCPROFILE *DLL_CALLCONV FreeImage_CreateICCProfile(FIBITMAP *dib, void *data, long size); -DLL_API void DLL_CALLCONV FreeImage_DestroyICCProfile(FIBITMAP *dib); - -// Line conversion routines ------------------------------------------------- - -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To4(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To4_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To4(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To4(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To8_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To8(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_555(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_565_To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To16_565(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16_555_To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To16_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To24(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To24_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine32To24(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine1To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine4To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine8To32(BYTE *target, BYTE *source, int width_in_pixels, RGBQUAD *palette); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_555(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine16To32_565(BYTE *target, BYTE *source, int width_in_pixels); -DLL_API void DLL_CALLCONV FreeImage_ConvertLine24To32(BYTE *target, BYTE *source, int width_in_pixels); - -// Smart conversion routines ------------------------------------------------ - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo4Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo8Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToGreyscale(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits555(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo16Bits565(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo24Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertTo32Bits(FIBITMAP *dib); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantize(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ColorQuantizeEx(FIBITMAP *dib, FREE_IMAGE_QUANTIZE quantize FI_DEFAULT(FIQ_WUQUANT), int PaletteSize FI_DEFAULT(256), int ReserveSize FI_DEFAULT(0), RGBQUAD *ReservePalette FI_DEFAULT(NULL)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Threshold(FIBITMAP *dib, BYTE T); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Dither(FIBITMAP *dib, FREE_IMAGE_DITHER algorithm); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBits(BYTE *bits, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); -DLL_API void DLL_CALLCONV FreeImage_ConvertToRawBits(BYTE *bits, FIBITMAP *dib, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE)); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToRGBF(FIBITMAP *dib); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToStandardType(FIBITMAP *src, BOOL scale_linear FI_DEFAULT(TRUE)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertToType(FIBITMAP *src, FREE_IMAGE_TYPE dst_type, BOOL scale_linear FI_DEFAULT(TRUE)); - -// tone mapping operators -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param FI_DEFAULT(0), double second_param FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoDrago03(FIBITMAP *src, double gamma FI_DEFAULT(2.2), double exposure FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoReinhard05Ex(FIBITMAP *src, double intensity FI_DEFAULT(0), double contrast FI_DEFAULT(0), double adaptation FI_DEFAULT(1), double color_correction FI_DEFAULT(0)); - -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_TmoFattal02(FIBITMAP *src, double color_saturation FI_DEFAULT(0.5), double attenuation FI_DEFAULT(0.85)); - -// ZLib interface ----------------------------------------------------------- - -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibUncompress(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibGUnzip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_size); -DLL_API DWORD DLL_CALLCONV FreeImage_ZLibCRC32(DWORD crc, BYTE *source, DWORD source_size); - -// -------------------------------------------------------------------------- -// Metadata routines -------------------------------------------------------- -// -------------------------------------------------------------------------- - -// tag creation / destruction -DLL_API FITAG *DLL_CALLCONV FreeImage_CreateTag(void); -DLL_API void DLL_CALLCONV FreeImage_DeleteTag(FITAG *tag); -DLL_API FITAG *DLL_CALLCONV FreeImage_CloneTag(FITAG *tag); - -// tag getters and setters -DLL_API const char *DLL_CALLCONV FreeImage_GetTagKey(FITAG *tag); -DLL_API const char *DLL_CALLCONV FreeImage_GetTagDescription(FITAG *tag); -DLL_API WORD DLL_CALLCONV FreeImage_GetTagID(FITAG *tag); -DLL_API FREE_IMAGE_MDTYPE DLL_CALLCONV FreeImage_GetTagType(FITAG *tag); -DLL_API DWORD DLL_CALLCONV FreeImage_GetTagCount(FITAG *tag); -DLL_API DWORD DLL_CALLCONV FreeImage_GetTagLength(FITAG *tag); -DLL_API const void *DLL_CALLCONV FreeImage_GetTagValue(FITAG *tag); - -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagKey(FITAG *tag, const char *key); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagDescription(FITAG *tag, const char *description); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagID(FITAG *tag, WORD id); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagType(FITAG *tag, FREE_IMAGE_MDTYPE type); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagCount(FITAG *tag, DWORD count); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagLength(FITAG *tag, DWORD length); -DLL_API BOOL DLL_CALLCONV FreeImage_SetTagValue(FITAG *tag, const void *value); - -// iterator -DLL_API FIMETADATA *DLL_CALLCONV FreeImage_FindFirstMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, FITAG **tag); -DLL_API BOOL DLL_CALLCONV FreeImage_FindNextMetadata(FIMETADATA *mdhandle, FITAG **tag); -DLL_API void DLL_CALLCONV FreeImage_FindCloseMetadata(FIMETADATA *mdhandle); - -// metadata setter and getter -DLL_API BOOL DLL_CALLCONV FreeImage_SetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG *tag); -DLL_API BOOL DLL_CALLCONV FreeImage_GetMetadata(FREE_IMAGE_MDMODEL model, FIBITMAP *dib, const char *key, FITAG **tag); - -// helpers -DLL_API unsigned DLL_CALLCONV FreeImage_GetMetadataCount(FREE_IMAGE_MDMODEL model, FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_CloneMetadata(FIBITMAP *dst, FIBITMAP *src); - -// tag to C string conversion -DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model, FITAG *tag, char *Make FI_DEFAULT(NULL)); - -// -------------------------------------------------------------------------- -// Image manipulation toolkit ----------------------------------------------- -// -------------------------------------------------------------------------- - -// rotation and flipping -/// @deprecated see FreeImage_Rotate -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateClassic(FIBITMAP *dib, double angle); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rotate(FIBITMAP *dib, double angle, const void *bkcolor FI_DEFAULT(NULL)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_RotateEx(FIBITMAP *dib, double angle, double x_shift, double y_shift, double x_origin, double y_origin, BOOL use_mask); -DLL_API BOOL DLL_CALLCONV FreeImage_FlipHorizontal(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_FlipVertical(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(FALSE)); -DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(FALSE)); - -// upsampling / downsampling -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Rescale(FIBITMAP *dib, int dst_width, int dst_height, FREE_IMAGE_FILTER filter); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MakeThumbnail(FIBITMAP *dib, int max_pixel_size, BOOL convert FI_DEFAULT(TRUE)); - -// color manipulation routines (point operations) -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustCurve(FIBITMAP *dib, BYTE *LUT, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustGamma(FIBITMAP *dib, double gamma); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustBrightness(FIBITMAP *dib, double percentage); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustContrast(FIBITMAP *dib, double percentage); -DLL_API BOOL DLL_CALLCONV FreeImage_Invert(FIBITMAP *dib); -DLL_API BOOL DLL_CALLCONV FreeImage_GetHistogram(FIBITMAP *dib, DWORD *histo, FREE_IMAGE_COLOR_CHANNEL channel FI_DEFAULT(FICC_BLACK)); -DLL_API int DLL_CALLCONV FreeImage_GetAdjustColorsLookupTable(BYTE *LUT, double brightness, double contrast, double gamma, BOOL invert); -DLL_API BOOL DLL_CALLCONV FreeImage_AdjustColors(FIBITMAP *dib, double brightness, double contrast, double gamma, BOOL invert FI_DEFAULT(FALSE)); -DLL_API unsigned DLL_CALLCONV FreeImage_ApplyColorMapping(FIBITMAP *dib, RGBQUAD *srccolors, RGBQUAD *dstcolors, unsigned count, BOOL ignore_alpha, BOOL swap); -DLL_API unsigned DLL_CALLCONV FreeImage_SwapColors(FIBITMAP *dib, RGBQUAD *color_a, RGBQUAD *color_b, BOOL ignore_alpha); -DLL_API unsigned DLL_CALLCONV FreeImage_ApplyPaletteIndexMapping(FIBITMAP *dib, BYTE *srcindices, BYTE *dstindices, unsigned count, BOOL swap); -DLL_API unsigned DLL_CALLCONV FreeImage_SwapPaletteIndices(FIBITMAP *dib, BYTE *index_a, BYTE *index_b); - -// channel processing routines -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetChannel(FIBITMAP *dib, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API BOOL DLL_CALLCONV FreeImage_SetChannel(FIBITMAP *dib, FIBITMAP *dib8, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_GetComplexChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); -DLL_API BOOL DLL_CALLCONV FreeImage_SetComplexChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel); - -// copy / paste / composite routines -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Copy(FIBITMAP *dib, int left, int top, int right, int bottom); -DLL_API BOOL DLL_CALLCONV FreeImage_Paste(FIBITMAP *dst, FIBITMAP *src, int left, int top, int alpha); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_Composite(FIBITMAP *fg, BOOL useFileBkg FI_DEFAULT(FALSE), RGBQUAD *appBkColor FI_DEFAULT(NULL), FIBITMAP *bg FI_DEFAULT(NULL)); -DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom); -DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCropU(const wchar_t *src_file, const wchar_t *dst_file, int left, int top, int right, int bottom); -DLL_API BOOL DLL_CALLCONV FreeImage_PreMultiplyWithAlpha(FIBITMAP *dib); - -// background filling routines -DLL_API BOOL DLL_CALLCONV FreeImage_FillBackground(FIBITMAP *dib, const void *color, int options FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_EnlargeCanvas(FIBITMAP *src, int left, int top, int right, int bottom, const void *color, int options FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateEx(int width, int height, int bpp, const RGBQUAD *color, int options FI_DEFAULT(0), const RGBQUAD *palette FI_DEFAULT(NULL), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_AllocateExT(FREE_IMAGE_TYPE type, int width, int height, int bpp, const void *color, int options FI_DEFAULT(0), const RGBQUAD *palette FI_DEFAULT(NULL), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0)); - -// miscellaneous algorithms -DLL_API FIBITMAP *DLL_CALLCONV FreeImage_MultigridPoissonSolver(FIBITMAP *Laplacian, int ncycle FI_DEFAULT(3)); - -// restore the borland-specific enum size option -#if defined(__BORLANDC__) -#pragma option pop -#endif - -#ifdef __cplusplus -} -#endif - -#endif // FREEIMAGE_H diff --git a/extern/FreeImage/FreeImage.lib b/extern/FreeImage/FreeImage.lib deleted file mode 100644 index 33927a81..00000000 Binary files a/extern/FreeImage/FreeImage.lib and /dev/null differ diff --git a/extern/FreeImage/Whatsnew.txt b/extern/FreeImage/Whatsnew.txt deleted file mode 100644 index b14d348a..00000000 --- a/extern/FreeImage/Whatsnew.txt +++ /dev/null @@ -1,993 +0,0 @@ -What's New for FreeImage - -* : fixed -- : removed -! : changed -+ : added - -December 22, 2009 - 3.13.1 -! FreeImage now uses libTIFF 3.9.2 -! FreeImage now uses OpenJPEG 1.3.0 (SVN patch 2009-11-05) -! FreeImage now uses libPNG 1.2.41 -+ [Berend Engelbrecht] added loading of Exif orientation tag in TIFF plugin -+ [Herve Drolon] added decoding support for the old and outdated JPEG-in-TIFF 6.0 format in TIFF plugin -+ [Herve Drolon] added new 'non standard' Exif tags -+ [Herve Drolon] added new Exif makernote tags -* [Herve Drolon] fixed TIF plugin crashing on a malformed TIFF-JPEG compressed image -* [Herve Drolon] fixed MNG plugin crashing on some old mng images -* [Herve Drolon] fixed handling of 2-bit grayscale transparent PNG -* [Herve Drolon] fixed a bug with the compression rate of JP2 and J2K encoders -* [zestony] fixed TIF plugin with the '65535 bytes' pitch size limitation on saving -* [Herve Drolon] fixed handling of PSD files with a non zero file header reserved member -* [Lucian Sabo] PNG plugin now keep transparency when saving 1- or 4-bit transparent images - -September 28th, 2009 - 3.13.0 -! FreeImage now uses LibJPEG 7 -! FreeImage now uses LibRaw-Lite 0.7.2 -! FreeImage now uses libPNG 1.2.40 -! FreeImage now uses libTIFF 3.9.1 -! FreeImage_RotateClassic is deprecated (use FreeImage_Rotate instead) -+ [Herve Drolon] added support for all Photoshop supported color modes to PSD plugin -+ [Herve Drolon] added support for 32-bit to JNG/MNG plugin -+ [Amir Ebrahimi] added loading support for the PICT format -+ [Herve Drolon] added loading support for camera RAW formats (using LibRawLite wrapper for dcraw) -+ [Mihail Naydenov] added UNICODE functions FreeImage_JPEGTransformU and FreeImage_JPEGCropU -+ [Carsten Klein] added FreeImage_OpenMultiBitmapFromHandle -+ [Carsten Klein] added FreeImage_FillBackground -+ [Carsten Klein] added FreeImage_EnlargeCanvas -+ [Carsten Klein] added FreeImage_AllocateEx / FreeImage_AllocateExT -+ [Mihail Naydenov/Herve Drolon] added FreeImage_TmoReinhard05Ex -+ [Herve Drolon] added FIT_RGBA16 to FIT_RGBF conversion to FreeImage_ConvertToRGBF -+ [Herve Drolon] added FreeImage_Rotate (support for most image types, support background color) -* [Christian Heimes] fixed function prototypes to use a void argument when no argument exist -* [Herve Drolon] fixed RGB color ordering on Intel macs -* [Herve Drolon] FreeImage_RotateClassic now keep transparency when applied to 8-bit images -* [Herve Drolon] fixed handling of transparency info in FreeImage_Copy -* [Herve Drolon] fixed a normalization error in FreeImage_GetAdjustColorsLookupTable -* [Herve Drolon] fixed invalid Exif rotation in PluginJPEG for orientation cases 2 and 4 -* [Mihail Naydenov / Carsten Klein] fixed compilation issues with MinGW32 -* [Mihail Naydenov] improved the loading speed of all targa images -* [Herve Drolon] FreeImage_TagToString now handles the Exif UserComment tag - -April 14th, 2009 - 3.12.0 -! FreeImage now uses libPNG 1.2.35 -! FreeImage now uses libTIFF 3.9.0beta (CVS patch 2009-02-12) -! FreeImage now uses OpenJPEG 1.3.0 (SVN patch 2008-08-21) -! [Herve Drolon] FreeImage_CloneMetadata no longer clone the FIMD_ANIMATION metadata (this was causing problems when saving to GIF format) -+ [Herve Drolon] added full support for the PFM format -+ [Herve Drolon] added JPEG_EXIFROTATE load flag to the JPEG plugin -+ [Herve Drolon] added 16-bit RGB(A) and float RGB(A)F support to FreeImage_GetChannel / FreeImage_SetChannel -+ [Herve Drolon] added src FIT_RGBA16 to dst 32-bit FIT_BITMAP conversion to FreeImage_ConvertToType -* [Carsten Klein] FreeImage_Copy now copies transparency info, resolution info, ICC profile and metadata -* [Carsten Klein] check for negative top/left values in FreeImage_Paste -* [Christian Heimes] changed exceptions with a "catch(char *text)" to a "catch(const char *text)" to make GCC 4.1 happy -* [Deif Lou] fixed a bug in FreeImage_SetTransparentIndex -* [Thomas Maiwald] BMP plugin: on saving, fixed correct setting of bfSize BMP file header for palettized images -* [Timothy Lee] fixed handling of frame disposal in GIF_PLAYBACK mode (GIF plugin) -* [Herve Drolon] fixed handling of Exif Olympus Type 2 maker notes (not yet supported but now safely ignored) -* [Rich Geldreich] fixed DXT1 color endpoint precision problem in DDS plugin -* [Mihail Naydenov] improved loading speed of 24-bit targa images -* [Eugene Golushkov] improved big endian / little endian swapping functions -* [Carsten Klein/Jean-Philippe Goerke] improved FreeImage_SetMetadata / FreeImage_GetMetadata accessors -* [Christian Ruppert] improved Linux Makefiles -* [Eugene Golushkov] fixed PluginBMP alignment bug while saving 16 or 24bit BMP on big endian or Apple machines - -July 28th, 2008 - 3.11.0 -! FreeImage now uses libTIFF 3.9.0beta (CVS patch 2008-05-24) -! FreeImage now uses OpenJPEG 1.3.0 (SVN patch 2008-05-22) -! FreeImage now uses libMNG 1.0.10 -! FreeImage now uses libPNG 1.2.29 -+ [Yves Schmid] added 48-bit RGB to 32-bit conversion support in FreeImage_ConvertTo32Bits -+ [Aaron Shumate] added RGB16-to-BITMAP and All-to-RGBF conversion support in FreeImage_ConvertToType -+ [Benjamin English] added a new OpenGL sample to FreeImage/Examples -+ [Lucian Sabo] added new compression flags to the PNG plugin -+ [Lucian Sabo] added new compression flags to the JPEG plugin (chroma subsampling options) -+ [Noam Gat] added support for SGI grayscale + alpha pics to SGI plugin -+ [Herve Drolon] added FreeImage_CloneMetadata -+ [Herve Drolon] added loading support for Windows Vista icons in ICO Plugin -+ [Herve Drolon] added loading and saving support for RGBF images to the TIF plugin (using the LogLuv codec) -* [Will Bryant] fixed makefile for MacOSX Tiger and Leopard -* [Maria Gullickson] fixed a 'divide by 0' error in PNM plugin and FreeImage_Rescale function -* [Yves Schmid] fixed a bug with Exif metadata reading in TIFF images -* [Herve Drolon] fixed some possible 64-bit portability issues with pointer calculations -* [wangyn] fixed a bug with transparency handling of indexed images in PNG plugin -* [Martin Dyring-Andersen] fixed a bug with GIFinfo structure initialization in GIF plugin -* [Noam Gat] fixed a bug in SGI plugin: when the file reports as two-dimensional, the height factor does not get loaded -* [Herve Drolon] added error messages in FreeImage_Load(U) / FreeImage_Save(U) in case of bad filenames -* [Scott Smith/Herve Drolon] added missing IPTC tags and renamed some tag names to be compatible with ExifTool naming convention -* [Martin Dyring-Andersen] fixed a crash problem with images containing exif data emitted by Picassa -* [Herve Drolon] removed RGBA to RGB transparent conversion in EXR plugin -* [Glenn Pierce] improved the speed of FreeImage_FlipHorizontal -* [Carsten Klein] fixed 65535 pixels width/height limitation in FreeImage_Paste - -November 19th, 2007 - 3.10.0 -! FreeImage now uses libTIFF 3.9.0beta (CVS patch 2007-10-05) -! FreeImage now uses OpenJPEG 1.2.0 (SVN patch 2007-07-13) -! FreeImage now uses OpenEXR 1.6.1 -! FreeImage now uses libPNG 1.2.23 -! FreeImage now hides its internal functions and internal libraries when compiled with gcc -- [Herve Drolon] removed VS C+ 6.0 project files : this IDE is no longer supported because of OpenEXR -+ [Herve Drolon] added VS 2005 project files -+ [Herve Drolon] added full support for the OpenEXR format -+ [Herve Drolon] added full support for the JPEG-2000 format -+ [Herve Drolon] added FreeImage_TmoFattal02 tone mapping operator -+ [Ryan Rubley] added support for RGB vs BGR regardless of endian -+ [Herve Drolon] added FreeImage_MultigridPoissonSolver -+ [Carsten Klein] added FreeImage_PreMultiplyWithAlpha -+ [Carsten Klein] added __stdcall version of FreeImage_OutputMessage -+ [Carsten Klein] added new palette and color manipulation functions (see below) : - added FreeImage_SetTransparentIndex - added FreeImage_GetTransparentIndex - added FreeImage_GetAdjustColorsLookupTable - added FreeImage_AdjustColors - added FreeImage_ApplyColorMapping - added FreeImage_SwapColors - added FreeImage_ApplyPaletteIndexMapping - added FreeImage_SwapPaletteIndices -* [Herve Drolon] fixed a bug in TIFF plugin when reading 8-bit + 8-bit alpha images -* [Herve Drolon] fixed a bug in TIFF plugin when reading images with uncommon bitdepths -* [rodrigo] fixed FreeImage exception handling under gcc (added -fexceptions to gcc compiler flags) -* [Martin Dyring-Andersen] fixed GIF plugin crashing on some corrupted files -* [Herve Drolon] fixed a bug with RLE encoding for 8-bit BMP images -* [Herve Drolon] fixed GPS metadata being skipped when reading metadata in Exif images -* [Herve Drolon] fixed a bug when reading OS/2 BMP images with a negative height -* [Ryan Rubley] fixed a bug with loading of GIFs with large amounts of solid color areas -* [Ryan Rubley] fixed OS X compile error in BitmapAccess.cpp -* [Herve Drolon] fixed a bug in FreeImage_Paste when pasting non-standard image types -* [Herve Drolon] saving 1-bit TIF with the TIFF_CCITTFAX3 flag is now compliant with the TIFF Class F specification -* [Carsten Klein] fixed topdown parameter in FreeImage_ConvertFromRawBits and FreeImage_ConvertToRawBits being handled in reverse -* [Herve Drolon] fixed a bug when reading some RLE-4 encoded BMP data -* [Carsten Klein] conversion from 1-bit to 32-bit now keep possibly present transparency - -February 11th, 2007 - 3.9.3 -! FreeImage now uses libPNG 1.2.16 -! [Ryan Rubley/Ryan Davis] reworked the MacOSX makefile in order to fully support Universal Binary builds of FreeImage -! [Herve Drolon] makefiles are now generated from VS2003 project files instead of VS6 project files -! [Herve Drolon] changed JPEG load/save flag option values -+ [Herve Drolon] added support for RGBAF images to FreeImage_ConvertToRGBF -+ [Herve Drolon] FreeImage_Paste now works with any bitmap type -+ [Herve Drolon] added full support for 64-bit RGBA images to the PNG and TIFF plugins -+ [Jascha Wetzel] added JPEG downsampling feature to PluginJPEG:Load -* [Thomas Chmielewski] fixed a bug in FreeImage_Dither and Bayer dithering, added FID_BAYER16x16 -* [Raphael Gaquer] greatly improved the speed of the GIF encoder -* [Herve Drolon] fixed saving of metadata in the PNG plugin -* [rampelstinskin] fixed transparency table to alpha channel conversion for 4-bit images in FreeImage_ConvertTo32Bits -* [Scott Smith] added missing IPTC tag named "Country/PrimaryLocationCode" -* [Herve Drolon] changed #include by #include in FreeImage.h (needed by Solaris 9) -* [Pierre Arnaud] fixed the use of FreeImage in low memory condition by checking some returned values of the malloc function -* [Pierre Arnaud] fixed TagLib::getTagFieldName not being thread safe - -October 30th, 2006 - 3.9.2 -! FreeImage now uses libTIFF 3.8.2 (with patch 2006-10-13) -+ [Herve Drolon] added full support for 16-bit greyscale and 48-bit RGB to the PNM plugin -+ [Herve Drolon] added IPTC writing support to JPEG & TIFF plugins -+ [Herve Drolon] added new Exif maker note tags -+ [Herve Drolon] added FreeImage_JPEGCrop -+ [Thorsten Radde] added support for 8-bit palettized bitmaps in FreeImage_RotateClassic -+ [Matt Rice] added automatic call to FreeImage_Initialise / FreeImage_DeInitialise when using FreeImage as a .so -+ [Martin Dyring-Andersen] added FreeImage_LoadMultiBitmapFromMemory to the multi-page API -+ [Herve Drolon] added support for tiled TIFF images -* [Carsten Klein] fixed a bug in FreeImage_SetMetadata occuring when deleting a tag -* [Herve Drolon] fixed a bug in PNG plugin when reading Macromedia 'false' PNG files -* [Thorsten Radde] added resolution support to PluginPSD -* [Ryan Rubley] fixed a bug in PluginGIF occuring with interlaced GIF -* [Ryan Rubley] fixed a bug in the multipage cache mechanism (internal FreeImage_FindBlock function) -* [Thorsten Radde] fixed a stack corruption in TIFF plugin occuring when reading exif tags -* [checkered] fixed a bug in the multipage cache mechanism causing VS2005 to crash on multipage files -* [Herve Drolon] fixed a bug with transparency support of 1- and 4-bit images -* [Roar Flolo] fixed a bug in PSD plugin when reading non compressed RGB images (alpha channel initialization) -* [Nicolas Hatier] fixed a bug in PluginGIF when using the GIF_PLAYBACK flag -* [Herve Drolon] fixed a bug in TIFF plugin when saving 8-bit images using LZW with differenciation -* [Herve Drolon] fixed 64-bit compilation issue with LibPNG and assembler code - -July 16th, 2006 - 3.9.1 -* [Ryan Rubley] fixed a bug in PluginGIF plugin causing FreeImage to crash on malformed GIF files - -July 6th, 2006 - 3.9.0 -! FreeImage now uses libPNG 1.2.12 -! FreeImage now uses libTIFF 3.8.2 (with patch 2006-06-24) -! FreeImage_Allocate/FreeImage_Allocate now set the resolution to 72 dpi instead of 0 -+ [Herve Drolon/Petr Pytelka] added a raw FAX G3 format loader -+ [Herve Drolon] added support for most image types to FreeImage_Rescale -+ [Herve Drolon] added FreeImage_MakeThumbnail -+ [Herve Drolon] added support for 64-bit images to FreeImage_ConvertTo32Bits -+ [Herve Drolon] added support for Exif tags to TIF plugin (read only) -+ [Herve Drolon] added FreeImage_ReadMemory -+ [Herve Drolon] added FreeImage_WriteMemory -+ [Herve Drolon] added new Exif maker note tags -+ [Sherman Wilcox] added a SGI file format loader -+ [Herve Drolon] added support for separated images to PluginTIFF -+ [Herve Drolon] added support for progressive-JPEG saving to PluginJPEG -* [Carsten Klein] FreeImage_Dither and FreeImage_Threshold now work with palettized 8-bit dib -* [Christophe Petit] fixed a bug in FreeImage_GetFIFFromFilenameU occuring with files without extension -* [Leigh Brasington] fixed a bug in PluginGIF causing FreeImage not working on Win/98/ME -* [Herve Drolon] fixed a bug in PluginTIFF with writing of JPEG-in-TIFF files -* [Jojakim Stahl] fixed a bug occuring with 4-bit PCX files -* [Sandor Szalacsi] fixed a bug in FreeImage_SetBackgroundColor (bkgnd clearing) -* [Petr Pytelka] fixed PluginTIFF::_tiffSizeProc failing on some images -* [Sherman Wilcox] fixed a bug in DDS plugin when loading images whose size is not a multiple of 4 -* [Sherman Wilcox] fixed a memory leak in PluginDDS::LoadDXT_Helper -* [Sherman Wilcox] fixed DDS plugin bad behavior with invalid DDS files (such as files with zero length) -* [Floris van den Berg] fixed a memory leak in the MultiPage cache mechanism -* [Herve Drolon] replaced WIN32 #define by _WIN32 #define as this is needed by VS2005 -* [Herve Drolon] fixed a VS2005 error in FreeImage_DeletePage -* [Petr Supina] fixed a pow(long,long) function not being standard ANSI C/C++ -* [Petr Supina] fixed FreeImage_FindBlock function not being standard ANSI C/C++ -* [Olaf Stoyke] added support for 64-bit Linux OS -* [Craig Stark] fixed FreeImage support on Intel based Mac OS -* [Herve Drolon] fixed PluginTIFF failing on bad fax tiff images (bad images are now loaded 'as is') -* [Zack Simpson] fixed a bug occuring in rare situations with FreeImage_Aligned_Malloc - -September 5, 2005 - 3.8.0 -! FreeImage now uses libTIFF 3.7.3 -! FreeImage now uses ZLib 1.2.3 -+ [Herve Drolon] added support for 48-bit images to FreeImage_ConvertTo24Bits -+ [Herve Drolon] added FreeImage_ConvertToGreyscale -+ [Herve Drolon] added support for 16-bit greyscale images to FreeImage_ConvertTo8Bits -+ [Petr Pytelka] added UNICODE functions (see below) - added FreeImage_LoadU - added FreeImage_SaveU - added FreeImage_GetFIFFromFilenameU - added FreeImage_GetFileTypeU -+ [Herve Drolon] FreeImage_Copy now works with any bitmap type -+ [Herve Drolon] added support for 1-bit images to FreeImage_Paste -* [Ryan Rubley] fixed PluginGIF failing to link on some broken gcc versions -* [Karl-Heinz Bussian] fixed a bug in LookupX11Color/LookupSVGColor with handling of grey color names -* [Herve Drolon] FreeImage_Dither now uses FreeImage_ConvertToGreyscale and handles 4/8-bit palletized images -* [Herve Drolon] FreeImage_Threshold now uses FreeImage_ConvertToGreyscale and handles 4/8-bit palletized images -* [Craig Hockenberry] fixed PluginGIF::Save swapping the byte order for the height on big endian machines (e.g. PPC on Mac OS X.) -* [Herve Drolon] fixed a bug in JPEG plugin when reading Exif maker notes from images produced by Nikon Editor -* [Herve Drolon] fixed a bug in BMP plugin when reading some malformed RLE8 bmp -* [Herve Drolon] fixed a bug in RAS plugin when loading 8-bit palettized images with less than 256 colors -* [Herve Drolon] fixed a bug in FreeImage_Rescale with 16-,48-,64-bit images -* [Herve Drolon] fixed a bug in the ICC profiles API when loading profile-less CMYK TIFF -* [Herve Drolon] 4-bit PNG are now loaded as 4-bit and no longer converted to 8-bit -* [Greg Ng] fixed a bug in FreeImage_ConvertToRGBF (FIT_BITMAP -> FIT_RGBF conversion) - -May 7, 2005 - 3.7.0 -! FreeImage now uses libTIFF 3.7.2 -! [Ryan Rubley] improved FreeImage_OpenMultiBitmap -+ [Detlev Vendt] added FreeImage_ZLibGUnzip -+ [Herve Drolon] added new image data types FIT_RGB16, FIT_RGBA16, FIT_RGBF, FIT_RGBAF -+ [Herve Drolon] FreeImage_FlipHorizontal & FreeImage_FlipVertical now work with any bitmap type -+ [Herve Drolon] added conversions to float and double in FreeImage_ConvertToType -+ [Herve Drolon] added FreeImage_ConvertToRGBF -+ [Herve Drolon] added support for 16-, 48- and 96-bit images to FreeImage_Rescale -+ [Ryan Rubley] added FreeImage_ColorQuantizeEx -+ [Ryan Rubley] added FIMD_ANIMATION and FIDT_PALETTE -+ [Ryan Rubley] added brand new PluginGIF with full animation multipage and metadata support -+ [Herve Drolon] added support for FIC_MINISWHITE 8-bit images to FreeImage_Rescale -+ [Herve Drolon] added HDR (High Dynamic Range) format (loader & writer) -+ [Herve Drolon] added support for 48-bit images in TIFF plugin -+ [Herve Drolon] added support for 48-bit images in PNG plugin -+ [Herve Drolon] added tone mapping operators (see below) -+ added FreeImage_ToneMapping -+ added FreeImage_TmoDrago03 -+ added FreeImage_TmoReinhard05 -+ [Petr Pytelka] added FreeImage_JPEGTransform -* [Herve Drolon] allowed loading of corrupted JPEG with a premature end of file -* [Herve Drolon] fixed a memory leak with loading of exif JPEG images -* [Detlev Vendt] changed some 'pointer-to-int' casts to 'pointer-to-long' for 64bit machines -* [Ryan Rubley] fixed a memory leak in the multipage API -* [Ryan Rubley] updated VB6 wrapper generation for new functions -* [Herve Drolon] fixed incorrect behavior when reading JPEG comments containing special characters -* [Herve Drolon] fixed incorrect behavior when reading JPEG ICC profiles with a size greater than 64 KB -* [Herve Drolon] fixed a bug in TIFF plugin when loading malformed multipage TIFF -* [Herve Drolon] fixed PluginTIFF not being thread safe - -February 20, 2005 - 3.6.1 -* [Ryan Rubley] fixed a memory leak in the metadata API -* [luedi] improved the robustness of FIBITMAP allocations - -February 13, 2005 - 3.6.0 -! FreeImage now uses libMNG 1.0.9 -! [Herve Drolon] improved the speed of FreeImage_Rescale -! [Herve Drolon] improved FreeImage_RotateClassic (more compact code, a little faster) -! [Herve Drolon] improved the metadata API using tag accessors -+ [Detlev Vendt] added LZW support to PluginGIF:Save -+ [Herve Drolon] added VS.Net 2003 project files -+ [Herve Drolon] added VERSIONINFO resource to the DLL -+ [Herve Drolon] added support for CMYK JPEG on loading -+ [Petr Supina] added 16-bytes alignment to FIBITMAP palette and pixels starting address -+ [Petr Supina] added support for MMX/SSE2 code in LibJPEG (based on Mozilla/Firefox code) -+ [Herve Drolon] added TIFF_JPEG compression flag to the TIFF plugin -+ [Detlev Vendt] added FreeImage_ZLibGZip -+ [Detlev Vendt] added FreeImage_ZLibCRC32 -* [Detlev Vendt] fixed PluginPNG not being thread safe -* [Herve Drolon] fixed compiler warning C4018 occuring with VS.Net 2003 - -December 29, 2004 - 3.5.3 -! FreeImage now uses ZLib 1.2.2 -! FreeImage now uses libPNG 1.2.8 -! FreeImage now uses libTIFF 3.7.1 -! [Herve Drolon] improved FreeImage_RotateClassic -! [Detlev Vendt] improved FreeImage_Rescale (more compact code, preserving 8-bpp colors) -+ [Herve Drolon] added support for transparency saving in ICO plugin -+ [Herve Drolon] added support for 1-bit images to FreeImage_RotateClassic -+ [Herve Drolon] added FreeImage_SetDotsPerMeterX and FreeImage_SetDotsPerMeterY -* [Nan Feng] fixed memory leak in FreeImage_DeleteTag (internal stuff) -* [Nigel Stewart] added conditional #pragma with #ifdef _MSC_VER / #endif -* [Herve Drolon] fixed the '65536 lines' limit on loading in PNM plugin - -November 27th, 2004 - 3.5.2 -* [Herve Drolon] fixed a second bug in FreeImage_Clone function - -November 26th, 2004 - 3.5.1 -+ [Riley McNiff] added FreeImage_ConvertTo4Bits -* [Herve Drolon] fixed a buffer overrun with some ILBM images -* [Riley McNiff] fixed a potential problem when reading TIFF resolution info -* [Dimitar Atanasov] fixed a bug in FreeImage_Clone function -* [Dimitar Atanasov] fixed several bugs in TIFF plugin - -November 1st, 2004 - 3.5.0 -! FreeImage now uses libPNG 1.2.7 -! FreeImage now uses libTIFF 3.7.0 -! FreeImage now uses libMNG 1.0.8 -! [Herve Drolon] improved TIFF LZW compression using a predictor -! [Detlev Vendt] FreeImagesPlus: corrected references to FreeImage.h and FreeImage.lib -+ [Herve Drolon] added support for loading/saving of 8-bit transparent TIFF -+ [Riley McNiff] added support for 4-bit dib in FreeImage_Paste -+ [Herve Drolon] added support for memory IO streams (see below) -+ added FreeImage_OpenMemory -+ added FreeImage_CloseMemory -+ added FreeImage_LoadFromMemory -+ added FreeImage_SaveToMemory -+ added FreeImage_TellMemory -+ added FreeImage_SeekMemory -+ added FreeImage_AcquireMemory -+ added FreeImage_GetFileTypeFromMemory -+ [Petr Pytelka] added FreeImage_GetFIFMimeType to the plugins function list -+ [Herve Drolon] added ICC profile support to JPEG plugin -+ [Herve Drolon] added support for metadata (see below) -+ added FreeImage_SetMetadata -+ added FreeImage_GetMetadata -+ added FreeImage_GetMetadataCount -+ added FreeImage_TagToString -+ added FreeImage_FindFirstMetadata -+ added FreeImage_FindNextMetadata -+ added FreeImage_FindCloseMetadata -* [Riley McNiff] fixed a bug with FreeImage_SetPixelIndex and 4-bit images -* [Petr Pytelka] fixed returned value in FreeImage_CloseMultiBitmap -* [Petr Pytelka] fixed index of new page in FreeImage_InsertPage -* [Aaron Shumate] fixed a minor bug in PNG plugin -* [Aaron Shumate] fixed a bug in IFF plugin (odd-length chunks) -* [Rupert Hewitt] fixed FreeImage not compiling on National Instruments Cvi Ccompiler -* [Herve Drolon] fixed a bug in IFF plugin (ILBM data) -* [Fred Harju] added a Makefile for Solaris 9 -* [Roddy Pratt] fixed FreeImage not linking under Borland C++ Builder -* [Vadim Alexandrov] fixed a memory leak in the multipage API -* [Herve Drolon] fixed a bug with DDS plugin behaviour on Big Endian OS -* [Herve Drolon] fixed a bug with conversion of JPEG resolution info on saving - -July 8th, 2004 - 3.4.0 -! [Jim Keir] improved FreeImage_FlipVertical function -! [Herve Drolon] LZW compression is now enabled in FreeImage -+ [Karl-Heinz Bussian] added constants to FreeImage.h to get at compile time the library version -+ [Karl-Heinz Bussian] added color lookup functions for X11 and SVG -+ [Herve Drolon] added TIFF tags TIFF_CCITTFAX3, TIFF_CCITTFAX4 and TIFF_LZW -+ [Detlev Vendt] added support for CMYK TIFF files with alpha channel -+ [Detlev Vendt] added (re-introduction of) PluginGIF -* [Herve Drolon] fixed a bug with loading of FAX TIFF images (introduced with LibTIFF 3.6.1) -* [Herve Drolon] fixed a bug in Floyd-Steinberg dithering algorithm -* [Herve Drolon] fixed a bug in Targa plugin save function -* [Herve Drolon] fixed a bug in FreeImage_AdjustCurve function -* [Ryan Rubley] fixed a bug with FreeImage_Rescale's filters accuracy -* [Ryan Rubley] fixed a bug in NN quantizer -* [Herve Drolon] fixed a bug with TIFF files containing additional Photoshop alpha channels -* [James Rossfeld] fixed a memory leak with some PSD images -* [Herve Drolon] fixed a bug with saving of 32-bit non transparent PNG images -* [Alexandr Zamaraev] fixed FreeImage not compiling with mingw32 -* [Herve Drolon] fixed FreeImage not compiling with VC.NET (pow function needs casts) - -May 2, 2004 - 3.3.0 -! [Ryan Rubley] FreeImage has been ported to MacOSX and should also work on other big endian processors -+ [Ryan Rubley] rewrote XPM plugin (better load support) and added save support -+ [Ryan Rubley] added ICO_MAKEALPHA flag to ICO plugin -+ [Ryan Rubley] Set/GetPixelColor now works with 16-bit pixels (555 or 565) -+ [Herve Drolon] PNG plugin now supports loading and saving of unsigned 16-bit greyscale images -* [Herve Drolon] fixed a bug with loading of 8-bit and 16-bit PNG with a 8-bit alpha channel -* [Herve Drolon] fixed a bug in NN quantizer algorithm with handling of 4-byte boundary alignment. -* [Herve Drolon] fixed a bug in PluginIFF Validate function -* [Herve Drolon] fixed a minor design issue in FreeImage_GetFIFFromFormat -* [Brad Schick] fixed some compiler warnings with VC++ 7.1 -* [Herve Drolon] fixed a bug with saving of 8-bit palettized images to 24-bit JPEG (channel inversion) - -March 16, 2004 - 3.2.1 -! [Volker Gärtner] improved the DDS plugin -! [Herve Drolon] FreeImage_Rescale now works on 8-, 24- and 32-bit images -! [Herve Drolon] FreeImage_Copy now works on 1-, 4-, 8-, 16-, 24- and 32-bit images -* [Floris van den Berg] fixed a bug in the MultiPage cache mechanism -* [Herve Drolon] fixed a bug with loading/saving of 8-bit transparent tga images -* [Herve Drolon] fixed a bug with loading of 1-bit TIFF (introduced with LibTIFF 3.6.1) - -February 18, 2004 - 3.2.0 -! FreeImage now uses libTIFF 3.6.1 -+ [Herve Drolon] added FreeImage_HasBackgroundColor -+ [Herve Drolon] added FreeImage_GetBackgroundColor -+ [Herve Drolon] added FreeImage_SetBackgroundColor -+ [Herve Drolon] added FreeImage_Composite -+ [Herve Drolon] added ICC profile support to PNG plugin -+ [Herve Drolon] added background color support to PNG plugin -+ [Volker Gärtner] added support for DDS format (loader) -* [Steve Johnson] improved FreeImage_OpenMultiBitmap/FreeImage_CloseMultiBitmap -* [Steve Johnson] fixed a bug in FreeImage_InsertPage -* [Herve Drolon] fixed a bug with JPEG compressed TIFF (red/blue swapping) -* [Herve Drolon] fixed a bug in PluginTarga where 8-bit images were saved incorrectly - -January 26, 2004 - 3.1.0 -! FreeImage now uses ZLib 1.2.1 -+ [Herve Drolon] added support for integer, real and complex image types (see below) -+ added FREE_IMAGE_TYPE enum -+ added FreeImage_AllocateT -+ added FreeImage_GetImageType -+ added FreeImage_FIFSupportsExportType -+ added FreeImage_ConvertToStandardType -+ added FreeImage_ConvertToType -+ added load/save support of all image types to TIFF plugin -+ [Peter Lemmens] added a Validate function to TARGA plugin -+ [Herve Drolon] added FreeImage_GetPixelIndex / FreeImage_SetPixelIndex -+ [Herve Drolon] added FreeImage_GetPixelColor / FreeImage_SetPixelColor -+ [Herve Drolon] added FreeImage_GetComplexChannel / FreeImage_SetComplexChannel -* [Serge Ivanchenko] TIFF_DEFLATE compression is now enabled in TIFF plugin -* [Herve Drolon] fixed a bug in NeuQuant color reduction algorithm - -November 16, 2003 - 3.0.4 -* [Tobias Persson] fixed FreeImage_GetChannel not working with FICC_ALPHA channel -* [Detlev Vendt] fixed a minor bug with PNG plugin and PNG_IGNOREGAMMA flag -* [Detlev Vendt] fixed a memory leak in PNG plugin save routine -* [Detlev Vendt] fixed JPEG validation problem with .jpe files -* [Ryan Rubley] added Source/LibTIFF/tif_extension.c to LibTIFF (needed for MacOSX) -* [Herve Drolon] improved error handling in TIFF plugin -+ [Karl-Heinz Bussian] added FreeImage_IsLittleEndian -+ [Karl-Heinz Bussian] added JPEG save support for 8-bit miniswhite bitmaps (transparent conversion to minisblack) -+ [Karl-Heinz Bussian] FreeImage_GetColorType now recognizes 8-bit FIC_MINISWHITE images -! [Herve Drolon] FreeImage_Rescale now supports rescaling of 32-bit images with alpha channel -! [Herve Drolon] FreeImage_Invert now supports inversion of 32-bit images with alpha channel -! [Herve Drolon] FreeImage_AdjustCurve now supports working with FICC_ALPHA channel - -November 2, 2003 - 3.0.3 -* [Ryan Rubley] improved makefile for Linux -* [Ryan Rubley] fixed FreeImage not compiling under MacOSX -* [Detlev Vendt] fixed still present inconsistancy with 32bpp transparency handling -* [Herve Drolon] fixed incorrect loading of 4-bit greyscale images in TIFF plugin - -October 27, 2003 - 3.0.2 -! FreeImage now uses libMNG 1.0.6 -* [Herve Drolon] fixed a boolean test in PluginCUT returning always false -* [Herve Drolon] fixed a warning in PluginIFF generated with g++ -* [Linus Tan] fixed a bug in FreeImage_Copy -* [Herve Drolon] fixed FreeImage not compiling under Linux (thanks to Michal) - -October 20, 2003 - 3.0.1 - -! FreeImage now uses libTIFF 3.6.0 -* [Detlev Vendt] fixed incorrect definition of the FREE_IMAGE_FORMAT enum -* [Detlev Vendt] fixed a potential crash problem with Load / Save routines -* [Herve Drolon] fixed incorrect loading of 16-bit greyscale images in TIFF plugin -* [Dennis Lim] fixed a memory leak in Floyd & Steinberg dithering routine -* [Herve Drolon] fixed a bug in BMP loader (incorrect loading of RLE4 bmp) -* [Detlev Vendt] fixed some inconsistancy with 32bpp transparency handling -+ [David Boland] added a C# wrapper -// Linux compatibility issues -- [Michal Novotny] removed the round function in Utilities.h -! [Herve Drolon] replaced the round routine by the clamp routine in PluginPCD -+ [Herve Drolon] added _itoa version in Utilities.h -* [Michal Novotny] fixed untyped consts not accepted by g++ in PluginBMP - -September 8, 2003 - 3.0.0 -- [Herve Drolon] removed deprecated functions -- [Herve Drolon] removed deprecated flags (TARGA_LOAD_RGB555, ICO_*, except ICO_DEFAULT) -- [Herve Drolon] removed the FreeImage pointer table (internal stuff) -+ [Herve Drolon] added a C++ wrapper -+ [Herve Drolon] added the FreeImage Toolkit (see below) -+ added FreeImage_Rescale -+ added FreeImage_RotateClassic -+ added FreeImage_RotateEx -+ added FreeImage_FlipHorizontal -+ added FreeImage_FlipVertical -+ added FreeImage_Invert -+ added FreeImage_AdjustCurve -+ added FreeImage_AdjustGamma -+ added FreeImage_AdjustBrightness -+ added FreeImage_AdjustContrast -+ added FreeImage_GetHistogram -+ added FreeImage_GetChannel -+ added FreeImage_SetChannel -+ added FreeImage_Copy -+ added FreeImage_Paste -+ [Karl-Heinz Bussian] added XPM loader -+ [Karl-Heinz Bussian] added flags parameter to FreeImage_CloseMultiBitmap -+ [Karl-Heinz Bussian] added JPEG save support for 8-bit palettized bitmaps (transparent conversion to 24-bit) -+ [Herve Drolon] added interface to ZLib compression functions -+ [Herve Drolon] added ICO format to the multipage API (loader & writer) -+ [Herve Drolon] added a MIME type to all plugins -* [Karl-Heinz Bussian] fixed incorrect conversion from 1-bit FIC_MINISWHITE bitmaps to 8-bit -* [Herve Drolon] fixed a bug in FreeImage_CloseMultiBitmap -* [Herve Drolon] fixed a potential memory leak in conversion functions (8-, 24-, 32-bit) -* [Robert Walker] fixed incorrect conversion from 16-bit to 24-bit and 16-bit to 32-bit -* [blurble] fixed TIFF validate signature problem (3DS files were recognized as TIFF) -* [Kurt Jankowski-Tepe] fixed FreeImage not compiling on MinGW / LCC WIN32 -* [Jani Peltonen] fixed bug in PluginTARGA where 32-bit bitmaps are not always correctly flipped -* [Detlev Vendt] fixed a bug with TIFF (memory leak with ICC profiles) - -May 25, 2003 - 2.6.1 -+ [Detlev Vendt] added FIC_CMYK to FREE_IMAGE_COLOR_TYPE -+ [Detlev Vendt] added ICC profile support to the library (see below) -+ added FreeImage_GetICCProfile -+ added FreeImage_CreateICCProfile -+ added FreeImage_DestroyICCProfile -+ added FIICCPROFILE & FIICCPROFILE flags -+ added plugin function FreeImage_FIFSupportsICCProfiles -+ [Detlev Vendt] added ICC profile support for TIFF -+ [Herve Drolon] added XBM (X11 Bitmap Format) support : loading -* [Herve Drolon] fixed incorrect IFF file detection (thanks Floris) -* [Herve Drolon] fixed incorrect conversion from 1/4-bit greyscale bitmaps to 8-bit -* [Herve Drolon] fixed a bug in TIFF writer when saving 1,4,8 bit dib (introduced in 2.6.0, sorry) -* [Herve Drolon] fixed a palette problem in TIFF loader when loading 1-bit b & w images -* [Herve Drolon] improved FreeImage_Dither to handle any bitdepth - -May 5th, 2003 - 2.6.0 -! FreeImage now uses libPNG 1.2.5 -! FreeImage now uses libMNG 1.0.5 -! [Markus Loibl] ActiveX wrapper is now distributed in a separate release (since 2.5.5) -! [Herve Drolon] the function FreeImage_Free is now deprecated : use FreeImage_Unload instead -! [Herve Drolon] updated the generic samples and removed deprecated functions -+ [Detlev Vendt] added CMYK support to TIFF save function -+ [Detlev Vendt] added TIFF_SAVE_CMYK flag constant -+ [Detlev Vendt] added 32-bit support (with transparency handling) to TIFF plugin -+ [Herve Drolon] added FreeImage_Threshold -+ [Herve Drolon] added FreeImage_Dither -+ [Herve Drolon] added FREE_IMAGE_DITHER parameter to FreeImage_Dither -* [Herve Drolon] improved error handling in PluginMNG -* [Herve Drolon] improved TIFF flags handling in TIFF save function -* [Herve Drolon] fixed a potential crash-problem in FreeImage_OutputMessage (in case of a null message) -* [Detlev Vendt] fixed a bug with the deprecated FreeImage_GetBitsRowCol (trailling backslash behind the DEPRECATE macro) - -July 24th, 2002 - 2.5.5 -! FreeImage now uses libPNG 1.2.4 -! FreeImage now uses libMNG 1.0.4 -+ [Markus Loibl] added ActiveX wrapper - -June 22th, 2002 - 2.5.4 -* [Timothy Roughton] fixed FreeImage not compiling on LCC WIN32 -* [Markus Loibl] fixed PluginTIFF sometimes saving with wrong X/Y resolution -* fixed crashbug when loading some RLE4 BMPs -! FreeImage now uses LibPNG 1.2.3 -! [Markus Loibl] improved startup plugin locate handling code -! [Gerhard Gruber] made some changes so that FreeImage compiles on VC5 -+ [Markus Loibl] added flags TIFF_PACKBITS, TIFF_DEFLATE, TIFF_ADOBE_DEFLATE and TIFF_NONE - -May 21th, 2002 - 2.5.3 -* fixed wrong colors when loading 16-bit grayscale TIFF -* fixed crash-problem with FreeImageQt -* fixed PluginTIFF saving some bitmaps flipped vertically -* [Laurent Rocher] fixed bug in FreeImage_GetLockedPageNumbers -* [Laurent Rocher] fixed bug in FreeImage_UnlockPage -! FreeImage now uses libpng 1.2.2 -+ added TARGA save support -+ added BMP RLE8 save support - -March 30th, 2002 - 2.5.2 -* fixed bug in PluginTARGA where 32-bit bitmaps are not always correctly flipped -* fixed FreeImage_GetLockedPageNumber being mentioned in FreeImage.h -* fixed crash bug when handling read-only multipage bitmaps -- removed internal function FreeImage_GetExtraDataPointer -! FreeImage now uses zlib 1.1.4 -+ added function FreeImage_GetLockedPageNumbers - -March 2nd 2002 - 2.5.1 -* fixed pluginTIFF not being able to save 32-bit bitmaps -* fixed not being able to save PNM bitmaps through the LoadXXX wrappers -* fixed a webcam generated BMP image being loaded with wrong colors -! FI_ReadProc, FI_WriteProc, etc. do now carry the DLL_CALLCONV flag -! the function FreeImage_GetBitsRowCol is now deprecated -! FreeImage_SetTransparencyTable now taken an integer as count parameter -! FreeImage_IsTransparent now always returns true for 32-bit bitmaps -! PluginPNG::Save now ignores the result of FreeImage_IsTransparent -! PluginTIFF now converts all 32-bit bitmaps to 24-bit, until our patch - to fully support alpha in TIFF is applied in libtiff -+ added full multi-paging support -+ added octal and hexadecimal number support to FreeImage_OutputMessage - -January 3rd 2002 - 2.5.0 -* fixed bug in FreeImage_SaveJPEG -* fixed bug in FreeImage_LoadMNG -* fixed bug in FreeImage_LoadPNG -* fixed small Visual C++ 5.0 compiler issue in PluginMNG.cpp -* fixed FreeImage crashing on JPEG 6.0 encoded TIFFs -! FreeImage now uses libTIFF 3.5.7 -! FreeImage now uses libPNG 1.2.1 -! all the FreeImage_LoadXXX and FreeImage_SaveXXX functions are now deprecated -+ added Dr. Halo (*.cut) support -+ added printf-like format string support to SetOutputMessage -+ added basic multi-paging support: open, close, counting and grabbing -+ added deprecation manager -+ added FreeImage_Clone function - -October 3rd 2001 - 2.4.2 -* fixed missing BI_BITFIELDS support for 32-bit BMPs -* fixed bug in FreeImage_ConvertLine16_555_To16_565 and vice versa -* fixed bug in FreeImage_ConvertToRawBits -* fixed PluginTIFF behaving incorrectly on PHOTOMETRIC_MASK images -* fixed 16 bit TIFFs not loading correctly -* fixed incorrect handling of CCITTFAX3 and CCITTFAX4 TIFFs -* fixed JPEG encoded TIFFs not being supported -! [Yours Detlev] patched libTIFF to handle EXTRASAMPLE_UNSPECIFIED -! [Juergen Riecker] improved speed of PCX loading a lot -! rewrote parts of FreeImage to improve support for c -! the internal RGB555 and RGB565 macros now read BGR instead of RGB -! FreeImage now uses libMNG 1.0.3 -! FreeImage now uses libPNG 1.2.0 -! FreeImage_Save now opens files with the "w+b" flag -! renamed internal macro CalculateUsedColors to CalculateUsedPaletteEntries -! enabling/disabling plugins no longer has effect on FIFSupportsReading -! enabling/disabling plugins no longer has effect on FIFSupportsWriting -+ added flag PNG_IGNOREGAMMA -+ added function FreeImage_FIFSupportsExportBPP - -July 30th 2001 - 2.4.1 -* [Jan Nauta] fixed some plugin ids not being passed to plugins -* [Jan Nauta] fixed some functions being natively called instead of indirect -* [Jan Nauta] fixed BMPs with signature BA not being regognised -* [Remo Eichenberger] fixed memory leak in the plugin system -* fixed seek bug in PluginIFF's Validate -* fixed transparency issue in PluginPNG -* fixed uncaught exceptions in WUQuantizer and NNQuantizer -* fixed some problems with PluginTARGA -* fixed some problems with PluginICO -* fixed some problems with PluginBMP -! improved FreeImageQt's load function a little -! tell/seek control for validation is now handled inside the plugin framework - -July 22th 2001 - 2.4.0 -* (Yours Detlev) fixed memory leak in FreeImage_GetFIFFromFilename -* (Yours Detlev) fixed memory leak in the ICO plugin -* (Yours Detlev) fixed memory leak in the PNG plugin -* fixed potential NULL-pointer access bug in Plugin::AddNode -* fixed problems with linking the static lib -- removed LBM plugin. Its functionality is placed in the IFF plugin now -- removed FreeImage_GetFIFByIndex -! FreeImage now uses LibMNG 1.0.2 -! FreeImage_SetTransparent now only enables alpha when the bitmap is 8 or 32 bit -! FreeImage_SetTransparencyTable now only enables alpha when the bitmap is 8 bit -! FreeImage_LoadLBM now uses Mark Sibly's IFF plugin -! FreeImage_SaveBMP now converts to 24-bit when bpp is 32 and transparency is off -! FreeImage_SaveJPEG now converts to 24-bit when bpp is 32 and transparency is off -! FreeImage_SavePNM now converts to 24-bit when bpp is 32 and transparency is off -! FreeImage_SaveTIFF now converts to 24-bit when bpp is 32 and transparency is off -+ [Mark Sibly] added IFF (ILBM) support -+ added basic support for Photoshop files -+ added mime type support (FreeImage_GetFIFFromMime) -+ added functions FreeImage_SetPluginEnabled and FreeImage_IsPluginEnabled - Disabling plugins modifies the behaviour of the following functions: - * FreeImage_LoadFromHandle - * FreeImage_SaveToHandle - * FreeImage_FIFSupportsReading - * FreeImage_FIFSupportsWriting - * FreeImage_GetFIFFromFormat - * FreeImage_GetFIFFromFilename - * FreeImage_GetFIFFromMime - * FreeImage_Validate - -June 30th 2001 - 2.3.2 -* fixed missing "targa" extension in targa extension list -* fixed small memory leak in PluginList::AddNode -* fixed 32 bit PNG saving suddenly disappeared from the distro? -* fixed 'black line' bug in LoadTARGA -- removed project FreeImageM2 -- removed FreeImage_Combine -! FreeImage_RegisterLocalPlugin now receives a FI_InitProc as first parameter -! FreeImage_GetFIFFromFilename now also takes the format id into account -! cleanup up the code a little for PluginPCD and PluginPCX -+ added static lib project - -June 11th 2001 - 2.3.1 -* [Machiel ten Brinke] fixed the loading of some 'ancient' TARGAs -* [Rui Lopes] fixed some bugs in the external plugin registration -* fixed the plugin system crashing when the init function isn't called -- removed project FreeImagePy -- removed 32 to 24 bit conversion while saving PNG in FreeImageQt -! the scanline convert functions are now accessable in plugins -! FreeImage now uses an STL map to store the plugin list -! PluginSDK.h is now integrated into FreeImage.h -! FreeImage_Register now receives the boolean parameter 'load_local_plugins_only' -! FreeImage now uses LibPNG 1.0.12 -+ [Rui Lopes] added plugin for GIF reading/writing support -+ added function FreeImage_SetTransparencyCount -+ added support for 32 bit PNG saving -+ added FreeImage_RegisterLocalPlugin to allow plugins inside apps -+ added FreeImage_RegisterExternalPlugin to manually load DLLs -+ added plugin for JBIG reading/writing support - -May 4th 2001 - 2.3.0 -* [Martin Weber] fixed some small bugs in the TARGA and BMP plugins -* [Martin Weber] fixed tiny bug in new 16 bit conversions -* [Martin Weber] fixed load flag inconsistency in the TARGA plugin -* [Martin Weber] fixed plugin id / load reference inconsistency for PNM -* [Jan Nauta] fixed bug in conversion 16 -> 16 -* [Herve Drolon] fixed small bug in 4-bit PCX loader -- removed code that loads BMPs renamed to ICO in PluginICO -! the flag TARGA_LOAD_RGB555 is now obsolete -! the plugin list is now sorted internally -! ConvertTo32Bits now stores the transparency table as alpha mask -! FreeImage now uses LibMNG 1.0,1 -! FreeImage now uses LibPNG 1.0.11 -+ added external plugin support via DLLs -+ added function FreeImage_GetFIFByIndex -+ added internal function CalculateScanLine -+ added transparency support for high-color PNGs -+ added transparency support for high-color TIFFs -+ added functions FreeImage_SetTransparent and FreeImage_IsTransparent -+ added constant FIC_RGBALPHA to FREE_IMAGE_COLOR_TYPE - -April 5th 2001 - 2.2.0 -* [Remo Eichenberger] fixed small bug concerning DLLMain and static LIB generation -* fixed 1-bit bitmaps not properly loading in FreeImageQt -* fixed bug in conversion 16->16 -* FreeImage now uses LibPNG 1.0.10 -! [Martin Weber] improved loading of BMP files -! [Martin Weber] improved loading of TARGA files -! [Dave Larson] improved visual appearance after 16 conversions -! FreeImageQt now converts 32-bit bitmaps to 24-bit when saving PNGs and JPEGs -+ added functions FreeImage_Initialise and FreeImage_DeInitialise -+ added internal plugins -+ re-added combine/alphablend functions - -March 8th 2001 - 2.1.0 -* [Martin Hemming] fixed bug in 16-bit TARGA loading code -* fixed PNG's with alpha masks not loading correctly -! FreeImage is now dual-licensed: the FI-License and the GPL license -! FreeImage now uses LibPNG 1.0.9 -! FreeImage now uses LibTIFF 3.5.6 Beta -! FreeImage now uses LiBMNG 1.0.0 -! changed the ordering of the FREE_IMAGE_FORMAT table -! improved linux support -! improved test script -+ added transparency table support to SavePNG -+ added BI_BITFIELDS support to LoadBMP and SaveBMP -+ added reading support for OS/2 2.x BMPs -+ added support for MNG and JNG reading using LibMNG -+ added support for Deluxe Paint reading -+ added 'hot swap' support to the Core DLL -+ added 'hot swap' support to FreeImage Qt -+ added functions GetFIFFromFormat and GetFIFFromFilename -+ added functions FIFSupportsReading and FIFSupportsWriting -+ added function GetFIFRegExpr - -January 14th 2001 - 2.0.0 -* [Herve Drolon] fixed a bug in the conversion 4->8 -* [Herve Drolon] fixed a bug in metrics handling in SaveJPEG -* [Herve Drolon] fixed a bug in the return value of the function SaveTIFF -* fixed the presence of two WuQuantizer.cpp files in the distribution -* fixed bug where a BMP renamed to ICO isn't loaded -- removed FreeImage_ConvertToGreyScale. Use FreeImage_ConvertTo8Bits instead. -- removed the boolean parameters from all conversion routines -- removed page handling in LoadTIFF. A new range of functions will be added. -! The void pointers used in FreeImage are now typed -! LoadBMP now takes palettes in 24/32 bit images in respect -! All effects and MMX functions are now stored in a new library (FreeEffects) -! [Herve Drolon] fixed bug in FreeImage_GetColorType -! [Herve Drolon] improved PCX loader. It can now read 1, 4, 8 and 24-bit images -! [Manfred Tausch] improved FreeImage_Rotate -! [Luca Piergentili] fixed crash bug when saving some 1-bit TIFFs -! rewrote all bitdepth conversion routines making use of the new scanline converters -! rewrote bitdepth conversion in FreeImageQt (uses less memory) -! FreeImage is now compiled __stdcall -+ [Herve Drolon] added WBMP (Wireless Bitmap Format) support: loading and saving -+ [Herve Drolon] added 4, 16 and 32 bitdepth handling in GetColorType -+ [Herve Drolon] added handling of 8-bit greyscale bitmaps in SaveJPEG -+ [Herve Drolon] added NeuQuant color reduction algorithm to ColorQuantize -+ added DLL_CALLCONV (calling convention) flag -+ added bitmask support to all bitmaps -+ added a series of functions converting scanlines from one bitdepth to another -+ added functions ConvertFromRawBits and ConvertToRawBits -+ added project FreeImageM2: Magenta II MMT bindings for FreeImage -+ added basic foundation for linux support - -December 2th 2000 - 1.4.4 -* fixed small bug related to TIFFSetDirectory in FreeImage_LoadTIFF -* fixed FreeImage_Rotate sometimes clipping too much pixels -* fixed other small bug in FreeImage_Rotate -* fixed FreeImage_Clone not taking the FREEIMAGEHEADER in account -* fixed bug in FreeImageQt where 1-bit images are not correctly allocated -* fixed FreeImage_Crop not copying the palette -* fixed message function pointer crash bug -* fixed bug where the palette wasn't copied when saving in FreeImageQt -* fixed FreeImage_Clone not copying the transparency table -- removed FreeImage_WritePaletteEntry -! [Adam Gates] rewrote parts of FreeImage so that c compilers can handle it better -! FreeImageQt doesn't statically link with the FreeImage lib anymore -! FreeImageQt now uses atexit() to automatically unregister -! rewrote parts of FreeImage_LoadBMP to increase speed -+ [Markus Loibl] added metrics handling code to LoadBMP, LoadJPEG, LoadTIFF and LoadPCX -+ added metrics handling code to FreeImageQt -+ added functions FIQT_IsLoaded, FIQT_GetVersion and FIQT_GetCopyrightMessage -+ added conversion 1 -> 16 -+ added FreeImage_SaveJPEG and JPEG quality settings -+ added FreeImage_GetBitsRowCol -+ added function FIQT_SetOutputMessage to FreeImageQt -+ added FreeImage_GetFileTypeFromExtension and FIQT_GetFileTypeFromFormat -+ added project FreeImagePy: python bindings for FreeImage - -November 7th 2000 - 1.4.3 -* fixed FreeImage_SavePNG crash bug -* fixed slighly corrupt size filter in FreeImage_Combine -* fixed FreeImage_SaveTIFF not saving 4-bit images -* [Herve Drolon] fixed bug in FreeImage_LoadTIFF -* [Herve Drolon] fixed bug in FreeImage_GetColorType -- removed fclose from FreeImage_SavePNM (who put it there?) -! rewrote FreeImage_Rotate -! FreeImageQt now automatically detects which formats are supported by Qt and which not -! FreeImage_Allocate now returns a void pointer -! FreeImage_Unload is now called FreeImage_Free -+ added 16-bit 5-5-5 support to FreeImage_LoadBMP -+ added RLE_DELTA support to FreeImage_LoadBMP -+ added directory support to FreeImage_LoadTIFF -+ added functions dealing with transparency -+ added transparency support to 8-bit PNG's in Qt -+ added FREE_IMAGE_QUANTIZE parameter to FreeImage_ColorQuantize -+ added custom FREEIMAGEHEADER header prepended to internal bitmaps -+ added new documentation - -October 18th 2000 - 1.4.2 -* fixed FreeImage_SaveBMP storing an incorrect bfSize value in the BITMAPFILEHEADER -* fixed bug where JPEG and PNG wouldn't load in FreeImageQt -* fixed FreeImage_Mirror mirroring one pixel less than needed -! FreeImage_MaskedCombine24 is now called FreeImage_MaskedCombine24Ex -! FreeImage_MaskedCombine32 is now called FreeImage_MaskedCombine32Ex -+ added 16-bit bitmap support to FreeImage_Mirror -+ added 16-bit bitmap support to FreeImage_ConvertTo8Bits -+ added simple version of FreeImage_MaskedCombine24 -+ added simple version of FreeImage_MaskedCombine32 - -October 17th 2000 - 1.4.1 -* [Herve Drolon] fixed bug in FreeImage_ConvertTo8Bits -* fixed bug in conversion with 16 -> 24 and 16 -> 32 -- removed static library support -- removed all unnecessary files from LibTIFF, LibPNG, LibJPEG and ZLib -- removed all absolute seeks from the library -! FreeImageQt now makes use of the DLL distro -! rebuilt the entire directory structure -! improved handling of BMP -! renamed FreeImage_MaskedCombine to FreeImage_MaskedCombine32 -+ [Alexander Dymerets] added 24-bit masked alpha blending with a seperate alpha mask -+ added FreeImage_Rotate (known bug in degrees 76 to 106) -+ added 4-bit bitmap support to FreeImage_ConvertTo16Bits -+ added 8-bit bitmap support to FreeImage_ConvertTo16Bits -+ added 32-bit bitmap support to FreeImage_ConvertTo16Bits -+ added 32-bit bitmap support to FreeImage_Mirror -+ added 16-bit 5-5-5 support to FreeImage_ConvertTo24Bits -+ added 16-bit 5-5-5 support to FreeImage_ConvertTo32Bits - -October 2th 2000 - 1.4.0 -* [Jani Kajala] fixed bug in conversion with 4 -> 24 and 8 -> 32 -* [Jani Kajala] fixed bug in FreeImage_Flip -* [Jani Kajala] fixed minor bug in FreeImage_LoadBMP -- [Herve Drolon] removed PBMFlags, PGMFlags and PPMFlags -- [Herve Drolon] removed FI_LoadGeneric -- removed FreeImage_Win32.h -! [Herve Drolon] changed FI_GetFileType -! [Herve Drolon] replaced FI_LoadPBM, FI_LoadPGM and FI_LoadPPM with FI_LoadPNM -! [Herve Drolon] improved FreeImage_LoadPNG -! FreeImage_WritePaletteEntry is now exported -+ [Herve Drolon] added FreeImage_SavePNG -+ [Herve Drolon] added FreeImage_SavePNM and PNMFlags -+ [Herve Drolon] added XXXFlags parameter to save functions -+ [Herve Drolon] added FreeImage_LoadRAS and FIF_RAS -+ added FreeImage_GetFileTypeFromExt - -September 7th 2000 - 1.3.5 -+ added conversion 4 -> 8 to FI_ConvertTo8Bits -+ added simple version of FI_GetFileType -+ added project FreeImageQt; a port of the library to the TrollTech library - -August 31th 2000 - 1.3.4 -* fixed 'ice effect' bug in new 24 bit PCX code -* fixed some bugs with the conversion 16 -> 24 and 16 -> 32 -! FI_Blur now returns void -! A debug build of the library now produces FreeImaged.dll and FreeImaged.lib -! TARGA_LOAD_ARGB8888 is now called TARGA_LOAD_RGB888 -! Alpha channels are now automatically loaded unless TARGA_LOAD_RGB888 is specified -! cleaned up the code a lot -+ added 32-bit bitmap support to FreeImage_ConvertToGreyscale -+ added support for 32-bit bottom-left TARGA images -+ added internal functions FreeImage_WritePaletteEntry() and FreeImage_GetScanLine() -+ added FreeImage_Win32.h, containing Windows functions needed to create DIBs -+ added documentation through Doxygen - -July 30th 2000 - 1.3.3 -* [Jani Kajala] fixed some bugs with the conversion 4 -> 24 and 8 -> 24 -* [Jani Kajala] fixed some bugs with the conversion 4 -> 32 and 8 -> 32 -* fixed bug in FI_LoadPNM's ASCII number loader -! [Herve Drolon] improved FI_LoadPNG -! [Herve Drolon] changed FI_ConvertToGreyScale (added changeable macro for conversion) -! improved FI_ConvertTo24Bits -! improved FI_ConvertTo32Bits -! freeImage now uses LibPNG 1.0.8 -+ [Herve Drolon] added FI_ColorQuantize, based on Wu's color quantizer -+ added the conversion 1 -> 24 -+ added the conversion 1 -> 32 -+ added FI_ConvertTo8Bits -+ added FI_Invert (very useful for image processing) -+ added FI_GetColorType and 'enum FREE_IMAGE_COLOR_TYPE' - -June 30th 2000 - 1.3.2 -- removed color reduction functions from the project -! [Herve Drolon] Improved FI_LoadTIFF code -! renamed FI_ToGrayscale to FI_ConvertToGreyScale -! renamed FI_IncreaseColors to FI_ConvertTo24Bits -! LoadBMP now supports 32-bit bitmaps -! [Jani Kajala] Improved FI_LoadTARGA and FI_LoadPCX code -+ added FI_ConvertTo32Bits to convert a bitmap to 32-bit -+ added FI_MaskCombine to combine two 32-bit bitmaps using a alpha mask -+ added FI_AddAlphaMask to enrich a 32-bit bitmap with an alpha mask -+ added FI_SaveTIFF -+ added 16-bit bitmap (565) support to the ConvertToXXX functions. -+ added FI_ConvertTo16Bits (555 and 565) - -June 1th 2000 - 1.3.1 -- removed Standard Template Library (STL) code -* [Jani Kajala] fixed minor bug in FI_LoadTARGA -* [Jani Kajala] fixed some minor bugs in FI_LoadPCX -! streamlined FI_LoadJPEG a little -! FreeImage now uses LibPNG 1.0.6 -! FreeImage now uses LibTIFF 3.5.5 -! FreeImage now uses malloc and free instead of new and delete -+ introduced compiler flags to disable certain features in the DLL -+ added experimental nearest color reduction (FI_ReduceColorsNearestColor) - -April 13th 2000 - 1.3.0 -* fixed some 8 bit PCX files loading incorrectly -* fixed tiny bug in internally used CalculateUsedColors function -- removed FI_SaveXPM. Only BMP is supported now. -- removed Windows dependencies for easier porting -! optimized FI_LoadKOALA a little -! optimized FI_Combine using MMX technology -! FI_Combine now receives an 'unsigned integer' as alpha blend parameter -! FI_InCreaseColors and FI_ReduceColors don't dispose the old bitmap anymore -+ added PNM support (PGM, PPM and PBM; both binary and ascii) -+ [Alexander Dymerets] added FI_EnableMMX and FI_DisableMMX -+ added various effect functions (FI_Blur, FI_Brighten and FI_Crop) - -March 1st 2000 - 1.2.1 -* fixed some 24 bit PCX files loading incorrectly - -February 8th 2000 - 1.2.0 -* fixed last bitmap data block in JPEG files being truncated -* fixed 4/8 bit BMP's incorrectly loading when the palette is smaller than the bitcount predicts -- removed FI_Load. There is no reliable way to identify all image formats -- removed FI_SetJpegDecodeMode. - Mode selection is now done using the 'DataEnum data' parameter of FI_LoadJPEG -! read_proc/write_proc/tell_proc in FreeImageIO now are same as fread/fwrite/ftell -+ added a 'DataEnum data' parameter to all FI_LoadXXX functions. -+ added 16 bit TARGA support -+ added RLE support for TARGA images -+ added FI_GetDIBSize to get the size of a DIB in bytes -+ added Kodak PhotoCD support (Base, Base/4 and Base/16 encoding) -+ added KOALA support -+ added FI_GetFileType. Note: there is no reliable way to identify TARGA, ICO and PCD. Therefore they have been excluded -In KOALA files only the files converted by a C64 emulator can be identified. -+ added FI_Combine to combine two 24-bit bitmaps with (optional) alpha blending - -January 15th 2000 - 1.1.1 -! FI_Copy is now called FI_Clone -+ added FI_ToGrayscale to convert a color bitmap to grayscale -+ added 32 bit TARGA support -+ added FI_IncreaseColors to increase the bitmap bitdepth from 4/8 bit to 24 bit - -January 14th 2000 - 1.1.0 -* FI_MIRROR: fixed nibbles not being mirrored in 4 bit images -* FI_MIRROR: fixed bits not being mirrored in 1 bit images -* fixed improper loading of 1, 4 and 8 bit OS/2 BMP's -* fixed some inconsistensies in the calculation of lines and pitches -* fixed incorrectly loading of Huffman and FAX encoded TIFFs -* fixed LoadTGA accepting 16 bit TGA's and returning corrupt DIB's -- removed LZW support for TIFFs -! FreeImage now uses LibTIFF 3.5.4 -+ added ICO support -+ added overridable file I/O support in the form of FreeImageIO and fi_handle -+ added FI_Load for generic image loading -+ added FI_ReduceColors for color reduction -+ added FI_Copy to copy a bitmap in memory - -January 5th 2000 - 1.0.0 diff --git a/extern/FreeImage/libFreeImage.a b/extern/FreeImage/libFreeImage.a deleted file mode 100644 index 1619cace..00000000 Binary files a/extern/FreeImage/libFreeImage.a and /dev/null differ diff --git a/extern/FreeImage/license-fi.txt b/extern/FreeImage/license-fi.txt deleted file mode 100644 index 03b666c5..00000000 --- a/extern/FreeImage/license-fi.txt +++ /dev/null @@ -1,142 +0,0 @@ -FreeImage Public License - Version 1.0 ---------------------------------------------- - -1. Definitions. - -1.1. "Contributor" means each entity that creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. - -1.3. "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. - -1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. - -1.5. "Executable" means Covered Code in any form other than Source Code. - -1.6. "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. - -1.7. "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. - -1.8. "License" means this document. - -1.9. "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a -Modification is: - -A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. - -B. Any new file that contains any part of the Original Code or previous Modifications. - -1.10. "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. - -1.11. "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control -compilation and installation of an Executable, or a list of source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. - -1.12. "You" means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the -direction or management of such entity, whether by contract or otherwise, or (b) ownership of fifty percent (50%) or more of the outstanding shares or beneficial ownership of such entity. - -2. Source Code License. - -2.1. The Initial Developer Grant. -The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: - -(a) to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, or as part of a Larger Work; and - -(b) under patents now or hereafter owned or controlled by Initial Developer, to make, have made, use and sell ("Utilize") the Original Code (or portions thereof), but solely to the extent that -any such patent is reasonably necessary to enable You to Utilize the Original Code (or portions thereof) and not to any greater extent that may be necessary to Utilize further Modifications or -combinations. - -2.2. Contributor Grant. -Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: - -(a) to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code or as part of a Larger Work; and - -(b) under patents now or hereafter owned or controlled by Contributor, to Utilize the Contributor Version (or portions thereof), but solely to the extent that any such patent is reasonably necessary to enable You to Utilize the Contributor Version (or portions thereof), and not to any greater extent that -may be necessary to Utilize further Modifications or combinations. - -3. Distribution Obligations. - -3.1. Application of License. -The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or -restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. - -3.2. Availability of Source Code. -Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. - -3.3. Description of Modifications. -You must cause all Covered Code to which you contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. - -3.4. Intellectual Property Matters - -(a) Third Party Claims. -If You have knowledge that a party claims an intellectual property right in particular functionality or code (or its utilization under this License), you must include a text file with the source code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If you obtain such knowledge after You make Your Modification available as described in Section 3.2, You shall promptly modify the LEGAL file in all copies You make -available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. - -(b) Contributor APIs. -If Your Modification is an application programming interface and You own or control patents which are reasonably necessary to implement that API, you must also include this information in the LEGAL file. - -3.5. Required Notices. -You must duplicate the notice in Exhibit A in each file of the Source Code, and this License in any documentation for the Source Code, where You describe recipients' rights relating to Covered Code. If You created one or more Modification(s), You may add your name as a Contributor to the notice described in Exhibit A. If it is not possible to put such notice in a particular Source Code file due to its -structure, then you must include such notice in a location (such as a relevant directory file) where a user would be likely to look for such a notice. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or -liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.6. Distribution of Executable Versions. -You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You -describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code under a license of Your choice, which may contain terms different from this License, -provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. - -3.7. Larger Works. -You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - -If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. - -5. Application of this License. - -This License applies to code to which the Initial Developer has attached the notice in Exhibit A, and to related Covered Code. - -6. Versions of the License. - -6.1. New Versions. -Floris van den Berg may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. - -6.2. Effect of New Versions. -Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Floris van den Berg -No one other than Floris van den Berg has the right to modify the terms applicable to Covered Code created under this License. - -6.3. Derivative Works. -If you create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), you must (a) rename Your license so that the phrases "FreeImage", `FreeImage Public License", "FIPL", or any confusingly similar phrase do not appear anywhere in your license and (b) otherwise make it clear that your version of the license contains terms which differ from the FreeImage Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) - -7. DISCLAIMER OF WARRANTY. - -COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -8. TERMINATION. - -This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. - -9. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE -EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -10. U.S. GOVERNMENT END USERS. - -The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. - -11. MISCELLANEOUS. - -This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by Dutch law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in, the The Netherlands: (a) unless otherwise agreed in writing, all disputes relating to this License (excepting any dispute relating to intellectual property rights) shall be subject to final and binding arbitration, with the losing party paying all costs of arbitration; (b) any arbitration relating to this Agreement shall be held in Almelo, The Netherlands; and (c) any litigation relating to this Agreement shall be subject to the jurisdiction of the court of Almelo, The Netherlands with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys fees and expenses. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. - -12. RESPONSIBILITY FOR CLAIMS. - -Except in cases where another Contributor has failed to comply with Section 3.4, You are responsible for damages arising, directly or indirectly, out of Your utilization of rights under this License, based -on the number of copies of Covered Code you made available, the revenues you received from utilizing such rights, and other relevant factors. You agree to work with affected parties to distribute -responsibility on an equitable basis. - -EXHIBIT A. - -"The contents of this file are subject to the FreeImage Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://home.wxs.nl/~flvdberg/freeimage-license.txt - -Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. \ No newline at end of file diff --git a/extern/FreeImage/license-gpl.txt b/extern/FreeImage/license-gpl.txt deleted file mode 100644 index 7d1f8605..00000000 --- a/extern/FreeImage/license-gpl.txt +++ /dev/null @@ -1,342 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - - diff --git a/extern/atitc/ATI_Compress.chm b/extern/atitc/ATI_Compress.chm deleted file mode 100644 index 1d17e286..00000000 Binary files a/extern/atitc/ATI_Compress.chm and /dev/null differ diff --git a/extern/atitc/ATI_Compress.h b/extern/atitc/ATI_Compress.h deleted file mode 100644 index f81aa9b4..00000000 --- a/extern/atitc/ATI_Compress.h +++ /dev/null @@ -1,175 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Advanced Micro Devices, Inc. -// 1 AMD Place -// Sunnyvale, CA -// USA 94088 -// -// File Name: ATI_Compress.h -// Description: A library to compress/decompress textures -// -// Copyright (c) 2007,2008 Advanced Micro Devices, Inc. -// Copyright (c) 2004-2006 ATI Technologies Inc. -// -// Version: 1.7 -// -// Developer: Seth Sowerby -// Email: gputools.support@amd.com -// -////////////////////////////////////////////////////////////////////////////// - -/// \file -/// ATI_Compress.h declares the interface to the ATI_Compress library. - -#ifndef ATI_COMPRESS -#define ATI_COMPRESS - -#define ATI_COMPRESS_VERSION_MAJOR 1 ///< The major version number of this release. -#define ATI_COMPRESS_VERSION_MINOR 7 ///< The minor version number of this release. - -typedef unsigned long ATI_TC_DWORD; ///< A 32-bit integer format. -typedef unsigned short ATI_TC_WORD; ///< A 16-bit integer format. -typedef unsigned char ATI_TC_BYTE; ///< An 8-bit integer format. - -#if defined(WIN32) || defined(_WIN64) -# define ATI_TC_API __cdecl -#else -# define ATI_TC_API -#endif - -#ifdef ATI_COMPRESS_INTERNAL_BUILD -# include "ATI_Compress_Internal.h" -#else // ATI_COMPRESS_INTERNAL_BUILD - -/// Texture format. -typedef enum -{ - ATI_TC_FORMAT_Unknown, ///< An undefined texture format. - ATI_TC_FORMAT_ARGB_8888, ///< An ARGB format with 8-bit fixed channels. - ATI_TC_FORMAT_RGB_888, ///< A RGB format with 8-bit fixed channels. - ATI_TC_FORMAT_RG_8, ///< A two component format with 8-bit fixed channels. - ATI_TC_FORMAT_R_8, ///< A single component format with 8-bit fixed channels. - ATI_TC_FORMAT_ARGB_2101010, ///< An ARGB format with 10-bit fixed channels for color & a 2-bit fixed channel for alpha. - ATI_TC_FORMAT_ARGB_16, ///< A ARGB format with 16-bit fixed channels. - ATI_TC_FORMAT_RG_16, ///< A two component format with 16-bit fixed channels. - ATI_TC_FORMAT_R_16, ///< A single component format with 16-bit fixed channels. - ATI_TC_FORMAT_ARGB_16F, ///< An ARGB format with 16-bit floating-point channels. - ATI_TC_FORMAT_RG_16F, ///< A two component format with 16-bit floating-point channels. - ATI_TC_FORMAT_R_16F, ///< A single component with 16-bit floating-point channels. - ATI_TC_FORMAT_ARGB_32F, ///< An ARGB format with 32-bit floating-point channels. - ATI_TC_FORMAT_RG_32F, ///< A two component format with 32-bit floating-point channels. - ATI_TC_FORMAT_R_32F, ///< A single component with 32-bit floating-point channels. - ATI_TC_FORMAT_DXT1, ///< An opaque (or 1-bit alpha) DXTC compressed texture format. Four bits per pixel. - ATI_TC_FORMAT_DXT3, ///< A DXTC compressed texture format with explicit alpha. Eight bits per pixel. - ATI_TC_FORMAT_DXT5, ///< A DXTC compressed texture format with interpolated alpha. Eight bits per pixel. - ATI_TC_FORMAT_DXT5_xGBR, ///< A DXT5 with the red component swizzled into the alpha channel. Eight bits per pixel. - ATI_TC_FORMAT_DXT5_RxBG, ///< A swizzled DXT5 format with the green component swizzled into the alpha channel. Eight bits per pixel. - ATI_TC_FORMAT_DXT5_RBxG, ///< A swizzled DXT5 format with the green component swizzled into the alpha channel & the blue component swizzled into the green channel. Eight bits per pixel. - ATI_TC_FORMAT_DXT5_xRBG, ///< A swizzled DXT5 format with the green component swizzled into the alpha channel & the red component swizzled into the green channel. Eight bits per pixel. - ATI_TC_FORMAT_DXT5_RGxB, ///< A swizzled DXT5 format with the blue component swizzled into the alpha channel. Eight bits per pixel. - ATI_TC_FORMAT_DXT5_xGxR, ///< A two-component swizzled DXT5 format with the red component swizzled into the alpha channel & the green component in the green channel. Eight bits per pixel. - ATI_TC_FORMAT_ATI1N, ///< A single component compression format using the same technique as DXT5 alpha. Four bits per pixel. - ATI_TC_FORMAT_ATI2N, ///< A two component compression format using the same technique as DXT5 alpha. Designed for compression object space normal maps. Eight bits per pixel. - ATI_TC_FORMAT_ATI2N_XY, ///< A two component compression format using the same technique as DXT5 alpha. The same as ATI2N but with the channels swizzled. Eight bits per pixel. - ATI_TC_FORMAT_ATI2N_DXT5, ///< An ATI2N like format using DXT5. Intended for use on GPUs that do not natively support ATI2N. Eight bits per pixel. - ATI_TC_FORMAT_BC1, ///< A four component opaque (or 1-bit alpha) compressed texture format for Microsoft DirectX10. Identical to DXT1. Four bits per pixel. - ATI_TC_FORMAT_BC2, ///< A four component compressed texture format with explicit alpha for Microsoft DirectX10. Identical to DXT3. Eight bits per pixel. - ATI_TC_FORMAT_BC3, ///< A four component compressed texture format with interpolated alpha for Microsoft DirectX10. Identical to DXT5. Eight bits per pixel. - ATI_TC_FORMAT_BC4, ///< A single component compressed texture format for Microsoft DirectX10. Identical to ATI1N. Four bits per pixel. - ATI_TC_FORMAT_BC5, ///< A two component compressed texture format for Microsoft DirectX10. Identical to ATI2N. Eight bits per pixel. - ATI_TC_FORMAT_ATC_RGB, ///< ATI_TC - a compressed RGB format for cellphones & hand-held devices. - ATI_TC_FORMAT_ATC_RGBA_Explicit, ///< ATI_TC - a compressed ARGB format with explicit alpha for cellphones & hand-held devices. - ATI_TC_FORMAT_ATC_RGBA_Interpolated, ///< ATI_TC - a compressed ARGB format with interpolated alpha for cellphones & hand-held devices. - ATI_TC_FORMAT_ETC_RGB, ///< ETC (aka Ericsson Texture Compression) - a compressed RGB format for cellphones. - ATI_TC_FORMAT_MAX = ATI_TC_FORMAT_ETC_RGB -} ATI_TC_FORMAT; - -/// An enum selecting the speed vs. quality trade-off. -typedef enum -{ - ATI_TC_Speed_Normal, ///< Highest quality mode - ATI_TC_Speed_Fast, ///< Slightly lower quality but much faster compression mode - DXTn & ATInN only - ATI_TC_Speed_SuperFast, ///< Slightly lower quality but much, much faster compression mode - DXTn & ATInN only -} ATI_TC_Speed; - -/// ATI_Compress error codes -typedef enum -{ - ATI_TC_OK = 0, ///< Ok. - ATI_TC_ABORTED, ///< The conversion was aborted. - ATI_TC_ERR_INVALID_SOURCE_TEXTURE, ///< The source texture is invalid. - ATI_TC_ERR_INVALID_DEST_TEXTURE, ///< The destination texture is invalid. - ATI_TC_ERR_UNSUPPORTED_SOURCE_FORMAT, ///< The source format is not a supported format. - ATI_TC_ERR_UNSUPPORTED_DEST_FORMAT, ///< The destination format is not a supported format. - ATI_TC_ERR_SIZE_MISMATCH, ///< The source and destination texture sizes do not match. - ATI_TC_ERR_UNABLE_TO_INIT_CODEC, ///< ATI_Compress was unable to initialize the codec needed for conversion. - ATI_TC_ERR_GENERIC ///< An unknown error occurred. -} ATI_TC_ERROR; - -/// Options for the compression. -/// Passing this structure is optional -typedef struct -{ - ATI_TC_DWORD dwSize; ///< The size of this structure. - BOOL bUseChannelWeighting; ///< Use channel weightings. With swizzled formats the weighting applies to the data within the specified channel not the channel itself. - double fWeightingRed; ///< The weighting of the Red or X Channel. - double fWeightingGreen; ///< The weighting of the Green or Y Channel. - double fWeightingBlue; ///< The weighting of the Blue or Z Channel. - BOOL bUseAdaptiveWeighting; ///< Adapt weighting on a per-block basis. - BOOL bDXT1UseAlpha; ///< Encode single-bit alpha data. Only valid when compressing to DXT1 & BC1. - ATI_TC_BYTE nAlphaThreshold; ///< The alpha threshold to use when compressing to DXT1 & BC1 with bDXT1UseAlpha. Texels with an alpha value less than the threshold are treated as transparent. - BOOL bDisableMultiThreading; ///< Disable multi-threading of the compression. This will slow the compression but can be useful if you're managing threads in your application. - ATI_TC_Speed nCompressionSpeed; ///< The trade-off between compression speed & quality. -} ATI_TC_CompressOptions; -#endif // !ATI_COMPRESS_INTERNAL_BUILD - -/// The structure describing a texture. -typedef struct -{ - ATI_TC_DWORD dwSize; ///< Size of this structure. - ATI_TC_DWORD dwWidth; ///< Width of the texture. - ATI_TC_DWORD dwHeight; ///< Height of the texture. - ATI_TC_DWORD dwPitch; ///< Distance to start of next line - necessary only for uncompressed textures. - ATI_TC_FORMAT format; ///< Format of the texture. - ATI_TC_DWORD dwDataSize; ///< Size of the allocated texture data. - ATI_TC_BYTE* pData; ///< Pointer to the texture data -} ATI_TC_Texture; - -#define MINIMUM_WEIGHT_VALUE 0.01f - - -#ifdef __cplusplus -extern "C" { -#endif - - /// ATI_TC_Feedback_Proc - /// Feedback function for conversion. - /// \param[in] fProgress The percentage progress of the texture compression. - /// \param[in] pUser1 User data as passed to ATI_TC_ConvertTexture. - /// \param[in] pUser2 User data as passed to ATI_TC_ConvertTexture. - /// \return non-NULL(true) value to abort conversion - typedef bool (ATI_TC_API * ATI_TC_Feedback_Proc)(float fProgress, DWORD_PTR pUser1, DWORD_PTR pUser2); - - /// Calculates the required buffer size for the specified texture - /// \param[in] pTexture A pointer to the texture. - /// \return The size of the buffer required to hold the texture data. - ATI_TC_DWORD ATI_TC_API ATI_TC_CalculateBufferSize(const ATI_TC_Texture* pTexture); - - /// Converts the source texture to the destination texture - /// This can be compression, decompression or converting between two uncompressed formats. - /// \param[in] pSourceTexture A pointer to the source texture. - /// \param[in] pDestTexture A pointer to the destination texture. - /// \param[in] pOptions A pointer to the compression options - can be NULL. - /// \param[in] pFeedbackProc A pointer to the feedback function - can be NULL. - /// \param[in] pUser1 User data to pass to the feedback function. - /// \param[in] pUser2 User data to pass to the feedback function. - /// \return ATI_TC_OK if successful, otherwise the error code. - ATI_TC_ERROR ATI_TC_API ATI_TC_ConvertTexture(const ATI_TC_Texture* pSourceTexture, ATI_TC_Texture* pDestTexture, - const ATI_TC_CompressOptions* pOptions, - ATI_TC_Feedback_Proc pFeedbackProc, DWORD_PTR pUser1, DWORD_PTR pUser2); - -#ifdef __cplusplus -}; -#endif - -#endif // !ATI_COMPRESS diff --git a/extern/atitc/VC7/MT DLL Debug/ATI_Compress_MT_DLL_VC7.lib b/extern/atitc/VC7/MT DLL Debug/ATI_Compress_MT_DLL_VC7.lib deleted file mode 100755 index ba0c2a82..00000000 Binary files a/extern/atitc/VC7/MT DLL Debug/ATI_Compress_MT_DLL_VC7.lib and /dev/null differ diff --git a/extern/atitc/VC7/MT DLL Release/ATI_Compress_MT_DLL_VC7.lib b/extern/atitc/VC7/MT DLL Release/ATI_Compress_MT_DLL_VC7.lib deleted file mode 100755 index 920bb9e8..00000000 Binary files a/extern/atitc/VC7/MT DLL Release/ATI_Compress_MT_DLL_VC7.lib and /dev/null differ diff --git a/extern/atitc/VC7/MT Debug/ATI_Compress_MT_VC7.lib b/extern/atitc/VC7/MT Debug/ATI_Compress_MT_VC7.lib deleted file mode 100755 index 0827f142..00000000 Binary files a/extern/atitc/VC7/MT Debug/ATI_Compress_MT_VC7.lib and /dev/null differ diff --git a/extern/atitc/VC7/MT Release/ATI_Compress_MT_VC7.lib b/extern/atitc/VC7/MT Release/ATI_Compress_MT_VC7.lib deleted file mode 100755 index 5bfd78d3..00000000 Binary files a/extern/atitc/VC7/MT Release/ATI_Compress_MT_VC7.lib and /dev/null differ diff --git a/extern/atitc/VC8/DLL Debug/Win32/ATI_Compress_1_7.dll b/extern/atitc/VC8/DLL Debug/Win32/ATI_Compress_1_7.dll deleted file mode 100755 index 49cb7434..00000000 Binary files a/extern/atitc/VC8/DLL Debug/Win32/ATI_Compress_1_7.dll and /dev/null differ diff --git a/extern/atitc/VC8/DLL Debug/Win32/ATI_Compress_1_7_DLL.lib b/extern/atitc/VC8/DLL Debug/Win32/ATI_Compress_1_7_DLL.lib deleted file mode 100755 index ede0c4cc..00000000 Binary files a/extern/atitc/VC8/DLL Debug/Win32/ATI_Compress_1_7_DLL.lib and /dev/null differ diff --git a/extern/atitc/VC8/DLL Debug/x64/ATI_Compress_1_7.dll b/extern/atitc/VC8/DLL Debug/x64/ATI_Compress_1_7.dll deleted file mode 100755 index 0b8f7f88..00000000 Binary files a/extern/atitc/VC8/DLL Debug/x64/ATI_Compress_1_7.dll and /dev/null differ diff --git a/extern/atitc/VC8/DLL Debug/x64/ATI_Compress_1_7_DLL.lib b/extern/atitc/VC8/DLL Debug/x64/ATI_Compress_1_7_DLL.lib deleted file mode 100755 index ab9802df..00000000 Binary files a/extern/atitc/VC8/DLL Debug/x64/ATI_Compress_1_7_DLL.lib and /dev/null differ diff --git a/extern/atitc/VC8/DLL Release/Win32/ATI_Compress_1_7.dll b/extern/atitc/VC8/DLL Release/Win32/ATI_Compress_1_7.dll deleted file mode 100755 index ccaa2868..00000000 Binary files a/extern/atitc/VC8/DLL Release/Win32/ATI_Compress_1_7.dll and /dev/null differ diff --git a/extern/atitc/VC8/DLL Release/Win32/ATI_Compress_1_7_DLL.lib b/extern/atitc/VC8/DLL Release/Win32/ATI_Compress_1_7_DLL.lib deleted file mode 100755 index d15c44e8..00000000 Binary files a/extern/atitc/VC8/DLL Release/Win32/ATI_Compress_1_7_DLL.lib and /dev/null differ diff --git a/extern/atitc/VC8/DLL Release/x64/ATI_Compress_1_7.dll b/extern/atitc/VC8/DLL Release/x64/ATI_Compress_1_7.dll deleted file mode 100755 index 70c5990a..00000000 Binary files a/extern/atitc/VC8/DLL Release/x64/ATI_Compress_1_7.dll and /dev/null differ diff --git a/extern/atitc/VC8/DLL Release/x64/ATI_Compress_1_7_DLL.lib b/extern/atitc/VC8/DLL Release/x64/ATI_Compress_1_7_DLL.lib deleted file mode 100755 index ed9a5720..00000000 Binary files a/extern/atitc/VC8/DLL Release/x64/ATI_Compress_1_7_DLL.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT DLL Debug/Win32/ATI_Compress_MT_DLL_VC8.lib b/extern/atitc/VC8/MT DLL Debug/Win32/ATI_Compress_MT_DLL_VC8.lib deleted file mode 100755 index 49be1aa9..00000000 Binary files a/extern/atitc/VC8/MT DLL Debug/Win32/ATI_Compress_MT_DLL_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT DLL Debug/x64/ATI_Compress_MT_DLL_VC8.lib b/extern/atitc/VC8/MT DLL Debug/x64/ATI_Compress_MT_DLL_VC8.lib deleted file mode 100755 index dc3f8889..00000000 Binary files a/extern/atitc/VC8/MT DLL Debug/x64/ATI_Compress_MT_DLL_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT DLL Release/Win32/ATI_Compress_MT_DLL_VC8.lib b/extern/atitc/VC8/MT DLL Release/Win32/ATI_Compress_MT_DLL_VC8.lib deleted file mode 100755 index 56d7df76..00000000 Binary files a/extern/atitc/VC8/MT DLL Release/Win32/ATI_Compress_MT_DLL_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT DLL Release/x64/ATI_Compress_MT_DLL_VC8.lib b/extern/atitc/VC8/MT DLL Release/x64/ATI_Compress_MT_DLL_VC8.lib deleted file mode 100755 index 4824101e..00000000 Binary files a/extern/atitc/VC8/MT DLL Release/x64/ATI_Compress_MT_DLL_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT Debug/Win32/ATI_Compress_MT_VC8.lib b/extern/atitc/VC8/MT Debug/Win32/ATI_Compress_MT_VC8.lib deleted file mode 100755 index bf185d84..00000000 Binary files a/extern/atitc/VC8/MT Debug/Win32/ATI_Compress_MT_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT Debug/x64/ATI_Compress_MT_VC8.lib b/extern/atitc/VC8/MT Debug/x64/ATI_Compress_MT_VC8.lib deleted file mode 100755 index ce545a65..00000000 Binary files a/extern/atitc/VC8/MT Debug/x64/ATI_Compress_MT_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT Release/Win32/ATI_Compress_MT_VC8.lib b/extern/atitc/VC8/MT Release/Win32/ATI_Compress_MT_VC8.lib deleted file mode 100755 index 27a5d2dc..00000000 Binary files a/extern/atitc/VC8/MT Release/Win32/ATI_Compress_MT_VC8.lib and /dev/null differ diff --git a/extern/atitc/VC8/MT Release/x64/ATI_Compress_MT_VC8.lib b/extern/atitc/VC8/MT Release/x64/ATI_Compress_MT_VC8.lib deleted file mode 100755 index 40e31db6..00000000 Binary files a/extern/atitc/VC8/MT Release/x64/ATI_Compress_MT_VC8.lib and /dev/null differ diff --git a/extern/butteraugli/CMakeLists.txt b/extern/butteraugli/CMakeLists.txt deleted file mode 100644 index da0d7da1..00000000 --- a/extern/butteraugli/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -SET(BUTTERAUGLI_SRCS - butteraugli.cc - butteraugli.h) - -ADD_LIBRARY(butteraugli STATIC ${BUTTERAUGLI_SRCS}) - diff --git a/extern/butteraugli/butteraugli.cc b/extern/butteraugli/butteraugli.cc deleted file mode 100755 index ebf7cc1e..00000000 --- a/extern/butteraugli/butteraugli.cc +++ /dev/null @@ -1,1588 +0,0 @@ -// Copyright 2016 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Author: Jyrki Alakuijala (jyrki.alakuijala@gmail.com) -// -// The physical architecture of butteraugli is based on the following naming -// convention: -// * Opsin - dynamics of the photosensitive chemicals in the retina -// with their immediate electrical processing -// * Xyb - hybrid opponent/trichromatic color space -// x is roughly red-subtract-green. -// y is yellow. -// b is blue. -// Xyb values are computed from Opsin mixing, not directly from rgb. -// * Mask - for visual masking -// * Hf - color modeling for spatially high-frequency features -// * Lf - color modeling for spatially low-frequency features -// * Diffmap - to cluster and build an image of error between the images -// * Blur - to hold the smoothing code - -#include "butteraugli.h" - -#include -#include -#include -#include -#include - -#include -#include - -// Restricted pointers speed up Convolution(); MSVC uses a different keyword. -#ifdef _MSC_VER -#define __restrict__ __restrict -#endif - -namespace butteraugli { - -void *CacheAligned::Allocate(const size_t bytes) { - char *const allocated = static_cast(malloc(bytes + kCacheLineSize)); - if (allocated == nullptr) { - return nullptr; - } - const uintptr_t misalignment = - reinterpret_cast(allocated) & (kCacheLineSize - 1); - // malloc is at least kPointerSize aligned, so we can store the "allocated" - // pointer immediately before the aligned memory. - assert(misalignment % kPointerSize == 0); - char *const aligned = allocated + kCacheLineSize - misalignment; - memcpy(aligned - kPointerSize, &allocated, kPointerSize); - return aligned; -} - -void CacheAligned::Free(void *aligned_pointer) { - if (aligned_pointer == nullptr) { - return; - } - char *const aligned = static_cast(aligned_pointer); - assert(reinterpret_cast(aligned) % kCacheLineSize == 0); - char *allocated; - memcpy(&allocated, aligned - kPointerSize, kPointerSize); - assert(allocated <= aligned - kPointerSize); - assert(allocated >= aligned - kCacheLineSize); - free(allocated); -} - -static inline bool IsNan(const float x) { - uint32_t bits; - memcpy(&bits, &x, sizeof(bits)); - const uint32_t bitmask_exp = 0x7F800000; - return (bits & bitmask_exp) == bitmask_exp && (bits & 0x7FFFFF); -} - -static inline bool IsNan(const double x) { - uint64_t bits; - memcpy(&bits, &x, sizeof(bits)); - return (0x7ff0000000000001ULL <= bits && bits <= 0x7fffffffffffffffULL) || - (0xfff0000000000001ULL <= bits && bits <= 0xffffffffffffffffULL); -} - -static inline void CheckImage(const ImageF &image, const char *name) { - for (size_t y = 0; y < image.ysize(); ++y) { - ConstRestrict row = image.Row(y); - for (size_t x = 0; x < image.xsize(); ++x) { - if (IsNan(row[x])) { - printf("Image %s @ %lu,%lu (of %lu,%lu)\n", name, x, y, image.xsize(), - image.ysize()); - exit(1); - } - } - } -} - -#if BUTTERAUGLI_ENABLE_CHECKS - -#define CHECK_NAN(x, str) \ - do { \ - if (IsNan(x)) { \ - printf("%d: %s\n", __LINE__, str); \ - abort(); \ - } \ - } while (0) - -#define CHECK_IMAGE(image, name) CheckImage(image, name) - -#else - -#define CHECK_NAN(x, str) -#define CHECK_IMAGE(image, name) - -#endif - - -static const double kInternalGoodQualityThreshold = 14.921561160295326; -static const double kGlobalScale = 1.0 / kInternalGoodQualityThreshold; - -inline double DotProduct(const double u[3], const double v[3]) { - return u[0] * v[0] + u[1] * v[1] + u[2] * v[2]; -} - -inline double DotProduct(const float u[3], const double v[3]) { - return u[0] * v[0] + u[1] * v[1] + u[2] * v[2]; -} - -// Computes a horizontal convolution and transposes the result. -static void Convolution(size_t xsize, size_t ysize, - size_t xstep, - size_t len, size_t offset, - const float* __restrict__ multipliers, - const float* __restrict__ inp, - double border_ratio, - float* __restrict__ result) { - PROFILER_FUNC; - double weight_no_border = 0; - for (int j = 0; j <= 2 * offset; ++j) { - weight_no_border += multipliers[j]; - } - for (size_t x = 0, ox = 0; x < xsize; x += xstep, ox++) { - int minx = x < offset ? 0 : x - offset; - int maxx = std::min(xsize, x + len - offset) - 1; - double weight = 0.0; - for (int j = minx; j <= maxx; ++j) { - weight += multipliers[j - x + offset]; - } - // Interpolate linearly between the no-border scaling and border scaling. - weight = (1.0 - border_ratio) * weight + border_ratio * weight_no_border; - double scale = 1.0 / weight; - for (size_t y = 0; y < ysize; ++y) { - double sum = 0.0; - for (int j = minx; j <= maxx; ++j) { - sum += inp[y * xsize + j] * multipliers[j - x + offset]; - } - result[ox * ysize + y] = sum * scale; - } - } -} - -void Blur(size_t xsize, size_t ysize, float* channel, double sigma, - double border_ratio) { - PROFILER_FUNC; - double m = 2.25; // Accuracy increases when m is increased. - const double scaler = -1.0 / (2 * sigma * sigma); - // For m = 9.0: exp(-scaler * diff * diff) < 2^ {-52} - const int diff = std::max(1, m * fabs(sigma)); - const int expn_size = 2 * diff + 1; - std::vector expn(expn_size); - for (int i = -diff; i <= diff; ++i) { - expn[i + diff] = exp(scaler * i * i); - } - const int xstep = std::max(1, int(sigma / 3)); - const int ystep = xstep; - int dxsize = (xsize + xstep - 1) / xstep; - int dysize = (ysize + ystep - 1) / ystep; - std::vector tmp(dxsize * ysize); - std::vector downsampled_output(dxsize * dysize); - Convolution(xsize, ysize, xstep, expn_size, diff, expn.data(), channel, - border_ratio, - tmp.data()); - Convolution(ysize, dxsize, ystep, expn_size, diff, expn.data(), tmp.data(), - border_ratio, - downsampled_output.data()); - for (int y = 0; y < ysize; y++) { - for (int x = 0; x < xsize; x++) { - // TODO: Use correct rounding. - channel[y * xsize + x] = - downsampled_output[(y / ystep) * dxsize + (x / xstep)]; - } - } -} - -// To change this to n, add the relevant FFTn function and kFFTnMapIndexTable. -constexpr size_t kBlockEdge = 8; -constexpr size_t kBlockSize = kBlockEdge * kBlockEdge; -constexpr size_t kBlockEdgeHalf = kBlockEdge / 2; -constexpr size_t kBlockHalf = kBlockEdge * kBlockEdgeHalf; - -// Contrast sensitivity related weights. -static const double *GetContrastSensitivityMatrix() { - static double csf8x8[kBlockHalf + kBlockEdgeHalf + 1] = { - 5.28270670524, - 0.0, - 0.0, - 0.0, - 0.3831134973, - 0.676303603859, - 3.58927792424, - 18.6104367002, - 18.6104367002, - 3.09093131948, - 1.0, - 0.498250875965, - 0.36198671102, - 0.308982169883, - 0.1312701920435, - 2.37370549629, - 3.58927792424, - 1.0, - 2.37370549629, - 0.991205724152, - 1.05178802919, - 0.627264168628, - 0.4, - 0.1312701920435, - 0.676303603859, - 0.498250875965, - 0.991205724152, - 0.5, - 0.3831134973, - 0.349686450518, - 0.627264168628, - 0.308982169883, - 0.3831134973, - 0.36198671102, - 1.05178802919, - 0.3831134973, - 0.12, - }; - return &csf8x8[0]; -} - -std::array MakeHighFreqColorDiffDx() { - std::array lut; - static const double off = 11.38708334481672; - static const double inc = 14.550189611520716; - lut[1] = off; - for (int i = 2; i < 21; ++i) { - lut[i] = lut[i - 1] + inc; - } - return lut; -} - -const double *GetHighFreqColorDiffDx() { - static const std::array kLut = MakeHighFreqColorDiffDx(); - return kLut.data(); -} - -std::array MakeHighFreqColorDiffDy() { - std::array lut; - static const double off = 1.4103373714040413; - static const double inc = 0.7084088867024; - lut[1] = off; - for (int i = 2; i < 21; ++i) { - lut[i] = lut[i - 1] + inc; - } - return lut; -} - -const double *GetHighFreqColorDiffDy() { - static const std::array kLut = MakeHighFreqColorDiffDy(); - return kLut.data(); -} - -std::array MakeLowFreqColorDiffDy() { - std::array lut; - static const double inc = 5.2511644570349185; - for (int i = 1; i < 21; ++i) { - lut[i] = lut[i - 1] + inc; - } - return lut; -} - -const double *GetLowFreqColorDiffDy() { - static const std::array kLut = MakeLowFreqColorDiffDy(); - return kLut.data(); -} - -inline double Interpolate(const double *array, int size, double sx) { - double ix = fabs(sx); - assert(ix < 10000); - int baseix = static_cast(ix); - double res; - if (baseix >= size - 1) { - res = array[size - 1]; - } else { - double mix = ix - baseix; - int nextix = baseix + 1; - res = array[baseix] + mix * (array[nextix] - array[baseix]); - } - if (sx < 0) res = -res; - return res; -} - -inline double InterpolateClampNegative(const double *array, - int size, double sx) { - if (sx < 0) { - sx = 0; - } - double ix = fabs(sx); - int baseix = static_cast(ix); - double res; - if (baseix >= size - 1) { - res = array[size - 1]; - } else { - double mix = ix - baseix; - int nextix = baseix + 1; - res = array[baseix] + mix * (array[nextix] - array[baseix]); - } - return res; -} - -void RgbToXyb(double r, double g, double b, - double *valx, double *valy, double *valz) { - static const double a0 = 1.01611726948; - static const double a1 = 0.982482243696; - static const double a2 = 1.43571362627; - static const double a3 = 0.896039849412; - *valx = a0 * r - a1 * g; - *valy = a2 * r + a3 * g; - *valz = b; -} - -static inline void XybToVals(double x, double y, double z, - double *valx, double *valy, double *valz) { - static const double xmul = 0.758304045695; - static const double ymul = 2.28148649801; - static const double zmul = 1.87816926918; - *valx = Interpolate(GetHighFreqColorDiffDx(), 21, x * xmul); - *valy = Interpolate(GetHighFreqColorDiffDy(), 21, y * ymul); - *valz = zmul * z; -} - -// Rough psychovisual distance to gray for low frequency colors. -static void XybLowFreqToVals(double x, double y, double z, - double *valx, double *valy, double *valz) { - static const double xmul = 6.64482198135; - static const double ymul = 0.837846224276; - static const double zmul = 7.34905756986; - static const double y_to_z_mul = 0.0812519812628; - z += y_to_z_mul * y; - *valz = z * zmul; - *valx = x * xmul; - *valy = Interpolate(GetLowFreqColorDiffDy(), 21, y * ymul); -} - -double RemoveRangeAroundZero(double v, double range) { - if (v >= -range && v < range) { - return 0; - } - if (v < 0) { - return v + range; - } else { - return v - range; - } -} - -void XybDiffLowFreqSquaredAccumulate(double r0, double g0, double b0, - double r1, double g1, double b1, - double factor, double res[3]) { - double valx0, valy0, valz0; - double valx1, valy1, valz1; - XybLowFreqToVals(r0, g0, b0, &valx0, &valy0, &valz0); - if (r1 == 0.0 && g1 == 0.0 && b1 == 0.0) { - PROFILER_ZONE("XybDiff r1=g1=b1=0"); - res[0] += factor * valx0 * valx0; - res[1] += factor * valy0 * valy0; - res[2] += factor * valz0 * valz0; - return; - } - XybLowFreqToVals(r1, g1, b1, &valx1, &valy1, &valz1); - // Approximate the distance of the colors by their respective distances - // to gray. - double valx = valx0 - valx1; - double valy = valy0 - valy1; - double valz = valz0 - valz1; - res[0] += factor * valx * valx; - res[1] += factor * valy * valy; - res[2] += factor * valz * valz; -} - -struct Complex { - public: - double real; - double imag; -}; - -inline double abssq(const Complex& c) { - return c.real * c.real + c.imag * c.imag; -} - -static void TransposeBlock(Complex data[kBlockSize]) { - for (int i = 0; i < kBlockEdge; i++) { - for (int j = 0; j < i; j++) { - std::swap(data[kBlockEdge * i + j], data[kBlockEdge * j + i]); - } - } -} - -// D. J. Bernstein's Fast Fourier Transform algorithm on 4 elements. -inline void FFT4(Complex* a) { - double t1, t2, t3, t4, t5, t6, t7, t8; - t5 = a[2].real; - t1 = a[0].real - t5; - t7 = a[3].real; - t5 += a[0].real; - t3 = a[1].real - t7; - t7 += a[1].real; - t8 = t5 + t7; - a[0].real = t8; - t5 -= t7; - a[1].real = t5; - t6 = a[2].imag; - t2 = a[0].imag - t6; - t6 += a[0].imag; - t5 = a[3].imag; - a[2].imag = t2 + t3; - t2 -= t3; - a[3].imag = t2; - t4 = a[1].imag - t5; - a[3].real = t1 + t4; - t1 -= t4; - a[2].real = t1; - t5 += a[1].imag; - a[0].imag = t6 + t5; - t6 -= t5; - a[1].imag = t6; -} - -static const double kSqrtHalf = 0.70710678118654752440084436210484903; - -// D. J. Bernstein's Fast Fourier Transform algorithm on 8 elements. -void FFT8(Complex* a) { - double t1, t2, t3, t4, t5, t6, t7, t8; - - t7 = a[4].imag; - t4 = a[0].imag - t7; - t7 += a[0].imag; - a[0].imag = t7; - - t8 = a[6].real; - t5 = a[2].real - t8; - t8 += a[2].real; - a[2].real = t8; - - t7 = a[6].imag; - a[6].imag = t4 - t5; - t4 += t5; - a[4].imag = t4; - - t6 = a[2].imag - t7; - t7 += a[2].imag; - a[2].imag = t7; - - t8 = a[4].real; - t3 = a[0].real - t8; - t8 += a[0].real; - a[0].real = t8; - - a[4].real = t3 - t6; - t3 += t6; - a[6].real = t3; - - t7 = a[5].real; - t3 = a[1].real - t7; - t7 += a[1].real; - a[1].real = t7; - - t8 = a[7].imag; - t6 = a[3].imag - t8; - t8 += a[3].imag; - a[3].imag = t8; - t1 = t3 - t6; - t3 += t6; - - t7 = a[5].imag; - t4 = a[1].imag - t7; - t7 += a[1].imag; - a[1].imag = t7; - - t8 = a[7].real; - t5 = a[3].real - t8; - t8 += a[3].real; - a[3].real = t8; - - t2 = t4 - t5; - t4 += t5; - - t6 = t1 - t4; - t8 = kSqrtHalf; - t6 *= t8; - a[5].real = a[4].real - t6; - t1 += t4; - t1 *= t8; - a[5].imag = a[4].imag - t1; - t6 += a[4].real; - a[4].real = t6; - t1 += a[4].imag; - a[4].imag = t1; - - t5 = t2 - t3; - t5 *= t8; - a[7].imag = a[6].imag - t5; - t2 += t3; - t2 *= t8; - a[7].real = a[6].real - t2; - t2 += a[6].real; - a[6].real = t2; - t5 += a[6].imag; - a[6].imag = t5; - - FFT4(a); - - // Reorder to the correct output order. - // TODO: Modify the above computation so that this is not needed. - Complex tmp = a[2]; - a[2] = a[3]; - a[3] = a[5]; - a[5] = a[7]; - a[7] = a[4]; - a[4] = a[1]; - a[1] = a[6]; - a[6] = tmp; -} - -// Same as FFT8, but all inputs are real. -// TODO: Since this does not need to be in-place, maybe there is a -// faster FFT than this one, which is derived from DJB's in-place complex FFT. -void RealFFT8(const double* in, Complex* out) { - double t1, t2, t3, t5, t6, t7, t8; - t8 = in[6]; - t5 = in[2] - t8; - t8 += in[2]; - out[2].real = t8; - out[6].imag = -t5; - out[4].imag = t5; - t8 = in[4]; - t3 = in[0] - t8; - t8 += in[0]; - out[0].real = t8; - out[4].real = t3; - out[6].real = t3; - t7 = in[5]; - t3 = in[1] - t7; - t7 += in[1]; - out[1].real = t7; - t8 = in[7]; - t5 = in[3] - t8; - t8 += in[3]; - out[3].real = t8; - t2 = -t5; - t6 = t3 - t5; - t8 = kSqrtHalf; - t6 *= t8; - out[5].real = out[4].real - t6; - t1 = t3 + t5; - t1 *= t8; - out[5].imag = out[4].imag - t1; - t6 += out[4].real; - out[4].real = t6; - t1 += out[4].imag; - out[4].imag = t1; - t5 = t2 - t3; - t5 *= t8; - out[7].imag = out[6].imag - t5; - t2 += t3; - t2 *= t8; - out[7].real = out[6].real - t2; - t2 += out[6].real; - out[6].real = t2; - t5 += out[6].imag; - out[6].imag = t5; - t5 = out[2].real; - t1 = out[0].real - t5; - t7 = out[3].real; - t5 += out[0].real; - t3 = out[1].real - t7; - t7 += out[1].real; - t8 = t5 + t7; - out[0].real = t8; - t5 -= t7; - out[1].real = t5; - out[2].imag = t3; - out[3].imag = -t3; - out[3].real = t1; - out[2].real = t1; - out[0].imag = 0; - out[1].imag = 0; - - // Reorder to the correct output order. - // TODO: Modify the above computation so that this is not needed. - Complex tmp = out[2]; - out[2] = out[3]; - out[3] = out[5]; - out[5] = out[7]; - out[7] = out[4]; - out[4] = out[1]; - out[1] = out[6]; - out[6] = tmp; -} - -// Fills in block[kBlockEdgeHalf..(kBlockHalf+kBlockEdgeHalf)], and leaves the -// rest unmodified. -void ButteraugliFFTSquared(double block[kBlockSize]) { - double global_mul = 0.000064; - Complex block_c[kBlockSize]; - assert(kBlockEdge == 8); - for (int y = 0; y < kBlockEdge; ++y) { - RealFFT8(block + y * kBlockEdge, block_c + y * kBlockEdge); - } - TransposeBlock(block_c); - double r0[kBlockEdge]; - double r1[kBlockEdge]; - for (int x = 0; x < kBlockEdge; ++x) { - r0[x] = block_c[x].real; - r1[x] = block_c[kBlockHalf + x].real; - } - RealFFT8(r0, block_c); - RealFFT8(r1, block_c + kBlockHalf); - for (int y = 1; y < kBlockEdgeHalf; ++y) { - FFT8(block_c + y * kBlockEdge); - } - for (int i = kBlockEdgeHalf; i < kBlockHalf + kBlockEdgeHalf + 1; ++i) { - block[i] = abssq(block_c[i]); - block[i] *= global_mul; - } -} - -// Computes 8x8 FFT of each channel of xyb0 and xyb1 and adds the total squared -// 3-dimensional xybdiff of the two blocks to diff_xyb_{dc,ac} and the average -// diff on the edges to diff_xyb_edge_dc. -void ButteraugliBlockDiff(double xyb0[3 * kBlockSize], - double xyb1[3 * kBlockSize], - double diff_xyb_dc[3], - double diff_xyb_ac[3], - double diff_xyb_edge_dc[3]) { - PROFILER_FUNC; - const double *csf8x8 = GetContrastSensitivityMatrix(); - - double avgdiff_xyb[3] = {0.0}; - double avgdiff_edge[3][4] = { {0.0} }; - for (int i = 0; i < 3 * kBlockSize; ++i) { - const double diff_xyb = xyb0[i] - xyb1[i]; - const int c = i / kBlockSize; - avgdiff_xyb[c] += diff_xyb / kBlockSize; - const int k = i % kBlockSize; - const int kx = k % kBlockEdge; - const int ky = k / kBlockEdge; - const int h_edge_idx = ky == 0 ? 1 : ky == 7 ? 3 : -1; - const int v_edge_idx = kx == 0 ? 0 : kx == 7 ? 2 : -1; - if (h_edge_idx >= 0) { - avgdiff_edge[c][h_edge_idx] += diff_xyb / kBlockEdge; - } - if (v_edge_idx >= 0) { - avgdiff_edge[c][v_edge_idx] += diff_xyb / kBlockEdge; - } - } - XybDiffLowFreqSquaredAccumulate(avgdiff_xyb[0], - avgdiff_xyb[1], - avgdiff_xyb[2], - 0, 0, 0, csf8x8[0], - diff_xyb_dc); - for (int i = 0; i < 4; ++i) { - XybDiffLowFreqSquaredAccumulate(avgdiff_edge[0][i], - avgdiff_edge[1][i], - avgdiff_edge[2][i], - 0, 0, 0, csf8x8[0], - diff_xyb_edge_dc); - } - - double* xyb_avg = xyb0; - double* xyb_halfdiff = xyb1; - for(int i = 0; i < 3 * kBlockSize; ++i) { - double avg = (xyb0[i] + xyb1[i])/2; - double halfdiff = (xyb0[i] - xyb1[i])/2; - xyb_avg[i] = avg; - xyb_halfdiff[i] = halfdiff; - } - double *y_avg = &xyb_avg[kBlockSize]; - double *x_halfdiff_squared = &xyb_halfdiff[0]; - double *y_halfdiff = &xyb_halfdiff[kBlockSize]; - double *z_halfdiff_squared = &xyb_halfdiff[2 * kBlockSize]; - ButteraugliFFTSquared(y_avg); - ButteraugliFFTSquared(x_halfdiff_squared); - ButteraugliFFTSquared(y_halfdiff); - ButteraugliFFTSquared(z_halfdiff_squared); - - static const double xmul = 64.8; - static const double ymul = 1.753123908348329; - static const double ymul2 = 1.51983458269; - static const double zmul = 2.4; - - for (size_t i = kBlockEdgeHalf; i < kBlockHalf + kBlockEdgeHalf + 1; ++i) { - double d = csf8x8[i]; - diff_xyb_ac[0] += d * xmul * x_halfdiff_squared[i]; - diff_xyb_ac[2] += d * zmul * z_halfdiff_squared[i]; - - y_avg[i] = sqrt(y_avg[i]); - y_halfdiff[i] = sqrt(y_halfdiff[i]); - double y0 = y_avg[i] - y_halfdiff[i]; - double y1 = y_avg[i] + y_halfdiff[i]; - // Remove the impact of small absolute values. - // This improves the behavior with flat noise. - static const double ylimit = 0.04; - y0 = RemoveRangeAroundZero(y0, ylimit); - y1 = RemoveRangeAroundZero(y1, ylimit); - if (y0 != y1) { - double valy0 = Interpolate(GetHighFreqColorDiffDy(), 21, y0 * ymul2); - double valy1 = Interpolate(GetHighFreqColorDiffDy(), 21, y1 * ymul2); - double valy = ymul * (valy0 - valy1); - diff_xyb_ac[1] += d * valy * valy; - } - } -} - -// Low frequency edge detectors. -// Two edge detectors are applied in each corner of the 8x8 square. -// The squared 3-dimensional error vector is added to diff_xyb. -void Butteraugli8x8CornerEdgeDetectorDiff( - const size_t pos_x, - const size_t pos_y, - const size_t xsize, - const size_t ysize, - const std::vector > &blurred0, - const std::vector > &blurred1, - double diff_xyb[3]) { - PROFILER_FUNC; - int local_count = 0; - double local_xyb[3] = { 0 }; - static const double w = 0.711100840192; - for (int k = 0; k < 4; ++k) { - size_t step = 3; - size_t offset[4][2] = { { 0, 0 }, { 0, 7 }, { 7, 0 }, { 7, 7 } }; - size_t x = pos_x + offset[k][0]; - size_t y = pos_y + offset[k][1]; - if (x >= step && x + step < xsize) { - size_t ix = y * xsize + (x - step); - size_t ix2 = ix + 2 * step; - XybDiffLowFreqSquaredAccumulate( - w * (blurred0[0][ix] - blurred0[0][ix2]), - w * (blurred0[1][ix] - blurred0[1][ix2]), - w * (blurred0[2][ix] - blurred0[2][ix2]), - w * (blurred1[0][ix] - blurred1[0][ix2]), - w * (blurred1[1][ix] - blurred1[1][ix2]), - w * (blurred1[2][ix] - blurred1[2][ix2]), - 1.0, local_xyb); - ++local_count; - } - if (y >= step && y + step < ysize) { - size_t ix = (y - step) * xsize + x; - size_t ix2 = ix + 2 * step * xsize; - XybDiffLowFreqSquaredAccumulate( - w * (blurred0[0][ix] - blurred0[0][ix2]), - w * (blurred0[1][ix] - blurred0[1][ix2]), - w * (blurred0[2][ix] - blurred0[2][ix2]), - w * (blurred1[0][ix] - blurred1[0][ix2]), - w * (blurred1[1][ix] - blurred1[1][ix2]), - w * (blurred1[2][ix] - blurred1[2][ix2]), - 1.0, local_xyb); - ++local_count; - } - } - static const double weight = 0.01617112696; - const double mul = weight * 8.0 / local_count; - for (int i = 0; i < 3; ++i) { - diff_xyb[i] += mul * local_xyb[i]; - } -} - -// https://en.wikipedia.org/wiki/Photopsin absordance modeling. -const double *GetOpsinAbsorbance() { - static const double kMix[12] = { - 0.348036746003, - 0.577814843137, - 0.0544556093735, - 0.774145581713, - 0.26922717275, - 0.767247733938, - 0.0366922708552, - 0.920130265014, - 0.0882062883536, - 0.158581714673, - 0.712857943858, - 10.6524069248, - }; - return &kMix[0]; -} - -void OpsinAbsorbance(const double in[3], double out[3]) { - const double *mix = GetOpsinAbsorbance(); - out[0] = mix[0] * in[0] + mix[1] * in[1] + mix[2] * in[2] + mix[3]; - out[1] = mix[4] * in[0] + mix[5] * in[1] + mix[6] * in[2] + mix[7]; - out[2] = mix[8] * in[0] + mix[9] * in[1] + mix[10] * in[2] + mix[11]; -} - -double GammaMinArg() { - double in[3] = { 0.0, 0.0, 0.0 }; - double out[3]; - OpsinAbsorbance(in, out); - return std::min(out[0], std::min(out[1], out[2])); -} - -double GammaMaxArg() { - double in[3] = { 255.0, 255.0, 255.0 }; - double out[3]; - OpsinAbsorbance(in, out); - return std::max(out[0], std::max(out[1], out[2])); -} - -ButteraugliComparator::ButteraugliComparator( - size_t xsize, size_t ysize, int step) - : xsize_(xsize), - ysize_(ysize), - num_pixels_(xsize * ysize), - step_(step), - res_xsize_((xsize + step - 1) / step), - res_ysize_((ysize + step - 1) / step) { - assert(step <= 4); -} - -void MaskHighIntensityChange( - size_t xsize, size_t ysize, - const std::vector > &c0, - const std::vector > &c1, - std::vector > &xyb0, - std::vector > &xyb1) { - PROFILER_FUNC; - for (int y = 0; y < ysize; ++y) { - for (int x = 0; x < xsize; ++x) { - int ix = y * xsize + x; - const double ave[3] = { - (c0[0][ix] + c1[0][ix]) * 0.5, - (c0[1][ix] + c1[1][ix]) * 0.5, - (c0[2][ix] + c1[2][ix]) * 0.5, - }; - double sqr_max_diff = -1; - { - int offset[4] = - { -1, 1, -static_cast(xsize), static_cast(xsize) }; - int border[4] = - { x == 0, x + 1 == xsize, y == 0, y + 1 == ysize }; - for (int dir = 0; dir < 4; ++dir) { - if (border[dir]) { - continue; - } - const int ix2 = ix + offset[dir]; - double diff = 0.5 * (c0[1][ix2] + c1[1][ix2]) - ave[1]; - diff *= diff; - if (sqr_max_diff < diff) { - sqr_max_diff = diff; - } - } - } - static const double kReductionX = 275.19165240059317; - static const double kReductionY = 18599.41286306991; - static const double kReductionZ = 410.8995306951065; - static const double kChromaBalance = 106.95800948271017; - double chroma_scale = kChromaBalance / (ave[1] + kChromaBalance); - - const double mix[3] = { - chroma_scale * kReductionX / (sqr_max_diff + kReductionX), - kReductionY / (sqr_max_diff + kReductionY), - chroma_scale * kReductionZ / (sqr_max_diff + kReductionZ), - }; - // Interpolate lineraly between the average color and the actual - // color -- to reduce the importance of this pixel. - for (int i = 0; i < 3; ++i) { - xyb0[i][ix] = mix[i] * c0[i][ix] + (1 - mix[i]) * ave[i]; - xyb1[i][ix] = mix[i] * c1[i][ix] + (1 - mix[i]) * ave[i]; - } - } - } -} - -double SimpleGamma(double v) { - static const double kGamma = 0.387494322593; - static const double limit = 43.01745241042018; - double bright = v - limit; - if (bright >= 0) { - static const double mul = 0.0383723643799; - v -= bright * mul; - } - static const double limit2 = 94.68634353321337; - double bright2 = v - limit2; - if (bright2 >= 0) { - static const double mul = 0.22885405968; - v -= bright2 * mul; - } - static const double offset = 0.156775786057; - static const double scale = 8.898059160493739; - double retval = scale * (offset + pow(v, kGamma)); - return retval; -} - -static inline double Gamma(double v) { - // return SimpleGamma(v); - return GammaPolynomial(v); -} - -void OpsinDynamicsImage(size_t xsize, size_t ysize, - std::vector > &rgb) { - PROFILER_FUNC; - std::vector > blurred = rgb; - static const double kSigma = 1.1; - for (int i = 0; i < 3; ++i) { - Blur(xsize, ysize, blurred[i].data(), kSigma, 0.0); - } - for (int i = 0; i < rgb[0].size(); ++i) { - double sensitivity[3]; - { - // Calculate sensitivity[3] based on the smoothed image gamma derivative. - double pre_rgb[3] = { blurred[0][i], blurred[1][i], blurred[2][i] }; - double pre_mixed[3]; - OpsinAbsorbance(pre_rgb, pre_mixed); - sensitivity[0] = Gamma(pre_mixed[0]) / pre_mixed[0]; - sensitivity[1] = Gamma(pre_mixed[1]) / pre_mixed[1]; - sensitivity[2] = Gamma(pre_mixed[2]) / pre_mixed[2]; - } - double cur_rgb[3] = { rgb[0][i], rgb[1][i], rgb[2][i] }; - double cur_mixed[3]; - OpsinAbsorbance(cur_rgb, cur_mixed); - cur_mixed[0] *= sensitivity[0]; - cur_mixed[1] *= sensitivity[1]; - cur_mixed[2] *= sensitivity[2]; - double x, y, z; - RgbToXyb(cur_mixed[0], cur_mixed[1], cur_mixed[2], &x, &y, &z); - rgb[0][i] = x; - rgb[1][i] = y; - rgb[2][i] = z; - } -} - -static void ScaleImage(double scale, std::vector *result) { - PROFILER_FUNC; - for (size_t i = 0; i < result->size(); ++i) { - (*result)[i] *= scale; - } -} - -// Making a cluster of local errors to be more impactful than -// just a single error. -void CalculateDiffmap(const size_t xsize, const size_t ysize, - const int step, - std::vector* diffmap) { - PROFILER_FUNC; - // Shift the diffmap more correctly above the pixels, from 2.5 pixels to 0.5 - // pixels distance over the original image. The border of 2 pixels on top and - // left side and 3 pixels on right and bottom side are zeroed, but these - // values have no meaning, they only exist to keep the result map the same - // size as the input images. - int s2 = (8 - step) / 2; - // Upsample and take square root. - std::vector diffmap_out(xsize * ysize); - const size_t res_xsize = (xsize + step - 1) / step; - for (size_t res_y = 0; res_y + 8 - step < ysize; res_y += step) { - for (size_t res_x = 0; res_x + 8 - step < xsize; res_x += step) { - size_t res_ix = (res_y * res_xsize + res_x) / step; - float orig_val = (*diffmap)[res_ix]; - constexpr float kInitialSlope = 100; - // TODO(b/29974893): Until that is fixed do not call sqrt on very small - // numbers. - double val = orig_val < (1.0 / (kInitialSlope * kInitialSlope)) - ? kInitialSlope * orig_val - : std::sqrt(orig_val); - for (size_t off_y = 0; off_y < step; ++off_y) { - for (size_t off_x = 0; off_x < step; ++off_x) { - diffmap_out[(res_y + off_y + s2) * xsize + res_x + off_x + s2] = val; - } - } - } - } - *diffmap = diffmap_out; - { - static const double kSigma = 8.8510880283; - static const double mul1 = 24.8235314874; - static const double scale = 1.0 / (1.0 + mul1); - const int s = 8 - step; - std::vector blurred((xsize - s) * (ysize - s)); - for (int y = 0; y < ysize - s; ++y) { - for (int x = 0; x < xsize - s; ++x) { - blurred[y * (xsize - s) + x] = (*diffmap)[(y + s2) * xsize + x + s2]; - } - } - static const double border_ratio = 0.03027655136; - Blur(xsize - s, ysize - s, blurred.data(), kSigma, border_ratio); - for (int y = 0; y < ysize - s; ++y) { - for (int x = 0; x < xsize - s; ++x) { - (*diffmap)[(y + s2) * xsize + x + s2] - += mul1 * blurred[y * (xsize - s) + x]; - } - } - ScaleImage(scale, diffmap); - } -} - -void ButteraugliComparator::Diffmap(const std::vector &rgb0_arg, - const std::vector &rgb1_arg, - ImageF &result) { - result = ImageF(xsize_, ysize_); - if (xsize_ < 8 || ysize_ < 8) return; - std::vector> rgb0_c = PackedFromPlanes(rgb0_arg); - std::vector> rgb1_c = PackedFromPlanes(rgb1_arg); - OpsinDynamicsImage(xsize_, ysize_, rgb0_c); - OpsinDynamicsImage(xsize_, ysize_, rgb1_c); - std::vector pg0 = PlanesFromPacked(xsize_, ysize_, rgb0_c); - std::vector pg1 = PlanesFromPacked(xsize_, ysize_, rgb1_c); - DiffmapOpsinDynamicsImage(pg0, pg1, result); -} - -void ButteraugliComparator::DiffmapOpsinDynamicsImage( - const std::vector &xyb0_arg, const std::vector &xyb1_arg, - ImageF &result) { - result = ImageF(xsize_, ysize_); - if (xsize_ < 8 || ysize_ < 8) return; - std::vector> xyb0 = PackedFromPlanes(xyb0_arg); - std::vector> xyb1 = PackedFromPlanes(xyb1_arg); - auto xyb0_c = xyb0; - auto xyb1_c = xyb1; - - MaskHighIntensityChange(xsize_, ysize_, xyb0_c, xyb1_c, xyb0, xyb1); - assert(8 <= xsize_); - for (int i = 0; i < 3; i++) { - assert(xyb0[i].size() == num_pixels_); - assert(xyb1[i].size() == num_pixels_); - } - std::vector > mask_xyb(3); - std::vector > mask_xyb_dc(3); - std::vector block_diff_dc(3 * res_xsize_ * res_ysize_); - std::vector block_diff_ac(3 * res_xsize_ * res_ysize_); - std::vector edge_detector_map(3 * res_xsize_ * res_ysize_); - std::vector packed_result; - BlockDiffMap(xyb0, xyb1, &block_diff_dc, &block_diff_ac); - EdgeDetectorMap(xyb0, xyb1, &edge_detector_map); - EdgeDetectorLowFreq(xyb0, xyb1, &block_diff_ac); - Mask(xyb0, xyb1, xsize_, ysize_, &mask_xyb, &mask_xyb_dc); - CombineChannels(mask_xyb, mask_xyb_dc, block_diff_dc, block_diff_ac, - edge_detector_map, &packed_result); - CalculateDiffmap(xsize_, ysize_, step_, &packed_result); - CopyFromPacked(packed_result, &result); -} - -void ButteraugliComparator::BlockDiffMap( - const std::vector > &xyb0, - const std::vector > &xyb1, - std::vector* block_diff_dc, - std::vector* block_diff_ac) { - PROFILER_FUNC; - for (size_t res_y = 0; res_y + (kBlockEdge - step_ - 1) < ysize_; - res_y += step_) { - for (size_t res_x = 0; res_x + (kBlockEdge - step_ - 1) < xsize_; - res_x += step_) { - size_t res_ix = (res_y * res_xsize_ + res_x) / step_; - size_t offset = (std::min(res_y, ysize_ - 8) * xsize_ + - std::min(res_x, xsize_ - 8)); - double block0[3 * kBlockEdge * kBlockEdge]; - double block1[3 * kBlockEdge * kBlockEdge]; - for (int i = 0; i < 3; ++i) { - double *m0 = &block0[i * kBlockEdge * kBlockEdge]; - double *m1 = &block1[i * kBlockEdge * kBlockEdge]; - for (size_t y = 0; y < kBlockEdge; y++) { - for (size_t x = 0; x < kBlockEdge; x++) { - m0[kBlockEdge * y + x] = xyb0[i][offset + y * xsize_ + x]; - m1[kBlockEdge * y + x] = xyb1[i][offset + y * xsize_ + x]; - } - } - } - double diff_xyb_dc[3] = { 0.0 }; - double diff_xyb_ac[3] = { 0.0 }; - double diff_xyb_edge_dc[3] = { 0.0 }; - ButteraugliBlockDiff(block0, block1, - diff_xyb_dc, diff_xyb_ac, diff_xyb_edge_dc); - for (int i = 0; i < 3; ++i) { - (*block_diff_dc)[3 * res_ix + i] = diff_xyb_dc[i]; - (*block_diff_ac)[3 * res_ix + i] = diff_xyb_ac[i]; - } - } - } -} - -void ButteraugliComparator::EdgeDetectorMap( - const std::vector > &xyb0, - const std::vector > &xyb1, - std::vector* edge_detector_map) { - PROFILER_FUNC; - static const double kSigma[3] = { - 1.5, - 0.586, - 0.4, - }; - std::vector > blurred0(xyb0); - std::vector > blurred1(xyb1); - for (int i = 0; i < 3; i++) { - Blur(xsize_, ysize_, blurred0[i].data(), kSigma[i], 0.0); - Blur(xsize_, ysize_, blurred1[i].data(), kSigma[i], 0.0); - } - for (size_t res_y = 0; res_y + (8 - step_) < ysize_; res_y += step_) { - for (size_t res_x = 0; res_x + (8 - step_) < xsize_; res_x += step_) { - size_t res_ix = (res_y * res_xsize_ + res_x) / step_; - double diff_xyb[3] = { 0.0 }; - Butteraugli8x8CornerEdgeDetectorDiff(std::min(res_x, xsize_ - 8), - std::min(res_y, ysize_ - 8), - xsize_, ysize_, - blurred0, blurred1, - diff_xyb); - for (int i = 0; i < 3; ++i) { - (*edge_detector_map)[3 * res_ix + i] = diff_xyb[i]; - } - } - } -} - -void ButteraugliComparator::EdgeDetectorLowFreq( - const std::vector > &xyb0, - const std::vector > &xyb1, - std::vector* block_diff_ac) { - PROFILER_FUNC; - static const double kSigma = 14; - static const double kMul = 10; - std::vector > blurred0(xyb0); - std::vector > blurred1(xyb1); - for (int i = 0; i < 3; i++) { - Blur(xsize_, ysize_, blurred0[i].data(), kSigma, 0.0); - Blur(xsize_, ysize_, blurred1[i].data(), kSigma, 0.0); - } - const int step = 8; - for (int y = 0; y + step < ysize_; y += step_) { - int resy = y / step_; - int resx = step / step_; - for (int x = 0; x + step < xsize_; x += step_, resx++) { - const int ix = y * xsize_ + x; - const int res_ix = resy * res_xsize_ + resx; - double diff[4][3]; - for (int i = 0; i < 3; ++i) { - int ix2 = ix + 8; - diff[0][i] = - ((blurred1[i][ix] - blurred0[i][ix]) + - (blurred0[i][ix2] - blurred1[i][ix2])); - ix2 = ix + 8 * xsize_; - diff[1][i] = - ((blurred1[i][ix] - blurred0[i][ix]) + - (blurred0[i][ix2] - blurred1[i][ix2])); - ix2 = ix + 6 * xsize_ + 6; - diff[2][i] = - ((blurred1[i][ix] - blurred0[i][ix]) + - (blurred0[i][ix2] - blurred1[i][ix2])); - ix2 = ix + 6 * xsize_ - 6; - diff[3][i] = x < step ? 0 : - ((blurred1[i][ix] - blurred0[i][ix]) + - (blurred0[i][ix2] - blurred1[i][ix2])); - } - double max_diff_xyb[3] = { 0 }; - for (int k = 0; k < 4; ++k) { - double diff_xyb[3] = { 0 }; - XybDiffLowFreqSquaredAccumulate(diff[k][0], diff[k][1], diff[k][2], - 0, 0, 0, 1.0, - diff_xyb); - for (int i = 0; i < 3; ++i) { - max_diff_xyb[i] = std::max(max_diff_xyb[i], diff_xyb[i]); - } - } - for (int i = 0; i < 3; ++i) { - (*block_diff_ac)[3 * res_ix + i] += kMul * max_diff_xyb[i]; - } - } - } -} - -void ButteraugliComparator::CombineChannels( - const std::vector >& mask_xyb, - const std::vector >& mask_xyb_dc, - const std::vector& block_diff_dc, - const std::vector& block_diff_ac, - const std::vector& edge_detector_map, - std::vector* result) { - PROFILER_FUNC; - result->resize(res_xsize_ * res_ysize_); - for (size_t res_y = 0; res_y + (8 - step_) < ysize_; res_y += step_) { - for (size_t res_x = 0; res_x + (8 - step_) < xsize_; res_x += step_) { - size_t res_ix = (res_y * res_xsize_ + res_x) / step_; - double mask[3]; - double dc_mask[3]; - for (int i = 0; i < 3; ++i) { - mask[i] = mask_xyb[i][(res_y + 3) * xsize_ + (res_x + 3)]; - dc_mask[i] = mask_xyb_dc[i][(res_y + 3) * xsize_ + (res_x + 3)]; - } - (*result)[res_ix] = - (DotProduct(&block_diff_dc[3 * res_ix], dc_mask) + - DotProduct(&block_diff_ac[3 * res_ix], mask) + - DotProduct(&edge_detector_map[3 * res_ix], mask)); - } - } -} - -double ButteraugliScoreFromDiffmap(const ImageF& diffmap) { - PROFILER_FUNC; - float retval = 0.0f; - for (size_t y = 0; y < diffmap.ysize(); ++y) { - ConstRestrict row = diffmap.Row(y); - for (size_t x = 0; x < diffmap.xsize(); ++x) { - retval = std::max(retval, row[x]); - } - } - return retval; -} - -static std::array MakeMask( - double extmul, double extoff, - double mul, double offset, - double scaler) { - std::array lut; - for (int i = 0; i < lut.size(); ++i) { - const double c = mul / ((0.01 * scaler * i) + offset); - lut[i] = 1.0 + extmul * (c + extoff); - assert(lut[i] >= 0.0); - lut[i] *= lut[i]; - } - return lut; -} - -double MaskX(double delta) { - PROFILER_FUNC; - static const double extmul = 0.975741017749; - static const double extoff = -4.25328244168; - static const double offset = 0.454909521427; - static const double scaler = 0.0738288224836; - static const double mul = 20.8029176447; - static const std::array lut = - MakeMask(extmul, extoff, mul, offset, scaler); - return InterpolateClampNegative(lut.data(), lut.size(), delta); -} - -double MaskY(double delta) { - PROFILER_FUNC; - static const double extmul = 0.373995618954; - static const double extoff = 1.5307267433; - static const double offset = 0.911952641929; - static const double scaler = 1.1731667845; - static const double mul = 16.2447033988; - static const std::array lut = - MakeMask(extmul, extoff, mul, offset, scaler); - return InterpolateClampNegative(lut.data(), lut.size(), delta); -} - -double MaskB(double delta) { - PROFILER_FUNC; - static const double extmul = 0.61582234137; - static const double extoff = -4.25376118646; - static const double offset = 1.05105070921; - static const double scaler = 0.47434643535; - static const double mul = 31.1444967089; - static const std::array lut = - MakeMask(extmul, extoff, mul, offset, scaler); - return InterpolateClampNegative(lut.data(), lut.size(), delta); -} - -double MaskDcX(double delta) { - PROFILER_FUNC; - static const double extmul = 1.79116943438; - static const double extoff = -3.86797479189; - static const double offset = 0.670960225853; - static const double scaler = 0.486575865525; - static const double mul = 20.4563479139; - static const std::array lut = - MakeMask(extmul, extoff, mul, offset, scaler); - return InterpolateClampNegative(lut.data(), lut.size(), delta); -} - -double MaskDcY(double delta) { - PROFILER_FUNC; - static const double extmul = 0.212223514236; - static const double extoff = -3.65647120524; - static const double offset = 1.73396799447; - static const double scaler = 0.170392660501; - static const double mul = 21.6566724788; - static const std::array lut = - MakeMask(extmul, extoff, mul, offset, scaler); - return InterpolateClampNegative(lut.data(), lut.size(), delta); -} - -double MaskDcB(double delta) { - PROFILER_FUNC; - static const double extmul = 0.349376011816; - static const double extoff = -0.894711072781; - static const double offset = 0.901647926679; - static const double scaler = 0.380086095024; - static const double mul = 18.0373825149; - static const std::array lut = - MakeMask(extmul, extoff, mul, offset, scaler); - return InterpolateClampNegative(lut.data(), lut.size(), delta); -} - -// Replaces values[x + y * xsize] with the minimum of the values in the -// square_size square with coordinates -// x - offset .. x + square_size - offset - 1, -// y - offset .. y + square_size - offset - 1. -void MinSquareVal(size_t square_size, size_t offset, - size_t xsize, size_t ysize, - float *values) { - PROFILER_FUNC; - // offset is not negative and smaller than square_size. - assert(offset < square_size); - std::vector tmp(xsize * ysize); - for (size_t y = 0; y < ysize; ++y) { - const size_t minh = offset > y ? 0 : y - offset; - const size_t maxh = std::min(ysize, y + square_size - offset); - for (size_t x = 0; x < xsize; ++x) { - double min = values[x + minh * xsize]; - for (size_t j = minh + 1; j < maxh; ++j) { - min = fmin(min, values[x + j * xsize]); - } - tmp[x + y * xsize] = min; - } - } - for (size_t x = 0; x < xsize; ++x) { - const size_t minw = offset > x ? 0 : x - offset; - const size_t maxw = std::min(xsize, x + square_size - offset); - for (size_t y = 0; y < ysize; ++y) { - double min = tmp[minw + y * xsize]; - for (size_t j = minw + 1; j < maxw; ++j) { - min = fmin(min, tmp[j + y * xsize]); - } - values[x + y * xsize] = min; - } - } -} - -// ===== Functions used by Mask only ===== -void Average5x5(int xsize, int ysize, std::vector* diffs) { - PROFILER_FUNC; - if (xsize < 4 || ysize < 4) { - // TODO: Make this work for small dimensions as well. - return; - } - static const float w = 0.679144890667; - static const float scale = 1.0 / (5.0 + 4 * w); - std::vector result = *diffs; - std::vector tmp0 = *diffs; - std::vector tmp1 = *diffs; - ScaleImage(w, &tmp1); - for (int y = 0; y < ysize; y++) { - const int row0 = y * xsize; - result[row0 + 1] += tmp0[row0]; - result[row0 + 0] += tmp0[row0 + 1]; - result[row0 + 2] += tmp0[row0 + 1]; - for (int x = 2; x < xsize - 2; ++x) { - result[row0 + x - 1] += tmp0[row0 + x]; - result[row0 + x + 1] += tmp0[row0 + x]; - } - result[row0 + xsize - 3] += tmp0[row0 + xsize - 2]; - result[row0 + xsize - 1] += tmp0[row0 + xsize - 2]; - result[row0 + xsize - 2] += tmp0[row0 + xsize - 1]; - if (y > 0) { - const int rowd1 = row0 - xsize; - result[rowd1 + 1] += tmp1[row0]; - result[rowd1 + 0] += tmp0[row0]; - for (int x = 1; x < xsize - 1; ++x) { - result[rowd1 + x + 1] += tmp1[row0 + x]; - result[rowd1 + x + 0] += tmp0[row0 + x]; - result[rowd1 + x - 1] += tmp1[row0 + x]; - } - result[rowd1 + xsize - 1] += tmp0[row0 + xsize - 1]; - result[rowd1 + xsize - 2] += tmp1[row0 + xsize - 1]; - } - if (y + 1 < ysize) { - const int rowu1 = row0 + xsize; - result[rowu1 + 1] += tmp1[row0]; - result[rowu1 + 0] += tmp0[row0]; - for (int x = 1; x < xsize - 1; ++x) { - result[rowu1 + x + 1] += tmp1[row0 + x]; - result[rowu1 + x + 0] += tmp0[row0 + x]; - result[rowu1 + x - 1] += tmp1[row0 + x]; - } - result[rowu1 + xsize - 1] += tmp0[row0 + xsize - 1]; - result[rowu1 + xsize - 2] += tmp1[row0 + xsize - 1]; - } - } - *diffs = result; - ScaleImage(scale, diffs); -} - -void DiffPrecompute( - const std::vector > &xyb0, - const std::vector > &xyb1, - size_t xsize, size_t ysize, - std::vector > *mask) { - PROFILER_FUNC; - mask->resize(3, std::vector(xyb0[0].size())); - double valsh0[3] = { 0.0 }; - double valsv0[3] = { 0.0 }; - double valsh1[3] = { 0.0 }; - double valsv1[3] = { 0.0 }; - int ix2; - for (size_t y = 0; y < ysize; ++y) { - for (size_t x = 0; x < xsize; ++x) { - size_t ix = x + xsize * y; - if (x + 1 < xsize) { - ix2 = ix + 1; - } else { - ix2 = ix - 1; - } - { - double x0 = (xyb0[0][ix] - xyb0[0][ix2]); - double y0 = (xyb0[1][ix] - xyb0[1][ix2]); - double z0 = (xyb0[2][ix] - xyb0[2][ix2]); - XybToVals(x0, y0, z0, &valsh0[0], &valsh0[1], &valsh0[2]); - double x1 = (xyb1[0][ix] - xyb1[0][ix2]); - double y1 = (xyb1[1][ix] - xyb1[1][ix2]); - double z1 = (xyb1[2][ix] - xyb1[2][ix2]); - XybToVals(x1, y1, z1, &valsh1[0], &valsh1[1], &valsh1[2]); - } - if (y + 1 < ysize) { - ix2 = ix + xsize; - } else { - ix2 = ix - xsize; - } - { - double x0 = (xyb0[0][ix] - xyb0[0][ix2]); - double y0 = (xyb0[1][ix] - xyb0[1][ix2]); - double z0 = (xyb0[2][ix] - xyb0[2][ix2]); - XybToVals(x0, y0, z0, &valsv0[0], &valsv0[1], &valsv0[2]); - double x1 = (xyb1[0][ix] - xyb1[0][ix2]); - double y1 = (xyb1[1][ix] - xyb1[1][ix2]); - double z1 = (xyb1[2][ix] - xyb1[2][ix2]); - XybToVals(x1, y1, z1, &valsv1[0], &valsv1[1], &valsv1[2]); - } - for (int i = 0; i < 3; ++i) { - double sup0 = fabs(valsh0[i]) + fabs(valsv0[i]); - double sup1 = fabs(valsh1[i]) + fabs(valsv1[i]); - double m = std::min(sup0, sup1); - (*mask)[i][ix] = m; - } - } - } -} - -void Mask(const std::vector > &xyb0, - const std::vector > &xyb1, - size_t xsize, size_t ysize, - std::vector > *mask, - std::vector > *mask_dc) { - PROFILER_FUNC; - mask->resize(3); - mask_dc->resize(3); - for (int i = 0; i < 3; ++i) { - (*mask)[i].resize(xsize * ysize); - (*mask_dc)[i].resize(xsize * ysize); - } - DiffPrecompute(xyb0, xyb1, xsize, ysize, mask); - for (int i = 0; i < 3; ++i) { - Average5x5(xsize, ysize, &(*mask)[i]); - MinSquareVal(4, 0, xsize, ysize, (*mask)[i].data()); - static const double sigma[3] = { - 9.65781083553, - 14.2644604355, - 4.53358927369, - }; - Blur(xsize, ysize, (*mask)[i].data(), sigma[i], 0.0); - } - static const double w00 = 232.206464018; - static const double w11 = 22.9455222245; - static const double w22 = 503.962310606; - - for (size_t y = 0; y < ysize; ++y) { - for (size_t x = 0; x < xsize; ++x) { - const size_t idx = y * xsize + x; - const double s0 = (*mask)[0][idx]; - const double s1 = (*mask)[1][idx]; - const double s2 = (*mask)[2][idx]; - const double p0 = w00 * s0; - const double p1 = w11 * s1; - const double p2 = w22 * s2; - - (*mask)[0][idx] = MaskX(p0); - (*mask)[1][idx] = MaskY(p1); - (*mask)[2][idx] = MaskB(p2); - (*mask_dc)[0][idx] = MaskDcX(p0); - (*mask_dc)[1][idx] = MaskDcY(p1); - (*mask_dc)[2][idx] = MaskDcB(p2); - } - } - for (int i = 0; i < 3; ++i) { - ScaleImage(kGlobalScale * kGlobalScale, &(*mask)[i]); - ScaleImage(kGlobalScale * kGlobalScale, &(*mask_dc)[i]); - } -} - -void ButteraugliDiffmap(const std::vector &rgb0_image, - const std::vector &rgb1_image, - ImageF &result_image) { - const size_t xsize = rgb0_image[0].xsize(); - const size_t ysize = rgb0_image[0].ysize(); - ButteraugliComparator butteraugli(xsize, ysize, 3); - butteraugli.Diffmap(rgb0_image, rgb1_image, result_image); -} - -bool ButteraugliInterface(const std::vector &rgb0, - const std::vector &rgb1, - ImageF &diffmap, - double &diffvalue) { - const size_t xsize = rgb0[0].xsize(); - const size_t ysize = rgb0[0].ysize(); - if (xsize < 1 || ysize < 1) { - // Butteraugli values for small (where xsize or ysize is smaller - // than 8 pixels) images are non-sensical, but most likely it is - // less disruptive to try to compute something than just give up. - return false; // No image. - } - for (int i = 1; i < 3; i++) { - if (rgb0[i].xsize() != xsize || rgb0[i].ysize() != ysize || - rgb1[i].xsize() != xsize || rgb1[i].ysize() != ysize) { - return false; // Image planes must have same dimensions. - } - } - if (xsize < 8 || ysize < 8) { - for (int y = 0; y < ysize; ++y) { - for (int x = 0; x < xsize; ++x) { - diffmap.Row(y)[x] = 0; - } - } - diffvalue = 0; - return true; - } - ButteraugliDiffmap(rgb0, rgb1, diffmap); - diffvalue = ButteraugliScoreFromDiffmap(diffmap); - return true; -} - -bool ButteraugliAdaptiveQuantization(size_t xsize, size_t ysize, - const std::vector > &rgb, std::vector &quant) { - if (xsize < 16 || ysize < 16) { - return false; // Butteraugli is undefined for small images. - } - size_t size = xsize * ysize; - - std::vector > scale_xyb(3); - std::vector > scale_xyb_dc(3); - Mask(rgb, rgb, xsize, ysize, &scale_xyb, &scale_xyb_dc); - quant.resize(size); - - // Mask gives us values in 3 color channels, but for now we take only - // the intensity channel. - for (size_t i = 0; i < size; i++) { - quant[i] = scale_xyb[1][i]; - } - return true; -} - -double ButteraugliFuzzyClass(double score) { - static const double fuzzy_width_up = 10.287189655; - static const double fuzzy_width_down = 6.97490803335; - static const double m0 = 2.0; - double fuzzy_width = score < 1.0 ? fuzzy_width_down : fuzzy_width_up; - return m0 / (1.0 + exp((score - 1.0) * fuzzy_width)); -} - -double ButteraugliFuzzyInverse(double seek) { - double pos = 0; - for (double range = 1.0; range >= 1e-10; range *= 0.5) { - double cur = ButteraugliFuzzyClass(pos); - if (cur < seek) { - pos -= range; - } else { - pos += range; - } - } - return pos; -} - -} // namespace butteraugli diff --git a/extern/butteraugli/butteraugli.h b/extern/butteraugli/butteraugli.h deleted file mode 100755 index 31824b88..00000000 --- a/extern/butteraugli/butteraugli.h +++ /dev/null @@ -1,560 +0,0 @@ -// Copyright 2016 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Disclaimer: This is not an official Google product. -// -// Author: Jyrki Alakuijala (jyrki.alakuijala@gmail.com) - -#ifndef BUTTERAUGLI_BUTTERAUGLI_H_ -#define BUTTERAUGLI_BUTTERAUGLI_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef PROFILER_ENABLED -#define PROFILER_ENABLED 0 -#endif -#if PROFILER_ENABLED -#else -#define PROFILER_FUNC -#define PROFILER_ZONE(name) -#endif - -#define BUTTERAUGLI_ENABLE_CHECKS 0 - -// This is the main interface to butteraugli image similarity -// analysis function. - -namespace butteraugli { - -template -class Image; - -using Image8 = Image; -using ImageF = Image; -using ImageD = Image; - -// ButteraugliInterface defines the public interface for butteraugli. -// -// It calculates the difference between rgb0 and rgb1. -// -// rgb0 and rgb1 contain the images. rgb0[c][px] and rgb1[c][px] contains -// the red image for c == 0, green for c == 1, blue for c == 2. Location index -// px is calculated as y * xsize + x. -// -// Value of pixels of images rgb0 and rgb1 need to be represented as raw -// intensity. Most image formats store gamma corrected intensity in pixel -// values. This gamma correction has to be removed, by applying the following -// function: -// butteraugli_val = 255.0 * pow(png_val / 255.0, gamma); -// A typical value of gamma is 2.2. It is usually stored in the image header. -// Take care not to confuse that value with its inverse. The gamma value should -// be always greater than one. -// Butteraugli does not work as intended if the caller does not perform -// gamma correction. -// -// diffmap will contain an image of the size xsize * ysize, containing -// localized differences for values px (indexed with the px the same as rgb0 -// and rgb1). diffvalue will give a global score of similarity. -// -// A diffvalue smaller than kButteraugliGood indicates that images can be -// observed as the same image. -// diffvalue larger than kButteraugliBad indicates that a difference between -// the images can be observed. -// A diffvalue between kButteraugliGood and kButteraugliBad indicates that -// a subtle difference can be observed between the images. -// -// Returns true on success. - -bool ButteraugliInterface(const std::vector &rgb0, - const std::vector &rgb1, - ImageF &diffmap, - double &diffvalue); - -const double kButteraugliQuantLow = 0.26; -const double kButteraugliQuantHigh = 1.454; - -// Converts the butteraugli score into fuzzy class values that are continuous -// at the class boundary. The class boundary location is based on human -// raters, but the slope is arbitrary. Particularly, it does not reflect -// the expectation value of probabilities of the human raters. It is just -// expected that a smoother class boundary will allow for higher-level -// optimization algorithms to work faster. -// -// Returns 2.0 for a perfect match, and 1.0 for 'ok', 0.0 for bad. Because the -// scoring is fuzzy, a butteraugli score of 0.96 would return a class of -// around 1.9. -double ButteraugliFuzzyClass(double score); - -// Input values should be in range 0 (bad) to 2 (good). Use -// kButteraugliNormalization as normalization. -double ButteraugliFuzzyInverse(double seek); - -// Returns a map which can be used for adaptive quantization. Values can -// typically range from kButteraugliQuantLow to kButteraugliQuantHigh. Low -// values require coarse quantization (e.g. near random noise), high values -// require fine quantization (e.g. in smooth bright areas). -bool ButteraugliAdaptiveQuantization(size_t xsize, size_t ysize, - const std::vector > &rgb, std::vector &quant); - -// Implementation details, don't use anything below or your code will -// break in the future. - -#ifdef _MSC_VER -#define BUTTERAUGLI_RESTRICT __restrict -#else -#define BUTTERAUGLI_RESTRICT __restrict__ -#endif - -#ifdef _MSC_VER -#define BUTTERAUGLI_CACHE_ALIGNED_RETURN /* not supported */ -#else -#define BUTTERAUGLI_CACHE_ALIGNED_RETURN __attribute__((assume_aligned(64))) -#endif - -// Alias for unchangeable, non-aliased pointers. T is a pointer type, -// possibly to a const type. Example: ConstRestrict ptr = nullptr. -// The conventional syntax uint8_t* const RESTRICT is more confusing - it is -// not immediately obvious that the pointee is non-const. -template -using ConstRestrict = T const BUTTERAUGLI_RESTRICT; - -// Functions that depend on the cache line size. -class CacheAligned { - public: - static constexpr size_t kPointerSize = sizeof(void *); - static constexpr size_t kCacheLineSize = 64; - - // The aligned-return annotation is only allowed on function declarations. - static void *Allocate(const size_t bytes) BUTTERAUGLI_CACHE_ALIGNED_RETURN; - static void Free(void *aligned_pointer); -}; - -template -using CacheAlignedUniquePtrT = std::unique_ptr; - -using CacheAlignedUniquePtr = CacheAlignedUniquePtrT; - -template -static inline CacheAlignedUniquePtrT Allocate(const size_t entries) { - return CacheAlignedUniquePtrT( - static_cast>( - CacheAligned::Allocate(entries * sizeof(T))), - CacheAligned::Free); -} - -// Returns the smallest integer not less than "amount" that is divisible by -// "multiple", which must be a power of two. -template -static inline size_t Align(const size_t amount) { - static_assert(multiple != 0 && ((multiple & (multiple - 1)) == 0), - "Align<> argument must be a power of two"); - return (amount + multiple - 1) & ~(multiple - 1); -} - -// Single channel, contiguous (cache-aligned) rows separated by padding. -// T must be POD. -// -// Rationale: vectorization benefits from aligned operands - unaligned loads and -// especially stores are expensive when the address crosses cache line -// boundaries. Introducing padding after each row ensures the start of a row is -// aligned, and that row loops can process entire vectors (writes to the padding -// are allowed and ignored). -// -// We prefer a planar representation, where channels are stored as separate -// 2D arrays, because that simplifies vectorization (repeating the same -// operation on multiple adjacent components) without the complexity of a -// hybrid layout (8 R, 8 G, 8 B, ...). In particular, clients can easily iterate -// over all components in a row and Image requires no knowledge of the pixel -// format beyond the component type "T". The downside is that we duplicate the -// xsize/ysize members for each channel. -// -// This image layout could also be achieved with a vector and a row accessor -// function, but a class wrapper with support for "deleter" allows wrapping -// existing memory allocated by clients without copying the pixels. It also -// provides convenient accessors for xsize/ysize, which shortens function -// argument lists. Supports move-construction so it can be stored in containers. -template -class Image { - // Returns cache-aligned row stride, being careful to avoid 2K aliasing. - static size_t BytesPerRow(const size_t xsize) { - // Allow reading one extra AVX-2 vector on the right margin. - const size_t row_size = xsize * sizeof(T) + 32; - const size_t align = CacheAligned::kCacheLineSize; - size_t bytes_per_row = (row_size + align - 1) & ~(align - 1); - // During the lengthy window before writes are committed to memory, CPUs - // guard against read after write hazards by checking the address, but - // only the lower 11 bits. We avoid a false dependency between writes to - // consecutive rows by ensuring their sizes are not multiples of 2 KiB. - if (bytes_per_row % 2048 == 0) { - bytes_per_row += align; - } - return bytes_per_row; - } - - public: - using T = ComponentType; - - Image() : xsize_(0), ysize_(0), bytes_per_row_(0), bytes_(nullptr, Ignore) {} - - Image(const size_t xsize, const size_t ysize) - : xsize_(xsize), - ysize_(ysize), - bytes_per_row_(BytesPerRow(xsize)), - bytes_(Allocate(bytes_per_row_ * ysize)) {} - - Image(const size_t xsize, const size_t ysize, ConstRestrict bytes, - const size_t bytes_per_row) - : xsize_(xsize), - ysize_(ysize), - bytes_per_row_(bytes_per_row), - bytes_(bytes, Ignore) {} - - // Move constructor (required for returning Image from function) - Image(Image &&other) - : xsize_(other.xsize_), - ysize_(other.ysize_), - bytes_per_row_(other.bytes_per_row_), - bytes_(std::move(other.bytes_)) {} - - // Move assignment (required for std::vector) - Image &operator=(Image &&other) { - xsize_ = other.xsize_; - ysize_ = other.ysize_; - bytes_per_row_ = other.bytes_per_row_; - bytes_ = std::move(other.bytes_); - return *this; - } - - void Swap(Image &other) { - std::swap(xsize_, other.xsize_); - std::swap(ysize_, other.ysize_); - std::swap(bytes_per_row_, other.bytes_per_row_); - std::swap(bytes_, other.bytes_); - } - - // How many pixels. - size_t xsize() const { return xsize_; } - size_t ysize() const { return ysize_; } - - ConstRestrict Row(const size_t y) BUTTERAUGLI_CACHE_ALIGNED_RETURN { -#ifdef BUTTERAUGLI_ENABLE_CHECKS - if (y >= ysize_) { - printf("Row %zu out of bounds (ysize=%zu)\n", y, ysize_); - abort(); - } -#endif - return reinterpret_cast(bytes_.get() + y * bytes_per_row_); - } - - ConstRestrict Row(const size_t y) const - BUTTERAUGLI_CACHE_ALIGNED_RETURN { -#ifdef BUTTERAUGLI_ENABLE_CHECKS - if (y >= ysize_) { - printf("Const row %zu out of bounds (ysize=%zu)\n", y, ysize_); - abort(); - } -#endif - return reinterpret_cast(bytes_.get() + y * bytes_per_row_); - } - - // Raw access to byte contents, for interfacing with other libraries. - // Unsigned char instead of char to avoid surprises (sign extension). - ConstRestrict bytes() { return bytes_.get(); } - ConstRestrict bytes() const { return bytes_.get(); } - size_t bytes_per_row() const { return bytes_per_row_; } - - // Returns number of pixels (some of which are padding) per row. Useful for - // computing other rows via pointer arithmetic. - intptr_t PixelsPerRow() const { - static_assert(CacheAligned::kCacheLineSize % sizeof(T) == 0, - "Padding must be divisible by the pixel size."); - return static_cast(bytes_per_row_ / sizeof(T)); - } - - private: - // Deleter used when bytes are not owned. - static void Ignore(void *ptr) {} - - // (Members are non-const to enable assignment during move-assignment.) - size_t xsize_; // original intended pixels, not including any padding. - size_t ysize_; - size_t bytes_per_row_; // [bytes] including padding. - CacheAlignedUniquePtr bytes_; -}; - -// Returns newly allocated planes of the given dimensions. -template -static inline std::vector> CreatePlanes(const size_t xsize, - const size_t ysize, - const size_t num_planes) { - std::vector> planes; - planes.reserve(num_planes); - for (size_t i = 0; i < num_planes; ++i) { - planes.emplace_back(xsize, ysize); - } - return planes; -} - -// Returns a new image with the same dimensions and pixel values. -template -static inline Image CopyPixels(const Image &other) { - Image copy(other.xsize(), other.ysize()); - const void *BUTTERAUGLI_RESTRICT from = other.bytes(); - void *BUTTERAUGLI_RESTRICT to = copy.bytes(); - memcpy(to, from, other.ysize() * other.bytes_per_row()); - return copy; -} - -// Returns new planes with the same dimensions and pixel values. -template -static inline std::vector> CopyPlanes( - const std::vector> &planes) { - std::vector> copy; - copy.reserve(planes.size()); - for (const Image &plane : planes) { - copy.push_back(CopyPixels(plane)); - } - return copy; -} - -// Compacts a padded image into a preallocated packed vector. -template -static inline void CopyToPacked(const Image &from, std::vector *to) { - const size_t xsize = from.xsize(); - const size_t ysize = from.ysize(); -#if BUTTERAUGLI_ENABLE_CHECKS - if (to->size() < xsize * ysize) { - printf("%zu x %zu exceeds %zu capacity\n", xsize, ysize, to->size()); - abort(); - } -#endif - for (size_t y = 0; y < ysize; ++y) { - ConstRestrict row_from = from.Row(y); - ConstRestrict row_to = to->data() + y * xsize; - memcpy(row_to, row_from, xsize * sizeof(T)); - } -} - -// Expands a packed vector into a preallocated padded image. -template -static inline void CopyFromPacked(const std::vector &from, Image *to) { - const size_t xsize = to->xsize(); - const size_t ysize = to->ysize(); - assert(from.size() == xsize * ysize); - for (size_t y = 0; y < ysize; ++y) { - ConstRestrict row_from = from.data() + y * xsize; - ConstRestrict row_to = to->Row(y); - memcpy(row_to, row_from, xsize * sizeof(T)); - } -} - -template -static inline std::vector> PlanesFromPacked( - const size_t xsize, const size_t ysize, - const std::vector> &packed) { - std::vector> planes; - planes.reserve(packed.size()); - for (const std::vector &p : packed) { - planes.push_back(Image(xsize, ysize)); - CopyFromPacked(p, &planes.back()); - } - return planes; -} - -template -static inline std::vector> PackedFromPlanes( - const std::vector> &planes) { - assert(!planes.empty()); - const size_t num_pixels = planes[0].xsize() * planes[0].ysize(); - std::vector> packed; - packed.reserve(planes.size()); - for (const Image &image : planes) { - packed.push_back(std::vector(num_pixels)); - CopyToPacked(image, &packed.back()); - } - return packed; -} - -class ButteraugliComparator { - public: - ButteraugliComparator(size_t xsize, size_t ysize, int step); - - // Computes the butteraugli map between rgb0 and rgb1 and updates result. - void Diffmap(const std::vector &rgb0, - const std::vector &rgb1, - ImageF &result); - - // Same as above, but OpsinDynamicsImage() was already applied to - // rgb0 and rgb1. - void DiffmapOpsinDynamicsImage(const std::vector &rgb0, - const std::vector &rgb1, - ImageF &result); - - private: - void BlockDiffMap(const std::vector > &rgb0, - const std::vector > &rgb1, - std::vector* block_diff_dc, - std::vector* block_diff_ac); - - - void EdgeDetectorMap(const std::vector > &rgb0, - const std::vector > &rgb1, - std::vector* edge_detector_map); - - void EdgeDetectorLowFreq(const std::vector > &rgb0, - const std::vector > &rgb1, - std::vector* block_diff_ac); - - void CombineChannels(const std::vector >& scale_xyb, - const std::vector >& scale_xyb_dc, - const std::vector& block_diff_dc, - const std::vector& block_diff_ac, - const std::vector& edge_detector_map, - std::vector* result); - - const size_t xsize_; - const size_t ysize_; - const size_t num_pixels_; - const int step_; - const size_t res_xsize_; - const size_t res_ysize_; -}; - -void ButteraugliDiffmap(const std::vector &rgb0, - const std::vector &rgb1, - ImageF &diffmap); - -double ButteraugliScoreFromDiffmap(const ImageF& distmap); - -// Compute values of local frequency and dc masking based on the activity -// in the two images. -void Mask(const std::vector > &rgb0, - const std::vector > &rgb1, - size_t xsize, size_t ysize, - std::vector > *mask, - std::vector > *mask_dc); - -// Computes difference metrics for one 8x8 block. -void ButteraugliBlockDiff(double rgb0[192], - double rgb1[192], - double diff_xyb_dc[3], - double diff_xyb_ac[3], - double diff_xyb_edge_dc[3]); - -void OpsinAbsorbance(const double in[3], double out[3]); - -void OpsinDynamicsImage(size_t xsize, size_t ysize, - std::vector > &rgb); - -void MaskHighIntensityChange( - size_t xsize, size_t ysize, - const std::vector > &c0, - const std::vector > &c1, - std::vector > &rgb0, - std::vector > &rgb1); - -void Blur(size_t xsize, size_t ysize, float* channel, double sigma, - double border_ratio = 0.0); - -void RgbToXyb(double r, double g, double b, - double *valx, double *valy, double *valz); - -double SimpleGamma(double v); - -double GammaMinArg(); -double GammaMaxArg(); - -// Polynomial evaluation via Clenshaw's scheme (similar to Horner's). -// Template enables compile-time unrolling of the recursion, but must reside -// outside of a class due to the specialization. -template -static inline void ClenshawRecursion(const double x, const double *coefficients, - double *b1, double *b2) { - const double x_b1 = x * (*b1); - const double t = (x_b1 + x_b1) - (*b2) + coefficients[INDEX]; - *b2 = *b1; - *b1 = t; - - ClenshawRecursion(x, coefficients, b1, b2); -} - -// Base case -template <> -inline void ClenshawRecursion<0>(const double x, const double *coefficients, - double *b1, double *b2) { - const double x_b1 = x * (*b1); - // The final iteration differs - no 2 * x_b1 here. - *b1 = x_b1 - (*b2) + coefficients[0]; -} - -// Rational polynomial := dividing two polynomial evaluations. These are easier -// to find than minimax polynomials. -struct RationalPolynomial { - template - static double EvaluatePolynomial(const double x, - const double (&coefficients)[N]) { - double b1 = 0.0; - double b2 = 0.0; - ClenshawRecursion(x, coefficients, &b1, &b2); - return b1; - } - - // Evaluates the polynomial at x (in [min_value, max_value]). - inline double operator()(const float x) const { - // First normalize to [0, 1]. - const double x01 = (x - min_value) / (max_value - min_value); - // And then to [-1, 1] domain of Chebyshev polynomials. - const double xc = 2.0 * x01 - 1.0; - - const double yp = EvaluatePolynomial(xc, p); - const double yq = EvaluatePolynomial(xc, q); - if (yq == 0.0) return 0.0; - return static_cast(yp / yq); - } - - // Domain of the polynomials; they are undefined elsewhere. - double min_value; - double max_value; - - // Coefficients of T_n (Chebyshev polynomials of the first kind). - // Degree 5/5 is a compromise between accuracy (0.1%) and numerical stability. - double p[5 + 1]; - double q[5 + 1]; -}; - -static inline float GammaPolynomial(float value) { - // Generated by gamma_polynomial.m from equispaced x/gamma(x) samples. - static const RationalPolynomial r = { - 0.770000000000000, 274.579999999999984, - { - 881.979476556478289, 1496.058452015812463, 908.662212739659481, - 373.566100223287378, 85.840860336314364, 6.683258861509244, - }, - { - 12.262350348616792, 20.557285797683576, 12.161463238367844, - 4.711532733641639, 0.899112889751053, 0.035662329617191, - }}; - return r(value); -} - -} // namespace butteraugli - -#endif // BUTTERAUGLI_BUTTERAUGLI_H_ diff --git a/extern/glew/LICENSE.txt b/extern/glew/LICENSE.txt deleted file mode 100644 index 89d74b80..00000000 --- a/extern/glew/LICENSE.txt +++ /dev/null @@ -1,73 +0,0 @@ -The OpenGL Extension Wrangler Library -Copyright (C) 2002-2007, Milan Ikits -Copyright (C) 2002-2007, Marcelo E. Magallon -Copyright (C) 2002, Lev Povalahev -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -* 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. -* The name of the author may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. - - -Mesa 3-D graphics library -Version: 7.0 - -Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -Copyright (c) 2007 The Khronos Group Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and/or associated documentation files (the -"Materials"), to deal in the Materials without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Materials, and to -permit persons to whom the Materials are furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Materials. - -THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. diff --git a/extern/glew/README.txt b/extern/glew/README.txt deleted file mode 100644 index 5fe48528..00000000 --- a/extern/glew/README.txt +++ /dev/null @@ -1,18 +0,0 @@ -See doc/index.html for more information. - -If you downloaded the tarball from the GLEW website, you just need to: - - Unix: - - make - - Windows: - - use the project file in build/vc6/ - -If you wish to build GLEW from scratch (update the extension data from -the net or add your own extension information), you need a Unix -environment (including wget, perl, and GNU make). The extension data -is regenerated from the top level source directory with: - - make extensions diff --git a/extern/glew/bin/glew32.dll b/extern/glew/bin/glew32.dll deleted file mode 100755 index e3707632..00000000 Binary files a/extern/glew/bin/glew32.dll and /dev/null differ diff --git a/extern/glew/include/GL/glew.h b/extern/glew/include/GL/glew.h deleted file mode 100755 index 2188402b..00000000 --- a/extern/glew/include/GL/glew.h +++ /dev/null @@ -1,13369 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * 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. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __glew_h__ -#define __glew_h__ -#define __GLEW_H__ - -#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H) -#error gl.h included before glew.h -#endif -#if defined(__glext_h_) || defined(__GLEXT_H_) -#error glext.h included before glew.h -#endif -#if defined(__gl_ATI_h_) -#error glATI.h included before glew.h -#endif - -#define __gl_h_ -#define __GL_H__ -#define __X_GL_H -#define __glext_h_ -#define __GLEXT_H_ -#define __gl_ATI_h_ - -#if defined(_WIN32) - -/* - * GLEW does not include to avoid name space pollution. - * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t - * defined properly. - */ -/* */ -#ifndef APIENTRY -#define GLEW_APIENTRY_DEFINED -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define APIENTRY __stdcall -# elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) -# define APIENTRY __stdcall -# else -# define APIENTRY -# endif -#endif -#ifndef GLAPI -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define GLAPI extern -# endif -#endif -/* */ -#ifndef CALLBACK -#define GLEW_CALLBACK_DEFINED -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define CALLBACK __attribute__ ((__stdcall__)) -# elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) -# define CALLBACK __stdcall -# else -# define CALLBACK -# endif -#endif -/* and */ -#ifndef WINGDIAPI -#define GLEW_WINGDIAPI_DEFINED -#define WINGDIAPI __declspec(dllimport) -#endif -/* */ -#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) -typedef unsigned short wchar_t; -# define _WCHAR_T_DEFINED -#endif -/* */ -#if !defined(_W64) -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif -#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) -# ifdef _WIN64 -typedef __int64 ptrdiff_t; -# else -typedef _W64 int ptrdiff_t; -# endif -# define _PTRDIFF_T_DEFINED -# define _PTRDIFF_T_ -#endif - -#ifndef GLAPI -# if defined(__MINGW32__) || defined(__CYGWIN__) -# define GLAPI extern -# else -# define GLAPI WINGDIAPI -# endif -#endif - -#ifndef GLAPIENTRY -#define GLAPIENTRY APIENTRY -#endif - -/* - * GLEW_STATIC needs to be set when using the static version. - * GLEW_BUILD is set when building the DLL version. - */ -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# ifdef GLEW_BUILD -# define GLEWAPI extern __declspec(dllexport) -# else -# define GLEWAPI extern __declspec(dllimport) -# endif -#endif - -#else /* _UNIX */ - -/* - * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO - * C. On my system, this amounts to _3 lines_ of included code, all of - * them pretty much harmless. If you know of a way of detecting 32 vs - * 64 _targets_ at compile time you are free to replace this with - * something that's portable. For now, _this_ is the portable solution. - * (mem, 2004-01-04) - */ - -#include -#include - -#define GLEW_APIENTRY_DEFINED -#define APIENTRY -#define GLEWAPI extern - -/* */ -#ifndef GLAPI -#define GLAPI extern -#endif -#ifndef GLAPIENTRY -#define GLAPIENTRY -#endif - -#endif /* _WIN32 */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ - -#ifndef GL_VERSION_1_1 -#define GL_VERSION_1_1 1 - -typedef unsigned int GLenum; -typedef unsigned int GLbitfield; -typedef unsigned int GLuint; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLboolean; -typedef signed char GLbyte; -typedef short GLshort; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned long GLulong; -typedef float GLfloat; -typedef float GLclampf; -typedef double GLdouble; -typedef double GLclampd; -typedef void GLvoid; -#if defined(_MSC_VER) -# if _MSC_VER < 1400 -typedef __int64 GLint64EXT; -typedef unsigned __int64 GLuint64EXT; -# else -typedef signed long long GLint64EXT; -typedef unsigned long long GLuint64EXT; -# endif -#else -# if defined(__MINGW32__) || defined(__CYGWIN__) -#include -# endif -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif -typedef GLint64EXT GLint64; -typedef GLuint64EXT GLuint64; -typedef struct __GLsync *GLsync; - -#define GL_ACCUM 0x0100 -#define GL_LOAD 0x0101 -#define GL_RETURN 0x0102 -#define GL_MULT 0x0103 -#define GL_ADD 0x0104 -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_CURRENT_BIT 0x00000001 -#define GL_POINT_BIT 0x00000002 -#define GL_LINE_BIT 0x00000004 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_HINT_BIT 0x00008000 -#define GL_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000fffff -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON 0x0009 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_TRUE 1 -#define GL_FALSE 0 -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_LINE_RESET_TOKEN 0x0707 -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LIST_MODE 0x0B30 -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_SHADE_MODEL 0x0B54 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_FOG 0x0B60 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_NORMALIZE 0x0BA1 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_INDEX_MODE 0x0C30 -#define GL_RGBA_MODE 0x0C31 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_RENDER_MODE 0x0C40 -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_INDEX_BITS 0x0D51 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_BORDER 0x1005 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_COLOR_INDEX 0x1900 -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_BITMAP 0x1A00 -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -#define GL_RENDER 0x1C00 -#define GL_FEEDBACK 0x1C01 -#define GL_SELECT 0x1C02 -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 -#define GL_TEXTURE_ENV 0x2300 -#define GL_EYE_LINEAR 0x2400 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_SPHERE_MAP 0x2402 -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_PLANE 0x2502 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_CLAMP 0x2900 -#define GL_REPEAT 0x2901 -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D -#define GL_LOGIC_OP GL_INDEX_LOGIC_OP -#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 - -GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); -GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); -GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void GLAPIENTRY glArrayElement (GLint i); -GLAPI void GLAPIENTRY glBegin (GLenum mode); -GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); -GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); -GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GLAPI void GLAPIENTRY glCallList (GLuint list); -GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); -GLAPI void GLAPIENTRY glClear (GLbitfield mask); -GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); -GLAPI void GLAPIENTRY glClearIndex (GLfloat c); -GLAPI void GLAPIENTRY glClearStencil (GLint s); -GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); -GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); -GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); -GLAPI void GLAPIENTRY glColor3iv (const GLint *v); -GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); -GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); -GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); -GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); -GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); -GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void GLAPIENTRY glColor4iv (const GLint *v); -GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); -GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); -GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); -GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); -GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); -GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); -GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); -GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); -GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glCullFace (GLenum mode); -GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); -GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GLAPI void GLAPIENTRY glDepthFunc (GLenum func); -GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); -GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); -GLAPI void GLAPIENTRY glDisable (GLenum cap); -GLAPI void GLAPIENTRY glDisableClientState (GLenum array); -GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); -GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); -GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); -GLAPI void GLAPIENTRY glEnable (GLenum cap); -GLAPI void GLAPIENTRY glEnableClientState (GLenum array); -GLAPI void GLAPIENTRY glEnd (void); -GLAPI void GLAPIENTRY glEndList (void); -GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); -GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); -GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); -GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); -GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); -GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); -GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); -GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); -GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); -GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); -GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); -GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); -GLAPI void GLAPIENTRY glFinish (void); -GLAPI void GLAPIENTRY glFlush (void); -GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glFrontFace (GLenum mode); -GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); -GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); -GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); -GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); -GLAPI GLenum GLAPIENTRY glGetError (void); -GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); -GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); -GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); -GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); -GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); -GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); -GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params); -GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); -GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); -GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); -GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); -GLAPI void GLAPIENTRY glIndexMask (GLuint mask); -GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glIndexd (GLdouble c); -GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); -GLAPI void GLAPIENTRY glIndexf (GLfloat c); -GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); -GLAPI void GLAPIENTRY glIndexi (GLint c); -GLAPI void GLAPIENTRY glIndexiv (const GLint *c); -GLAPI void GLAPIENTRY glIndexs (GLshort c); -GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); -GLAPI void GLAPIENTRY glIndexub (GLubyte c); -GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); -GLAPI void GLAPIENTRY glInitNames (void); -GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); -GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); -GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); -GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); -GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); -GLAPI void GLAPIENTRY glLineWidth (GLfloat width); -GLAPI void GLAPIENTRY glListBase (GLuint base); -GLAPI void GLAPIENTRY glLoadIdentity (void); -GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); -GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); -GLAPI void GLAPIENTRY glLoadName (GLuint name); -GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); -GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); -GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); -GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); -GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); -GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); -GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); -GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); -GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); -GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); -GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); -GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); -GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void GLAPIENTRY glPassThrough (GLfloat token); -GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); -GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); -GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); -GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); -GLAPI void GLAPIENTRY glPointSize (GLfloat size); -GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); -GLAPI void GLAPIENTRY glPopAttrib (void); -GLAPI void GLAPIENTRY glPopClientAttrib (void); -GLAPI void GLAPIENTRY glPopMatrix (void); -GLAPI void GLAPIENTRY glPopName (void); -GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); -GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); -GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); -GLAPI void GLAPIENTRY glPushMatrix (void); -GLAPI void GLAPIENTRY glPushName (GLuint name); -GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); -GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); -GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); -GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); -GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); -GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); -GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); -GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); -GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); -GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); -GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); -GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); -GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); -GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); -GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); -GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); -GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); -GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); -GLAPI void GLAPIENTRY glShadeModel (GLenum mode); -GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GLAPI void GLAPIENTRY glStencilMask (GLuint mask); -GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); -GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); -GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord1i (GLint s); -GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); -GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); -GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); -GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); -GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); -GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); -GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); -GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); -GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); -GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); -GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); -GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); -GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); -GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); -GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); -GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); -GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); -GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); -GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) - -#endif /* GL_VERSION_1_1 */ - -/* ---------------------------------- GLU ---------------------------------- */ - -/* this is where we can safely include GLU */ -#if defined(__APPLE__) && defined(__MACH__) -#include -#else -#include -#endif - -/* ----------------------------- GL_VERSION_1_2 ---------------------------- */ - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 - -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E - -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); - -#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) -#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) -#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) -#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) - -#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) - -#endif /* GL_VERSION_1_2 */ - -/* ----------------------------- GL_VERSION_1_3 ---------------------------- */ - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 - -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_SUBTRACT 0x84E7 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#define GL_MULTISAMPLE_BIT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); - -#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) -#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) -#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) -#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) -#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) -#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) -#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) -#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) -#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) -#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) -#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) -#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) -#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) -#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) -#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) -#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) -#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) -#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) -#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) -#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) -#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) -#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) -#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) -#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) -#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) -#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) -#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) -#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) -#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) -#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) -#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) -#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) -#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) -#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) -#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) -#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) -#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) -#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) -#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) -#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) -#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) -#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) -#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) -#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) -#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) -#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) - -#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) - -#endif /* GL_VERSION_1_3 */ - -/* ----------------------------- GL_VERSION_1_4 ---------------------------- */ - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 - -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E - -typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); - -#define glBlendColor GLEW_GET_FUN(__glewBlendColor) -#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) -#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) -#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) -#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) -#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) -#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) -#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) -#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) -#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) -#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) -#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) -#define glPointParameteri GLEW_GET_FUN(__glewPointParameteri) -#define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv) -#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) -#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) -#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) -#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) -#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) -#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) -#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) -#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) -#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) -#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) -#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) -#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) -#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) -#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) -#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) -#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) -#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) -#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) -#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) -#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) -#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) -#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) -#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) -#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) -#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) -#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) -#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) -#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) -#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) -#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) -#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) -#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) -#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) - -#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) - -#endif /* GL_VERSION_1_4 */ - -/* ----------------------------- GL_VERSION_1_5 ---------------------------- */ - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 - -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 - -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); -typedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); - -#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) -#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) -#define glBufferData GLEW_GET_FUN(__glewBufferData) -#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) -#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) -#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) -#define glEndQuery GLEW_GET_FUN(__glewEndQuery) -#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) -#define glGenQueries GLEW_GET_FUN(__glewGenQueries) -#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) -#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) -#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) -#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) -#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) -#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) -#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) -#define glIsQuery GLEW_GET_FUN(__glewIsQuery) -#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) -#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) - -#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) - -#endif /* GL_VERSION_1_5 */ - -/* ----------------------------- GL_VERSION_2_0 ---------------------------- */ - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 - -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 - -typedef char GLchar; - -typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); -typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); -typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); -typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); -typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); -typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); -typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); - -#define glAttachShader GLEW_GET_FUN(__glewAttachShader) -#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) -#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) -#define glCompileShader GLEW_GET_FUN(__glewCompileShader) -#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) -#define glCreateShader GLEW_GET_FUN(__glewCreateShader) -#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) -#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) -#define glDetachShader GLEW_GET_FUN(__glewDetachShader) -#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) -#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) -#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) -#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) -#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) -#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) -#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) -#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) -#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) -#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) -#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) -#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) -#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) -#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) -#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) -#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) -#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) -#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) -#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) -#define glIsProgram GLEW_GET_FUN(__glewIsProgram) -#define glIsShader GLEW_GET_FUN(__glewIsShader) -#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) -#define glShaderSource GLEW_GET_FUN(__glewShaderSource) -#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) -#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) -#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) -#define glUniform1f GLEW_GET_FUN(__glewUniform1f) -#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) -#define glUniform1i GLEW_GET_FUN(__glewUniform1i) -#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) -#define glUniform2f GLEW_GET_FUN(__glewUniform2f) -#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) -#define glUniform2i GLEW_GET_FUN(__glewUniform2i) -#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) -#define glUniform3f GLEW_GET_FUN(__glewUniform3f) -#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) -#define glUniform3i GLEW_GET_FUN(__glewUniform3i) -#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) -#define glUniform4f GLEW_GET_FUN(__glewUniform4f) -#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) -#define glUniform4i GLEW_GET_FUN(__glewUniform4i) -#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) -#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) -#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) -#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) -#define glUseProgram GLEW_GET_FUN(__glewUseProgram) -#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) -#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) -#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) -#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) -#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) -#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) -#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) -#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) -#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) -#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) -#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) -#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) -#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) -#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) -#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) -#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) -#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) -#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) -#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) -#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) -#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) -#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) -#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) -#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) -#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) -#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) -#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) -#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) -#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) -#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) -#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) -#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) -#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) -#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) -#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) -#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) -#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) -#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) - -#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) - -#endif /* GL_VERSION_2_0 */ - -/* ----------------------------- GL_VERSION_2_1 ---------------------------- */ - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 - -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B - -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - -#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) -#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) -#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) -#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) -#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) -#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) - -#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) - -#endif /* GL_VERSION_2_1 */ - -/* ----------------------------- GL_VERSION_3_0 ---------------------------- */ - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 - -#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES -#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 -#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 -#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 -#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB -#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 -#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 -#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 -#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 -#define GL_STENCIL_BUFFER 0x8224 -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_ALPHA_INTEGER 0x8D97 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint, GLenum); -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum); -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint, GLuint, const GLchar*); -typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum, GLenum); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum, GLint, GLfloat, GLint); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum, GLint, const GLfloat*); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum, GLint, const GLint*); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum, GLint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -typedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum, GLuint, GLboolean*); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint, const GLchar*); -typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum, GLenum, GLint*); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum, GLenum, GLuint*); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint, GLuint, GLint*); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint, GLint, GLuint*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint, GLenum, GLint*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint, GLenum, GLuint*); -typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum, GLenum, const GLint*); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum, GLenum, const GLuint*); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint, GLsizei, const GLchar **, GLenum); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint, GLuint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint, GLint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint, GLint, GLint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint, const GLbyte*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint, GLint, GLint, GLint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint, const GLshort*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint, const GLubyte*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint, GLuint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint, const GLushort*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum, GLsizei, const GLvoid*); - -#define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender) -#define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback) -#define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation) -#define glClampColor GLEW_GET_FUN(__glewClampColor) -#define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi) -#define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv) -#define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv) -#define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv) -#define glColorMaski GLEW_GET_FUN(__glewColorMaski) -#define glDisablei GLEW_GET_FUN(__glewDisablei) -#define glEnablei GLEW_GET_FUN(__glewEnablei) -#define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender) -#define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback) -#define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v) -#define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation) -#define glGetStringi GLEW_GET_FUN(__glewGetStringi) -#define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv) -#define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv) -#define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying) -#define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv) -#define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv) -#define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv) -#define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi) -#define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv) -#define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv) -#define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings) -#define glUniform1ui GLEW_GET_FUN(__glewUniform1ui) -#define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv) -#define glUniform2ui GLEW_GET_FUN(__glewUniform2ui) -#define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv) -#define glUniform3ui GLEW_GET_FUN(__glewUniform3ui) -#define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv) -#define glUniform4ui GLEW_GET_FUN(__glewUniform4ui) -#define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv) -#define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i) -#define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv) -#define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui) -#define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv) -#define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i) -#define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv) -#define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui) -#define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv) -#define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i) -#define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv) -#define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui) -#define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv) -#define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv) -#define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i) -#define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv) -#define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv) -#define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv) -#define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui) -#define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv) -#define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv) -#define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer) - -#define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0) - -#endif /* GL_VERSION_3_0 */ - -/* ----------------------------- GL_VERSION_3_1 ---------------------------- */ - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 - -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum, GLint, GLsizei, GLsizei); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum, GLsizei, GLenum, const GLvoid*, GLsizei); -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint); -typedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum, GLenum, GLuint); - -#define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced) -#define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced) -#define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex) -#define glTexBuffer GLEW_GET_FUN(__glewTexBuffer) - -#define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1) - -#endif /* GL_VERSION_3_1 */ - -/* ----------------------------- GL_VERSION_3_2 ---------------------------- */ - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 - -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum, GLenum, GLuint, GLint); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum, GLenum, GLint64 *); -typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum, GLuint, GLint64 *); - -#define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture) -#define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v) -#define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v) - -#define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2) - -#endif /* GL_VERSION_3_2 */ - -/* -------------------------- GL_3DFX_multisample -------------------------- */ - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 - -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 - -#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) - -#endif /* GL_3DFX_multisample */ - -/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 - -typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); - -#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) - -#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) - -#endif /* GL_3DFX_tbuffer */ - -/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 - -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 - -#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) - -#endif /* GL_3DFX_texture_compression_FXT1 */ - -/* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */ - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); - -#define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD) -#define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD) -#define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD) -#define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD) - -#define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend) - -#endif /* GL_AMD_draw_buffers_blend */ - -/* ----------------------- GL_AMD_performance_monitor ---------------------- */ - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 - -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 - -typedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); -typedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void* data); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, char *counterString); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, char *groupString); -typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList); - -#define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD) -#define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD) -#define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD) -#define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD) -#define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD) -#define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD) -#define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD) -#define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD) -#define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD) -#define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD) -#define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD) - -#define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor) - -#endif /* GL_AMD_performance_monitor */ - -/* ------------------------ GL_AMD_texture_texture4 ------------------------ */ - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 - -#define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4) - -#endif /* GL_AMD_texture_texture4 */ - -/* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */ - -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 - -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 - -typedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); - -#define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD) -#define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD) - -#define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator) - -#endif /* GL_AMD_vertex_shader_tessellator */ - -/* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */ - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 - -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 - -#define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil) - -#endif /* GL_APPLE_aux_depth_stencil */ - -/* ------------------------ GL_APPLE_client_storage ------------------------ */ - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 - -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 - -#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) - -#endif /* GL_APPLE_client_storage */ - -/* ------------------------- GL_APPLE_element_array ------------------------ */ - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 - -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); - -#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) -#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) -#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) -#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) -#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) - -#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) - -#endif /* GL_APPLE_element_array */ - -/* ----------------------------- GL_APPLE_fence ---------------------------- */ - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 - -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B - -typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); -typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); -typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); - -#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) -#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) -#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) -#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) -#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) -#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) -#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) -#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) - -#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) - -#endif /* GL_APPLE_fence */ - -/* ------------------------- GL_APPLE_float_pixels ------------------------- */ - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 - -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F - -#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) - -#endif /* GL_APPLE_float_pixels */ - -/* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */ - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 - -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 - -typedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); - -#define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE) -#define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE) - -#define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range) - -#endif /* GL_APPLE_flush_buffer_range */ - -/* ----------------------- GL_APPLE_object_purgeable ----------------------- */ - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 - -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D - -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params); -typedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); - -#define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE) -#define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE) -#define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE) - -#define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable) - -#endif /* GL_APPLE_object_purgeable */ - -/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ - -#ifndef GL_APPLE_pixel_buffer -#define GL_APPLE_pixel_buffer 1 - -#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 - -#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) - -#endif /* GL_APPLE_pixel_buffer */ - -/* ---------------------------- GL_APPLE_rgb_422 --------------------------- */ - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 - -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#define GL_RGB_422_APPLE 0x8A1F - -#define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422) - -#endif /* GL_APPLE_rgb_422 */ - -/* --------------------------- GL_APPLE_row_bytes -------------------------- */ - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 - -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 - -#define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes) - -#endif /* GL_APPLE_row_bytes */ - -/* ------------------------ GL_APPLE_specular_vector ----------------------- */ - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 - -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 - -#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) - -#endif /* GL_APPLE_specular_vector */ - -/* ------------------------- GL_APPLE_texture_range ------------------------ */ - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 - -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF - -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); -typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer); - -#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) -#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) - -#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) - -#endif /* GL_APPLE_texture_range */ - -/* ------------------------ GL_APPLE_transform_hint ------------------------ */ - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 - -#define GL_TRANSFORM_HINT_APPLE 0x85B1 - -#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) - -#endif /* GL_APPLE_transform_hint */ - -/* ---------------------- GL_APPLE_vertex_array_object --------------------- */ - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 - -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); - -#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) -#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) -#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) -#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) - -#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) - -#endif /* GL_APPLE_vertex_array_object */ - -/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 - -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF - -typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); - -#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) -#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) -#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) - -#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) - -#endif /* GL_APPLE_vertex_array_range */ - -/* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */ - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 - -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 - -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points); -typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points); - -#define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE) -#define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE) -#define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE) -#define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE) -#define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE) -#define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE) -#define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE) - -#define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators) - -#endif /* GL_APPLE_vertex_program_evaluators */ - -/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 - -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB - -#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) - -#endif /* GL_APPLE_ycbcr_422 */ - -/* ----------------------- GL_ARB_color_buffer_float ----------------------- */ - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 - -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D - -typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); - -#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) - -#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) - -#endif /* GL_ARB_color_buffer_float */ - -/* -------------------------- GL_ARB_compatibility ------------------------- */ - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 - -#define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility) - -#endif /* GL_ARB_compatibility */ - -/* --------------------------- GL_ARB_copy_buffer -------------------------- */ - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 - -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 - -typedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size); - -#define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData) - -#define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer) - -#endif /* GL_ARB_copy_buffer */ - -/* ----------------------- GL_ARB_depth_buffer_float ----------------------- */ - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 - -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD - -#define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float) - -#endif /* GL_ARB_depth_buffer_float */ - -/* --------------------------- GL_ARB_depth_clamp -------------------------- */ - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 - -#define GL_DEPTH_CLAMP 0x864F - -#define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp) - -#endif /* GL_ARB_depth_clamp */ - -/* -------------------------- GL_ARB_depth_texture ------------------------- */ - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 - -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B - -#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) - -#endif /* GL_ARB_depth_texture */ - -/* -------------------------- GL_ARB_draw_buffers -------------------------- */ - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 - -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 - -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); - -#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) - -#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) - -#endif /* GL_ARB_draw_buffers */ - -/* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */ - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); - -#define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB) -#define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB) -#define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB) -#define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB) - -#define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend) - -#endif /* GL_ARB_draw_buffers_blend */ - -/* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */ - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, void* indices, GLint basevertex); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLint basevertex); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, void* indices, GLint basevertex); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei* count, GLenum type, GLvoid**indices, GLsizei primcount, GLint *basevertex); - -#define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex) -#define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex) -#define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex) -#define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex) - -#define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex) - -#endif /* GL_ARB_draw_elements_base_vertex */ - -/* ------------------------- GL_ARB_draw_instanced ------------------------- */ - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); - -#define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB) -#define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB) - -#define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced) - -#endif /* GL_ARB_draw_instanced */ - -/* ------------------- GL_ARB_fragment_coord_conventions ------------------- */ - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 - -#define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions) - -#endif /* GL_ARB_fragment_coord_conventions */ - -/* ------------------------ GL_ARB_fragment_program ------------------------ */ - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 - -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 - -#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) - -#endif /* GL_ARB_fragment_program */ - -/* --------------------- GL_ARB_fragment_program_shadow -------------------- */ - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 - -#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) - -#endif /* GL_ARB_fragment_program_shadow */ - -/* ------------------------- GL_ARB_fragment_shader ------------------------ */ - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 - -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B - -#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) - -#endif /* GL_ARB_fragment_shader */ - -/* ----------------------- GL_ARB_framebuffer_object ----------------------- */ - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_INDEX 0x8222 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_SRGB 0x8C40 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 - -typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); -typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer) -#define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer) -#define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer) -#define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus) -#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers) -#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers) -#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer) -#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D) -#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D) -#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D) -#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer) -#define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers) -#define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers) -#define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap) -#define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv) -#define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv) -#define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer) -#define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer) -#define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage) -#define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample) - -#define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object) - -#endif /* GL_ARB_framebuffer_object */ - -/* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */ - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 - -#define GL_FRAMEBUFFER_SRGB 0x8DB9 - -#define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB) - -#endif /* GL_ARB_framebuffer_sRGB */ - -/* ------------------------ GL_ARB_geometry_shader4 ------------------------ */ - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 - -#define GL_LINES_ADJACENCY_ARB 0xA -#define GL_LINE_STRIP_ADJACENCY_ARB 0xB -#define GL_TRIANGLES_ADJACENCY_ARB 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); - -#define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB) -#define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB) -#define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB) -#define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB) - -#define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4) - -#endif /* GL_ARB_geometry_shader4 */ - -/* ------------------------ GL_ARB_half_float_pixel ------------------------ */ - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 - -#define GL_HALF_FLOAT_ARB 0x140B - -#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) - -#endif /* GL_ARB_half_float_pixel */ - -/* ------------------------ GL_ARB_half_float_vertex ----------------------- */ - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 - -#define GL_HALF_FLOAT 0x140B - -#define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex) - -#endif /* GL_ARB_half_float_vertex */ - -/* ----------------------------- GL_ARB_imaging ---------------------------- */ - -#ifndef GL_ARB_imaging -#define GL_ARB_imaging 1 - -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_IGNORE_BORDER 0x8150 -#define GL_CONSTANT_BORDER 0x8151 -#define GL_WRAP_BORDER 0x8152 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 - -typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); - -#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) -#define glColorTable GLEW_GET_FUN(__glewColorTable) -#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) -#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) -#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) -#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) -#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) -#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) -#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) -#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) -#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) -#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) -#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) -#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) -#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) -#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) -#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) -#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) -#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) -#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) -#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) -#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) -#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) -#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) -#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) -#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) -#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) -#define glHistogram GLEW_GET_FUN(__glewHistogram) -#define glMinmax GLEW_GET_FUN(__glewMinmax) -#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) -#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) -#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) - -#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) - -#endif /* GL_ARB_imaging */ - -/* ------------------------ GL_ARB_instanced_arrays ------------------------ */ - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 - -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE - -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); - -#define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB) - -#define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays) - -#endif /* GL_ARB_instanced_arrays */ - -/* ------------------------ GL_ARB_map_buffer_range ------------------------ */ - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 - -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 - -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); - -#define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange) -#define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange) - -#define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range) - -#endif /* GL_ARB_map_buffer_range */ - -/* ------------------------- GL_ARB_matrix_palette ------------------------- */ - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 - -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 - -typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); - -#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) -#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) -#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) -#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) -#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) - -#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) - -#endif /* GL_ARB_matrix_palette */ - -/* --------------------------- GL_ARB_multisample -------------------------- */ - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 - -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 - -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); - -#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) - -#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) - -#endif /* GL_ARB_multisample */ - -/* -------------------------- GL_ARB_multitexture -------------------------- */ - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 - -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 - -typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); - -#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) -#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) -#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) -#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) -#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) -#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) -#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) -#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) -#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) -#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) -#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) -#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) -#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) -#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) -#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) -#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) -#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) -#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) -#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) -#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) -#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) -#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) -#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) -#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) -#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) -#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) -#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) -#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) -#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) -#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) -#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) -#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) -#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) -#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) - -#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) - -#endif /* GL_ARB_multitexture */ - -/* ------------------------- GL_ARB_occlusion_query ------------------------ */ - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 - -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); - -#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) -#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) -#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) -#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) -#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) -#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) -#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) -#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) - -#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) - -#endif /* GL_ARB_occlusion_query */ - -/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 - -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF - -#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) - -#endif /* GL_ARB_pixel_buffer_object */ - -/* ------------------------ GL_ARB_point_parameters ------------------------ */ - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 - -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, GLfloat* params); - -#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) -#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) - -#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) - -#endif /* GL_ARB_point_parameters */ - -/* -------------------------- GL_ARB_point_sprite -------------------------- */ - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 - -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 - -#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) - -#endif /* GL_ARB_point_sprite */ - -/* ------------------------ GL_ARB_provoking_vertex ------------------------ */ - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 - -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F - -typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode); - -#define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex) - -#define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex) - -#endif /* GL_ARB_provoking_vertex */ - -/* ------------------------- GL_ARB_sample_shading ------------------------- */ - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 - -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 - -typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); - -#define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB) - -#define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading) - -#endif /* GL_ARB_sample_shading */ - -/* ------------------------ GL_ARB_seamless_cube_map ----------------------- */ - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 - -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F - -#define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map) - -#endif /* GL_ARB_seamless_cube_map */ - -/* ------------------------- GL_ARB_shader_objects ------------------------- */ - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 - -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 - -typedef char GLcharARB; -typedef unsigned int GLhandleARB; - -typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); -typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); -typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); - -#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) -#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) -#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) -#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) -#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) -#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) -#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) -#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) -#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) -#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) -#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) -#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) -#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) -#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) -#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) -#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) -#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) -#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) -#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) -#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) -#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) -#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) -#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) -#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) -#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) -#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) -#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) -#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) -#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) -#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) -#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) -#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) -#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) -#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) -#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) -#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) -#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) -#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) -#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) - -#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) - -#endif /* GL_ARB_shader_objects */ - -/* ----------------------- GL_ARB_shader_texture_lod ----------------------- */ - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 - -#define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod) - -#endif /* GL_ARB_shader_texture_lod */ - -/* ---------------------- GL_ARB_shading_language_100 ---------------------- */ - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 - -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C - -#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) - -#endif /* GL_ARB_shading_language_100 */ - -/* ----------------------------- GL_ARB_shadow ----------------------------- */ - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 - -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E - -#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) - -#endif /* GL_ARB_shadow */ - -/* ------------------------- GL_ARB_shadow_ambient ------------------------- */ - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 - -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF - -#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) - -#endif /* GL_ARB_shadow_ambient */ - -/* ------------------------------ GL_ARB_sync ------------------------------ */ - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 - -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF - -typedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); -typedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync); -typedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags); -typedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params); -typedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values); -typedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync); -typedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout); - -#define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync) -#define glDeleteSync GLEW_GET_FUN(__glewDeleteSync) -#define glFenceSync GLEW_GET_FUN(__glewFenceSync) -#define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v) -#define glGetSynciv GLEW_GET_FUN(__glewGetSynciv) -#define glIsSync GLEW_GET_FUN(__glewIsSync) -#define glWaitSync GLEW_GET_FUN(__glewWaitSync) - -#define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync) - -#endif /* GL_ARB_sync */ - -/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 - -#define GL_CLAMP_TO_BORDER_ARB 0x812D - -#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) - -#endif /* GL_ARB_texture_border_clamp */ - -/* ---------------------- GL_ARB_texture_buffer_object --------------------- */ - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 - -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E - -typedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); - -#define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB) - -#define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object) - -#endif /* GL_ARB_texture_buffer_object */ - -/* ----------------------- GL_ARB_texture_compression ---------------------- */ - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 - -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 - -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img); - -#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) -#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) -#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) -#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) -#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) -#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) -#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) - -#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) - -#endif /* GL_ARB_texture_compression */ - -/* -------------------- GL_ARB_texture_compression_rgtc -------------------- */ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 - -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE - -#define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc) - -#endif /* GL_ARB_texture_compression_rgtc */ - -/* ------------------------ GL_ARB_texture_cube_map ------------------------ */ - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 - -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C - -#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) - -#endif /* GL_ARB_texture_cube_map */ - -/* --------------------- GL_ARB_texture_cube_map_array --------------------- */ - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 - -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F - -#define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array) - -#endif /* GL_ARB_texture_cube_map_array */ - -/* ------------------------- GL_ARB_texture_env_add ------------------------ */ - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 - -#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) - -#endif /* GL_ARB_texture_env_add */ - -/* ----------------------- GL_ARB_texture_env_combine ---------------------- */ - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 - -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A - -#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) - -#endif /* GL_ARB_texture_env_combine */ - -/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 - -#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) - -#endif /* GL_ARB_texture_env_crossbar */ - -/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 - -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF - -#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) - -#endif /* GL_ARB_texture_env_dot3 */ - -/* -------------------------- GL_ARB_texture_float ------------------------- */ - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 - -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 - -#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) - -#endif /* GL_ARB_texture_float */ - -/* ------------------------- GL_ARB_texture_gather ------------------------- */ - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 - -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F - -#define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather) - -#endif /* GL_ARB_texture_gather */ - -/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 - -#define GL_MIRRORED_REPEAT_ARB 0x8370 - -#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) - -#endif /* GL_ARB_texture_mirrored_repeat */ - -/* ----------------------- GL_ARB_texture_multisample ---------------------- */ - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 - -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 - -typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val); -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); - -#define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv) -#define glSampleMaski GLEW_GET_FUN(__glewSampleMaski) -#define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample) -#define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample) - -#define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample) - -#endif /* GL_ARB_texture_multisample */ - -/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 - -#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) - -#endif /* GL_ARB_texture_non_power_of_two */ - -/* ------------------------ GL_ARB_texture_query_lod ----------------------- */ - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 - -#define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod) - -#endif /* GL_ARB_texture_query_lod */ - -/* ------------------------ GL_ARB_texture_rectangle ----------------------- */ - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 - -#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) - -#endif /* GL_ARB_texture_rectangle */ - -/* --------------------------- GL_ARB_texture_rg --------------------------- */ - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 - -#define GL_RED 0x1903 -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C - -#define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg) - -#endif /* GL_ARB_texture_rg */ - -/* ------------------------ GL_ARB_transpose_matrix ------------------------ */ - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 - -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 - -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); - -#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) -#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) -#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) -#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) - -#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) - -#endif /* GL_ARB_transpose_matrix */ - -/* ---------------------- GL_ARB_uniform_buffer_object --------------------- */ - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 - -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFF - -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, char* uniformBlockName); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, char* uniformName); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data); -typedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const char* uniformBlockName); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const char** uniformNames, GLuint* uniformIndices); -typedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); - -#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase) -#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange) -#define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName) -#define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv) -#define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName) -#define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv) -#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v) -#define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex) -#define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices) -#define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding) - -#define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object) - -#endif /* GL_ARB_uniform_buffer_object */ - -/* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */ - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 - -#define GL_BGRA 0x80E1 - -#define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra) - -#endif /* GL_ARB_vertex_array_bgra */ - -/* ----------------------- GL_ARB_vertex_array_object ---------------------- */ - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 - -#define GL_VERTEX_ARRAY_BINDING 0x85B5 - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array); - -#define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray) -#define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays) -#define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays) -#define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray) - -#define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object) - -#endif /* GL_ARB_vertex_array_object */ - -/* -------------------------- GL_ARB_vertex_blend -------------------------- */ - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 - -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F - -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); -typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); - -#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) -#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) -#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) -#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) -#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) -#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) -#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) -#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) -#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) -#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) - -#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) - -#endif /* GL_ARB_vertex_blend */ - -/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 - -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA - -typedef ptrdiff_t GLsizeiptrARB; -typedef ptrdiff_t GLintptrARB; - -typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); - -#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) -#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) -#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) -#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) -#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) -#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) -#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) -#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) -#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) -#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) -#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) - -#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) - -#endif /* GL_ARB_vertex_buffer_object */ - -/* ------------------------- GL_ARB_vertex_program ------------------------- */ - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 - -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF - -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); - -#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) -#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) -#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) -#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) -#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) -#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) -#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) -#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) -#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) -#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) -#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) -#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) -#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) -#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) -#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) -#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) -#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) -#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) -#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) -#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) -#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) -#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) -#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) -#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) -#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) -#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) -#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) -#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) -#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) -#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) -#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) -#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) -#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) -#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) -#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) -#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) -#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) -#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) -#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) -#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) -#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) -#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) -#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) -#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) -#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) -#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) -#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) -#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) -#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) -#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) -#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) -#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) -#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) -#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) -#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) -#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) -#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) -#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) -#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) -#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) -#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) -#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) - -#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) - -#endif /* GL_ARB_vertex_program */ - -/* -------------------------- GL_ARB_vertex_shader ------------------------- */ - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 - -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A - -typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); -typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); - -#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) -#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) -#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) - -#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) - -#endif /* GL_ARB_vertex_shader */ - -/* --------------------------- GL_ARB_window_pos --------------------------- */ - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 - -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); - -#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) -#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) -#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) -#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) -#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) -#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) -#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) -#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) -#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) -#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) -#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) -#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) -#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) -#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) -#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) -#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) - -#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) - -#endif /* GL_ARB_window_pos */ - -/* ------------------------- GL_ATIX_point_sprites ------------------------- */ - -#ifndef GL_ATIX_point_sprites -#define GL_ATIX_point_sprites 1 - -#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 -#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 -#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 -#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 -#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 -#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 - -#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) - -#endif /* GL_ATIX_point_sprites */ - -/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ - -#ifndef GL_ATIX_texture_env_combine3 -#define GL_ATIX_texture_env_combine3 1 - -#define GL_MODULATE_ADD_ATIX 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 -#define GL_MODULATE_SUBTRACT_ATIX 0x8746 - -#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) - -#endif /* GL_ATIX_texture_env_combine3 */ - -/* ----------------------- GL_ATIX_texture_env_route ----------------------- */ - -#ifndef GL_ATIX_texture_env_route -#define GL_ATIX_texture_env_route 1 - -#define GL_SECONDARY_COLOR_ATIX 0x8747 -#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 -#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 - -#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) - -#endif /* GL_ATIX_texture_env_route */ - -/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ - -#ifndef GL_ATIX_vertex_shader_output_point_size -#define GL_ATIX_vertex_shader_output_point_size 1 - -#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E - -#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) - -#endif /* GL_ATIX_vertex_shader_output_point_size */ - -/* -------------------------- GL_ATI_draw_buffers -------------------------- */ - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 - -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 - -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); - -#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) - -#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) - -#endif /* GL_ATI_draw_buffers */ - -/* -------------------------- GL_ATI_element_array ------------------------- */ - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 - -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer); - -#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) -#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) -#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) - -#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) - -#endif /* GL_ATI_element_array */ - -/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 - -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C - -typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); - -#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) -#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) -#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) -#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) - -#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) - -#endif /* GL_ATI_envmap_bumpmap */ - -/* ------------------------- GL_ATI_fragment_shader ------------------------ */ - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 - -#define GL_RED_BIT_ATI 0x00000001 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B - -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); - -#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) -#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) -#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) -#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) -#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) -#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) -#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) -#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) -#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) -#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) -#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) -#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) -#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) -#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) - -#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) - -#endif /* GL_ATI_fragment_shader */ - -/* ------------------------ GL_ATI_map_object_buffer ----------------------- */ - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 - -typedef void* (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); - -#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) -#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) - -#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) - -#endif /* GL_ATI_map_object_buffer */ - -/* ----------------------------- GL_ATI_meminfo ---------------------------- */ - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 - -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD - -#define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo) - -#endif /* GL_ATI_meminfo */ - -/* -------------------------- GL_ATI_pn_triangles -------------------------- */ - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 - -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 - -typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); - -#define glPNTrianglesfATI GLEW_GET_FUN(__glPNTrianglewesfATI) -#define glPNTrianglesiATI GLEW_GET_FUN(__glPNTrianglewesiATI) - -#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) - -#endif /* GL_ATI_pn_triangles */ - -/* ------------------------ GL_ATI_separate_stencil ------------------------ */ - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 - -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 - -typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); - -#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) -#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) - -#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) - -#endif /* GL_ATI_separate_stencil */ - -/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ - -#ifndef GL_ATI_shader_texture_lod -#define GL_ATI_shader_texture_lod 1 - -#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) - -#endif /* GL_ATI_shader_texture_lod */ - -/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 - -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 - -#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) - -#endif /* GL_ATI_text_fragment_shader */ - -/* --------------------- GL_ATI_texture_compression_3dc -------------------- */ - -#ifndef GL_ATI_texture_compression_3dc -#define GL_ATI_texture_compression_3dc 1 - -#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 - -#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) - -#endif /* GL_ATI_texture_compression_3dc */ - -/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 - -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 - -#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) - -#endif /* GL_ATI_texture_env_combine3 */ - -/* -------------------------- GL_ATI_texture_float ------------------------- */ - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 - -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F - -#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) - -#endif /* GL_ATI_texture_float */ - -/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 - -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 - -#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) - -#endif /* GL_ATI_texture_mirror_once */ - -/* ----------------------- GL_ATI_vertex_array_object ---------------------- */ - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 - -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 - -typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage); -typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve); -typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); - -#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) -#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) -#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) -#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) -#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) -#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) -#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) -#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) -#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) -#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) -#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) -#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) - -#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) - -#endif /* GL_ATI_vertex_array_object */ - -/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 - -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); - -#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) -#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) -#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) - -#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) - -#endif /* GL_ATI_vertex_attrib_array_object */ - -/* ------------------------- GL_ATI_vertex_streams ------------------------- */ - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 - -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_SOURCE_ATI 0x876C -#define GL_VERTEX_STREAM0_ATI 0x876D -#define GL_VERTEX_STREAM1_ATI 0x876E -#define GL_VERTEX_STREAM2_ATI 0x876F -#define GL_VERTEX_STREAM3_ATI 0x8770 -#define GL_VERTEX_STREAM4_ATI 0x8771 -#define GL_VERTEX_STREAM5_ATI 0x8772 -#define GL_VERTEX_STREAM6_ATI 0x8773 -#define GL_VERTEX_STREAM7_ATI 0x8774 - -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *v); - -#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) -#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) -#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) -#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) -#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) -#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) -#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) -#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) -#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) -#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) -#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) -#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) -#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) -#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) -#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) -#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) -#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) -#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) -#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) -#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) -#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) -#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) -#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) -#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) -#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) -#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) -#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) -#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) -#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) -#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) -#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) -#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) -#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) -#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) -#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) -#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) -#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) - -#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) - -#endif /* GL_ATI_vertex_streams */ - -/* --------------------------- GL_EXT_422_pixels --------------------------- */ - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 - -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF - -#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) - -#endif /* GL_EXT_422_pixels */ - -/* ---------------------------- GL_EXT_Cg_shader --------------------------- */ - -#ifndef GL_EXT_Cg_shader -#define GL_EXT_Cg_shader 1 - -#define GL_CG_VERTEX_SHADER_EXT 0x890E -#define GL_CG_FRAGMENT_SHADER_EXT 0x890F - -#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) - -#endif /* GL_EXT_Cg_shader */ - -/* ------------------------------ GL_EXT_abgr ------------------------------ */ - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 - -#define GL_ABGR_EXT 0x8000 - -#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) - -#endif /* GL_EXT_abgr */ - -/* ------------------------------ GL_EXT_bgra ------------------------------ */ - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 - -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 - -#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) - -#endif /* GL_EXT_bgra */ - -/* ------------------------ GL_EXT_bindable_uniform ------------------------ */ - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 - -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF - -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); - -#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) -#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) -#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) - -#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) - -#endif /* GL_EXT_bindable_uniform */ - -/* --------------------------- GL_EXT_blend_color -------------------------- */ - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 - -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 - -typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - -#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) - -#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) - -#endif /* GL_EXT_blend_color */ - -/* --------------------- GL_EXT_blend_equation_separate -------------------- */ - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 - -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); - -#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) - -#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) - -#endif /* GL_EXT_blend_equation_separate */ - -/* ----------------------- GL_EXT_blend_func_separate ---------------------- */ - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 - -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB - -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); - -#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) - -#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) - -#endif /* GL_EXT_blend_func_separate */ - -/* ------------------------- GL_EXT_blend_logic_op ------------------------- */ - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 - -#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) - -#endif /* GL_EXT_blend_logic_op */ - -/* -------------------------- GL_EXT_blend_minmax -------------------------- */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 - -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); - -#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) - -#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) - -#endif /* GL_EXT_blend_minmax */ - -/* ------------------------- GL_EXT_blend_subtract ------------------------- */ - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 - -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B - -#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) - -#endif /* GL_EXT_blend_subtract */ - -/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 - -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 - -#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) - -#endif /* GL_EXT_clip_volume_hint */ - -/* ------------------------------ GL_EXT_cmyka ----------------------------- */ - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 - -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F - -#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) - -#endif /* GL_EXT_cmyka */ - -/* ------------------------- GL_EXT_color_subtable ------------------------- */ - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 - -typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); - -#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) -#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) - -#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) - -#endif /* GL_EXT_color_subtable */ - -/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 - -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 - -typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); - -#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) -#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) - -#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) - -#endif /* GL_EXT_compiled_vertex_array */ - -/* --------------------------- GL_EXT_convolution -------------------------- */ - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 - -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 - -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span); -typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column); - -#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) -#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) -#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) -#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) -#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) -#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) -#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) -#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) -#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) -#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) -#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) -#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) -#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) - -#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) - -#endif /* GL_EXT_convolution */ - -/* ------------------------ GL_EXT_coordinate_frame ------------------------ */ - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 - -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 - -typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); -typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); - -#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) -#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) - -#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) - -#endif /* GL_EXT_coordinate_frame */ - -/* -------------------------- GL_EXT_copy_texture -------------------------- */ - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 - -typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); - -#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) -#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) -#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) -#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) -#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) - -#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) - -#endif /* GL_EXT_copy_texture */ - -/* --------------------------- GL_EXT_cull_vertex -------------------------- */ - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 - -typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); - -#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) -#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) - -#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) - -#endif /* GL_EXT_cull_vertex */ - -/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 - -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 - -typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); - -#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) - -#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) - -#endif /* GL_EXT_depth_bounds_test */ - -/* ----------------------- GL_EXT_direct_state_access ---------------------- */ - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 - -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F - -typedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void* img); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void* img); -typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void* pixels); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void* data); -typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void* string); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void* pixels); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLvoid** param); -typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, GLvoid** param); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); -typedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void* pointer); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void* data); -typedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void* string); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); - -#define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT) -#define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT) -#define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT) -#define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT) -#define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT) -#define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT) -#define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT) -#define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT) -#define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT) -#define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT) -#define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT) -#define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT) -#define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT) -#define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT) -#define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT) -#define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT) -#define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT) -#define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT) -#define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT) -#define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT) -#define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT) -#define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT) -#define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT) -#define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT) -#define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT) -#define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT) -#define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT) -#define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT) -#define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT) -#define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT) -#define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT) -#define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT) -#define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT) -#define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT) -#define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT) -#define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT) -#define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT) -#define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT) -#define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT) -#define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT) -#define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT) -#define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT) -#define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT) -#define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT) -#define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT) -#define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT) -#define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT) -#define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT) -#define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT) -#define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT) -#define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT) -#define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT) -#define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT) -#define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT) -#define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT) -#define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT) -#define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT) -#define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT) -#define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT) -#define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT) -#define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT) -#define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT) -#define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT) -#define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT) -#define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT) -#define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT) -#define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT) -#define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT) -#define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT) -#define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT) -#define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT) -#define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT) -#define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT) -#define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT) -#define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT) -#define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT) -#define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT) -#define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT) -#define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT) -#define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT) -#define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT) -#define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT) -#define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT) -#define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT) -#define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT) -#define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT) -#define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT) -#define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT) -#define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT) -#define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT) -#define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT) -#define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT) -#define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT) -#define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT) -#define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT) -#define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT) -#define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT) -#define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT) -#define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT) -#define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT) -#define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT) -#define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT) -#define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT) -#define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT) -#define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT) -#define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT) -#define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT) -#define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT) -#define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT) -#define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT) -#define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT) -#define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT) -#define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT) -#define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT) -#define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT) -#define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT) -#define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT) -#define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT) -#define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT) -#define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT) -#define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT) -#define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT) -#define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT) -#define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT) -#define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT) -#define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT) -#define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT) -#define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT) -#define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT) -#define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT) -#define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT) -#define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT) -#define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT) -#define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT) -#define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT) -#define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT) -#define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT) -#define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT) -#define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT) -#define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT) -#define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT) -#define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT) -#define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT) -#define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT) -#define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT) -#define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT) -#define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT) -#define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT) -#define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT) -#define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT) -#define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT) -#define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT) -#define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT) -#define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT) -#define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT) -#define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT) -#define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT) -#define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT) -#define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT) -#define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT) -#define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT) -#define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT) -#define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT) -#define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT) -#define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT) -#define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT) -#define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT) -#define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT) -#define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT) -#define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT) -#define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT) -#define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT) -#define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT) -#define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT) -#define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT) -#define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT) -#define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT) -#define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT) -#define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT) -#define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT) -#define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT) -#define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT) -#define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT) -#define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT) -#define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT) -#define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT) -#define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT) -#define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT) -#define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT) -#define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT) -#define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT) -#define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT) -#define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT) -#define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT) -#define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT) -#define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT) -#define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT) -#define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT) -#define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT) -#define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT) -#define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT) -#define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT) -#define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT) -#define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT) -#define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT) -#define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT) -#define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT) -#define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT) -#define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT) -#define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT) -#define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT) -#define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT) -#define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT) - -#define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access) - -#endif /* GL_EXT_direct_state_access */ - -/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 - -typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data); -typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data); -typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); - -#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) -#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) -#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) -#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) -#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) -#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) - -#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) - -#endif /* GL_EXT_draw_buffers2 */ - -/* ------------------------- GL_EXT_draw_instanced ------------------------- */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); - -#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) -#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) - -#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) - -#endif /* GL_EXT_draw_instanced */ - -/* ----------------------- GL_EXT_draw_range_elements ---------------------- */ - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 - -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 - -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); - -#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) - -#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) - -#endif /* GL_EXT_draw_range_elements */ - -/* ---------------------------- GL_EXT_fog_coord --------------------------- */ - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 - -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 - -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); - -#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) -#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) -#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) -#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) -#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) - -#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) - -#endif /* GL_EXT_fog_coord */ - -/* ------------------------ GL_EXT_fragment_lighting ----------------------- */ - -#ifndef GL_EXT_fragment_lighting -#define GL_EXT_fragment_lighting 1 - -#define GL_FRAGMENT_LIGHTING_EXT 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 -#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 -#define GL_LIGHT_ENV_MODE_EXT 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B -#define GL_FRAGMENT_LIGHT0_EXT 0x840C -#define GL_FRAGMENT_LIGHT7_EXT 0x8413 - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); - -#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) -#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) -#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) -#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) -#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) -#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) -#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) -#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) -#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) -#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) -#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) -#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) -#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) -#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) -#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) -#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) -#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) -#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) - -#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) - -#endif /* GL_EXT_fragment_lighting */ - -/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 - -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA - -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); - -#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) - -#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) - -#endif /* GL_EXT_framebuffer_blit */ - -/* --------------------- GL_EXT_framebuffer_multisample -------------------- */ - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 - -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) - -#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) - -#endif /* GL_EXT_framebuffer_multisample */ - -/* ----------------------- GL_EXT_framebuffer_object ----------------------- */ - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 - -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 - -typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - -#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) -#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) -#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) -#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) -#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) -#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) -#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) -#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) -#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) -#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) -#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) -#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) -#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) -#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) -#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) -#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) -#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) - -#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) - -#endif /* GL_EXT_framebuffer_object */ - -/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 - -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA - -#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) - -#endif /* GL_EXT_framebuffer_sRGB */ - -/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 - -#define GL_LINES_ADJACENCY_EXT 0xA -#define GL_LINE_STRIP_ADJACENCY_EXT 0xB -#define GL_TRIANGLES_ADJACENCY_EXT 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); - -#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) -#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) -#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) -#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) - -#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) - -#endif /* GL_EXT_geometry_shader4 */ - -/* --------------------- GL_EXT_gpu_program_parameters --------------------- */ - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 - -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); - -#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) -#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) - -#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) - -#endif /* GL_EXT_gpu_program_parameters */ - -/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 - -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 - -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - -#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) -#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) -#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) -#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) -#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) -#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) -#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) -#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) -#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) -#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) -#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) -#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) -#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) -#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) -#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) -#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) -#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) -#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) -#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) -#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) -#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) -#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) -#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) -#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) -#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) -#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) -#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) -#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) -#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) -#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) -#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) -#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) -#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) -#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) - -#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) - -#endif /* GL_EXT_gpu_shader4 */ - -/* ---------------------------- GL_EXT_histogram --------------------------- */ - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 - -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 - -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); - -#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) -#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) -#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) -#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) -#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) -#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) -#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) -#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) -#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) -#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) - -#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) - -#endif /* GL_EXT_histogram */ - -/* ----------------------- GL_EXT_index_array_formats ---------------------- */ - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 - -#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) - -#endif /* GL_EXT_index_array_formats */ - -/* --------------------------- GL_EXT_index_func --------------------------- */ - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 - -typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); - -#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) - -#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) - -#endif /* GL_EXT_index_func */ - -/* ------------------------- GL_EXT_index_material ------------------------- */ - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 - -typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); - -#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) - -#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) - -#endif /* GL_EXT_index_material */ - -/* -------------------------- GL_EXT_index_texture ------------------------- */ - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 - -#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) - -#endif /* GL_EXT_index_texture */ - -/* -------------------------- GL_EXT_light_texture ------------------------- */ - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 - -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 - -typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); - -#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) -#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) -#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) - -#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) - -#endif /* GL_EXT_light_texture */ - -/* ------------------------- GL_EXT_misc_attribute ------------------------- */ - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 - -#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) - -#endif /* GL_EXT_misc_attribute */ - -/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint* first, GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount); - -#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) -#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) - -#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) - -#endif /* GL_EXT_multi_draw_arrays */ - -/* --------------------------- GL_EXT_multisample -------------------------- */ - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 - -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); - -#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) -#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) - -#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) - -#endif /* GL_EXT_multisample */ - -/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 - -#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) - -#endif /* GL_EXT_packed_depth_stencil */ - -/* -------------------------- GL_EXT_packed_float -------------------------- */ - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 - -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C - -#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) - -#endif /* GL_EXT_packed_float */ - -/* -------------------------- GL_EXT_packed_pixels ------------------------- */ - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 - -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 - -#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) - -#endif /* GL_EXT_packed_pixels */ - -/* ------------------------ GL_EXT_paletted_texture ------------------------ */ - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 - -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 -#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B - -typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); - -#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) -#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) -#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) -#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) - -#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) - -#endif /* GL_EXT_paletted_texture */ - -/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 - -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF - -#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) - -#endif /* GL_EXT_pixel_buffer_object */ - -/* ------------------------- GL_EXT_pixel_transform ------------------------ */ - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 - -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 - -typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) -#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) -#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) -#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) -#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) -#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) - -#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) - -#endif /* GL_EXT_pixel_transform */ - -/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 - -#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) - -#endif /* GL_EXT_pixel_transform_color_table */ - -/* ------------------------ GL_EXT_point_parameters ------------------------ */ - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 - -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); - -#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) -#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) - -#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) - -#endif /* GL_EXT_point_parameters */ - -/* ------------------------- GL_EXT_polygon_offset ------------------------- */ - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 - -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 - -typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); - -#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) - -#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) - -#endif /* GL_EXT_polygon_offset */ - -/* ------------------------ GL_EXT_provoking_vertex ------------------------ */ - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 - -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F - -typedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); - -#define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT) - -#define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex) - -#endif /* GL_EXT_provoking_vertex */ - -/* ------------------------- GL_EXT_rescale_normal ------------------------- */ - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 - -#define GL_RESCALE_NORMAL_EXT 0x803A - -#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) - -#endif /* GL_EXT_rescale_normal */ - -/* -------------------------- GL_EXT_scene_marker -------------------------- */ - -#ifndef GL_EXT_scene_marker -#define GL_EXT_scene_marker 1 - -typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); - -#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) -#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) - -#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) - -#endif /* GL_EXT_scene_marker */ - -/* ------------------------- GL_EXT_secondary_color ------------------------ */ - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 - -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E - -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); - -#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) -#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) -#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) -#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) -#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) -#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) -#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) -#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) -#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) -#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) -#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) -#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) -#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) -#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) -#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) -#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) -#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) - -#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) - -#endif /* GL_EXT_secondary_color */ - -/* --------------------- GL_EXT_separate_shader_objects -------------------- */ - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 - -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D - -typedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const char* string); -typedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); - -#define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT) -#define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT) -#define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT) - -#define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects) - -#endif /* GL_EXT_separate_shader_objects */ - -/* --------------------- GL_EXT_separate_specular_color -------------------- */ - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 - -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA - -#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) - -#endif /* GL_EXT_separate_specular_color */ - -/* -------------------------- GL_EXT_shadow_funcs -------------------------- */ - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 - -#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) - -#endif /* GL_EXT_shadow_funcs */ - -/* --------------------- GL_EXT_shared_texture_palette --------------------- */ - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 - -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB - -#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) - -#endif /* GL_EXT_shared_texture_palette */ - -/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 - -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 - -#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) - -#endif /* GL_EXT_stencil_clear_tag */ - -/* ------------------------ GL_EXT_stencil_two_side ------------------------ */ - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 - -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 - -typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); - -#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) - -#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) - -#endif /* GL_EXT_stencil_two_side */ - -/* -------------------------- GL_EXT_stencil_wrap -------------------------- */ - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 - -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 - -#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) - -#endif /* GL_EXT_stencil_wrap */ - -/* --------------------------- GL_EXT_subtexture --------------------------- */ - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 - -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); - -#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) -#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) -#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) - -#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) - -#endif /* GL_EXT_subtexture */ - -/* ----------------------------- GL_EXT_texture ---------------------------- */ - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 - -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 - -#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) - -#endif /* GL_EXT_texture */ - -/* ---------------------------- GL_EXT_texture3D --------------------------- */ - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 - -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); - -#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) - -#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) - -#endif /* GL_EXT_texture3D */ - -/* -------------------------- GL_EXT_texture_array ------------------------- */ - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 - -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D - -#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) - -#endif /* GL_EXT_texture_array */ - -/* ---------------------- GL_EXT_texture_buffer_object --------------------- */ - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 - -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E - -typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); - -#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) - -#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) - -#endif /* GL_EXT_texture_buffer_object */ - -/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ - -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 - -#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) - -#endif /* GL_EXT_texture_compression_dxt1 */ - -/* -------------------- GL_EXT_texture_compression_latc -------------------- */ - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 - -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 - -#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) - -#endif /* GL_EXT_texture_compression_latc */ - -/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 - -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE - -#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) - -#endif /* GL_EXT_texture_compression_rgtc */ - -/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 - -#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) - -#endif /* GL_EXT_texture_compression_s3tc */ - -/* ------------------------ GL_EXT_texture_cube_map ------------------------ */ - -#ifndef GL_EXT_texture_cube_map -#define GL_EXT_texture_cube_map 1 - -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C - -#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) - -#endif /* GL_EXT_texture_cube_map */ - -/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ - -#ifndef GL_EXT_texture_edge_clamp -#define GL_EXT_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_EXT 0x812F - -#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) - -#endif /* GL_EXT_texture_edge_clamp */ - -/* --------------------------- GL_EXT_texture_env -------------------------- */ - -#ifndef GL_EXT_texture_env -#define GL_EXT_texture_env 1 - -#define GL_TEXTURE_ENV0_EXT 0 -#define GL_ENV_BLEND_EXT 0 -#define GL_TEXTURE_ENV_SHIFT_EXT 0 -#define GL_ENV_REPLACE_EXT 0 -#define GL_ENV_ADD_EXT 0 -#define GL_ENV_SUBTRACT_EXT 0 -#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0 -#define GL_ENV_REVERSE_SUBTRACT_EXT 0 -#define GL_ENV_REVERSE_BLEND_EXT 0 -#define GL_ENV_COPY_EXT 0 -#define GL_ENV_MODULATE_EXT 0 - -#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) - -#endif /* GL_EXT_texture_env */ - -/* ------------------------- GL_EXT_texture_env_add ------------------------ */ - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 - -#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) - -#endif /* GL_EXT_texture_env_add */ - -/* ----------------------- GL_EXT_texture_env_combine ---------------------- */ - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 - -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A - -#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) - -#endif /* GL_EXT_texture_env_combine */ - -/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 - -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 - -#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) - -#endif /* GL_EXT_texture_env_dot3 */ - -/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 - -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF - -#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) - -#endif /* GL_EXT_texture_filter_anisotropic */ - -/* ------------------------- GL_EXT_texture_integer ------------------------ */ - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 - -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E - -typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); - -#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) -#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) -#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) -#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) -#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) -#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) - -#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) - -#endif /* GL_EXT_texture_integer */ - -/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 - -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 - -#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) - -#endif /* GL_EXT_texture_lod_bias */ - -/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 - -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 - -#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) - -#endif /* GL_EXT_texture_mirror_clamp */ - -/* ------------------------- GL_EXT_texture_object ------------------------- */ - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 - -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A - -typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); -typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); -typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); -typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); - -#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) -#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) -#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) -#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) -#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) -#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) - -#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) - -#endif /* GL_EXT_texture_object */ - -/* --------------------- GL_EXT_texture_perturb_normal --------------------- */ - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 - -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF - -typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); - -#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) - -#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) - -#endif /* GL_EXT_texture_perturb_normal */ - -/* ------------------------ GL_EXT_texture_rectangle ----------------------- */ - -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 - -#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) - -#endif /* GL_EXT_texture_rectangle */ - -/* -------------------------- GL_EXT_texture_sRGB -------------------------- */ - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 - -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F - -#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) - -#endif /* GL_EXT_texture_sRGB */ - -/* --------------------- GL_EXT_texture_shared_exponent -------------------- */ - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 - -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F - -#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) - -#endif /* GL_EXT_texture_shared_exponent */ - -/* -------------------------- GL_EXT_texture_snorm ------------------------- */ - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 - -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B - -#define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm) - -#endif /* GL_EXT_texture_snorm */ - -/* ------------------------- GL_EXT_texture_swizzle ------------------------ */ - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 - -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 - -#define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle) - -#endif /* GL_EXT_texture_swizzle */ - -/* --------------------------- GL_EXT_timer_query -------------------------- */ - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 - -#define GL_TIME_ELAPSED_EXT 0x88BF - -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); - -#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) -#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) - -#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) - -#endif /* GL_EXT_timer_query */ - -/* ----------------------- GL_EXT_transform_feedback ----------------------- */ - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 - -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F - -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, char *name); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const char ** varyings, GLenum bufferMode); - -#define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT) -#define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT) -#define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT) -#define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT) -#define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT) -#define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT) -#define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT) - -#define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback) - -#endif /* GL_EXT_transform_feedback */ - -/* -------------------------- GL_EXT_vertex_array -------------------------- */ - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 - -#define GL_DOUBLE_EXT 0x140A -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 - -typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); -typedef void (GLAPIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); - -#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) -#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) -#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) -#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) -#define glGetPointervEXT GLEW_GET_FUN(__glewGetPointervEXT) -#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) -#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) -#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) -#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) - -#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) - -#endif /* GL_EXT_vertex_array */ - -/* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */ - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 - -#define GL_BGRA 0x80E1 - -#define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra) - -#endif /* GL_EXT_vertex_array_bgra */ - -/* -------------------------- GL_EXT_vertex_shader ------------------------- */ - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 - -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED - -typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); -typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); -typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); -typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); -typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); -typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); - -#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) -#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) -#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) -#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) -#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) -#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) -#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) -#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) -#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) -#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) -#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) -#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) -#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) -#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) -#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) -#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) -#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) -#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) -#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) -#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) -#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) -#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) -#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) -#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) -#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) -#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) -#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) -#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) -#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) -#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) -#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) -#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) -#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) -#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) -#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) -#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) -#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) -#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) -#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) -#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) -#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) -#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) - -#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) - -#endif /* GL_EXT_vertex_shader */ - -/* ------------------------ GL_EXT_vertex_weighting ------------------------ */ - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 - -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 - -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); - -#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) -#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) -#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) - -#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) - -#endif /* GL_EXT_vertex_weighting */ - -/* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */ - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 - -typedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void); - -#define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY) - -#define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator) - -#endif /* GL_GREMEDY_frame_terminator */ - -/* ------------------------ GL_GREMEDY_string_marker ----------------------- */ - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 - -typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string); - -#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) - -#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) - -#endif /* GL_GREMEDY_string_marker */ - -/* --------------------- GL_HP_convolution_border_modes -------------------- */ - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 - -#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) - -#endif /* GL_HP_convolution_border_modes */ - -/* ------------------------- GL_HP_image_transform ------------------------- */ - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 - -typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) -#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) -#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) -#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) -#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) -#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) - -#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) - -#endif /* GL_HP_image_transform */ - -/* -------------------------- GL_HP_occlusion_test ------------------------- */ - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 - -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 - -#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) - -#endif /* GL_HP_occlusion_test */ - -/* ------------------------- GL_HP_texture_lighting ------------------------ */ - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 - -#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) - -#endif /* GL_HP_texture_lighting */ - -/* --------------------------- GL_IBM_cull_vertex -------------------------- */ - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 - -#define GL_CULL_VERTEX_IBM 103050 - -#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) - -#endif /* GL_IBM_cull_vertex */ - -/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 - -typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride); - -#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) -#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) - -#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) - -#endif /* GL_IBM_multimode_draw_arrays */ - -/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 - -#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 - -#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) - -#endif /* GL_IBM_rasterpos_clip */ - -/* --------------------------- GL_IBM_static_data -------------------------- */ - -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 - -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 - -#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) - -#endif /* GL_IBM_static_data */ - -/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 - -#define GL_MIRRORED_REPEAT_IBM 0x8370 - -#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) - -#endif /* GL_IBM_texture_mirrored_repeat */ - -/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 - -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 - -typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); - -#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) -#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) -#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) -#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) -#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) -#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) -#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) -#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) - -#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) - -#endif /* GL_IBM_vertex_array_lists */ - -/* -------------------------- GL_INGR_color_clamp -------------------------- */ - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 - -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 - -#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) - -#endif /* GL_INGR_color_clamp */ - -/* ------------------------- GL_INGR_interlace_read ------------------------ */ - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 - -#define GL_INTERLACE_READ_INGR 0x8568 - -#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) - -#endif /* GL_INGR_interlace_read */ - -/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 - -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 - -typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); - -#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) -#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) -#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) -#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) - -#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) - -#endif /* GL_INTEL_parallel_arrays */ - -/* ------------------------ GL_INTEL_texture_scissor ----------------------- */ - -#ifndef GL_INTEL_texture_scissor -#define GL_INTEL_texture_scissor 1 - -typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); -typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); - -#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) -#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) - -#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) - -#endif /* GL_INTEL_texture_scissor */ - -/* -------------------------- GL_KTX_buffer_region ------------------------- */ - -#ifndef GL_KTX_buffer_region -#define GL_KTX_buffer_region 1 - -#define GL_KTX_FRONT_REGION 0x0 -#define GL_KTX_BACK_REGION 0x1 -#define GL_KTX_Z_REGION 0x2 -#define GL_KTX_STENCIL_REGION 0x3 - -typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONEXTPROC) (GLenum region); -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); -typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONEXTPROC) (GLenum region); -typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); - -#define glBufferRegionEnabledEXT GLEW_GET_FUN(__glewBufferRegionEnabledEXT) -#define glDeleteBufferRegionEXT GLEW_GET_FUN(__glewDeleteBufferRegionEXT) -#define glDrawBufferRegionEXT GLEW_GET_FUN(__glewDrawBufferRegionEXT) -#define glNewBufferRegionEXT GLEW_GET_FUN(__glewNewBufferRegionEXT) -#define glReadBufferRegionEXT GLEW_GET_FUN(__glewReadBufferRegionEXT) - -#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) - -#endif /* GL_KTX_buffer_region */ - -/* ------------------------- GL_MESAX_texture_stack ------------------------ */ - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 - -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E - -#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) - -#endif /* GL_MESAX_texture_stack */ - -/* -------------------------- GL_MESA_pack_invert -------------------------- */ - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 - -#define GL_PACK_INVERT_MESA 0x8758 - -#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) - -#endif /* GL_MESA_pack_invert */ - -/* ------------------------- GL_MESA_resize_buffers ------------------------ */ - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 - -typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); - -#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) - -#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) - -#endif /* GL_MESA_resize_buffers */ - -/* --------------------------- GL_MESA_window_pos -------------------------- */ - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 - -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); - -#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) -#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) -#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) -#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) -#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) -#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) -#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) -#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) -#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) -#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) -#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) -#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) -#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) -#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) -#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) -#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) -#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) -#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) -#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) -#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) -#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) -#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) -#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) -#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) - -#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) - -#endif /* GL_MESA_window_pos */ - -/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 - -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 - -#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) - -#endif /* GL_MESA_ycbcr_texture */ - -/* --------------------------- GL_NV_blend_square -------------------------- */ - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 - -#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) - -#endif /* GL_NV_blend_square */ - -/* ------------------------ GL_NV_conditional_render ----------------------- */ - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 - -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void); - -#define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV) -#define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV) - -#define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render) - -#endif /* GL_NV_conditional_render */ - -/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 - -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F - -#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) - -#endif /* GL_NV_copy_depth_to_color */ - -/* ---------------------------- GL_NV_copy_image --------------------------- */ - -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 - -typedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); - -#define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV) - -#define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image) - -#endif /* GL_NV_copy_image */ - -/* ------------------------ GL_NV_depth_buffer_float ----------------------- */ - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 - -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); - -#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) -#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) -#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) - -#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) - -#endif /* GL_NV_depth_buffer_float */ - -/* --------------------------- GL_NV_depth_clamp --------------------------- */ - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 - -#define GL_DEPTH_CLAMP_NV 0x864F - -#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) - -#endif /* GL_NV_depth_clamp */ - -/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ - -#ifndef GL_NV_depth_range_unclamped -#define GL_NV_depth_range_unclamped 1 - -#define GL_SAMPLE_COUNT_BITS_NV 0x8864 -#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 -#define GL_QUERY_RESULT_NV 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 -#define GL_SAMPLE_COUNT_NV 0x8914 - -#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) - -#endif /* GL_NV_depth_range_unclamped */ - -/* ---------------------------- GL_NV_evaluators --------------------------- */ - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 - -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 - -typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points); -typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points); -typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) -#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) -#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) -#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) -#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) -#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) -#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) -#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) -#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) - -#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) - -#endif /* GL_NV_evaluators */ - -/* ----------------------- GL_NV_explicit_multisample ---------------------- */ - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 - -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 - -typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val); -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); - -#define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV) -#define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV) -#define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV) - -#define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample) - -#endif /* GL_NV_explicit_multisample */ - -/* ------------------------------ GL_NV_fence ------------------------------ */ - -#ifndef GL_NV_fence -#define GL_NV_fence 1 - -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 - -typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); -typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); -typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); - -#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) -#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) -#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) -#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) -#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) -#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) -#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) - -#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) - -#endif /* GL_NV_fence */ - -/* --------------------------- GL_NV_float_buffer -------------------------- */ - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 - -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E - -#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) - -#endif /* GL_NV_float_buffer */ - -/* --------------------------- GL_NV_fog_distance -------------------------- */ - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 - -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C - -#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) - -#endif /* GL_NV_fog_distance */ - -/* ------------------------- GL_NV_fragment_program ------------------------ */ - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 - -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 - -typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); - -#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) -#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) -#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) -#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) -#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) -#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) - -#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) - -#endif /* GL_NV_fragment_program */ - -/* ------------------------ GL_NV_fragment_program2 ------------------------ */ - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 - -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 - -#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) - -#endif /* GL_NV_fragment_program2 */ - -/* ------------------------ GL_NV_fragment_program4 ------------------------ */ - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 - -#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) - -#endif /* GL_NV_fragment_program4 */ - -/* --------------------- GL_NV_fragment_program_option --------------------- */ - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 - -#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) - -#endif /* GL_NV_fragment_program_option */ - -/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 - -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) - -#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) - -#endif /* GL_NV_framebuffer_multisample_coverage */ - -/* ------------------------ GL_NV_geometry_program4 ------------------------ */ - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 - -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 - -typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); - -#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) - -#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) - -#endif /* GL_NV_geometry_program4 */ - -/* ------------------------- GL_NV_geometry_shader4 ------------------------ */ - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 - -#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) - -#endif /* GL_NV_geometry_shader4 */ - -/* --------------------------- GL_NV_gpu_program4 -------------------------- */ - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 - -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 - -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); - -#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) -#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) -#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) -#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) -#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) -#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) -#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) -#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) -#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) -#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) -#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) -#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) - -#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) - -#endif /* GL_NV_gpu_program4 */ - -/* ---------------------------- GL_NV_half_float --------------------------- */ - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 - -#define GL_HALF_FLOAT_NV 0x140B - -typedef unsigned short GLhalf; - -typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); -typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); -typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); -typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); -typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); -typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); -typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); -typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); -typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); -typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); - -#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) -#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) -#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) -#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) -#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) -#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) -#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) -#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) -#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) -#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) -#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) -#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) -#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) -#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) -#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) -#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) -#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) -#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) -#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) -#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) -#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) -#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) -#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) -#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) -#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) -#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) -#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) -#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) -#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) -#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) -#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) -#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) -#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) -#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) -#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) -#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) -#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) -#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) -#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) -#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) -#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) -#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) -#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) -#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) -#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) -#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) - -#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) - -#endif /* GL_NV_half_float */ - -/* ------------------------ GL_NV_light_max_exponent ----------------------- */ - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 - -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 - -#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) - -#endif /* GL_NV_light_max_exponent */ - -/* --------------------- GL_NV_multisample_filter_hint --------------------- */ - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 - -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 - -#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) - -#endif /* GL_NV_multisample_filter_hint */ - -/* ------------------------- GL_NV_occlusion_query ------------------------- */ - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 - -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 - -typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); - -#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) -#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) -#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) -#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) -#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) -#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) -#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) - -#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) - -#endif /* GL_NV_occlusion_query */ - -/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA - -#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) - -#endif /* GL_NV_packed_depth_stencil */ - -/* --------------------- GL_NV_parameter_buffer_object --------------------- */ - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 - -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 - -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); - -#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) -#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) -#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) - -#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) - -#endif /* GL_NV_parameter_buffer_object */ - -/* --------------------- GL_NV_parameter_buffer_object2 -------------------- */ - -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 - -#define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2) - -#endif /* GL_NV_parameter_buffer_object2 */ - -/* ------------------------- GL_NV_pixel_data_range ------------------------ */ - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 - -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D - -typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer); - -#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) -#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) - -#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) - -#endif /* GL_NV_pixel_data_range */ - -/* --------------------------- GL_NV_point_sprite -------------------------- */ - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 - -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); - -#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) -#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) - -#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) - -#endif /* GL_NV_point_sprite */ - -/* -------------------------- GL_NV_present_video -------------------------- */ - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 - -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B - -typedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); - -#define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV) -#define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV) -#define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV) -#define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV) -#define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV) -#define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV) - -#define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video) - -#endif /* GL_NV_present_video */ - -/* ------------------------ GL_NV_primitive_restart ------------------------ */ - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 - -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 - -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); - -#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) -#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) - -#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) - -#endif /* GL_NV_primitive_restart */ - -/* ------------------------ GL_NV_register_combiners ----------------------- */ - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 - -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 - -typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); - -#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) -#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) -#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) -#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) -#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) -#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) -#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) -#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) -#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) -#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) -#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) -#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) -#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) - -#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) - -#endif /* GL_NV_register_combiners */ - -/* ----------------------- GL_NV_register_combiners2 ----------------------- */ - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 - -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 - -typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); - -#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) -#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) - -#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) - -#endif /* GL_NV_register_combiners2 */ - -/* ------------------------ GL_NV_shader_buffer_load ----------------------- */ - -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 - -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 - -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value); - -#define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV) -#define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV) -#define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV) -#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV) -#define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV) -#define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV) -#define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV) -#define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV) -#define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV) -#define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV) -#define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV) -#define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV) -#define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV) -#define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV) - -#define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load) - -#endif /* GL_NV_shader_buffer_load */ - -/* -------------------------- GL_NV_texgen_emboss -------------------------- */ - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 - -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F - -#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) - -#endif /* GL_NV_texgen_emboss */ - -/* ------------------------ GL_NV_texgen_reflection ------------------------ */ - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 - -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 - -#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) - -#endif /* GL_NV_texgen_reflection */ - -/* ------------------------- GL_NV_texture_barrier ------------------------- */ - -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 - -typedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void); - -#define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV) - -#define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier) - -#endif /* GL_NV_texture_barrier */ - -/* --------------------- GL_NV_texture_compression_vtc --------------------- */ - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 - -#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) - -#endif /* GL_NV_texture_compression_vtc */ - -/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 - -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B - -#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) - -#endif /* GL_NV_texture_env_combine4 */ - -/* ---------------------- GL_NV_texture_expand_normal ---------------------- */ - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 - -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F - -#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) - -#endif /* GL_NV_texture_expand_normal */ - -/* ------------------------ GL_NV_texture_rectangle ------------------------ */ - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 - -#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) - -#endif /* GL_NV_texture_rectangle */ - -/* -------------------------- GL_NV_texture_shader ------------------------- */ - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 - -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F - -#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) - -#endif /* GL_NV_texture_shader */ - -/* ------------------------- GL_NV_texture_shader2 ------------------------- */ - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 - -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D - -#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) - -#endif /* GL_NV_texture_shader2 */ - -/* ------------------------- GL_NV_texture_shader3 ------------------------- */ - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 - -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 - -#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) - -#endif /* GL_NV_texture_shader3 */ - -/* ------------------------ GL_NV_transform_feedback ----------------------- */ - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 - -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F - -typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); - -#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) -#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) -#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) -#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) -#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) -#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) -#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) -#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) -#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) -#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) -#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) - -#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) - -#endif /* GL_NV_transform_feedback */ - -/* ----------------------- GL_NV_transform_feedback2 ----------------------- */ - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 - -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 - -typedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -typedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids); -typedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); - -#define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV) -#define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV) -#define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV) -#define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV) -#define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV) -#define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV) -#define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV) - -#define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2) - -#endif /* GL_NV_transform_feedback2 */ - -/* ------------------------ GL_NV_vertex_array_range ----------------------- */ - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 - -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 - -typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer); - -#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) -#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) - -#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) - -#endif /* GL_NV_vertex_array_range */ - -/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 - -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 - -#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) - -#endif /* GL_NV_vertex_array_range2 */ - -/* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */ - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 - -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 - -typedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]); -typedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); - -#define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV) -#define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV) -#define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV) -#define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV) -#define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV) -#define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV) -#define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV) -#define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV) -#define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV) -#define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV) -#define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV) -#define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV) - -#define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory) - -#endif /* GL_NV_vertex_buffer_unified_memory */ - -/* -------------------------- GL_NV_vertex_program ------------------------- */ - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 - -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F - -typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint num, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint num, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); - -#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) -#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) -#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) -#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) -#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) -#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) -#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) -#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) -#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) -#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) -#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) -#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) -#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) -#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) -#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) -#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) -#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) -#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) -#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) -#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) -#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) -#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) -#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) -#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) -#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) -#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) -#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) -#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) -#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) -#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) -#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) -#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) -#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) -#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) -#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) -#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) -#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) -#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) -#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) -#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) -#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) -#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) -#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) -#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) -#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) -#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) -#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) -#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) -#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) -#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) -#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) -#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) -#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) -#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) -#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) -#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) -#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) -#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) -#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) -#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) -#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) -#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) -#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) -#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) - -#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) - -#endif /* GL_NV_vertex_program */ - -/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 - -#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) - -#endif /* GL_NV_vertex_program1_1 */ - -/* ------------------------- GL_NV_vertex_program2 ------------------------- */ - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 - -#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) - -#endif /* GL_NV_vertex_program2 */ - -/* ---------------------- GL_NV_vertex_program2_option --------------------- */ - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 - -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 - -#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) - -#endif /* GL_NV_vertex_program2_option */ - -/* ------------------------- GL_NV_vertex_program3 ------------------------- */ - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 - -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C - -#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) - -#endif /* GL_NV_vertex_program3 */ - -/* ------------------------- GL_NV_vertex_program4 ------------------------- */ - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 - -#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) - -#endif /* GL_NV_vertex_program4 */ - -/* ------------------------ GL_OES_byte_coordinates ------------------------ */ - -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 - -#define GL_BYTE 0x1400 - -#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) - -#endif /* GL_OES_byte_coordinates */ - -/* ------------------- GL_OES_compressed_paletted_texture ------------------ */ - -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 - -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 - -#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) - -#endif /* GL_OES_compressed_paletted_texture */ - -/* --------------------------- GL_OES_read_format -------------------------- */ - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 - -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B - -#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) - -#endif /* GL_OES_read_format */ - -/* ------------------------ GL_OES_single_precision ------------------------ */ - -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth); -typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); - -#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) -#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) -#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) -#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) -#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) -#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) - -#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) - -#endif /* GL_OES_single_precision */ - -/* ---------------------------- GL_OML_interlace --------------------------- */ - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 - -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 - -#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) - -#endif /* GL_OML_interlace */ - -/* ---------------------------- GL_OML_resample ---------------------------- */ - -#ifndef GL_OML_resample -#define GL_OML_resample 1 - -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 - -#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) - -#endif /* GL_OML_resample */ - -/* ---------------------------- GL_OML_subsample --------------------------- */ - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 - -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 - -#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) - -#endif /* GL_OML_subsample */ - -/* --------------------------- GL_PGI_misc_hints --------------------------- */ - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 - -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 -#define GL_CONSERVE_MEMORY_HINT_PGI 107005 -#define GL_RECLAIM_MEMORY_HINT_PGI 107006 -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 -#define GL_ALWAYS_FAST_HINT_PGI 107020 -#define GL_ALWAYS_SOFT_HINT_PGI 107021 -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 -#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 -#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 -#define GL_STRICT_LIGHTING_HINT_PGI 107031 -#define GL_STRICT_SCISSOR_HINT_PGI 107032 -#define GL_FULL_STIPPLE_HINT_PGI 107033 -#define GL_CLIP_NEAR_HINT_PGI 107040 -#define GL_CLIP_FAR_HINT_PGI 107041 -#define GL_WIDE_LINE_HINT_PGI 107042 -#define GL_BACK_NORMALS_HINT_PGI 107043 - -#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) - -#endif /* GL_PGI_misc_hints */ - -/* -------------------------- GL_PGI_vertex_hints -------------------------- */ - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 - -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_VERTEX_DATA_HINT_PGI 107050 -#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 -#define GL_MATERIAL_SIDE_HINT_PGI 107052 -#define GL_MAX_VERTEX_HINT_PGI 107053 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 - -#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) - -#endif /* GL_PGI_vertex_hints */ - -/* ----------------------- GL_REND_screen_coordinates ---------------------- */ - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 - -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 - -#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) - -#endif /* GL_REND_screen_coordinates */ - -/* ------------------------------- GL_S3_s3tc ------------------------------ */ - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 - -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 - -#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) - -#endif /* GL_S3_s3tc */ - -/* -------------------------- GL_SGIS_color_range -------------------------- */ - -#ifndef GL_SGIS_color_range -#define GL_SGIS_color_range 1 - -#define GL_EXTENDED_RANGE_SGIS 0x85A5 -#define GL_MIN_RED_SGIS 0x85A6 -#define GL_MAX_RED_SGIS 0x85A7 -#define GL_MIN_GREEN_SGIS 0x85A8 -#define GL_MAX_GREEN_SGIS 0x85A9 -#define GL_MIN_BLUE_SGIS 0x85AA -#define GL_MAX_BLUE_SGIS 0x85AB -#define GL_MIN_ALPHA_SGIS 0x85AC -#define GL_MAX_ALPHA_SGIS 0x85AD - -#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) - -#endif /* GL_SGIS_color_range */ - -/* ------------------------- GL_SGIS_detail_texture ------------------------ */ - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 - -typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); - -#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) -#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) - -#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) - -#endif /* GL_SGIS_detail_texture */ - -/* -------------------------- GL_SGIS_fog_function ------------------------- */ - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 - -typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); - -#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) -#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) - -#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) - -#endif /* GL_SGIS_fog_function */ - -/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 - -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 - -#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) - -#endif /* GL_SGIS_generate_mipmap */ - -/* -------------------------- GL_SGIS_multisample -------------------------- */ - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 - -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); - -#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) -#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) - -#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) - -#endif /* GL_SGIS_multisample */ - -/* ------------------------- GL_SGIS_pixel_texture ------------------------- */ - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 - -#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) - -#endif /* GL_SGIS_pixel_texture */ - -/* ----------------------- GL_SGIS_point_line_texgen ----------------------- */ - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 - -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 - -#define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen) - -#endif /* GL_SGIS_point_line_texgen */ - -/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 - -typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); -typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); - -#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) -#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) - -#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) - -#endif /* GL_SGIS_sharpen_texture */ - -/* --------------------------- GL_SGIS_texture4D --------------------------- */ - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels); - -#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) -#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) - -#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) - -#endif /* GL_SGIS_texture4D */ - -/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 - -#define GL_CLAMP_TO_BORDER_SGIS 0x812D - -#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) - -#endif /* GL_SGIS_texture_border_clamp */ - -/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_SGIS 0x812F - -#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) - -#endif /* GL_SGIS_texture_edge_clamp */ - -/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 - -typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); -typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); - -#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) -#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) - -#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) - -#endif /* GL_SGIS_texture_filter4 */ - -/* -------------------------- GL_SGIS_texture_lod -------------------------- */ - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 - -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D - -#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) - -#endif /* GL_SGIS_texture_lod */ - -/* ------------------------- GL_SGIS_texture_select ------------------------ */ - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 - -#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) - -#endif /* GL_SGIS_texture_select */ - -/* ----------------------------- GL_SGIX_async ----------------------------- */ - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 - -#define GL_ASYNC_MARKER_SGIX 0x8329 - -typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); -typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); - -#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) -#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) -#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) -#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) -#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) -#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) - -#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) - -#endif /* GL_SGIX_async */ - -/* ------------------------ GL_SGIX_async_histogram ------------------------ */ - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 - -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D - -#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) - -#endif /* GL_SGIX_async_histogram */ - -/* -------------------------- GL_SGIX_async_pixel -------------------------- */ - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 - -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 - -#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) - -#endif /* GL_SGIX_async_pixel */ - -/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 - -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 - -#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) - -#endif /* GL_SGIX_blend_alpha_minmax */ - -/* ---------------------------- GL_SGIX_clipmap ---------------------------- */ - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 - -#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) - -#endif /* GL_SGIX_clipmap */ - -/* ---------------------- GL_SGIX_convolution_accuracy --------------------- */ - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 - -#define GL_CONVOLUTION_HINT_SGIX 0x8316 - -#define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy) - -#endif /* GL_SGIX_convolution_accuracy */ - -/* ------------------------- GL_SGIX_depth_texture ------------------------- */ - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 - -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 - -#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) - -#endif /* GL_SGIX_depth_texture */ - -/* -------------------------- GL_SGIX_flush_raster ------------------------- */ - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 - -typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); - -#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) - -#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) - -#endif /* GL_SGIX_flush_raster */ - -/* --------------------------- GL_SGIX_fog_offset -------------------------- */ - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 - -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 - -#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) - -#endif /* GL_SGIX_fog_offset */ - -/* -------------------------- GL_SGIX_fog_texture -------------------------- */ - -#ifndef GL_SGIX_fog_texture -#define GL_SGIX_fog_texture 1 - -#define GL_TEXTURE_FOG_SGIX 0 -#define GL_FOG_PATCHY_FACTOR_SGIX 0 -#define GL_FRAGMENT_FOG_SGIX 0 - -typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); - -#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) - -#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) - -#endif /* GL_SGIX_fog_texture */ - -/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ - -#ifndef GL_SGIX_fragment_specular_lighting -#define GL_SGIX_fragment_specular_lighting 1 - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); - -#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) -#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) -#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) -#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) -#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) -#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) -#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) -#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) -#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) -#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) -#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) -#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) -#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) -#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) -#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) -#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) -#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) - -#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) - -#endif /* GL_SGIX_fragment_specular_lighting */ - -/* --------------------------- GL_SGIX_framezoom --------------------------- */ - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 - -typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); - -#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) - -#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) - -#endif /* GL_SGIX_framezoom */ - -/* --------------------------- GL_SGIX_interlace --------------------------- */ - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 - -#define GL_INTERLACE_SGIX 0x8094 - -#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) - -#endif /* GL_SGIX_interlace */ - -/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 - -#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) - -#endif /* GL_SGIX_ir_instrument1 */ - -/* ------------------------- GL_SGIX_list_priority ------------------------- */ - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 - -#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) - -#endif /* GL_SGIX_list_priority */ - -/* ------------------------- GL_SGIX_pixel_texture ------------------------- */ - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 - -typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); - -#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) - -#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) - -#endif /* GL_SGIX_pixel_texture */ - -/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ - -#ifndef GL_SGIX_pixel_texture_bits -#define GL_SGIX_pixel_texture_bits 1 - -#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) - -#endif /* GL_SGIX_pixel_texture_bits */ - -/* ------------------------ GL_SGIX_reference_plane ------------------------ */ - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 - -typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); - -#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) - -#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) - -#endif /* GL_SGIX_reference_plane */ - -/* ---------------------------- GL_SGIX_resample --------------------------- */ - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 - -#define GL_PACK_RESAMPLE_SGIX 0x842E -#define GL_UNPACK_RESAMPLE_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 - -#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) - -#endif /* GL_SGIX_resample */ - -/* ----------------------------- GL_SGIX_shadow ---------------------------- */ - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 - -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D - -#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) - -#endif /* GL_SGIX_shadow */ - -/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 - -#define GL_SHADOW_AMBIENT_SGIX 0x80BF - -#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) - -#endif /* GL_SGIX_shadow_ambient */ - -/* ----------------------------- GL_SGIX_sprite ---------------------------- */ - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 - -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); - -#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) -#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) -#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) -#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) - -#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) - -#endif /* GL_SGIX_sprite */ - -/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 - -typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); - -#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) - -#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) - -#endif /* GL_SGIX_tag_sample_buffer */ - -/* ------------------------ GL_SGIX_texture_add_env ------------------------ */ - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 - -#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) - -#endif /* GL_SGIX_texture_add_env */ - -/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 - -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B - -#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) - -#endif /* GL_SGIX_texture_coordinate_clamp */ - -/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 - -#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) - -#endif /* GL_SGIX_texture_lod_bias */ - -/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 - -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E - -#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) - -#endif /* GL_SGIX_texture_multi_buffer */ - -/* ------------------------- GL_SGIX_texture_range ------------------------- */ - -#ifndef GL_SGIX_texture_range -#define GL_SGIX_texture_range 1 - -#define GL_RGB_SIGNED_SGIX 0x85E0 -#define GL_RGBA_SIGNED_SGIX 0x85E1 -#define GL_ALPHA_SIGNED_SGIX 0x85E2 -#define GL_LUMINANCE_SIGNED_SGIX 0x85E3 -#define GL_INTENSITY_SIGNED_SGIX 0x85E4 -#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 -#define GL_RGB16_SIGNED_SGIX 0x85E6 -#define GL_RGBA16_SIGNED_SGIX 0x85E7 -#define GL_ALPHA16_SIGNED_SGIX 0x85E8 -#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 -#define GL_INTENSITY16_SIGNED_SGIX 0x85EA -#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB -#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC -#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED -#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE -#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF -#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 -#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 -#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 -#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 -#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 -#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 -#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 -#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 -#define GL_MIN_LUMINANCE_SGIS 0x85F8 -#define GL_MAX_LUMINANCE_SGIS 0x85F9 -#define GL_MIN_INTENSITY_SGIS 0x85FA -#define GL_MAX_INTENSITY_SGIS 0x85FB - -#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) - -#endif /* GL_SGIX_texture_range */ - -/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 - -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C - -#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) - -#endif /* GL_SGIX_texture_scale_bias */ - -/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 - -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF - -#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) - -#endif /* GL_SGIX_vertex_preclip */ - -/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ - -#ifndef GL_SGIX_vertex_preclip_hint -#define GL_SGIX_vertex_preclip_hint 1 - -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF - -#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) - -#endif /* GL_SGIX_vertex_preclip_hint */ - -/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 - -#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) - -#endif /* GL_SGIX_ycrcb */ - -/* -------------------------- GL_SGI_color_matrix -------------------------- */ - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 - -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB - -#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) - -#endif /* GL_SGI_color_matrix */ - -/* --------------------------- GL_SGI_color_table -------------------------- */ - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 - -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF - -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table); - -#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) -#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) -#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) -#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) -#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) -#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) -#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) - -#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) - -#endif /* GL_SGI_color_table */ - -/* ----------------------- GL_SGI_texture_color_table ---------------------- */ - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 - -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD - -#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) - -#endif /* GL_SGI_texture_color_table */ - -/* ------------------------- GL_SUNX_constant_data ------------------------- */ - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 - -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 - -typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); - -#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) - -#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) - -#endif /* GL_SUNX_constant_data */ - -/* -------------------- GL_SUN_convolution_border_modes -------------------- */ - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 - -#define GL_WRAP_BORDER_SUN 0x81D4 - -#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) - -#endif /* GL_SUN_convolution_border_modes */ - -/* -------------------------- GL_SUN_global_alpha -------------------------- */ - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 - -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA - -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); - -#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) -#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) -#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) -#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) -#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) -#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) -#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) -#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) - -#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) - -#endif /* GL_SUN_global_alpha */ - -/* --------------------------- GL_SUN_mesh_array --------------------------- */ - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 - -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 - -#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) - -#endif /* GL_SUN_mesh_array */ - -/* ------------------------ GL_SUN_read_video_pixels ----------------------- */ - -#ifndef GL_SUN_read_video_pixels -#define GL_SUN_read_video_pixels 1 - -typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); - -#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) - -#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) - -#endif /* GL_SUN_read_video_pixels */ - -/* --------------------------- GL_SUN_slice_accum -------------------------- */ - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 - -#define GL_SLICE_ACCUM_SUN 0x85CC - -#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) - -#endif /* GL_SUN_slice_accum */ - -/* -------------------------- GL_SUN_triangle_list ------------------------- */ - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 - -#define GL_RESTART_SUN 0x01 -#define GL_REPLACE_MIDDLE_SUN 0x02 -#define GL_REPLACE_OLDEST_SUN 0x03 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB - -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); - -#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) -#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) -#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) -#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) -#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) -#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) -#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) - -#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) - -#endif /* GL_SUN_triangle_list */ - -/* ----------------------------- GL_SUN_vertex ----------------------------- */ - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 - -typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); - -#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) -#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) -#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) -#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) -#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) -#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) -#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) -#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) -#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) -#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) -#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) -#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) -#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) -#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) -#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) -#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) -#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) -#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) -#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) -#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) -#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) -#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) -#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) -#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) -#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) -#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) -#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) -#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) -#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) -#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) -#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) -#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) -#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) -#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) - -#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) - -#endif /* GL_SUN_vertex */ - -/* -------------------------- GL_WIN_phong_shading ------------------------- */ - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 - -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB - -#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) - -#endif /* GL_WIN_phong_shading */ - -/* -------------------------- GL_WIN_specular_fog -------------------------- */ - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 - -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC - -#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) - -#endif /* GL_WIN_specular_fog */ - -/* ---------------------------- GL_WIN_swap_hint --------------------------- */ - -#ifndef GL_WIN_swap_hint -#define GL_WIN_swap_hint 1 - -typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); - -#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) - -#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) - -#endif /* GL_WIN_swap_hint */ - -/* ------------------------------------------------------------------------- */ - -#if defined(GLEW_MX) && defined(_WIN32) -#define GLEW_FUN_EXPORT -#else -#define GLEW_FUN_EXPORT GLEWAPI -#endif /* GLEW_MX */ - -#if defined(GLEW_MX) -#define GLEW_VAR_EXPORT -#else -#define GLEW_VAR_EXPORT GLEWAPI -#endif /* GLEW_MX */ - -#if defined(GLEW_MX) && defined(_WIN32) -struct GLEWContextStruct -{ -#endif /* GLEW_MX */ - -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; - -GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; -GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; - -GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; -GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; -GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; -GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; -GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; -GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; -GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; -GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; -GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; -GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; -GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; -GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; -GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; -GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; -GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; -GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; -GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; - -GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; -GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; -GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; -GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; -GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; -GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; -GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; -GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; -GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; -GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; -GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; -GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; -GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; -GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; -GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; -GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; -GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; -GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; -GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; -GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; -GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; -GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; -GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; -GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; -GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; -GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; -GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; -GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; -GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; -GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; -GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; -GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; -GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; -GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; -GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; -GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; -GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; -GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; -GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; - -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender; -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback; -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation; -GLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv; -GLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski; -GLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei; -GLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback; -GLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v; -GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation; -GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv; -GLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced; -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex; -GLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v; -GLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v; - -GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD; -GLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD; - -GLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD; -GLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD; -GLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD; -GLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD; -GLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD; -GLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD; - -GLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD; -GLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; - -GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; -GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; -GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; -GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; -GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; -GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; -GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; -GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; - -GLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE; -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE; -GLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE; -GLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE; - -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; -GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; -GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; -GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; - -GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE; -GLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE; -GLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE; - -GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; - -GLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData; - -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB; -GLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB; - -GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer; -GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer; -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer; -GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus; -GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers; -GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer; -GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers; -GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers; -GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv; -GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv; -GLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer; -GLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB; - -GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; -GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; -GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; -GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; -GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; -GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; -GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; -GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; -GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; -GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; - -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB; - -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange; -GLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange; - -GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; - -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; - -GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; -GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; -GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; -GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; -GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; -GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; - -GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex; - -GLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB; - -GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; -GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; -GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; -GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; -GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; -GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; -GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; -GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; -GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; -GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; -GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; - -GLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync; -GLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync; -GLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync; -GLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v; -GLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv; -GLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync; -GLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync; - -GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB; - -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; - -GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv; -GLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski; -GLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample; -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample; - -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; - -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv; -GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v; -GLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex; -GLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices; -GLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays; -GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays; -GLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray; - -GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; -GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; -GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; -GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; - -GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; -GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; -GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; -GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; -GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; -GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; -GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; - -GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; -GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; -GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; - -GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; -GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; -GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; - -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; - -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; -GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; - -GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; -GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; -GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; -GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; - -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; -GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; -GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; -GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; -GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; -GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; - -GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; -GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; - -GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI; -GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI; - -GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; -GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; - -GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; -GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; -GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; -GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; -GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; -GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; -GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; -GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; - -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; - -GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; -GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; -GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; - -GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; -GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; -GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; - -GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; - -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; - -GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; -GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; - -GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; -GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; - -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; -GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; - -GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; -GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; - -GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; - -GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; -GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; - -GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; - -GLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT; -GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT; -GLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT; -GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT; -GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT; -GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT; -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT; -GLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT; -GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT; -GLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT; -GLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT; -GLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT; -GLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT; -GLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT; -GLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT; -GLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT; -GLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT; -GLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT; - -GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; -GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; -GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; -GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; -GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; - -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; - -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; -GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; - -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; -GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; -GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; -GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; -GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; -GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; -GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; -GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; - -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; - -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; -GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; -GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; -GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; -GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; - -GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; - -GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; - -GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; -GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; - -GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; -GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; - -GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; - -GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; - -GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; - -GLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT; - -GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; -GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; - -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; - -GLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT; -GLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT; -GLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT; - -GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; - -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; - -GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; - -GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; -GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; - -GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; -GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; -GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; -GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; -GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; - -GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; - -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; - -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT; - -GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; -GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; -GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; -GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT; -GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; -GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; - -GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; -GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; -GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; -GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; -GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; -GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; -GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; -GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; -GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; -GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; -GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; -GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; -GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; -GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; -GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; -GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; -GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; - -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; - -GLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY; - -GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; - -GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; -GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; - -GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; -GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; - -GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; -GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; -GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; -GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; - -GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; -GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; - -GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; -GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; - -GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT; -GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT; -GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT; -GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT; - -GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; - -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV; - -GLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; -GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; - -GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; -GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; -GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; -GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; -GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; -GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; -GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; - -GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV; -GLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV; -GLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV; - -GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; -GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; -GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; -GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; -GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; -GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; -GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; - -GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; - -GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; -GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; -GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; -GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; -GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; -GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; -GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; -GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; -GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; - -GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; -GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; -GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; -GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; -GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; -GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; -GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; - -GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; -GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; - -GLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV; -GLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV; -GLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV; - -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; - -GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; -GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; -GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; -GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; - -GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; - -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV; -GLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV; -GLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV; -GLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV; -GLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV; -GLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV; -GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV; -GLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV; -GLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV; -GLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV; - -GLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV; - -GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; -GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; - -GLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV; -GLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV; -GLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV; - -GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; - -GLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV; -GLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV; -GLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV; -GLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV; -GLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV; -GLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV; -GLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV; -GLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV; - -GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; -GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; -GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; -GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; -GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; -GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; -GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; -GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; -GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; -GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; -GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; -GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; -GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; - -GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; -GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; - -GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; -GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; - -GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; -GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; - -GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; -GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; - -GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; -GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; - -GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; -GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; -GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; -GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; -GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; -GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; - -GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; - -GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; - -GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; - -GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; - -GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; - -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; - -GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; - -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; -GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; -GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; - -GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; - -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; - -GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; - -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; - -GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; - -GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; - -#if defined(GLEW_MX) && !defined(_WIN32) -struct GLEWContextStruct -{ -#endif /* GLEW_MX */ - -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4; -GLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; -GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator; -GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; -GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; -GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; -GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; -GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; -GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; -GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; -GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; - -#ifdef GLEW_MX -}; /* GLEWContextStruct */ -#endif /* GLEW_MX */ - -/* ------------------------------------------------------------------------- */ - -/* error codes */ -#define GLEW_OK 0 -#define GLEW_NO_ERROR 0 -#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ -#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */ -#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */ - -/* string codes */ -#define GLEW_VERSION 1 -#define GLEW_VERSION_MAJOR 2 -#define GLEW_VERSION_MINOR 3 -#define GLEW_VERSION_MICRO 4 - -/* API */ -#ifdef GLEW_MX - -typedef struct GLEWContextStruct GLEWContext; -GLEWAPI GLenum glewContextInit (GLEWContext* ctx); -GLEWAPI GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name); - -#define glewInit() glewContextInit(glewGetContext()) -#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) -#define glewIsExtensionSupported(x) glewIsSupported(x) - -#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) -#ifdef _WIN32 -# define GLEW_GET_FUN(x) glewGetContext()->x -#else -# define GLEW_GET_FUN(x) x -#endif - -#else /* GLEW_MX */ - -GLEWAPI GLenum glewInit (); -GLEWAPI GLboolean glewIsSupported (const char* name); -#define glewIsExtensionSupported(x) glewIsSupported(x) - -#define GLEW_GET_VAR(x) (*(const GLboolean*)&x) -#define GLEW_GET_FUN(x) x - -#endif /* GLEW_MX */ - -GLEWAPI GLboolean glewExperimental; -GLEWAPI GLboolean glewGetExtension (const char* name); -GLEWAPI const GLubyte* glewGetErrorString (GLenum error); -GLEWAPI const GLubyte* glewGetString (GLenum name); - -#ifdef __cplusplus -} -#endif - -#ifdef GLEW_APIENTRY_DEFINED -#undef GLEW_APIENTRY_DEFINED -#undef APIENTRY -#undef GLAPIENTRY -#define GLAPIENTRY -#endif - -#ifdef GLEW_CALLBACK_DEFINED -#undef GLEW_CALLBACK_DEFINED -#undef CALLBACK -#endif - -#ifdef GLEW_WINGDIAPI_DEFINED -#undef GLEW_WINGDIAPI_DEFINED -#undef WINGDIAPI -#endif - -#undef GLAPI -/* #undef GLEWAPI */ - -#endif /* __glew_h__ */ diff --git a/extern/glew/include/GL/glxew.h b/extern/glew/include/GL/glxew.h deleted file mode 100755 index 47b39e34..00000000 --- a/extern/glew/include/GL/glxew.h +++ /dev/null @@ -1,1446 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * 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. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __glxew_h__ -#define __glxew_h__ -#define __GLXEW_H__ - -#ifdef __glxext_h_ -#error glxext.h included before glxew.h -#endif -#ifdef GLX_H -#error glx.h included before glxew.h -#endif - -#define __glxext_h_ -#define __GLX_glx_h__ -#define GLX_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------------------------- GLX_VERSION_1_0 --------------------------- */ - -#ifndef GLX_VERSION_1_0 -#define GLX_VERSION_1_0 1 - -#define GLX_USE_GL 1 -#define GLX_BUFFER_SIZE 2 -#define GLX_LEVEL 3 -#define GLX_RGBA 4 -#define GLX_DOUBLEBUFFER 5 -#define GLX_STEREO 6 -#define GLX_AUX_BUFFERS 7 -#define GLX_RED_SIZE 8 -#define GLX_GREEN_SIZE 9 -#define GLX_BLUE_SIZE 10 -#define GLX_ALPHA_SIZE 11 -#define GLX_DEPTH_SIZE 12 -#define GLX_STENCIL_SIZE 13 -#define GLX_ACCUM_RED_SIZE 14 -#define GLX_ACCUM_GREEN_SIZE 15 -#define GLX_ACCUM_BLUE_SIZE 16 -#define GLX_ACCUM_ALPHA_SIZE 17 -#define GLX_BAD_SCREEN 1 -#define GLX_BAD_ATTRIBUTE 2 -#define GLX_NO_EXTENSION 3 -#define GLX_BAD_VISUAL 4 -#define GLX_BAD_CONTEXT 5 -#define GLX_BAD_VALUE 6 -#define GLX_BAD_ENUM 7 - -typedef XID GLXDrawable; -typedef XID GLXPixmap; -#ifdef __sun -typedef struct __glXContextRec *GLXContext; -#else -typedef struct __GLXcontextRec *GLXContext; -#endif - -typedef unsigned int GLXVideoDeviceNV; - -extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); -extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); -extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); -extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); -extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); -extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); -extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); -extern void glXDestroyContext (Display *dpy, GLXContext ctx); -extern Bool glXIsDirect (Display *dpy, GLXContext ctx); -extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); -extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); -extern GLXContext glXGetCurrentContext (void); -extern GLXDrawable glXGetCurrentDrawable (void); -extern void glXWaitGL (void); -extern void glXWaitX (void); -extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); -extern void glXUseXFont (Font font, int first, int count, int listBase); - -#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0) - -#endif /* GLX_VERSION_1_0 */ - -/* ---------------------------- GLX_VERSION_1_1 --------------------------- */ - -#ifndef GLX_VERSION_1_1 -#define GLX_VERSION_1_1 - -#define GLX_VENDOR 0x1 -#define GLX_VERSION 0x2 -#define GLX_EXTENSIONS 0x3 - -extern const char* glXQueryExtensionsString (Display *dpy, int screen); -extern const char* glXGetClientString (Display *dpy, int name); -extern const char* glXQueryServerString (Display *dpy, int screen, int name); - -#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1) - -#endif /* GLX_VERSION_1_1 */ - -/* ---------------------------- GLX_VERSION_1_2 ---------------------------- */ - -#ifndef GLX_VERSION_1_2 -#define GLX_VERSION_1_2 1 - -typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void); - -#define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay) - -#define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2) - -#endif /* GLX_VERSION_1_2 */ - -/* ---------------------------- GLX_VERSION_1_3 ---------------------------- */ - -#ifndef GLX_VERSION_1_3 -#define GLX_VERSION_1_3 1 - -#define GLX_RGBA_BIT 0x00000001 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_VISUAL_ID 0x800B -#define GLX_SCREEN 0x800C -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_DONT_CARE 0xFFFFFFFF - -typedef XID GLXFBConfigID; -typedef XID GLXWindow; -typedef XID GLXPbuffer; -typedef struct __GLXFBConfigRec *GLXFBConfig; - -typedef struct { - int event_type; - int draw_type; - unsigned long serial; - Bool send_event; - Display *display; - GLXDrawable drawable; - unsigned int buffer_mask; - unsigned int aux_buffer; - int x, y; - int width, height; - int count; -} GLXPbufferClobberEvent; -typedef union __GLXEvent { - GLXPbufferClobberEvent glxpbufferclobber; - long pad[24]; -} GLXEvent; - -typedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); -typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); -typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); -typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); -typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); -typedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); -typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); -typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); -typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); -typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); - -#define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig) -#define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext) -#define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer) -#define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap) -#define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow) -#define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer) -#define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap) -#define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow) -#define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable) -#define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib) -#define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs) -#define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent) -#define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig) -#define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent) -#define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext) -#define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable) -#define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent) - -#define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3) - -#endif /* GLX_VERSION_1_3 */ - -/* ---------------------------- GLX_VERSION_1_4 ---------------------------- */ - -#ifndef GLX_VERSION_1_4 -#define GLX_VERSION_1_4 1 - -#define GLX_SAMPLE_BUFFERS 100000 -#define GLX_SAMPLES 100001 - -extern void ( * glXGetProcAddress (const GLubyte *procName)) (void); - -#define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4) - -#endif /* GLX_VERSION_1_4 */ - -/* -------------------------- GLX_3DFX_multisample ------------------------- */ - -#ifndef GLX_3DFX_multisample -#define GLX_3DFX_multisample 1 - -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 - -#define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample) - -#endif /* GLX_3DFX_multisample */ - -/* ------------------------- GLX_ARB_create_context ------------------------ */ - -#ifndef GLX_ARB_create_context -#define GLX_ARB_create_context 1 - -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 - -typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); - -#define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB) - -#define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context) - -#endif /* GLX_ARB_create_context */ - -/* --------------------- GLX_ARB_create_context_profile -------------------- */ - -#ifndef GLX_ARB_create_context_profile -#define GLX_ARB_create_context_profile 1 - -#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 - -#define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile) - -#endif /* GLX_ARB_create_context_profile */ - -/* ------------------------- GLX_ARB_fbconfig_float ------------------------ */ - -#ifndef GLX_ARB_fbconfig_float -#define GLX_ARB_fbconfig_float 1 - -#define GLX_RGBA_FLOAT_BIT 0x00000004 -#define GLX_RGBA_FLOAT_TYPE 0x20B9 - -#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float) - -#endif /* GLX_ARB_fbconfig_float */ - -/* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */ - -#ifndef GLX_ARB_framebuffer_sRGB -#define GLX_ARB_framebuffer_sRGB 1 - -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 - -#define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB) - -#endif /* GLX_ARB_framebuffer_sRGB */ - -/* ------------------------ GLX_ARB_get_proc_address ----------------------- */ - -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 - -extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void); - -#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address) - -#endif /* GLX_ARB_get_proc_address */ - -/* -------------------------- GLX_ARB_multisample -------------------------- */ - -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 - -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 - -#define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample) - -#endif /* GLX_ARB_multisample */ - -/* ----------------------- GLX_ATI_pixel_format_float ---------------------- */ - -#ifndef GLX_ATI_pixel_format_float -#define GLX_ATI_pixel_format_float 1 - -#define GLX_RGBA_FLOAT_ATI_BIT 0x00000100 - -#define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float) - -#endif /* GLX_ATI_pixel_format_float */ - -/* ------------------------- GLX_ATI_render_texture ------------------------ */ - -#ifndef GLX_ATI_render_texture -#define GLX_ATI_render_texture 1 - -#define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800 -#define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801 -#define GLX_TEXTURE_FORMAT_ATI 0x9802 -#define GLX_TEXTURE_TARGET_ATI 0x9803 -#define GLX_MIPMAP_TEXTURE_ATI 0x9804 -#define GLX_TEXTURE_RGB_ATI 0x9805 -#define GLX_TEXTURE_RGBA_ATI 0x9806 -#define GLX_NO_TEXTURE_ATI 0x9807 -#define GLX_TEXTURE_CUBE_MAP_ATI 0x9808 -#define GLX_TEXTURE_1D_ATI 0x9809 -#define GLX_TEXTURE_2D_ATI 0x980A -#define GLX_MIPMAP_LEVEL_ATI 0x980B -#define GLX_CUBE_MAP_FACE_ATI 0x980C -#define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D -#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E -#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F -#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810 -#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811 -#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812 -#define GLX_FRONT_LEFT_ATI 0x9813 -#define GLX_FRONT_RIGHT_ATI 0x9814 -#define GLX_BACK_LEFT_ATI 0x9815 -#define GLX_BACK_RIGHT_ATI 0x9816 -#define GLX_AUX0_ATI 0x9817 -#define GLX_AUX1_ATI 0x9818 -#define GLX_AUX2_ATI 0x9819 -#define GLX_AUX3_ATI 0x981A -#define GLX_AUX4_ATI 0x981B -#define GLX_AUX5_ATI 0x981C -#define GLX_AUX6_ATI 0x981D -#define GLX_AUX7_ATI 0x981E -#define GLX_AUX8_ATI 0x981F -#define GLX_AUX9_ATI 0x9820 -#define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821 -#define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822 - -typedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); -typedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); - -#define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI) -#define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI) -#define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI) - -#define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture) - -#endif /* GLX_ATI_render_texture */ - -/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */ - -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_EXT_fbconfig_packed_float 1 - -#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 -#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 - -#define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float) - -#endif /* GLX_EXT_fbconfig_packed_float */ - -/* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */ - -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_EXT_framebuffer_sRGB 1 - -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 - -#define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB) - -#endif /* GLX_EXT_framebuffer_sRGB */ - -/* ------------------------- GLX_EXT_import_context ------------------------ */ - -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 - -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C - -typedef XID GLXContextID; - -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value); - -#define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT) -#define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT) -#define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT) -#define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT) - -#define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context) - -#endif /* GLX_EXT_import_context */ - -/* -------------------------- GLX_EXT_scene_marker ------------------------- */ - -#ifndef GLX_EXT_scene_marker -#define GLX_EXT_scene_marker 1 - -#define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker) - -#endif /* GLX_EXT_scene_marker */ - -/* -------------------------- GLX_EXT_swap_control ------------------------- */ - -#ifndef GLX_EXT_swap_control -#define GLX_EXT_swap_control 1 - -#define GLX_SWAP_INTERVAL_EXT 0x20F1 -#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 - -typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval); - -#define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT) - -#define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control) - -#endif /* GLX_EXT_swap_control */ - -/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */ - -#ifndef GLX_EXT_texture_from_pixmap -#define GLX_EXT_texture_from_pixmap 1 - -#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 -#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define GLX_Y_INVERTED_EXT 0x20D4 -#define GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define GLX_TEXTURE_TARGET_EXT 0x20D6 -#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 -#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA -#define GLX_TEXTURE_1D_EXT 0x20DB -#define GLX_TEXTURE_2D_EXT 0x20DC -#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD -#define GLX_FRONT_LEFT_EXT 0x20DE -#define GLX_FRONT_RIGHT_EXT 0x20DF -#define GLX_BACK_LEFT_EXT 0x20E0 -#define GLX_BACK_RIGHT_EXT 0x20E1 -#define GLX_AUX0_EXT 0x20E2 -#define GLX_AUX1_EXT 0x20E3 -#define GLX_AUX2_EXT 0x20E4 -#define GLX_AUX3_EXT 0x20E5 -#define GLX_AUX4_EXT 0x20E6 -#define GLX_AUX5_EXT 0x20E7 -#define GLX_AUX6_EXT 0x20E8 -#define GLX_AUX7_EXT 0x20E9 -#define GLX_AUX8_EXT 0x20EA -#define GLX_AUX9_EXT 0x20EB - -typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer); - -#define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT) -#define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT) - -#define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap) - -#endif /* GLX_EXT_texture_from_pixmap */ - -/* -------------------------- GLX_EXT_visual_info -------------------------- */ - -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 - -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 - -#define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info) - -#endif /* GLX_EXT_visual_info */ - -/* ------------------------- GLX_EXT_visual_rating ------------------------- */ - -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 - -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D - -#define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating) - -#endif /* GLX_EXT_visual_rating */ - -/* -------------------------- GLX_MESA_agp_offset -------------------------- */ - -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 - -typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer); - -#define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA) - -#define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset) - -#endif /* GLX_MESA_agp_offset */ - -/* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */ - -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 - -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height); - -#define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA) - -#define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer) - -#endif /* GLX_MESA_copy_sub_buffer */ - -/* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */ - -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 - -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); - -#define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA) - -#define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap) - -#endif /* GLX_MESA_pixmap_colormap */ - -/* ------------------------ GLX_MESA_release_buffers ----------------------- */ - -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 - -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d); - -#define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA) - -#define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers) - -#endif /* GLX_MESA_release_buffers */ - -/* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */ - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 - -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 - -typedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode); - -#define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA) - -#define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode) - -#endif /* GLX_MESA_set_3dfx_mode */ - -/* --------------------------- GLX_NV_copy_image --------------------------- */ - -#ifndef GLX_NV_copy_image -#define GLX_NV_copy_image 1 - -typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); - -#define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV) - -#define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image) - -#endif /* GLX_NV_copy_image */ - -/* -------------------------- GLX_NV_float_buffer -------------------------- */ - -#ifndef GLX_NV_float_buffer -#define GLX_NV_float_buffer 1 - -#define GLX_FLOAT_COMPONENTS_NV 0x20B0 - -#define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer) - -#endif /* GLX_NV_float_buffer */ - -/* -------------------------- GLX_NV_present_video ------------------------- */ - -#ifndef GLX_NV_present_video -#define GLX_NV_present_video 1 - -#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 - -typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); -typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); - -#define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV) -#define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV) - -#define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video) - -#endif /* GLX_NV_present_video */ - -/* --------------------------- GLX_NV_swap_group --------------------------- */ - -#ifndef GLX_NV_swap_group -#define GLX_NV_swap_group 1 - -typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier); -typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group); -typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count); -typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); -typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); -typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen); - -#define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV) -#define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV) -#define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV) -#define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV) -#define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV) -#define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV) - -#define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group) - -#endif /* GLX_NV_swap_group */ - -/* ----------------------- GLX_NV_vertex_array_range ----------------------- */ - -#ifndef GLX_NV_vertex_array_range -#define GLX_NV_vertex_array_range 1 - -typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); -typedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer); - -#define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV) -#define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV) - -#define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range) - -#endif /* GLX_NV_vertex_array_range */ - -/* -------------------------- GLX_NV_video_output -------------------------- */ - -#ifndef GLX_NV_video_output -#define GLX_NV_video_output 1 - -#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 -#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 -#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 -#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 -#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 -#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA -#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB -#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC - -typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); -typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); -typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice); -typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf); -typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); - -#define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV) -#define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV) -#define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV) -#define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV) -#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV) -#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV) - -#define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output) - -#endif /* GLX_NV_video_output */ - -/* -------------------------- GLX_OML_swap_method -------------------------- */ - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 - -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 - -#define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method) - -#endif /* GLX_OML_swap_method */ - -/* -------------------------- GLX_OML_sync_control ------------------------- */ - -#if !defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include -#define GLX_OML_sync_control 1 - -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); - -#define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML) -#define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML) -#define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML) -#define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML) -#define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML) - -#define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control) - -#endif /* GLX_OML_sync_control */ - -/* ------------------------ GLX_SGIS_blended_overlay ----------------------- */ - -#ifndef GLX_SGIS_blended_overlay -#define GLX_SGIS_blended_overlay 1 - -#define GLX_BLENDED_RGBA_SGIS 0x8025 - -#define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay) - -#endif /* GLX_SGIS_blended_overlay */ - -/* -------------------------- GLX_SGIS_color_range ------------------------- */ - -#ifndef GLX_SGIS_color_range -#define GLX_SGIS_color_range 1 - -#define GLX_MIN_RED_SGIS 0 -#define GLX_MAX_GREEN_SGIS 0 -#define GLX_MIN_BLUE_SGIS 0 -#define GLX_MAX_ALPHA_SGIS 0 -#define GLX_MIN_GREEN_SGIS 0 -#define GLX_MIN_ALPHA_SGIS 0 -#define GLX_MAX_RED_SGIS 0 -#define GLX_EXTENDED_RANGE_SGIS 0 -#define GLX_MAX_BLUE_SGIS 0 - -#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range) - -#endif /* GLX_SGIS_color_range */ - -/* -------------------------- GLX_SGIS_multisample ------------------------- */ - -#ifndef GLX_SGIS_multisample -#define GLX_SGIS_multisample 1 - -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 - -#define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample) - -#endif /* GLX_SGIS_multisample */ - -/* ---------------------- GLX_SGIS_shared_multisample ---------------------- */ - -#ifndef GLX_SGIS_shared_multisample -#define GLX_SGIS_shared_multisample 1 - -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 - -#define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample) - -#endif /* GLX_SGIS_shared_multisample */ - -/* --------------------------- GLX_SGIX_fbconfig --------------------------- */ - -#ifndef GLX_SGIX_fbconfig -#define GLX_SGIX_fbconfig 1 - -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_SCREEN_EXT 0x800C -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 - -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; - -typedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap); -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis); -typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config); - -#define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX) -#define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX) -#define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX) -#define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX) -#define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX) -#define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX) - -#define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig) - -#endif /* GLX_SGIX_fbconfig */ - -/* --------------------------- GLX_SGIX_hyperpipe -------------------------- */ - -#ifndef GLX_SGIX_hyperpipe -#define GLX_SGIX_hyperpipe 1 - -#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define GLX_PIPE_RECT_SGIX 0x00000001 -#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define GLX_BAD_HYPERPIPE_SGIX 92 -#define GLX_HYPERPIPE_ID_SGIX 0x8030 - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int networkId; -} GLXHyperpipeNetworkSGIX; -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int XOrigin; - int YOrigin; - int maxHeight; - int maxWidth; -} GLXPipeRectLimits; -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int channel; - unsigned int participationType; - int timeSlice; -} GLXHyperpipeConfigSGIX; -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int srcXOrigin; - int srcYOrigin; - int srcWidth; - int srcHeight; - int destXOrigin; - int destYOrigin; - int destWidth; - int destHeight; -} GLXPipeRect; - -typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); -typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); -typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); -typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); -typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); -typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); - -#define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX) -#define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX) -#define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX) -#define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX) -#define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX) -#define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX) -#define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX) -#define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX) - -#define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe) - -#endif /* GLX_SGIX_hyperpipe */ - -/* ---------------------------- GLX_SGIX_pbuffer --------------------------- */ - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 - -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 - -typedef XID GLXPbufferSGIX; -typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX; - -typedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask); -typedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask); - -#define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX) -#define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX) -#define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX) -#define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX) -#define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX) - -#define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer) - -#endif /* GLX_SGIX_pbuffer */ - -/* ------------------------- GLX_SGIX_swap_barrier ------------------------- */ - -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 - -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); - -#define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX) -#define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX) - -#define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier) - -#endif /* GLX_SGIX_swap_barrier */ - -/* -------------------------- GLX_SGIX_swap_group -------------------------- */ - -#ifndef GLX_SGIX_swap_group -#define GLX_SGIX_swap_group 1 - -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); - -#define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX) - -#define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group) - -#endif /* GLX_SGIX_swap_group */ - -/* ------------------------- GLX_SGIX_video_resize ------------------------- */ - -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 - -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 - -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); - -#define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX) -#define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX) -#define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX) -#define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX) -#define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX) - -#define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize) - -#endif /* GLX_SGIX_video_resize */ - -/* ---------------------- GLX_SGIX_visual_select_group --------------------- */ - -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 - -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 - -#define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group) - -#endif /* GLX_SGIX_visual_select_group */ - -/* ---------------------------- GLX_SGI_cushion ---------------------------- */ - -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 - -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion); - -#define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI) - -#define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion) - -#endif /* GLX_SGI_cushion */ - -/* ----------------------- GLX_SGI_make_current_read ----------------------- */ - -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 - -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); - -#define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI) -#define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI) - -#define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read) - -#endif /* GLX_SGI_make_current_read */ - -/* -------------------------- GLX_SGI_swap_control ------------------------- */ - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 - -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); - -#define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI) - -#define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control) - -#endif /* GLX_SGI_swap_control */ - -/* --------------------------- GLX_SGI_video_sync -------------------------- */ - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 - -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (uint* count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count); - -#define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI) -#define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI) - -#define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync) - -#endif /* GLX_SGI_video_sync */ - -/* --------------------- GLX_SUN_get_transparent_index --------------------- */ - -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 - -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); - -#define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN) - -#define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index) - -#endif /* GLX_SUN_get_transparent_index */ - -/* -------------------------- GLX_SUN_video_resize ------------------------- */ - -#ifndef GLX_SUN_video_resize -#define GLX_SUN_video_resize 1 - -#define GLX_VIDEO_RESIZE_SUN 0x8171 -#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD - -typedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor); -typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor); - -#define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN) -#define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN) - -#define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize) - -#endif /* GLX_SUN_video_resize */ - -/* ------------------------------------------------------------------------- */ - -#ifdef GLEW_MX -#define GLXEW_EXPORT -#else -#define GLXEW_EXPORT extern -#endif /* GLEW_MX */ - -extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay; - -extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig; -extern PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext; -extern PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer; -extern PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap; -extern PFNGLXCREATEWINDOWPROC __glewXCreateWindow; -extern PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer; -extern PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap; -extern PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow; -extern PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable; -extern PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib; -extern PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs; -extern PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent; -extern PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig; -extern PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent; -extern PFNGLXQUERYCONTEXTPROC __glewXQueryContext; -extern PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable; -extern PFNGLXSELECTEVENTPROC __glewXSelectEvent; - -extern PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB; - -extern PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI; -extern PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI; -extern PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI; - -extern PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT; -extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT; -extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT; -extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT; - -extern PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT; - -extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT; -extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT; - -extern PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA; - -extern PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA; - -extern PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA; - -extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA; - -extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA; - -extern PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV; - -extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV; -extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV; - -extern PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV; -extern PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV; -extern PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV; -extern PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV; -extern PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV; -extern PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV; - -extern PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV; -extern PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV; - -extern PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV; -extern PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV; -extern PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV; -extern PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV; -extern PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV; -extern PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV; - -#ifdef GLX_OML_sync_control -extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML; -extern PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML; -extern PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML; -extern PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML; -extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML; -#endif - -extern PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX; -extern PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX; -extern PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX; -extern PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX; -extern PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX; -extern PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX; - -extern PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX; -extern PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX; -extern PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX; -extern PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX; -extern PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX; -extern PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX; -extern PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX; -extern PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX; - -extern PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX; -extern PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX; -extern PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX; -extern PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX; -extern PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX; - -extern PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX; -extern PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX; - -extern PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX; - -extern PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX; -extern PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX; -extern PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX; -extern PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX; -extern PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX; - -extern PFNGLXCUSHIONSGIPROC __glewXCushionSGI; - -extern PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI; -extern PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI; - -extern PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI; - -extern PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI; -extern PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI; - -extern PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN; - -extern PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN; -extern PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN; - -#if defined(GLEW_MX) -struct GLXEWContextStruct -{ -#endif /* GLEW_MX */ - -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_0; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_1; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_2; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4; -GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample; -GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context; -GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_profile; -GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float; -GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB; -GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address; -GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample; -GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float; -GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture; -GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float; -GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB; -GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context; -GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker; -GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control; -GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap; -GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info; -GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating; -GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset; -GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer; -GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap; -GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers; -GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode; -GLXEW_EXPORT GLboolean __GLXEW_NV_copy_image; -GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer; -GLXEW_EXPORT GLboolean __GLXEW_NV_present_video; -GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group; -GLXEW_EXPORT GLboolean __GLXEW_NV_vertex_array_range; -GLXEW_EXPORT GLboolean __GLXEW_NV_video_output; -GLXEW_EXPORT GLboolean __GLXEW_OML_swap_method; -GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_blended_overlay; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_color_range; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_multisample; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_shared_multisample; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_fbconfig; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_hyperpipe; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_pbuffer; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_barrier; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_group; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_video_resize; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_visual_select_group; -GLXEW_EXPORT GLboolean __GLXEW_SGI_cushion; -GLXEW_EXPORT GLboolean __GLXEW_SGI_make_current_read; -GLXEW_EXPORT GLboolean __GLXEW_SGI_swap_control; -GLXEW_EXPORT GLboolean __GLXEW_SGI_video_sync; -GLXEW_EXPORT GLboolean __GLXEW_SUN_get_transparent_index; -GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize; - -#ifdef GLEW_MX -}; /* GLXEWContextStruct */ -#endif /* GLEW_MX */ - -/* ------------------------------------------------------------------------ */ - -#ifdef GLEW_MX - -typedef struct GLXEWContextStruct GLXEWContext; -extern GLenum glxewContextInit (GLXEWContext* ctx); -extern GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name); - -#define glxewInit() glxewContextInit(glxewGetContext()) -#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x) - -#define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x)) -#define GLXEW_GET_FUN(x) x - -#else /* GLEW_MX */ - -#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) -#define GLXEW_GET_FUN(x) x - -extern GLboolean glxewIsSupported (const char* name); - -#endif /* GLEW_MX */ - -extern GLboolean glxewGetExtension (const char* name); - -#ifdef __cplusplus -} -#endif - -#endif /* __glxew_h__ */ diff --git a/extern/glew/include/GL/wglew.h b/extern/glew/include/GL/wglew.h deleted file mode 100755 index 34786665..00000000 --- a/extern/glew/include/GL/wglew.h +++ /dev/null @@ -1,1247 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * 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. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. -*/ - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __wglew_h__ -#define __wglew_h__ -#define __WGLEW_H__ - -#ifdef __wglext_h_ -#error wglext.h included before wglew.h -#endif - -#define __wglext_h_ - -#if !defined(WINAPI) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN 1 -# endif -#include -# undef WIN32_LEAN_AND_MEAN -#endif - -/* - * GLEW_STATIC needs to be set when using the static version. - * GLEW_BUILD is set when building the DLL version. - */ -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# ifdef GLEW_BUILD -# define GLEWAPI extern __declspec(dllexport) -# else -# define GLEWAPI extern __declspec(dllimport) -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* -------------------------- WGL_3DFX_multisample ------------------------- */ - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 - -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 - -#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) - -#endif /* WGL_3DFX_multisample */ - -/* ------------------------- WGL_3DL_stereo_control ------------------------ */ - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 - -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 - -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); - -#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) - -#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) - -#endif /* WGL_3DL_stereo_control */ - -/* ------------------------ WGL_AMD_gpu_association ------------------------ */ - -#ifndef WGL_AMD_gpu_association -#define WGL_AMD_gpu_association 1 - -#define WGL_GPU_VENDOR_AMD 0x1F00 -#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define WGL_GPU_RAM_AMD 0x21A3 -#define WGL_GPU_CLOCK_AMD 0x21A4 -#define WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define WGL_GPU_NUM_RB_AMD 0x21A7 -#define WGL_GPU_NUM_SPI_AMD 0x21A8 - -typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); -typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); -typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); -typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); -typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); -typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); -typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); - -#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) -#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) -#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) -#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) -#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) -#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) -#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) -#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) -#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) - -#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) - -#endif /* WGL_AMD_gpu_association */ - -/* ------------------------- WGL_ARB_buffer_region ------------------------- */ - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 - -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 - -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); - -#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) -#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) -#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) -#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) - -#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) - -#endif /* WGL_ARB_buffer_region */ - -/* ------------------------- WGL_ARB_create_context ------------------------ */ - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 - -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 - -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); - -#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) - -#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) - -#endif /* WGL_ARB_create_context */ - -/* --------------------- WGL_ARB_create_context_profile -------------------- */ - -#ifndef WGL_ARB_create_context_profile -#define WGL_ARB_create_context_profile 1 - -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 - -#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) - -#endif /* WGL_ARB_create_context_profile */ - -/* ----------------------- WGL_ARB_extensions_string ----------------------- */ - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 - -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); - -#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) - -#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) - -#endif /* WGL_ARB_extensions_string */ - -/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_ARB_framebuffer_sRGB 1 - -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 - -#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) - -#endif /* WGL_ARB_framebuffer_sRGB */ - -/* ----------------------- WGL_ARB_make_current_read ----------------------- */ - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 - -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 - -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); - -#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) -#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) - -#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) - -#endif /* WGL_ARB_make_current_read */ - -/* -------------------------- WGL_ARB_multisample -------------------------- */ - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 - -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 - -#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) - -#endif /* WGL_ARB_multisample */ - -/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 - -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 - -DECLARE_HANDLE(HPBUFFERARB); - -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); - -#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) -#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) -#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) -#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) -#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) - -#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) - -#endif /* WGL_ARB_pbuffer */ - -/* -------------------------- WGL_ARB_pixel_format ------------------------- */ - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 - -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B - -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); - -#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) -#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) -#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) - -#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) - -#endif /* WGL_ARB_pixel_format */ - -/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 - -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 - -#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) - -#endif /* WGL_ARB_pixel_format_float */ - -/* ------------------------- WGL_ARB_render_texture ------------------------ */ - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 - -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 - -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); - -#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) -#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) -#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) - -#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) - -#endif /* WGL_ARB_render_texture */ - -/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 - -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 - -#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) - -#endif /* WGL_ATI_pixel_format_float */ - -/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ - -#ifndef WGL_ATI_render_texture_rectangle -#define WGL_ATI_render_texture_rectangle 1 - -#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 - -#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) - -#endif /* WGL_ATI_render_texture_rectangle */ - -/* -------------------------- WGL_EXT_depth_float -------------------------- */ - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 - -#define WGL_DEPTH_FLOAT_EXT 0x2040 - -#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) - -#endif /* WGL_EXT_depth_float */ - -/* ---------------------- WGL_EXT_display_color_table ---------------------- */ - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 - -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); - -#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) -#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) -#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) -#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) - -#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) - -#endif /* WGL_EXT_display_color_table */ - -/* ----------------------- WGL_EXT_extensions_string ----------------------- */ - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 - -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); - -#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) - -#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) - -#endif /* WGL_EXT_extensions_string */ - -/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 - -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 - -#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) - -#endif /* WGL_EXT_framebuffer_sRGB */ - -/* ----------------------- WGL_EXT_make_current_read ----------------------- */ - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 - -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 - -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); - -#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) -#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) - -#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) - -#endif /* WGL_EXT_make_current_read */ - -/* -------------------------- WGL_EXT_multisample -------------------------- */ - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 - -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 - -#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) - -#endif /* WGL_EXT_multisample */ - -/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 - -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 - -DECLARE_HANDLE(HPBUFFEREXT); - -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); - -#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) -#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) -#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) -#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) -#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) - -#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) - -#endif /* WGL_EXT_pbuffer */ - -/* -------------------------- WGL_EXT_pixel_format ------------------------- */ - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 - -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C - -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); - -#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) -#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) -#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) - -#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) - -#endif /* WGL_EXT_pixel_format */ - -/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 - -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 - -#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) - -#endif /* WGL_EXT_pixel_format_packed_float */ - -/* -------------------------- WGL_EXT_swap_control ------------------------- */ - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 - -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); - -#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) -#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) - -#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) - -#endif /* WGL_EXT_swap_control */ - -/* --------------------- WGL_I3D_digital_video_control --------------------- */ - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 - -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 - -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); - -#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) -#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) - -#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) - -#endif /* WGL_I3D_digital_video_control */ - -/* ----------------------------- WGL_I3D_gamma ----------------------------- */ - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 - -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F - -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); - -#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) -#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) -#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) -#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) - -#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) - -#endif /* WGL_I3D_gamma */ - -/* ---------------------------- WGL_I3D_genlock ---------------------------- */ - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 - -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C - -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); - -#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) -#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) -#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) -#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) -#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) -#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) -#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) -#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) -#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) -#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) -#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) -#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) - -#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) - -#endif /* WGL_I3D_genlock */ - -/* -------------------------- WGL_I3D_image_buffer ------------------------- */ - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 - -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 - -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); - -#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) -#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) -#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) -#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) - -#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) - -#endif /* WGL_I3D_image_buffer */ - -/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 - -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); - -#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) -#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) -#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) -#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) - -#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) - -#endif /* WGL_I3D_swap_frame_lock */ - -/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 - -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); - -#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) -#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) -#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) -#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) - -#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) - -#endif /* WGL_I3D_swap_frame_usage */ - -/* --------------------------- WGL_NV_copy_image --------------------------- */ - -#ifndef WGL_NV_copy_image -#define WGL_NV_copy_image 1 - -typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); - -#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) - -#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) - -#endif /* WGL_NV_copy_image */ - -/* -------------------------- WGL_NV_float_buffer -------------------------- */ - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 - -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 - -#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) - -#endif /* WGL_NV_float_buffer */ - -/* -------------------------- WGL_NV_gpu_affinity -------------------------- */ - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 - -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 - -DECLARE_HANDLE(HGPUNV); -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; - -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); - -#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) -#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) -#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) -#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) -#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) - -#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) - -#endif /* WGL_NV_gpu_affinity */ - -/* -------------------------- WGL_NV_present_video ------------------------- */ - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 - -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 - -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); - -#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) -#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) -#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) - -#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) - -#endif /* WGL_NV_present_video */ - -/* ---------------------- WGL_NV_render_depth_texture ---------------------- */ - -#ifndef WGL_NV_render_depth_texture -#define WGL_NV_render_depth_texture 1 - -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 - -#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) - -#endif /* WGL_NV_render_depth_texture */ - -/* -------------------- WGL_NV_render_texture_rectangle -------------------- */ - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_NV_render_texture_rectangle 1 - -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 - -#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) - -#endif /* WGL_NV_render_texture_rectangle */ - -/* --------------------------- WGL_NV_swap_group --------------------------- */ - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 - -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); - -#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) -#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) -#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) -#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) -#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) -#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) - -#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) - -#endif /* WGL_NV_swap_group */ - -/* ----------------------- WGL_NV_vertex_array_range ----------------------- */ - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 - -typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); - -#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) -#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) - -#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) - -#endif /* WGL_NV_vertex_array_range */ - -/* -------------------------- WGL_NV_video_output -------------------------- */ - -#ifndef WGL_NV_video_output -#define WGL_NV_video_output 1 - -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC - -DECLARE_HANDLE(HPVIDEODEV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); - -#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) -#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) -#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) -#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) -#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) -#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) - -#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) - -#endif /* WGL_NV_video_output */ - -/* -------------------------- WGL_OML_sync_control ------------------------- */ - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 - -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); - -#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) -#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) -#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) -#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) -#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) -#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) - -#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) - -#endif /* WGL_OML_sync_control */ - -/* ------------------------------------------------------------------------- */ - -#ifdef GLEW_MX -#define WGLEW_EXPORT -#else -#define WGLEW_EXPORT GLEWAPI -#endif /* GLEW_MX */ - -#ifdef GLEW_MX -struct WGLEWContextStruct -{ -#endif /* GLEW_MX */ - -WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; - -WGLEW_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; -WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; -WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; -WGLEW_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; -WGLEW_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; -WGLEW_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; -WGLEW_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; -WGLEW_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; -WGLEW_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; - -WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; -WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; -WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; -WGLEW_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; - -WGLEW_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; - -WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; - -WGLEW_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; -WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; - -WGLEW_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; -WGLEW_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; -WGLEW_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; -WGLEW_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; -WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; - -WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; - -WGLEW_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; -WGLEW_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; -WGLEW_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; - -WGLEW_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; -WGLEW_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; -WGLEW_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; -WGLEW_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; - -WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; - -WGLEW_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; -WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; - -WGLEW_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; -WGLEW_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; -WGLEW_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; -WGLEW_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; -WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; - -WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; - -WGLEW_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; -WGLEW_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; - -WGLEW_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; -WGLEW_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; - -WGLEW_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; -WGLEW_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; -WGLEW_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; -WGLEW_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; - -WGLEW_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; -WGLEW_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; -WGLEW_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; -WGLEW_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; -WGLEW_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; -WGLEW_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; -WGLEW_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; -WGLEW_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; - -WGLEW_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; -WGLEW_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; -WGLEW_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; -WGLEW_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; - -WGLEW_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; -WGLEW_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; -WGLEW_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; -WGLEW_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; - -WGLEW_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; -WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; -WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; -WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; - -WGLEW_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; - -WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; -WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; -WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; -WGLEW_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; -WGLEW_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; - -WGLEW_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; -WGLEW_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; -WGLEW_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; - -WGLEW_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; -WGLEW_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; -WGLEW_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; -WGLEW_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; -WGLEW_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; -WGLEW_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; - -WGLEW_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; -WGLEW_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; - -WGLEW_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; -WGLEW_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; -WGLEW_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; -WGLEW_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; -WGLEW_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; -WGLEW_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; - -WGLEW_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; -WGLEW_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; -WGLEW_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; -WGLEW_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; -WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; -WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; -WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample; -WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control; -WGLEW_EXPORT GLboolean __WGLEW_AMD_gpu_association; -WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region; -WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context; -WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_profile; -WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string; -WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; -WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read; -WGLEW_EXPORT GLboolean __WGLEW_ARB_multisample; -WGLEW_EXPORT GLboolean __WGLEW_ARB_pbuffer; -WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format; -WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; -WGLEW_EXPORT GLboolean __WGLEW_ARB_render_texture; -WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; -WGLEW_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; -WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float; -WGLEW_EXPORT GLboolean __WGLEW_EXT_display_color_table; -WGLEW_EXPORT GLboolean __WGLEW_EXT_extensions_string; -WGLEW_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; -WGLEW_EXPORT GLboolean __WGLEW_EXT_make_current_read; -WGLEW_EXPORT GLboolean __WGLEW_EXT_multisample; -WGLEW_EXPORT GLboolean __WGLEW_EXT_pbuffer; -WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format; -WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; -WGLEW_EXPORT GLboolean __WGLEW_EXT_swap_control; -WGLEW_EXPORT GLboolean __WGLEW_I3D_digital_video_control; -WGLEW_EXPORT GLboolean __WGLEW_I3D_gamma; -WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock; -WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer; -WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; -WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; -WGLEW_EXPORT GLboolean __WGLEW_NV_copy_image; -WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer; -WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity; -WGLEW_EXPORT GLboolean __WGLEW_NV_present_video; -WGLEW_EXPORT GLboolean __WGLEW_NV_render_depth_texture; -WGLEW_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; -WGLEW_EXPORT GLboolean __WGLEW_NV_swap_group; -WGLEW_EXPORT GLboolean __WGLEW_NV_vertex_array_range; -WGLEW_EXPORT GLboolean __WGLEW_NV_video_output; -WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control; - -#ifdef GLEW_MX -}; /* WGLEWContextStruct */ -#endif /* GLEW_MX */ - -/* ------------------------------------------------------------------------- */ - -#ifdef GLEW_MX - -typedef struct WGLEWContextStruct WGLEWContext; -GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx); -GLEWAPI GLboolean wglewContextIsSupported (WGLEWContext* ctx, const char* name); - -#define wglewInit() wglewContextInit(wglewGetContext()) -#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) - -#define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) -#define WGLEW_GET_FUN(x) wglewGetContext()->x - -#else /* GLEW_MX */ - -#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) -#define WGLEW_GET_FUN(x) x - -GLEWAPI GLboolean wglewIsSupported (const char* name); - -#endif /* GLEW_MX */ - -GLEWAPI GLboolean wglewGetExtension (const char* name); - -#ifdef __cplusplus -} -#endif - -#undef GLEWAPI - -#endif /* __wglew_h__ */ diff --git a/extern/glew/lib/glew32.lib b/extern/glew/lib/glew32.lib deleted file mode 100755 index 8fc0a8ec..00000000 Binary files a/extern/glew/lib/glew32.lib and /dev/null differ diff --git a/extern/glew/lib/glew32s.lib b/extern/glew/lib/glew32s.lib deleted file mode 100755 index 2d157685..00000000 Binary files a/extern/glew/lib/glew32s.lib and /dev/null differ diff --git a/extern/gnuwin32/CMakeLists.txt b/extern/gnuwin32/CMakeLists.txt deleted file mode 100644 index 7dd11bac..00000000 --- a/extern/gnuwin32/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -INSTALL(PROGRAMS - bin/win32/jpeg62.dll - bin/win32/libpng12.dll - bin/win32/libtiff3.dll - bin/win32/zlib1.dll - DESTINATION bin) diff --git a/extern/gnuwin32/bin/win32/jpeg62.dll b/extern/gnuwin32/bin/win32/jpeg62.dll deleted file mode 100755 index 21c03d55..00000000 Binary files a/extern/gnuwin32/bin/win32/jpeg62.dll and /dev/null differ diff --git a/extern/gnuwin32/bin/win32/libpng12.dll b/extern/gnuwin32/bin/win32/libpng12.dll deleted file mode 100755 index c3aa866c..00000000 Binary files a/extern/gnuwin32/bin/win32/libpng12.dll and /dev/null differ diff --git a/extern/gnuwin32/bin/win32/libtiff3.dll b/extern/gnuwin32/bin/win32/libtiff3.dll deleted file mode 100755 index 9883c51a..00000000 Binary files a/extern/gnuwin32/bin/win32/libtiff3.dll and /dev/null differ diff --git a/extern/gnuwin32/bin/win32/zlib1.dll b/extern/gnuwin32/bin/win32/zlib1.dll deleted file mode 100755 index 31996cd3..00000000 Binary files a/extern/gnuwin32/bin/win32/zlib1.dll and /dev/null differ diff --git a/extern/gnuwin32/include/jconfig.h b/extern/gnuwin32/include/jconfig.h deleted file mode 100644 index cf29877c..00000000 --- a/extern/gnuwin32/include/jconfig.h +++ /dev/null @@ -1,58 +0,0 @@ -/* jconfig.h. Generated automatically by configure. */ -/* jconfig.cfg --- source file edited by configure script */ -/* see jconfig.doc for explanations */ - -#define HAVE_PROTOTYPES -#define HAVE_UNSIGNED_CHAR -#define HAVE_UNSIGNED_SHORT - -#ifdef _WIN32 -# include -/* Define "boolean" as unsigned char, not int, per Windows custom */ -# if !defined __RPCNDR_H__ || defined __MINGW32__ /* don't conflict if rpcndr.h already read */ -# ifndef boolean /* don't conflict if rpcndr.h already read */ - typedef unsigned char boolean; -# endif /* boolean */ -# endif /* __RPCNDR_H__ */ -# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -# define USE_WINDOWS_MESSAGEBOX 1 -#endif /* _WIN32 */ - -#undef void -#undef const -#undef CHAR_IS_UNSIGNED -#define HAVE_STDDEF_H -#define HAVE_STDLIB_H -#undef NEED_BSD_STRINGS -#undef NEED_SYS_TYPES_H -#undef NEED_FAR_POINTERS -#undef NEED_SHORT_EXTERNAL_NAMES -/* Define this if you get warnings about undefined structures. */ -#undef INCOMPLETE_TYPES_BROKEN - -#ifdef JPEG_INTERNALS - -#undef RIGHT_SHIFT_IS_UNSIGNED -#define INLINE __inline__ -/* These are for configuring the JPEG memory manager. */ -#undef DEFAULT_MAX_MEM -#undef NO_MKTEMP - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -#define RLE_SUPPORTED /* Utah RLE image file format */ -#define TARGA_SUPPORTED /* Targa image file format */ - -#undef TWO_FILE_COMMANDLINE -#undef NEED_SIGNAL_CATCHER -#undef DONT_USE_B_MODE - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ -#undef PROGRESS_REPORT - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/extern/gnuwin32/include/jerror.h b/extern/gnuwin32/include/jerror.h deleted file mode 100644 index f5fb3c3f..00000000 --- a/extern/gnuwin32/include/jerror.h +++ /dev/null @@ -1,303 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_DROP_SAMPLING, - "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT6(cinfo,code,p1,p2,p3,p4,p5,p6) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (cinfo)->err->msg_parm.i[4] = (p5), \ - (cinfo)->err->msg_parm.i[5] = (p6), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/extern/gnuwin32/include/jmorecfg.h b/extern/gnuwin32/include/jmorecfg.h deleted file mode 100644 index 30178ac3..00000000 --- a/extern/gnuwin32/include/jmorecfg.h +++ /dev/null @@ -1,426 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - -#if (defined (_MSC_VER) && (_MSC_VER >= 800)) -#define HAVE_UNSIGNED_CHAR -#define HAVE_ALL_INTS -#define EXTERN(type) extern type __cdecl -#endif - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ -#ifndef HAVE_ALL_INTS - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#if !defined(XMD_H) && !defined(_WIN32) /* X11/xmd.h correctly defines INT32 */ -typedef long INT32; -#endif - -#endif /* HAVE_ALL_INTS */ - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -#ifdef _WIN32 -# if defined(ALL_STATIC) -# if defined(JPEG_DLL) -# undef JPEG_DLL -# endif -# if !defined(JPEG_STATIC) -# define JPEG_STATIC -# endif -# endif -# if defined(JPEG_DLL) -# if defined(JPEG_STATIC) -# undef JPEG_STATIC -# endif -# endif -# if defined(JPEG_DLL) -/* building a DLL */ -# define JPEG_IMPEXP __declspec(dllexport) -# elif defined(JPEG_STATIC) -/* building or linking to a static library */ -# define JPEG_IMPEXP -# else -/* linking to the DLL */ -# define JPEG_IMPEXP __declspec(dllimport) -# endif -# if !defined(JPEG_API) -# define JPEG_API __cdecl -# endif -/* The only remaining magic that is necessary for cygwin */ -#elif defined(__CYGWIN__) -# if !defined(JPEG_IMPEXP) -# define JPEG_IMPEXP -# endif -# if !defined(JPEG_API) -# define JPEG_API __cdecl -# endif -#endif - -/* Ensure our magic doesn't hurt other platforms */ -#if !defined(JPEG_IMPEXP) -# define JPEG_IMPEXP -#endif -#if !defined(JPEG_API) -# define JPEG_API -#endif - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type JPEG_API -/* a reference to a GLOBAL function: */ -#ifndef EXTERN -# define EXTERN(type) extern JPEG_IMPEXP type JPEG_API -/* a reference to a "GLOBAL" function exported by sourcefiles of utility progs */ -#endif /* EXTERN */ -#define EXTERN_1(type) extern type JPEG_API - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -/* jmorecfg.h line 220 */ -/* HJH modification: several of the windows header files already define FAR - because of this, the code below was changed so that it only tinkers with - the FAR define if FAR is still undefined */ -#ifndef FAR - #ifdef NEED_FAR_POINTERS - #define FAR far - #else - #define FAR - #endif -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/extern/gnuwin32/include/jpeglib.h b/extern/gnuwin32/include/jpeglib.h deleted file mode 100644 index 498c6f9e..00000000 --- a/extern/gnuwin32/include/jpeglib.h +++ /dev/null @@ -1,1110 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - -#ifdef __cplusplus -} -#endif - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* JPEGLIB_H */ diff --git a/extern/gnuwin32/include/png.h b/extern/gnuwin32/include/png.h deleted file mode 100644 index d5ed6516..00000000 --- a/extern/gnuwin32/include/png.h +++ /dev/null @@ -1,3551 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.2.24 - December 14, 2007 - * Copyright (c) 1998-2007 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.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.24 - December 14, 2007: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - * 1.0.12rc1 2 10012 2.1.0.12rc1 - * 1.0.12 2 10012 2.1.0.12 - * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - * 1.2.0rc1 3 10200 3.1.2.0rc1 - * 1.2.0 3 10200 3.1.2.0 - * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 - * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - * 1.2.1 3 10201 3.1.2.1 - * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - * 1.0.13 10 10013 10.so.0.1.0.13 - * 1.2.2 12 10202 12.so.0.1.2.2 - * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - * 1.2.3 12 10203 12.so.0.1.2.3 - * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 - * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - * 1.0.14 10 10014 10.so.0.1.0.14 - * 1.2.4 13 10204 12.so.0.1.2.4 - * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - * 1.0.15 10 10015 10.so.0.1.0.15 - * 1.2.5 13 10205 12.so.0.1.2.5 - * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - * 1.0.16 10 10016 10.so.0.1.0.16 - * 1.2.6 13 10206 12.so.0.1.2.6 - * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 - * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 10.so.0.1.0.17 - * 1.2.7 13 10207 12.so.0.1.2.7 - * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 - * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 10.so.0.1.0.18 - * 1.2.8 13 10208 12.so.0.1.2.8 - * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - * 1.2.9beta4-11 13 10209 12.so.0.9[.0] - * 1.2.9rc1 13 10209 12.so.0.9[.0] - * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-8 13 10210 12.so.0.10[.0] - * 1.2.10rc1-3 13 10210 12.so.0.10[.0] - * 1.2.10 13 10210 12.so.0.10[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.0.19rc1-5 10 10019 10.so.0.19[.0] - * 1.2.11rc1-5 13 10211 12.so.0.11[.0] - * 1.0.19 10 10019 10.so.0.19[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.0.20 10 10020 10.so.0.20[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.2.13beta1 13 10213 12.so.0.13[.0] - * 1.0.21 10 10021 10.so.0.21[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.2.14beta1-2 13 10214 12.so.0.14[.0] - * 1.0.22rc1 10 10022 10.so.0.22[.0] - * 1.2.14rc1 13 10214 12.so.0.14[.0] - * 1.0.22 10 10022 10.so.0.22[.0] - * 1.2.14 13 10214 12.so.0.14[.0] - * 1.2.15beta1-6 13 10215 12.so.0.15[.0] - * 1.0.23rc1-5 10 10023 10.so.0.23[.0] - * 1.2.15rc1-5 13 10215 12.so.0.15[.0] - * 1.0.23 10 10023 10.so.0.23[.0] - * 1.2.15 13 10215 12.so.0.15[.0] - * 1.2.16beta1-2 13 10216 12.so.0.16[.0] - * 1.2.16rc1 13 10216 12.so.0.16[.0] - * 1.0.24 10 10024 10.so.0.24[.0] - * 1.2.16 13 10216 12.so.0.16[.0] - * 1.2.17beta1-2 13 10217 12.so.0.17[.0] - * 1.0.25rc1 10 10025 10.so.0.25[.0] - * 1.2.17rc1-3 13 10217 12.so.0.17[.0] - * 1.0.25 10 10025 10.so.0.25[.0] - * 1.2.17 13 10217 12.so.0.17[.0] - * 1.0.26 10 10026 10.so.0.26[.0] - * 1.2.18 13 10218 12.so.0.18[.0] - * 1.2.19beta1-31 13 10219 12.so.0.19[.0] - * 1.0.27rc1-6 10 10027 10.so.0.27[.0] - * 1.2.19rc1-6 13 10219 12.so.0.19[.0] - * 1.0.27 10 10027 10.so.0.27[.0] - * 1.2.19 13 10219 12.so.0.19[.0] - * 1.2.20beta01-04 13 10220 12.so.0.20[.0] - * 1.0.28rc1-6 10 10028 10.so.0.28[.0] - * 1.2.20rc1-6 13 10220 12.so.0.20[.0] - * 1.0.28 10 10028 10.so.0.28[.0] - * 1.2.20 13 10220 12.so.0.20[.0] - * 1.2.21beta1-2 13 10221 12.so.0.21[.0] - * 1.2.21rc1-3 13 10221 12.so.0.21[.0] - * 1.0.29 10 10029 10.so.0.29[.0] - * 1.2.21 13 10221 12.so.0.21[.0] - * 1.2.22beta1-4 13 10222 12.so.0.22[.0] - * 1.0.30rc1 10 10030 10.so.0.30[.0] - * 1.2.22rc1 13 10222 12.so.0.22[.0] - * 1.0.30 10 10030 10.so.0.30[.0] - * 1.2.22 13 10222 12.so.0.22[.0] - * 1.2.23beta01-05 13 10223 12.so.0.23[.0] - * 1.2.23rc01 13 10223 12.so.0.23[.0] - * 1.2.23 13 10223 12.so.0.23[.0] - * 1.2.24beta01-02 13 10224 12.so.0.24[.0] - * 1.2.24rc01 13 10224 12.so.0.24[.0] - * 1.2.24 13 10224 12.so.0.24[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_uint_32 rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. - */ -typedef struct png_struct_def png_struct; -typedef png_struct FAR * png_structp; - -typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); -typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); -typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); -typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, - int)); -typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); -typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, - png_row_infop, png_bytep)); -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) -typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); -#endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); -typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); - -/* 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, except to store - * the jmp_buf. - */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmpbuf; /* used in png_error */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ - png_error_ptr warning_fn; /* function for printing warnings */ - 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 */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#if defined(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 */ -#if defined(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 */ - - z_stream zstream; /* pointer to decompression structure (below) */ - png_bytep zbuf; /* buffer for zlib */ - png_size_t zbuf_size; /* size of zbuf */ - 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 */ - - 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_uint_32 rowbytes; /* size of row in bytes */ - png_uint_32 irowbytes; /* size of current interlaced 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_bytep prev_row; /* buffer to save previous (unfiltered) row */ - png_bytep row_buf; /* buffer to save current (unfiltered) row */ -#ifndef PNG_NO_WRITE_FILTERING - png_bytep sub_row; /* buffer to save "sub" row when filtering */ - png_bytep up_row; /* buffer to save "up" row when filtering */ - png_bytep avg_row; /* buffer to save "avg" row when filtering */ - png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ -#endif - png_row_info row_info; /* used for transformation routines */ - - 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 */ - png_uint_16 num_trans; /* number of transparency values */ - png_byte chunk_name[5]; /* null-terminated name of current chunk */ - 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_ below ) */ - 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 */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ - png_byte usr_channels; /* channels at start of write */ - png_byte sig_bytes; /* magic bytes read/written from start of file */ - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -#ifdef PNG_LEGACY_SUPPORTED - png_byte filler; /* filler byte for pixel expansion */ -#else - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif -#endif - -#if defined(PNG_bKGD_SUPPORTED) - png_byte background_gamma_type; -# ifdef PNG_FLOATING_POINT_SUPPORTED - float background_gamma; -# endif - png_color_16 background; /* background color in screen gamma space */ -#if defined(PNG_READ_GAMMA_SUPPORTED) - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* PNG_bKGD_SUPPORTED */ - -#if defined(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 - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ -#ifdef PNG_FLOATING_POINT_SUPPORTED - float gamma; /* file gamma value */ - float screen_gamma; /* screen gamma value (display_exponent) */ -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - 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_table; /* gamma table for 16-bit depth files */ - 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 - -#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; /* transparency values for paletted files */ - png_color_16 trans_values; /* transparency values 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 each 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 */ - -# if defined(PNG_TEXT_SUPPORTED) - png_size_t current_text_size; /* current size of text input data */ - png_size_t current_text_left; /* how much text left to read in input */ - png_charp current_text; /* current text chunk buffer */ - png_charp current_text_ptr; /* current location in current_text */ -# endif /* PNG_TEXT_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#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 - -#if defined(PNG_READ_DITHER_SUPPORTED) - png_bytep palette_lookup; /* lookup table for dithering */ - png_bytep dither_index; /* index translation for palette files */ -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) - png_uint_16p hist; /* histogram */ -#endif - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) - png_byte heuristic_method; /* heuristic for row filter selection */ - png_byte num_prev_filters; /* number of weights for previous rows */ - png_bytep prev_filters; /* filter type(s) of previous row(s) */ - png_uint_16p filter_weights; /* weight(s) for previous line(s) */ - png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ - png_uint_16p filter_costs; /* relative filter calculation cost */ - png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) - png_charp time_buffer; /* String to hold RFC 1123 time text */ -#endif - -/* New members added in libpng-1.0.6 */ - -#ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ -#endif - -#if defined(PNG_USER_CHUNKS_SUPPORTED) - png_voidp user_chunk_ptr; - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - int num_chunk_list; - png_bytep chunk_list; -#endif - -/* New members added in libpng-1.0.3 */ -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_byte rgb_to_gray_status; - /* 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; - png_uint_16 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) || \ - defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ -#ifdef PNG_1_0_X - png_byte mng_features_permitted; -#else - png_uint_32 mng_features_permitted; -#endif /* PNG_1_0_X */ -#endif - -/* New member added in libpng-1.0.7 */ -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_fixed_point int_gamma; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) - png_byte filter_type; -#endif - -#if defined(PNG_1_0_X) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -# if !defined(PNG_1_0_X) -# if defined(PNG_MMX_CODE_SUPPORTED) - png_byte mmx_bitdepth_threshold; - png_uint_32 mmx_rowbytes_threshold; -# endif - png_uint_32 asm_flags; -# endif -#endif - -/* 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 */ - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_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_SET_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; -#endif - -/* New member added in libpng-1.0.25 and 1.2.17 */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunk that the library doesn't recognize. */ - png_unknown_chunk unknown_chunk; -#endif -}; - - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef png_structp version_1_2_24; - -typedef png_struct FAR * FAR * png_structpp; - -/* Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - */ - -/* Returns the version number of the library */ -extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); - -/* Tell lib we have already handled the first magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, - int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -extern PNG_EXPORT(png_structp,png_create_read_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -extern PNG_EXPORT(png_structp,png_create_write_struct) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn)); - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_WRITE_SUPPORTED -extern PNG_EXPORT(void,png_set_compression_buffer_size) - PNGARG((png_structp png_ptr, png_uint_32 size)); -#endif - -/* Reset the compression stream */ -extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_structp,png_create_read_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -extern PNG_EXPORT(png_structp,png_create_write_struct_2) - PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -#endif - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, - png_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -extern PNG_EXPORT(png_infop,png_create_info_struct) - PNGARG((png_structp png_ptr)); - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#undef png_info_init -#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ - png_sizeof(png_info)); -#endif - -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the information before the actual image data. */ -extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#if defined(PNG_TIME_RFC1123_SUPPORTED) -extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) - PNGARG((png_structp png_ptr, png_timep ptime)); -#endif - -#if !defined(_WIN32_WCE) -/* "time.h" functions are not supported on WindowsCE */ -#if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ -extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, - struct tm FAR * ttime)); - -/* convert from time_t to png_time. Uses gmtime() */ -extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, - time_t ttime)); -#endif /* PNG_WRITE_tIME_SUPPORTED */ -#endif /* _WIN32_WCE */ - -#if defined(PNG_READ_EXPAND_SUPPORTED) -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp - png_ptr)); -#endif -extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated */ -extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* Expand the grayscale to 24-bit RGB if necessary. */ -extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* Reduce RGB to grayscale. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, - int error_action, double red, double green )); -#endif -extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green )); -extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp - png_ptr)); -#endif - -extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, - png_colorp palette)); - -#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -#define PNG_FILLER_BEFORE 0 -#define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -#if !defined(PNG_1_0_X) -extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, - png_uint_32 filler, int flags)); -#endif -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, - png_color_8p true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. */ -extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -/* Handle alpha and tRNS by replacing with a background color. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, - png_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -#endif -#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -#define PNG_BACKGROUND_GAMMA_SCREEN 1 -#define PNG_BACKGROUND_GAMMA_FILE 2 -#define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ -extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -/* Turn on dithering, and reduce the palette to the number of colors available. */ -extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_uint_16p histogram, int full_dither)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -/* Handle gamma correction. Screen_gamma=(display_exponent) */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, - double screen_gamma, double default_file_gamma)); -#endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ -/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ -extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, - int empty_plte_permitted)); -#endif -#endif - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -/* Set how many lines between output flushes - 0 for no flushing */ -extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); -#endif - -/* optional update palette with requested transformations */ -extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); - -/* optional call to update the users info structure */ -extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read one or more rows of image data. */ -extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read a row of data. */ -extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, - png_bytep row, - png_bytep display_row)); -#endif - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the whole image into memory at once. */ -extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, - png_bytepp image)); -#endif - -/* write a row of image data */ -extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, - png_bytep row)); - -/* write a few rows of image data */ -extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, - png_bytepp row, png_uint_32 num_rows)); - -/* write the image data */ -extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, - png_bytepp image)); - -/* writes the end of the PNG file. */ -extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the end of the PNG file. */ -extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -/* free any memory associated with the png_info_struct */ -extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp - png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ -/* Debian note: exporting as it is required by legacy applications */ -extern PNG_EXPORT(void,png_read_destroy) PNGARG((png_structp png_ptr, png_infop info_ptr, - png_infop end_info_ptr)); - -/* free any memory associated with the png_struct and the png_info_structs */ -extern PNG_EXPORT(void,png_destroy_write_struct) - PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); - -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ -/* Debian note: exporting as it is required by legacy applications */ -extern PNG_EXPORT(void,png_write_destroy) PNGARG((png_structp png_ptr)); - -/* set the libpng method of handling chunk CRC errors */ -extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, - int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() to say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, - int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, - int heuristic_method, int num_weights, png_doublep filter_weights, - png_doublep filter_costs)); -#endif -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, - int level)); - -extern PNG_EXPORT(void,png_set_compression_mem_level) - PNGARG((png_structp png_ptr, int mem_level)); - -extern PNG_EXPORT(void,png_set_compression_strategy) - PNGARG((png_structp png_ptr, int strategy)); - -extern PNG_EXPORT(void,png_set_compression_window_bits) - PNGARG((png_structp png_ptr, int window_bits)); - -extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, - int method)); - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng.txt for - * more information. - */ - -#if !defined(PNG_NO_STDIO) -/* Initialize the input/output for the PNG file to the default functions. */ -extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - */ -extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, - png_voidp io_ptr, png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); - -extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr read_user_transform_fn)); -#endif - -#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp - png_ptr, png_user_transform_ptr write_user_transform_fn)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) -extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp - png_ptr, png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) - PNGARG((png_structp png_ptr)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp - png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, - png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn)); - -/* returns the user pointer associated with the push read functions */ -extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) - PNGARG((png_structp png_ptr)); - -/* function to be called when data becomes available */ -extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* function that combines rows. Not very much different than the - * png_combine_row() call. Is this even used????? - */ -extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, - png_bytep old_row, png_bytep new_row)); -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, - png_uint_32 size)); - -#if defined(PNG_1_0_X) -# define png_malloc_warn png_malloc -#else -/* Added at libpng version 1.2.4 */ -extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, - png_uint_32 size)); -#endif - -/* frees a pointer allocated by png_malloc() */ -extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); - -#if defined(PNG_1_0_X) -/* Function to allocate memory for zlib. */ -extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, - uInt size)); - -/* Function to free memory for zlib */ -extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); -#endif - -/* Free data that was allocated internally */ -extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 free_me, int num)); -#ifdef PNG_FREE_ME_SUPPORTED -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, - png_infop info_ptr, int freer, png_uint_32 mask)); -#endif -/* assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, - png_uint_32 size)); -extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, - png_voidp ptr)); -#endif - -extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, - png_voidp s1, png_voidp s2, png_uint_32 size)); - -extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, - png_voidp s1, int value, png_uint_32 size)); - -#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ -extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, - int check)); -#endif /* USE_FAR_KEYWORD */ - -#ifndef PNG_NO_ERROR_TEXT -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); - -/* The same, but the chunk name is prepended to the error string. */ -extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, - png_const_charp error_message)); -#else -/* Fatal error in PNG image of libpng - can't continue */ -extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)); -#endif - -#ifndef PNG_NO_WARNINGS -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); - -#ifdef PNG_READ_SUPPORTED -/* Non-fatal error in libpng, chunk name is prepended to message. */ -extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, - png_const_charp warning_message)); -#endif /* PNG_READ_SUPPORTED */ -#endif /* PNG_NO_WARNINGS */ - -/* The png_set_ functions are for storing values in the png_info_struct. - * Similarly, the png_get_ calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_ functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ -extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, -png_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ -extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image height in pixels. */ -extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image bit_depth. */ -extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image color_type. */ -extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image filter_type. */ -extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image interlace_type. */ -extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image compression_type. */ -extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -#endif - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); -extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp -png_ptr, png_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p *background)); -#endif - -#if defined(PNG_bKGD_SUPPORTED) -extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_16p background)); -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point - *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point - *int_blue_x, png_fixed_point *int_blue_y)); -#endif -#endif - -#if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, double white_x, double white_y, double red_x, - double red_y, double green_x, double green_y, double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double *file_gamma)); -#endif -extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point *int_file_gamma)); -#endif - -#if defined(PNG_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -#endif -extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p *hist)); -#endif - -#if defined(PNG_hIST_SUPPORTED) -extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_16p hist)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#if defined(PNG_oFFs_SUPPORTED) -extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, - int *type, int *nparams, png_charp *units, png_charpp *params)); -#endif - -#if defined(PNG_pCAL_SUPPORTED) -extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_charp units, png_charpp params)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#if defined(PNG_pHYs_SUPPORTED) -extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp *palette, int *num_palette)); - -extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_colorp palette, int num_palette)); - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p *sig_bit)); -#endif - -#if defined(PNG_sBIT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_color_8p sig_bit)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *intent)); -#endif - -#if defined(PNG_sRGB_SUPPORTED) -extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, - png_infop info_ptr, int intent)); -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charpp name, int *compression_type, - png_charpp profile, png_uint_32 *proflen)); - /* Note to maintainer: profile should be png_bytepp */ -#endif - -#if defined(PNG_iCCP_SUPPORTED) -extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_charp name, int compression_type, - png_charp profile, png_uint_32 proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tpp entries)); -#endif - -#if defined(PNG_sPLT_SUPPORTED) -extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_sPLT_tp entries, int nentries)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) -/* png_get_text also returns the number of text chunks in *num_text */ -extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* - * Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#if defined(PNG_TEXT_SUPPORTED) -extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep *mod_time)); -#endif - -#if defined(PNG_tIME_SUPPORTED) -extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_timep mod_time)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep *trans, int *num_trans, - png_color_16p *trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_bytep trans, int num_trans, - png_color_16p trans_values)); -#endif - -#if defined(PNG_tRNS_SUPPORTED) -#endif - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, double *width, double *height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED */ - -#if defined(PNG_sCAL_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, - png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); -#endif -#endif -#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. - keep = 0: follow default behaviour - = 1: do not keep - = 2: keep only if safe-to-copy - = 3: keep even if unsafe-to-copy -*/ -extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp - png_ptr, int keep, png_bytep chunk_list, int num_chunks)); -extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, - png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); -extern PNG_EXPORT(void, png_set_unknown_chunk_location) - PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp - png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); -#endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ -extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, - png_infop info_ptr, int mask)); - -#if defined(PNG_INFO_IMAGE_SUPPORTED) -/* The "params" pointer is currently not used and is for future expansion. */ -extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, - png_infop info_ptr, - int transforms, - png_voidp params)); -#endif - -/* 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. - */ -#ifdef PNG_DEBUG -#if (PNG_DEBUG > 0) -#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -#include -#if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) -#endif -#else /* PNG_DEBUG_FILE || !_MSC_VER */ -#ifndef PNG_DEBUG_FILE -#define PNG_DEBUG_FILE stderr -#endif /* PNG_DEBUG_FILE */ -#if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} -#endif /* (PNG_DEBUG > 1) */ -#endif /* _MSC_VER */ -#endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -#define png_debug(l, m) -#endif -#ifndef png_debug1 -#define png_debug1(l, m, p1) -#endif -#ifndef png_debug2 -#define png_debug2(l, m, p1, p2) -#endif - -extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); -extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp - png_ptr, png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 - -/* Added to version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ -#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 -#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 -#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 -#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 -#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 -#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 -#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ - -#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) -#define PNG_MMX_WRITE_FLAGS ( 0 ) - -#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ - | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ - | PNG_MMX_READ_FLAGS \ - | PNG_MMX_WRITE_FLAGS ) - -#define PNG_SELECT_READ 1 -#define PNG_SELECT_WRITE 2 -#endif /* PNG_MMX_CODE_SUPPORTED */ - -#if !defined(PNG_1_0_X) -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) - PNGARG((int flag_select, int *compilerID)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) - PNGARG((int flag_select)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_asm_flags) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) - PNGARG((png_structp png_ptr)); - -/* pngget.c */ -extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) - PNGARG((png_structp png_ptr)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_asm_flags) - PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); - -/* pngset.c */ -extern PNG_EXPORT(void,png_set_mmx_thresholds) - PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, - png_uint_32 mmx_rowbytes_threshold)); - -#endif /* PNG_1_0_X */ - -#if !defined(PNG_1_0_X) -/* png.c, pnggccrd.c, or pngvcrd.c */ -extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp - png_ptr, png_uint_32 strip_mode)); -#endif - -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp - png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); -extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp - png_ptr)); -extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp - png_ptr)); -#endif - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 - \ - (png_uint_16)(alpha)) + (png_uint_16)128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(png_uint_32)(65535L - \ - (png_uint_32)(alpha)) + (png_uint_32)32768L); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - (png_uint_16)127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ - (png_uint_32)32767) / (png_uint_32)65535L) - -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -/* Inline macros to do direct reads of bytes from the input buffer. These - * require that you are using an architecture that uses PNG byte ordering - * (MSB first) and supports unaligned data storage. I think that PowerPC - * in big-endian mode and 680x0 are the only ones that will support this. - * The x86 line of processors definitely do not. The png_get_int_32() - * routine also assumes we are using two's complement format for negative - * values, which is almost certainly true. - */ -#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) -# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) -# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) -# define png_get_int_32(buf) ( *((png_int_32p) (buf))) -#else -extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); -extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); -#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ -extern PNG_EXPORT(png_uint_32,png_get_uint_31) - PNGARG((png_structp png_ptr, png_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). - */ -extern PNG_EXPORT(void,png_save_uint_32) - PNGARG((png_bytep buf, png_uint_32 i)); -extern PNG_EXPORT(void,png_save_int_32) - PNGARG((png_bytep buf, png_int_32 i)); - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -extern PNG_EXPORT(void,png_save_uint_16) - PNGARG((png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ - -/* ************************************************************************* */ - -/* These next functions are used internally in the code. They generally - * shouldn't be used unless you are writing code to add or replace some - * functionality in libpng. More information about most functions can - * be found in the files where the functions are located. - */ - - -/* Various modes of operation, that are visible to applications because - * they are used for unknown chunk location. - */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_HAVE_IDAT 0x04 -#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ -#define PNG_HAVE_IEND 0x10 - -#if defined(PNG_INTERNAL) - -/* More modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. - */ -#define PNG_HAVE_gAMA 0x20 -#define PNG_HAVE_cHRM 0x40 -#define PNG_HAVE_sRGB 0x80 -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - -/* flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_DITHER 0x0040 -#define PNG_BACKGROUND 0x0080 -#define PNG_BACKGROUND_EXPAND 0x0100 - /* 0x0200 unused */ -#define PNG_16_TO_8 0x0400 -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000L -#define PNG_PACKSWAP 0x10000L -#define PNG_SWAP_ALPHA 0x20000L -#define PNG_STRIP_ALPHA 0x40000L -#define PNG_INVERT_ALPHA 0x80000L -#define PNG_USER_TRANSFORM 0x100000L -#define PNG_RGB_TO_GRAY_ERR 0x200000L -#define PNG_RGB_TO_GRAY_WARN 0x400000L -#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ - /* 0x800000L Unused */ -#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -/* flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 - -/* Scaling factor for filter heuristic weighting calculations */ -#define PNG_WEIGHT_SHIFT 8 -#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) -#define PNG_COST_SHIFT 3 -#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) - -/* flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 -#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 -#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 -#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 -#define PNG_FLAG_ZLIB_FINISHED 0x0020 -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_FREE_PLTE 0x1000 -#define PNG_FLAG_FREE_TRNS 0x2000 -#define PNG_FLAG_FREE_HIST 0x4000 -#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L -#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L -#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L -#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ -#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ - /* 0x800000L unused */ - /* 0x1000000L unused */ - /* 0x2000000L unused */ - /* 0x4000000L unused */ - /* 0x8000000L unused */ - /* 0x10000000L unused */ - /* 0x20000000L unused */ - /* 0x40000000L unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ - (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ -#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ -#ifdef PNG_USE_GLOBAL_ARRAYS - PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; -#else -#endif -#endif /* PNG_NO_EXTERN */ - -/* Constant strings for known chunk types. If you need to add a chunk, - * define the name here, and add an invocation of the macro in png.c and - * wherever it's needed. - */ -#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} -#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} -#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} -#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} -#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} -#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} -#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} -#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} -#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} -#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} -#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} -#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} -#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} -#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} -#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} -#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} -#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} -#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} -#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} -#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} -#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} - -#ifdef PNG_USE_GLOBAL_ARRAYS -PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5]; -PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5]; -#endif /* PNG_USE_GLOBAL_ARRAYS */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for reading, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_read_struct instead). - */ -extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#undef png_read_init -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Initialize png_ptr struct for writing, and allocate any other memory. - * (old interface - DEPRECATED - use png_create_write_struct instead). - */ -extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#undef png_write_init -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); -#endif - -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); -extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t - png_info_size)); - -/* Allocate memory for an internal libpng struct */ -PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); - -/* Free memory from internal libpng struct */ -PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); - -PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); -PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); - -/* Free any memory that info_ptr points to and reset struct. */ -PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -#ifndef PNG_1_0_X -/* Function to allocate memory for zlib. */ -PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); - -/* Function to free memory for zlib */ -PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); - -#ifdef PNG_SIZE_T -/* Function to convert a sizeof an item to png_sizeof item */ - PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); -#endif - -/* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ - -PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif - -PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, - png_bytep data, png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -#if !defined(PNG_NO_STDIO) -PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); -#endif -#endif -#else /* PNG_1_0_X */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t length)); -#endif -#endif /* PNG_1_0_X */ - -/* Reset the CRC variable */ -PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); - -/* Write the "data" buffer to whatever output you are using. */ -PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, - png_size_t length)); - -/* Decompress data in a chunk that uses compression */ -#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, - png_size_t prefix_length, png_size_t *data_length)); -#endif - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, - png_size_t length)); - -#if defined(PNG_WRITE_FLUSH_SUPPORTED) -PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); -#endif - -/* simple function to write the signature */ -PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); - -/* write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, - png_uint_32 height, - int bit_depth, int color_type, int compression_method, int filter_method, - int interlace_method)); - -PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, - png_uint_32 num_pal)); - -PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, - png_size_t length)); - -PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); - -#if defined(PNG_WRITE_gAMA_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point - file_gamma)); -#endif -#endif - -#if defined(PNG_WRITE_sBIT_SUPPORTED) -PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, - int color_type)); -#endif - -#if defined(PNG_WRITE_cHRM_SUPPORTED) -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, - double white_x, double white_y, - double red_x, double red_y, double green_x, double green_y, - double blue_x, double blue_y)); -#endif -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, - png_fixed_point int_white_x, png_fixed_point int_white_y, - png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point - int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -#endif -#endif - -#if defined(PNG_WRITE_sRGB_SUPPORTED) -PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, - int intent)); -#endif - -#if defined(PNG_WRITE_iCCP_SUPPORTED) -PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, - png_charp name, int compression_type, - png_charp profile, int proflen)); - /* Note to maintainer: profile should be png_bytep */ -#endif - -#if defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, - png_sPLT_tp palette)); -#endif - -#if defined(PNG_WRITE_tRNS_SUPPORTED) -PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, - png_color_16p values, int number, int color_type)); -#endif - -#if defined(PNG_WRITE_bKGD_SUPPORTED) -PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, - png_color_16p values, int color_type)); -#endif - -#if defined(PNG_WRITE_hIST_SUPPORTED) -PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, - int num_hist)); -#endif - -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, - png_charp key, png_charpp new_key)); -#endif - -#if defined(PNG_WRITE_tEXt_SUPPORTED) -PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len)); -#endif - -#if defined(PNG_WRITE_zTXt_SUPPORTED) -PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, - png_charp text, png_size_t text_len, int compression)); -#endif - -#if defined(PNG_WRITE_iTXt_SUPPORTED) -PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, - int compression, png_charp key, png_charp lang, png_charp lang_key, - png_charp text)); -#endif - -#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ -PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, - png_infop info_ptr, png_textp text_ptr, int num_text)); -#endif - -#if defined(PNG_WRITE_oFFs_SUPPORTED) -PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type)); -#endif - -#if defined(PNG_WRITE_pCAL_SUPPORTED) -PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, - png_int_32 X0, png_int_32 X1, int type, int nparams, - png_charp units, png_charpp params)); -#endif - -#if defined(PNG_WRITE_pHYs_SUPPORTED) -PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type)); -#endif - -#if defined(PNG_WRITE_tIME_SUPPORTED) -PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, - png_timep mod_time)); -#endif - -#if defined(PNG_WRITE_sCAL_SUPPORTED) -#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) -PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, - int unit, double width, double height)); -#else -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, - int unit, png_charp width, png_charp height)); -#endif -#endif -#endif - -/* Called when finished processing a row of data */ -PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); - -/* Internal use only. Called before first row of data */ -PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); -#endif - -/* combine a row of data, dealing with alpha, etc. if requested */ -PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, - int mask)); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ -/* OLD pre-1.0.9 interface: -PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations)); - */ -PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ -PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, - png_bytep row, int pass)); -#endif - -/* unfilter a row */ -PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, - png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); - -/* Choose the best filter to use and filter the row data */ -PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, - png_row_infop row_info)); - -/* Write out the filtered row. */ -PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, - png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ -PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); - -/* initialize the row buffers, etc. */ -PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ -PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); - -/* these are the functions that do the transformations */ -#if defined(PNG_READ_FILLER_SUPPORTED) -PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 filler, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 flags)); -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop - row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) -PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p sig_bits)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_16_TO_8_SUPPORTED) -PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_READ_DITHER_SUPPORTED) -PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, - png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); - -# if defined(PNG_CORRECT_PALETTE_SUPPORTED) -PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, - png_colorp palette, int num_palette)); -# endif -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) -PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, - png_bytep row, png_uint_32 bit_depth)); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) -PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, - png_color_8p bit_depth)); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background, - png_color_16p background_1, - png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, - png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, - png_uint_16pp gamma_16_to_1, int gamma_shift)); -#else -PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, - png_color_16p trans_values, png_color_16p background)); -#endif -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) -PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, - png_bytep gamma_table, png_uint_16pp gamma_16_table, - int gamma_shift)); -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) -PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, - png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); -PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, - png_bytep row, png_color_16p trans_value)); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* decode the IHDR chunk */ -PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); - -#if defined(PNG_READ_bKGD_SUPPORTED) -PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_cHRM_SUPPORTED) -PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_gAMA_SUPPORTED) -PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_hIST_SUPPORTED) -PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_iCCP_SUPPORTED) -extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_iCCP_SUPPORTED */ - -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_oFFs_SUPPORTED) -PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pCAL_SUPPORTED) -PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_pHYs_SUPPORTED) -PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sBIT_SUPPORTED) -PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sCAL_SUPPORTED) -PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_sPLT_SUPPORTED) -extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif /* PNG_READ_sPLT_SUPPORTED */ - -#if defined(PNG_READ_sRGB_SUPPORTED) -PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tIME_SUPPORTED) -PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_tRNS_SUPPORTED) -PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, - png_uint_32 length)); -#endif - -PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); - -PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, - png_bytep chunk_name)); - -/* handle the transformations for reading and writing */ -PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); - -PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, - png_uint_32 length)); -PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, - png_bytep buffer, png_size_t buffer_length)); -PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); -PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); -PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, - png_infop info_ptr)); -PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); -#if defined(PNG_READ_tEXt_SUPPORTED) -PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_zTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif -#if defined(PNG_READ_iTXt_SUPPORTED) -PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr, png_uint_32 length)); -PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, - png_infop info_ptr)); -#endif - -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, - png_bytep row)); -#endif - -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* png.c */ /* PRIVATE */ -PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); -#endif -#endif - -#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, -png_infop info_ptr)); - -#if defined(PNG_pHYs_SUPPORTED) -PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, -png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ - -/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ - -#endif /* PNG_INTERNAL */ - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ -#endif /* PNG_H */ diff --git a/extern/gnuwin32/include/pngconf.h b/extern/gnuwin32/include/pngconf.h deleted file mode 100644 index 0848dcb8..00000000 --- a/extern/gnuwin32/include/pngconf.h +++ /dev/null @@ -1,1481 +0,0 @@ - -/* pngconf.h - machine configurable file for libpng - * - * libpng version 1.2.24 - December 14, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 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.) - */ - -/* 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 - -#define PNG_1_2_X - -/* - * PNG_USER_CONFIG has to be defined on the compiler command line. This - * includes the resource compiler for Windows DLL configurations. - */ -#ifdef PNG_USER_CONFIG -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD -# endif -#include "pngusr.h" -#endif - -/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ -#ifdef PNG_CONFIGURE_LIBPNG -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -/* - * Added at libpng-1.2.8 - * - * If you create a private DLL you need to define in "pngusr.h" the followings: - * #define PNG_USER_PRIVATEBUILD - * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." - * #define PNG_USER_DLLFNAME_POSTFIX - * 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 - */ - -#ifdef __STDC__ -#ifdef SPECIALBUILD -# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ - are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") -#endif - -#ifdef PRIVATEBUILD -# pragma message("PRIVATEBUILD is deprecated.\ - Use PNG_USER_PRIVATEBUILD instead.") -# define PNG_USER_PRIVATEBUILD PRIVATEBUILD -#endif -#endif /* __STDC__ */ - -#ifndef PNG_VERSION_INFO_ONLY - -/* End of material added to libpng-1.2.8 */ - -/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble - Restored at libpng-1.2.21 */ -#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \ - !defined(PNG_WARN_UNINITIALIZED_ROW) -# define PNG_WARN_UNINITIALIZED_ROW 1 -#endif -/* End of material added at libpng-1.2.19/1.2.21 */ - -/* 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 will 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. - */ - -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif - -/* Enable if you want a write-only libpng */ - -#ifndef PNG_NO_READ_SUPPORTED -# define PNG_READ_SUPPORTED -#endif - -/* Enable if you want a read-only libpng */ - -#ifndef PNG_NO_WRITE_SUPPORTED -# define PNG_WRITE_SUPPORTED -#endif - -/* Enabled by default in 1.2.0. You can disable this if you don't need to - support PNGs that are embedded in MNG datastreams */ -#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) -# ifndef PNG_MNG_FEATURES_SUPPORTED -# define PNG_MNG_FEATURES_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_FLOATING_POINT_SUPPORTED -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FLOATING_POINT_SUPPORTED -# endif -#endif - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. -#define PNG_MAX_MALLOC_64K - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -/* Special munging to support doing things the 'cygwin' way: - * 'Normal' png-on-win32 defines/defaults: - * PNG_BUILD_DLL -- building dll - * PNG_USE_DLL -- building an application, linking to dll - * (no define) -- building static library, or building an - * application and linking to the static lib - * 'Cygwin' defines/defaults: - * PNG_BUILD_DLL -- (ignored) building the dll - * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an - * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an - * application that links to the static libs. - * Thus, - * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and - * this bit of #ifdefs will define the 'correct' config variables based on - * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but - * unnecessary. - * - * Also, the precedence order is: - * ALL_STATIC (since we can't #undef something outside our namespace) - * PNG_BUILD_DLL - * PNG_STATIC - * (nothing) == PNG_USE_DLL - * - * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about - * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, - * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about - * PNG_BUILD_DLL and PNG_STATIC because those change some defaults - * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. - */ -#if defined(__CYGWIN__) -# if defined(ALL_STATIC) -# if defined(PNG_BUILD_DLL) -# undef PNG_BUILD_DLL -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# if !defined(PNG_STATIC) -# define PNG_STATIC -# endif -# else -# if defined (PNG_BUILD_DLL) -# if defined(PNG_STATIC) -# undef PNG_STATIC -# endif -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# else -# if defined(PNG_STATIC) -# if defined(PNG_USE_DLL) -# undef PNG_USE_DLL -# endif -# if defined(PNG_DLL) -# undef PNG_DLL -# endif -# else -# if !defined(PNG_USE_DLL) -# define PNG_USE_DLL -# endif -# if !defined(PNG_DLL) -# define PNG_DLL -# endif -# endif -# endif -# endif -#endif - -/* 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. - * - * #define PNG_NO_CONSOLE_IO - * #define PNG_NO_STDIO - */ - -#if defined(_WIN32_WCE) -# include - /* Console I/O functions are not supported on WindowsCE */ -# define PNG_NO_CONSOLE_IO -# ifdef PNG_DEBUG -# undef PNG_DEBUG -# endif -#endif - -#ifdef PNG_BUILD_DLL -# ifndef PNG_CONSOLE_IO_SUPPORTED -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# endif -#endif - -# ifdef PNG_NO_STDIO -# ifndef PNG_NO_CONSOLE_IO -# define PNG_NO_CONSOLE_IO -# endif -# ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# include -# endif -# endif -# else -# if !defined(_WIN32_WCE) -/* "stdio.h" functions are not supported on WindowsCE */ -# include -# endif -# endif - -/* This macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -#ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -#else - -#ifdef _NO_PROTO -# define PNGARG(arglist) () -# ifndef PNG_TYPECAST_NULL -# define PNG_TYPECAST_NULL -# endif -#else -# define PNGARG(arglist) arglist -#endif /* _NO_PROTO */ - - -#endif /* OF */ - -#endif /* PNGARG */ - -/* Try to determine if we are compiling on a Mac. Note that testing for - * just __MWERKS__ is not good enough, because the Codewarrior is now used - * on non-Mac platforms. - */ -#ifndef MACOS -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) -# define MACOS -# endif -#endif - -/* enough people need this for various reasons to include it here */ -#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) -# include -#endif - -#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) -# define PNG_SETJMP_SUPPORTED -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This is an attempt to force a single setjmp behaviour on Linux. If - * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. - */ - -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __pngconf.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ - - /* include setjmp.h for error handling */ -# include - -# ifdef __linux__ -# ifdef PNG_SAVE_BSD_SOURCE -# ifndef _BSD_SOURCE -# define _BSD_SOURCE -# endif -# undef PNG_SAVE_BSD_SOURCE -# endif -# endif /* __linux__ */ -#endif /* PNG_SETJMP_SUPPORTED */ - -#ifdef BSD -# include -#else -# include -#endif - -/* Other defines for things like memory and the like can go here. */ -#ifdef PNG_INTERNAL - -#include - -/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which - * aren't usually used outside the library (as far as I know), so it is - * debatable if they should be exported at all. In the future, when it is - * possible to have run-time registry of chunk-handling functions, some of - * these will be made available again. -#define PNG_EXTERN extern - */ -#define PNG_EXTERN - -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) -# if defined(MACOS) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* Codewarrior on NT has linking problems without this. */ -#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) -# define PNG_ALWAYS_EXTERN -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include -# include -#endif - -/* I have no idea why is this necessary... */ -#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ - defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) -# include -#endif - -/* This controls how fine the dithering gets. As this allocates - * a largish chunk of memory (32K), those who are not as concerned - * with dithering quality can decrease some or all of these. - */ -#ifndef PNG_DITHER_RED_BITS -# define PNG_DITHER_RED_BITS 5 -#endif -#ifndef PNG_DITHER_GREEN_BITS -# define PNG_DITHER_GREEN_BITS 5 -#endif -#ifndef PNG_DITHER_BLUE_BITS -# define PNG_DITHER_BLUE_BITS 5 -#endif - -/* 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 then 8, and even that may not work (I haven't tested it). - */ - -#ifndef PNG_MAX_GAMMA_8 -# define PNG_MAX_GAMMA_8 11 -#endif - -/* This controls how much a difference in gamma we can tolerate before - * we actually start doing gamma conversion. - */ -#ifndef PNG_GAMMA_THRESHOLD -# define PNG_GAMMA_THRESHOLD 0.05 -#endif - -#endif /* PNG_INTERNAL */ - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - */ - -#ifndef PNG_NO_CONST -# define PNG_CONST const -#else -# define PNG_CONST -#endif - -/* The following defines give you the ability to remove code from the - * library that you will not be using. I wish I could figure out how to - * automate this, but I can't do that without making it seriously hard - * on the users. So if you are not using an ability, change the #define - * to and #undef, and that part of the library will not be compiled. If - * your linker can't find a function, you may want to make sure the - * ability is defined here. Some of these depend upon some others being - * defined. I haven't figured out all the interactions here, so you may - * have to experiment awhile to get everything to compile. If you are - * creating or using a shared library, you probably shouldn't touch this, - * as it will affect the size of the structures, and this will cause bad - * things to happen if the library and/or application ever change. - */ - -/* Any features you will not be using can be undef'ed here */ - -/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user - * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS - * on the compile line, then pick and choose which ones to define without - * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED - * if you only want to have a png-compliant reader/writer but don't need - * any of the extra transformations. This saves about 80 kbytes in a - * typical installation of the library. (PNG_NO_* form added in version - * 1.0.1c, for consistency) - */ - -/* 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.3.0. - */ - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -# ifndef PNG_NO_iTXt_SUPPORTED -# define PNG_NO_iTXt_SUPPORTED -# endif -# ifndef PNG_NO_READ_iTXt -# define PNG_NO_READ_iTXt -# endif -# ifndef PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_iTXt -# endif -#endif - -#if !defined(PNG_NO_iTXt_SUPPORTED) -# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) -# define PNG_READ_iTXt -# endif -# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) -# define PNG_WRITE_iTXt -# endif -#endif - -/* The following support, added after version 1.0.0, can be turned off here en - * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility - * with old applications that require the length of png_struct and png_info - * to remain unchanged. - */ - -#ifdef PNG_LEGACY_SUPPORTED -# define PNG_NO_FREE_ME -# define PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_NO_READ_USER_CHUNKS -# define PNG_NO_READ_iCCP -# define PNG_NO_WRITE_iCCP -# define PNG_NO_READ_iTXt -# define PNG_NO_WRITE_iTXt -# define PNG_NO_READ_sCAL -# define PNG_NO_WRITE_sCAL -# define PNG_NO_READ_sPLT -# define PNG_NO_WRITE_sPLT -# define PNG_NO_INFO_IMAGE -# define PNG_NO_READ_RGB_TO_GRAY -# define PNG_NO_READ_USER_TRANSFORM -# define PNG_NO_WRITE_USER_TRANSFORM -# define PNG_NO_USER_MEM -# define PNG_NO_READ_EMPTY_PLTE -# define PNG_NO_MNG_FEATURES -# define PNG_NO_FIXED_POINT_SUPPORTED -#endif - -/* Ignore attempt to turn off both floating and fixed point support */ -#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ - !defined(PNG_NO_FIXED_POINT_SUPPORTED) -# define PNG_FIXED_POINT_SUPPORTED -#endif - -#ifndef PNG_NO_FREE_ME -# define PNG_FREE_ME_SUPPORTED -#endif - -#if defined(PNG_READ_SUPPORTED) - -#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_TRANSFORMS) -# define PNG_READ_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_READ_EXPAND -# define PNG_READ_EXPAND_SUPPORTED -# endif -# ifndef PNG_NO_READ_SHIFT -# define PNG_READ_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACK -# define PNG_READ_PACK_SUPPORTED -# endif -# ifndef PNG_NO_READ_BGR -# define PNG_READ_BGR_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP -# define PNG_READ_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_PACKSWAP -# define PNG_READ_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT -# define PNG_READ_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_READ_DITHER -# define PNG_READ_DITHER_SUPPORTED -# endif -# ifndef PNG_NO_READ_BACKGROUND -# define PNG_READ_BACKGROUND_SUPPORTED -# endif -# ifndef PNG_NO_READ_16_TO_8 -# define PNG_READ_16_TO_8_SUPPORTED -# endif -# ifndef PNG_NO_READ_FILLER -# define PNG_READ_FILLER_SUPPORTED -# endif -# ifndef PNG_NO_READ_GAMMA -# define PNG_READ_GAMMA_SUPPORTED -# endif -# ifndef PNG_NO_READ_GRAY_TO_RGB -# define PNG_READ_GRAY_TO_RGB_SUPPORTED -# endif -# ifndef PNG_NO_READ_SWAP_ALPHA -# define PNG_READ_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_INVERT_ALPHA -# define PNG_READ_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_STRIP_ALPHA -# define PNG_READ_STRIP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_READ_USER_TRANSFORM -# define PNG_READ_USER_TRANSFORM_SUPPORTED -# endif -# ifndef PNG_NO_READ_RGB_TO_GRAY -# define PNG_READ_RGB_TO_GRAY_SUPPORTED -# endif -#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_PROGRESSIVE_READ) && \ - !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */ -# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ -#endif /* about interlacing capability! You'll */ - /* still have interlacing unless you change the following line: */ - -#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */ - -#ifndef PNG_NO_READ_COMPOSITE_NODIV -# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ -# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ -# endif -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, will be removed from version 2.0.0. - Use PNG_MNG_FEATURES_SUPPORTED instead. */ -#ifndef PNG_NO_READ_EMPTY_PLTE -# define PNG_READ_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_READ_SUPPORTED */ - -#if defined(PNG_WRITE_SUPPORTED) - -# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_TRANSFORMS) -# define PNG_WRITE_TRANSFORMS_SUPPORTED -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -# ifndef PNG_NO_WRITE_SHIFT -# define PNG_WRITE_SHIFT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACK -# define PNG_WRITE_PACK_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_BGR -# define PNG_WRITE_BGR_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_SWAP -# define PNG_WRITE_SWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_PACKSWAP -# define PNG_WRITE_PACKSWAP_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT -# define PNG_WRITE_INVERT_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_FILLER -# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ -# endif -# ifndef PNG_NO_WRITE_SWAP_ALPHA -# define PNG_WRITE_SWAP_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_INVERT_ALPHA -# define PNG_WRITE_INVERT_ALPHA_SUPPORTED -# endif -# ifndef PNG_NO_WRITE_USER_TRANSFORM -# define PNG_WRITE_USER_TRANSFORM_SUPPORTED -# endif -#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ - -#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ - !defined(PNG_WRITE_INTERLACING_SUPPORTED) -#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant - encoders, but can cause trouble - if left undefined */ -#endif - -#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ - !defined(PNG_WRITE_WEIGHTED_FILTER) && \ - defined(PNG_FLOATING_POINT_SUPPORTED) -# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#endif - -#ifndef PNG_NO_WRITE_FLUSH -# define PNG_WRITE_FLUSH_SUPPORTED -#endif - -#if defined(PNG_1_0_X) || defined (PNG_1_2_X) -/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ -#ifndef PNG_NO_WRITE_EMPTY_PLTE -# define PNG_WRITE_EMPTY_PLTE_SUPPORTED -#endif -#endif - -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef PNG_1_0_X -# ifndef PNG_NO_ERROR_NUMBERS -# define PNG_ERROR_NUMBERS_SUPPORTED -# endif -#endif /* PNG_1_0_X */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -# ifndef PNG_NO_USER_TRANSFORM_PTR -# define PNG_USER_TRANSFORM_PTR_SUPPORTED -# endif -#endif - -#ifndef PNG_NO_STDIO -# define PNG_TIME_RFC1123_SUPPORTED -#endif - -/* This adds extra functions in pngget.c for accessing data from the - * info pointer (added in version 0.99) - * png_get_image_width() - * png_get_image_height() - * png_get_bit_depth() - * png_get_color_type() - * png_get_compression_type() - * png_get_filter_type() - * png_get_interlace_type() - * png_get_pixel_aspect_ratio() - * png_get_pixels_per_meter() - * png_get_x_offset_pixels() - * png_get_y_offset_pixels() - * png_get_x_offset_microns() - * png_get_y_offset_microns() - */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) -# define PNG_EASY_ACCESS_SUPPORTED -#endif - -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 - * and removed from version 1.2.20. The following will be removed - * from libpng-1.4.0 -*/ - -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE) -# ifndef PNG_OPTIMIZED_CODE_SUPPORTED -# define PNG_OPTIMIZED_CODE_SUPPORTED -# endif -#endif - -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) && defined(__i386__) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif - -# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4) - /* work around 64-bit gcc compiler bugs in gcc-3.x */ -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE -# endif -# endif - -# if defined(__APPLE__) -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE -# endif -# endif - -# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh)) -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_NO_MMX_CODE -# endif -# endif - -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif - -#endif -/* end of obsolete code to be removed from libpng-1.4.0 */ - -#if !defined(PNG_1_0_X) -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.2.6 */ -#if !defined(PNG_1_0_X) -#ifndef PNG_SET_USER_LIMITS_SUPPORTED -#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) -# define PNG_SET_USER_LIMITS_SUPPORTED -#endif -#endif -#endif /* PNG_1_0_X */ - -/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter - * how large, set these limits to 0x7fffffffL - */ -#ifndef PNG_USER_WIDTH_MAX -# define PNG_USER_WIDTH_MAX 1000000L -#endif -#ifndef PNG_USER_HEIGHT_MAX -# define PNG_USER_HEIGHT_MAX 1000000L -#endif - -/* These are currently experimental features, define them if you want */ - -/* very little testing */ -/* -#ifdef PNG_READ_SUPPORTED -# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -# endif -#endif -*/ - -/* This is only for PowerPC big-endian and 680x0 systems */ -/* some testing */ -/* -#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED -# define PNG_READ_BIG_ENDIAN_SUPPORTED -#endif -*/ - -/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ -/* -#define PNG_NO_POINTER_INDEXING -*/ - -/* These functions are turned off by default, as they will be phased out. */ -/* -#define PNG_USELESS_TESTS_SUPPORTED -#define PNG_CORRECT_PALETTE_SUPPORTED -*/ - -/* Any chunks you are not interested in, you can undef here. The - * ones that allocate memory may be expecially important (hIST, - * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info - * a bit smaller. - */ - -#if defined(PNG_READ_SUPPORTED) && \ - !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_READ_ANCILLARY_CHUNKS) -# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#if defined(PNG_WRITE_SUPPORTED) && \ - !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ - !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) -# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#endif - -#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_READ_TEXT -# define PNG_NO_READ_iTXt -# define PNG_NO_READ_tEXt -# define PNG_NO_READ_zTXt -#endif -#ifndef PNG_NO_READ_bKGD -# define PNG_READ_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -#endif -#ifndef PNG_NO_READ_cHRM -# define PNG_READ_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -#endif -#ifndef PNG_NO_READ_gAMA -# define PNG_READ_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -#endif -#ifndef PNG_NO_READ_hIST -# define PNG_READ_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -#endif -#ifndef PNG_NO_READ_iCCP -# define PNG_READ_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -#endif -#ifndef PNG_NO_READ_iTXt -# ifndef PNG_READ_iTXt_SUPPORTED -# define PNG_READ_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_READ_oFFs -# define PNG_READ_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -#endif -#ifndef PNG_NO_READ_pCAL -# define PNG_READ_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_sCAL -# define PNG_READ_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -#endif -#ifndef PNG_NO_READ_pHYs -# define PNG_READ_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -#endif -#ifndef PNG_NO_READ_sBIT -# define PNG_READ_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sPLT -# define PNG_READ_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -#endif -#ifndef PNG_NO_READ_sRGB -# define PNG_READ_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -#endif -#ifndef PNG_NO_READ_tEXt -# define PNG_READ_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_tIME -# define PNG_READ_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -#endif -#ifndef PNG_NO_READ_tRNS -# define PNG_READ_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -#endif -#ifndef PNG_NO_READ_zTXt -# define PNG_READ_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -#endif -#ifndef PNG_NO_READ_UNKNOWN_CHUNKS -# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -#endif -#if !defined(PNG_NO_READ_USER_CHUNKS) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) -# define PNG_READ_USER_CHUNKS_SUPPORTED -# define PNG_USER_CHUNKS_SUPPORTED -# ifdef PNG_NO_READ_UNKNOWN_CHUNKS -# undef PNG_NO_READ_UNKNOWN_CHUNKS -# endif -# ifdef PNG_NO_HANDLE_AS_UNKNOWN -# undef PNG_NO_HANDLE_AS_UNKNOWN -# endif -#endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif - -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ - -#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED - -#ifdef PNG_NO_WRITE_TEXT -# define PNG_NO_WRITE_iTXt -# define PNG_NO_WRITE_tEXt -# define PNG_NO_WRITE_zTXt -#endif -#ifndef PNG_NO_WRITE_bKGD -# define PNG_WRITE_bKGD_SUPPORTED -# ifndef PNG_bKGD_SUPPORTED -# define PNG_bKGD_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_cHRM -# define PNG_WRITE_cHRM_SUPPORTED -# ifndef PNG_cHRM_SUPPORTED -# define PNG_cHRM_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_gAMA -# define PNG_WRITE_gAMA_SUPPORTED -# ifndef PNG_gAMA_SUPPORTED -# define PNG_gAMA_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_hIST -# define PNG_WRITE_hIST_SUPPORTED -# ifndef PNG_hIST_SUPPORTED -# define PNG_hIST_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iCCP -# define PNG_WRITE_iCCP_SUPPORTED -# ifndef PNG_iCCP_SUPPORTED -# define PNG_iCCP_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_iTXt -# ifndef PNG_WRITE_iTXt_SUPPORTED -# define PNG_WRITE_iTXt_SUPPORTED -# endif -# ifndef PNG_iTXt_SUPPORTED -# define PNG_iTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_oFFs -# define PNG_WRITE_oFFs_SUPPORTED -# ifndef PNG_oFFs_SUPPORTED -# define PNG_oFFs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pCAL -# define PNG_WRITE_pCAL_SUPPORTED -# ifndef PNG_pCAL_SUPPORTED -# define PNG_pCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sCAL -# define PNG_WRITE_sCAL_SUPPORTED -# ifndef PNG_sCAL_SUPPORTED -# define PNG_sCAL_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_pHYs -# define PNG_WRITE_pHYs_SUPPORTED -# ifndef PNG_pHYs_SUPPORTED -# define PNG_pHYs_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sBIT -# define PNG_WRITE_sBIT_SUPPORTED -# ifndef PNG_sBIT_SUPPORTED -# define PNG_sBIT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sPLT -# define PNG_WRITE_sPLT_SUPPORTED -# ifndef PNG_sPLT_SUPPORTED -# define PNG_sPLT_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_sRGB -# define PNG_WRITE_sRGB_SUPPORTED -# ifndef PNG_sRGB_SUPPORTED -# define PNG_sRGB_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tEXt -# define PNG_WRITE_tEXt_SUPPORTED -# ifndef PNG_tEXt_SUPPORTED -# define PNG_tEXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tIME -# define PNG_WRITE_tIME_SUPPORTED -# ifndef PNG_tIME_SUPPORTED -# define PNG_tIME_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_tRNS -# define PNG_WRITE_tRNS_SUPPORTED -# ifndef PNG_tRNS_SUPPORTED -# define PNG_tRNS_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_zTXt -# define PNG_WRITE_zTXt_SUPPORTED -# ifndef PNG_zTXt_SUPPORTED -# define PNG_zTXt_SUPPORTED -# endif -#endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif -#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ - defined(PNG_WRITE_zTXt_SUPPORTED) -# define PNG_WRITE_TEXT_SUPPORTED -# ifndef PNG_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -# endif -#endif - -#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ - -/* Turn this off to disable png_read_png() and - * png_write_png() and leave the row_pointers member - * out of the info structure. - */ -#ifndef PNG_NO_INFO_IMAGE -# define PNG_INFO_IMAGE_SUPPORTED -#endif - -/* need the time information for reading tIME chunks */ -#if defined(PNG_tIME_SUPPORTED) -# if !defined(_WIN32_WCE) - /* "time.h" functions are not supported on WindowsCE */ -# include -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may - * want to have unsigned int for png_uint_32 instead of unsigned long. - */ - -typedef unsigned long png_uint_32; -typedef long png_int_32; -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -/* This is usually size_t. It is typedef'ed just in case you need it to - change (I'm not sure if you will or not, so I thought I'd be safe) */ -#ifdef PNG_SIZE_T - typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) -#else - typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) -#endif - -/* The following is needed for medium model support. It cannot be in the - * PNG_INTERNAL section. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - defines FAR. (SJT) */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#if defined(FAR) -# if defined(M_I86MM) -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - to fixed-point with a multiple of 100,000, e.g., int_gamma */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef png_byte FAR * png_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST char FAR * png_const_charp; -typedef char FAR * png_charp; -typedef png_fixed_point FAR * png_fixed_point_p; - -#ifndef PNG_NO_STDIO -#if defined(_WIN32_WCE) -typedef HANDLE png_FILE_p; -#else -typedef FILE * png_FILE_p; -#endif -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -#if defined(PNG_1_0_X) || defined(PNG_1_2_X) -/* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ -/* libpng typedefs for types in zlib. If zlib changes - * or another compression library is used, then change these. - * Eliminates need to change all the source files. - */ -typedef charf * png_zcharp; -typedef charf * FAR * png_zcharpp; -typedef z_stream FAR * png_zstreamp; -#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ - -/* - * Define PNG_BUILD_DLL if the module being built is a Windows - * LIBPNG DLL. - * - * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. - * It is equivalent to Microsoft predefined macro _DLL that is - * automatically defined when you compile using the share - * version of the CRT (C Run-Time library) - * - * The cygwin mods make this behavior a little different: - * Define PNG_BUILD_DLL if you are building a dll for use with cygwin - * Define PNG_STATIC if you are building a static library for use with cygwin, - * -or- if you are building an application that you want to link to the - * static library. - * PNG_USE_DLL is defined by default (no user action needed) unless one of - * the other flags is defined. - */ - -#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) -# define PNG_DLL -#endif -/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. - * When building a static lib, default to no GLOBAL ARRAYS, but allow - * command-line override - */ -#if defined(__CYGWIN__) -# if !defined(PNG_STATIC) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -# else -# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) -# if defined(PNG_USE_GLOBAL_ARRAYS) -# undef PNG_USE_GLOBAL_ARRAYS -# endif -# endif -# endif -# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# define PNG_USE_LOCAL_ARRAYS -# endif -#endif - -/* Do not use global arrays (helps with building DLL's) - * They are no longer used in libpng itself, since version 1.0.5c, - * but might be required for some pre-1.0.5c applications. - */ -#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) -# if defined(PNG_NO_GLOBAL_ARRAYS) || \ - (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER) -# define PNG_USE_LOCAL_ARRAYS -# else -# define PNG_USE_GLOBAL_ARRAYS -# endif -#endif - -#if defined(__CYGWIN__) -# undef PNGAPI -# define PNGAPI __cdecl -# undef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", - * you may get warnings regarding the linkage of png_zalloc and png_zfree. - * Don't ignore those warnings; you must also reset the default calling - * convention in your compiler to match your PNGAPI, and you must build - * zlib and your applications the same way you build libpng. - */ - -#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) -# ifndef PNG_NO_MODULEDEF -# define PNG_NO_MODULEDEF -# endif -#endif - -#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) -# define PNG_IMPEXP -#endif - -#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ - (( defined(_Windows) || defined(_WINDOWS) || \ - defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) - -# ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGAPI __cdecl -# else -# define PNGAPI _cdecl -# endif -# endif - -# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ - 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) -# define PNG_IMPEXP -# endif - -# if !defined(PNG_IMPEXP) - -# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol -# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol - - /* Borland/Microsoft */ -# if defined(_MSC_VER) || defined(__BORLANDC__) -# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) -# define PNG_EXPORT PNG_EXPORT_TYPE1 -# else -# define PNG_EXPORT PNG_EXPORT_TYPE2 -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __export -# else -# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in - VC++ */ -# endif /* Exists in Borland C++ for - C++ classes (== huge) */ -# endif -# endif - -# if !defined(PNG_IMPEXP) -# if defined(PNG_BUILD_DLL) -# define PNG_IMPEXP __declspec(dllexport) -# else -# define PNG_IMPEXP __declspec(dllimport) -# endif -# endif -# endif /* PNG_IMPEXP */ -#else /* !(DLL || non-cygwin WINDOWS) */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# ifndef PNGAPI -# define PNGAPI _System -# endif -# else -# if 0 /* ... other platforms, with other meanings */ -# endif -# endif -#endif - -#ifndef PNGAPI -# define PNGAPI -#endif -#ifndef PNG_IMPEXP -# define PNG_IMPEXP -#endif - -#ifdef PNG_BUILDSYMS -# ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END -# endif -# ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT -# endif -# endif -#endif - -#ifndef PNG_EXPORT -# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol -#endif - -#ifdef PNG_USE_GLOBAL_ARRAYS -# ifndef PNG_EXPORT_VAR -# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type -# endif -#endif - -/* User may want to use these so they are not in PNG_INTERNAL. Any library - * functions that are passed far data must be model independent. - */ - -#ifndef PNG_ABORT -# define PNG_ABORT() abort() -#endif - -#ifdef PNG_SETJMP_SUPPORTED -# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) -#endif - -#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ -/* use this to make far-to-near assignments */ -# define CHECK 1 -# define NOCHECK 0 -# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) -# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) -# define png_snprintf _fsnprintf /* Added to v 1.2.19 */ -# define png_strlen _fstrlen -# define png_memcmp _fmemcmp /* SJT: added */ -# define png_memcpy _fmemcpy -# define png_memset _fmemset -#else /* use the usual functions */ -# define CVT_PTR(ptr) (ptr) -# define CVT_PTR_NOCHECK(ptr) (ptr) -# ifndef PNG_NO_SNPRINTF -# ifdef _MSC_VER -# define png_snprintf _snprintf /* Added to v 1.2.19 */ -# define png_snprintf2 _snprintf -# define png_snprintf6 _snprintf -# else -# define png_snprintf snprintf /* Added to v 1.2.19 */ -# define png_snprintf2 snprintf -# define png_snprintf6 snprintf -# endif -# else - /* You don't have or don't want to use snprintf(). Caution: Using - * sprintf instead of snprintf exposes your application to accidental - * or malevolent buffer overflows. If you don't have snprintf() - * as a general rule you should provide one (you can get one from - * Portable OpenSSH). */ -# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1) -# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2) -# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ - sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) -# endif -# define png_strlen strlen -# define png_memcmp memcmp /* SJT: added */ -# define png_memcpy memcpy -# define png_memset memset -#endif -/* End of memory model independent support */ - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - -/* Added at libpng-1.2.8 */ -#endif /* PNG_VERSION_INFO_ONLY */ - -#endif /* PNGCONF_H */ diff --git a/extern/gnuwin32/include/tiff.h b/extern/gnuwin32/include/tiff.h deleted file mode 100644 index 6330795b..00000000 --- a/extern/gnuwin32/include/tiff.h +++ /dev/null @@ -1,647 +0,0 @@ -/* $Id: tiff.h,v 1.42 2005/12/23 15:10:45 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFF_ -#define _TIFF_ - -#include "tiffconf.h" - -/* - * Tag Image File Format (TIFF) - * - * Based on Rev 6.0 from: - * Developer's Desk - * Aldus Corporation - * 411 First Ave. South - * Suite 200 - * Seattle, WA 98104 - * 206-622-5500 - * - * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) - * - * For Big TIFF design notes see the following link - * http://gdal.maptools.org/twiki/bin/view/libtiff/BigTIFFDesign - */ -#define TIFF_VERSION 42 -#define TIFF_BIGTIFF_VERSION 43 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 -/* - * Intrinsic data types required by the file format: - * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * strings unsigned char* - */ - -#ifndef HAVE_INT8 -typedef signed char int8; /* NB: non-ANSI compilers may not grok */ -#endif -typedef unsigned char uint8; -#ifndef HAVE_INT16 -typedef short int16; -#endif -typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ -#if SIZEOF_INT == 4 -#ifndef HAVE_INT32 -typedef int int32; -#endif -typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ -#elif SIZEOF_LONG == 4 -#ifndef HAVE_INT32 -typedef long int32; -#endif -typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ -#endif - -/* For TIFFReassignTagToIgnore */ -enum TIFFIgnoreSense /* IGNORE tag table */ -{ - TIS_STORE, - TIS_EXTRACT, - TIS_EMPTY -}; - -/* - * TIFF header. - */ -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ -#define TIFF_MAGIC_SIZE 2 - uint16 tiff_version; /* TIFF version number */ -#define TIFF_VERSION_SIZE 2 - uint32 tiff_diroff; /* byte offset to first directory */ -#define TIFF_DIROFFSET_SIZE 4 -} TIFFHeader; - - -/* - * TIFF Image File Directories are comprised of a table of field - * descriptors of the form shown below. The table is sorted in - * ascending order by tag. The values associated with each entry are - * disjoint and may appear anywhere in the file (so long as they are - * placed on a word boundary). - * - * If the value is 4 bytes or less, then it is placed in the offset - * field to save space. If the value is less than 4 bytes, it is - * left-justified in the offset field. - */ -typedef struct { - uint16 tdir_tag; /* see below */ - uint16 tdir_type; /* data type; see below */ - uint32 tdir_count; /* number of items; length in spec */ - uint32 tdir_offset; /* byte offset to field data */ -} TIFFDirEntry; - -/* - * NB: In the comments below, - * - items marked with a + are obsoleted by revision 5.0, - * - items marked with a ! are introduced in revision 6.0. - * - items marked with a % are introduced post revision 6.0. - * - items marked with a $ are obsoleted by revision 6.0. - * - items marked with a & are introduced by Adobe DNG specification. - */ - -/* - * Tag data type information. - * - * Note: RATIONALs are the ratio of two 32-bit integer values. - */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */ -} TIFFDataType; - -/* - * TIFF Tag Definitions. - */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ -/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ -#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ -#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ -#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define PREDICTOR_NONE 1 /* no prediction scheme used */ -#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ -#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ -#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ -#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_CLIPPATH 343 /* %ClipPath - [Adobe TIFF technote 2] */ -#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_INDEXED 346 /* %Indexed - [Adobe TIFF Technote 3] */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ -/* - * Tags 512-521 are obsoleted by Technical Note #2 which specifies a - * revised JPEG-in-TIFF scheme. - */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_XMLPACKET 700 /* %XML packet - [Adobe XMP Specification, - January 2004 */ -#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID - [Adobe TIFF technote] */ -/* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ -/* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ -/* tags 33300-33309 are private tags registered to Pixar */ -/* - * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. - * They reflect the size of the original uncropped image. - * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used - * to determine the position of the smaller image in the larger one. - */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ - /* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ -#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 -#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 -/* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -/* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ -/* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ -/* Adobe Digital Negative (DNG) format tags */ -#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ -#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ -#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ -#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model - name */ -#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space - mapping */ -#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ -#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ -#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for - the BlackLevel tag */ -#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ -#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level - differences (columns) */ -#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level - differences (rows) */ -#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding - level */ -#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ -#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image - area */ -#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image - area */ -#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space - transformation matrix 1 */ -#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space - transformation matrix 2 */ -#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ -#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ -#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction - matrix 1 */ -#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction - matrix 2 */ -#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw - values*/ -#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in - linear reference space */ -#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in - x-y chromaticity - coordinates */ -#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero - point */ -#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ -#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of - sharpening */ -#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of - the green pixels in the - blue/green rows track the - values of the green pixels - in the red/green rows */ -#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ -#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ -#define TIFFTAG_LENSINFO 50736 /* info about the lens */ -#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ -#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the - camera's anti-alias filter */ -#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ -#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ -#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote - tag is safe to preserve - along with the rest of the - EXIF data */ -#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ -#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ -#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ -#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for - the raw image data */ -#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original - raw file */ -#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original - raw file */ -#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels - of the sensor */ -#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates - of fully masked pixels */ -#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ -#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space - into ICC profile space */ -#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ -#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ -/* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ - -/* - * The following are ``pseudo tags'' that can be used to control - * codec-specific functionality. These tags are not written to file. - * Note that these values start at 0xffff+1 so that they'll never - * collide with Aldus-assigned tags. - * - * If you want your private pseudo tags ``registered'' (i.e. added to - * this file), please post a bug report via the tracking system at - * http://www.remotesensing.org/libtiff/bugs.html with the appropriate - * C definitions to add. - */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ -/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ -/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ -/* 65550-65556 are allocated to Oceana Matrix */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ -/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ -/* 65559 is allocated to Oceana Matrix */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ -#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ -#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ - -/* - * EXIF tags - */ -#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ -#define EXIFTAG_FNUMBER 33437 /* F number */ -#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define EXIFTAG_OECF 34856 /* Optoelectric conversion - factor */ -#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ -#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original - data generation */ -#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital - data generation */ -#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ -#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ -#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ -#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ -#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ -#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ -#define EXIFTAG_FLASH 37385 /* Flash */ -#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ -#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ -#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ -#define EXIFTAG_USERCOMMENT 37510 /* User comments */ -#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ -#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ -#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ -#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ -#define EXIFTAG_COLORSPACE 40961 /* Color space information */ -#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ -#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ -#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ -#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ -#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ -#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ -#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ -#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ -#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ -#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ -#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ -#define EXIFTAG_FILESOURCE 41728 /* File source */ -#define EXIFTAG_SCENETYPE 41729 /* Scene type */ -#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ -#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ -#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ -#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ -#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ -#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ -#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_CONTRAST 41992 /* Contrast */ -#define EXIFTAG_SATURATION 41993 /* Saturation */ -#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ -#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ -#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ - -#endif /* _TIFF_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/extern/gnuwin32/include/tiffconf.h b/extern/gnuwin32/include/tiffconf.h deleted file mode 100644 index bf889386..00000000 --- a/extern/gnuwin32/include/tiffconf.h +++ /dev/null @@ -1,101 +0,0 @@ -/* libtiff/tiffconf.h. Generated by configure. */ -/* - Configuration defines for installed libtiff. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* Define to 1 if the system has the type `int16'. */ -/* #undef HAVE_INT16 */ - -/* Define to 1 if the system has the type `int32'. */ -/* #undef HAVE_INT32 */ - -/* Define to 1 if the system has the type `int8'. */ -/* #undef HAVE_INT8 */ - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#define HOST_BIGENDIAN 0 - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -#define JPEG_SUPPORT 1 - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ -/* #undef OJPEG_SUPPORT */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -#define PIXARLOG_SUPPORT 1 - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -#define ZIP_SUPPORT 1 - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* Support MS MDI magic number files as TIFF */ -#define MDI_SUPPORT 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ diff --git a/extern/gnuwin32/include/tiffio.h b/extern/gnuwin32/include/tiffio.h deleted file mode 100644 index 52654b59..00000000 --- a/extern/gnuwin32/include/tiffio.h +++ /dev/null @@ -1,549 +0,0 @@ -/* $Id: tiffio.h,v 1.50 2006/03/21 16:37:51 dron Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -#ifndef __GNUC__ -# define __DLL_IMPORT__ __declspec(dllimport) -# define __DLL_EXPORT__ __declspec(dllexport) -#else -# define __DLL_IMPORT__ __attribute__((dllimport)) extern -# define __DLL_EXPORT__ __attribute__((dllexport)) extern -#endif - -#if (defined __WIN32__) || (defined _WIN32) -# ifdef BUILD_LIBTIFF_DLL -# define LIBTIFF_DLL_IMPEXP __DLL_EXPORT__ -# elif defined(LIBTIFF_STATIC) -# define LIBTIFF_DLL_IMPEXP -# elif defined (USE_LIBTIFF_DLL) -# define LIBTIFF_DLL_IMPEXP __DLL_IMPORT__ -# elif defined (USE_LIBTIFF_STATIC) -# define LIBTIFF_DLL_IMPEXP -# else /* assume USE_LIBTIFF_DLL */ -# define LIBTIFF_DLL_IMPEXP __DLL_IMPORT__ -# endif -#else /* __WIN32__ */ -# define LIBTIFF_DLL_IMPEXP -#endif - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" -#include "tiffvers.h" - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets being the most important, and to ensure - * that it is unsigned, rather than signed. - */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrip_t; /* strip number */ -typedef uint32 ttile_t; /* tile number */ -typedef int32 tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ -typedef uint32 toff_t; /* file offset */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* - * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c - * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). - * - * By default tif_unix.c is assumed. - */ - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -# define BINMODE "b" -# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) -# define AVOID_WIN32_FILEIO -# endif -# include -# include -# ifdef SET_BINARY -# undef SET_BINARY -# endif /* SET_BINARY */ -# define SET_BINARY(f) do {if (!_isatty(f)) _setmode(f,_O_BINARY);} while (0) -#else /* Windows */ -# define BINMODE -# define SET_BINARY(f) (void)0 -#endif /* Windows */ - -#if defined(USE_WIN32_FILEIO) -# define VC_EXTRALEAN -# include -# ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -# else -typedef HFILE thandle_t; /* client data handle */ -# endif /* __WIN32__ */ -#else -typedef void* thandle_t; /* client data handle */ -#endif /* USE_WIN32_FILEIO */ - -#ifndef NULL -# define NULL (void *)0 -#endif - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * Colour conversion stuff - */ - -/* reference white */ -#define D65_X0 (95.0470F) -#define D65_Y0 (100.0F) -#define D65_Z0 (108.8827F) - -#define D50_X0 (96.4250F) -#define D50_Y0 (100.0F) -#define D50_Z0 (82.4680F) - -/* Structure for holding information about a display device. */ - -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ - -typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ - float d_Y0G; - float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; -} TIFFDisplay; - -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; -} TIFFYCbCrToRGB; - -typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ -#define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ -} TIFFCIELabToRGB; - -/* - * RGBA-style image support. - */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap pallete */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; /* put decoded strip/tile */ - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include -#include - -/* share internal LogLuv conversion routines? */ -#ifndef LOGLUV_PUBLIC -#define LOGLUV_PUBLIC 1 -#endif - -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); -typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); -typedef void (*TIFFExtendProc)(TIFF*); - -LIBTIFF_DLL_IMPEXP const char* TIFFGetVersion(void); - -LIBTIFF_DLL_IMPEXP const TIFFCodec* TIFFFindCODEC(uint16); -LIBTIFF_DLL_IMPEXP TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -LIBTIFF_DLL_IMPEXP void TIFFUnRegisterCODEC(TIFFCodec*); -LIBTIFF_DLL_IMPEXP int TIFFIsCODECConfigured(uint16); -LIBTIFF_DLL_IMPEXP TIFFCodec* TIFFGetConfiguredCODECs(void); - -/* - * Auxiliary functions. - */ - -LIBTIFF_DLL_IMPEXP tdata_t _TIFFmalloc(tsize_t); -LIBTIFF_DLL_IMPEXP tdata_t _TIFFrealloc(tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP void _TIFFmemset(tdata_t, int, tsize_t); -LIBTIFF_DLL_IMPEXP void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP void _TIFFfree(tdata_t); - -/* -** Stuff, related to tag handling and creating custom tags. -*/ -LIBTIFF_DLL_IMPEXP int TIFFGetTagListCount( TIFF * ); -LIBTIFF_DLL_IMPEXP ttag_t TIFFGetTagListEntry( TIFF *, int tag_index ); - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -#define FIELD_CUSTOM 65 - -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -typedef struct _TIFFTagValue { - const TIFFFieldInfo *info; - int count; - void *value; -} TIFFTagValue; - -LIBTIFF_DLL_IMPEXP void TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); -LIBTIFF_DLL_IMPEXP const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); -LIBTIFF_DLL_IMPEXP const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *, - TIFFDataType); -LIBTIFF_DLL_IMPEXP const TIFFFieldInfo* TIFFFieldWithTag(TIFF*, ttag_t); -LIBTIFF_DLL_IMPEXP const TIFFFieldInfo* TIFFFieldWithName(TIFF*, const char *); - -typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - -typedef struct { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ -} TIFFTagMethods; - -LIBTIFF_DLL_IMPEXP TIFFTagMethods *TIFFAccessTagMethods( TIFF * ); -LIBTIFF_DLL_IMPEXP void *TIFFGetClientInfo( TIFF *, const char * ); -LIBTIFF_DLL_IMPEXP void TIFFSetClientInfo( TIFF *, void *, const char * ); - -LIBTIFF_DLL_IMPEXP void TIFFCleanup(TIFF*); -LIBTIFF_DLL_IMPEXP void TIFFClose(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFFlush(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFFlushData(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFGetField(TIFF*, ttag_t, ...); -LIBTIFF_DLL_IMPEXP int TIFFVGetField(TIFF*, ttag_t, va_list); -LIBTIFF_DLL_IMPEXP int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); -LIBTIFF_DLL_IMPEXP int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); -LIBTIFF_DLL_IMPEXP int TIFFReadDirectory(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFReadCustomDirectory(TIFF*, toff_t, const TIFFFieldInfo[], - size_t); -LIBTIFF_DLL_IMPEXP int TIFFReadEXIFDirectory(TIFF*, toff_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFScanlineSize(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFRasterScanlineSize(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFStripSize(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFRawStripSize(TIFF*, tstrip_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFVStripSize(TIFF*, uint32); -LIBTIFF_DLL_IMPEXP tsize_t TIFFTileRowSize(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFTileSize(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFVTileSize(TIFF*, uint32); -LIBTIFF_DLL_IMPEXP uint32 TIFFDefaultStripSize(TIFF*, uint32); -LIBTIFF_DLL_IMPEXP void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -LIBTIFF_DLL_IMPEXP int TIFFFileno(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFSetFileno(TIFF*, int); -LIBTIFF_DLL_IMPEXP thandle_t TIFFClientdata(TIFF*); -LIBTIFF_DLL_IMPEXP thandle_t TIFFSetClientdata(TIFF*, thandle_t); -LIBTIFF_DLL_IMPEXP int TIFFGetMode(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFSetMode(TIFF*, int); -LIBTIFF_DLL_IMPEXP int TIFFIsTiled(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFIsByteSwapped(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFIsUpSampled(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFIsMSB2LSB(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFIsBigEndian(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFReadWriteProc TIFFGetReadProc(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFReadWriteProc TIFFGetWriteProc(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFSeekProc TIFFGetSeekProc(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFCloseProc TIFFGetCloseProc(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFSizeProc TIFFGetSizeProc(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFMapFileProc TIFFGetMapFileProc(TIFF*); -LIBTIFF_DLL_IMPEXP TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -LIBTIFF_DLL_IMPEXP uint32 TIFFCurrentRow(TIFF*); -LIBTIFF_DLL_IMPEXP tdir_t TIFFCurrentDirectory(TIFF*); -LIBTIFF_DLL_IMPEXP tdir_t TIFFNumberOfDirectories(TIFF*); -LIBTIFF_DLL_IMPEXP uint32 TIFFCurrentDirOffset(TIFF*); -LIBTIFF_DLL_IMPEXP tstrip_t TIFFCurrentStrip(TIFF*); -LIBTIFF_DLL_IMPEXP ttile_t TIFFCurrentTile(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP int TIFFSetupStrips(TIFF *); -LIBTIFF_DLL_IMPEXP int TIFFWriteCheck(TIFF*, int, const char *); -LIBTIFF_DLL_IMPEXP void TIFFFreeDirectory(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFCreateDirectory(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFLastDirectory(TIFF*); -LIBTIFF_DLL_IMPEXP int TIFFSetDirectory(TIFF*, tdir_t); -LIBTIFF_DLL_IMPEXP int TIFFSetSubDirectory(TIFF*, uint32); -LIBTIFF_DLL_IMPEXP int TIFFUnlinkDirectory(TIFF*, tdir_t); -LIBTIFF_DLL_IMPEXP int TIFFSetField(TIFF*, ttag_t, ...); -LIBTIFF_DLL_IMPEXP int TIFFVSetField(TIFF*, ttag_t, va_list); -LIBTIFF_DLL_IMPEXP int TIFFWriteDirectory(TIFF *); -LIBTIFF_DLL_IMPEXP int TIFFCheckpointDirectory(TIFF *); -LIBTIFF_DLL_IMPEXP int TIFFRewriteDirectory(TIFF *); -LIBTIFF_DLL_IMPEXP int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); - -#if defined(c_plusplus) || defined(__cplusplus) -LIBTIFF_DLL_IMPEXP void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -LIBTIFF_DLL_IMPEXP int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -LIBTIFF_DLL_IMPEXP int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -LIBTIFF_DLL_IMPEXP int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -LIBTIFF_DLL_IMPEXP int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); -#else -LIBTIFF_DLL_IMPEXP void TIFFPrintDirectory(TIFF*, FILE*, long); -LIBTIFF_DLL_IMPEXP int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -LIBTIFF_DLL_IMPEXP int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); -#endif - -LIBTIFF_DLL_IMPEXP int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); -LIBTIFF_DLL_IMPEXP int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -LIBTIFF_DLL_IMPEXP int TIFFRGBAImageOK(TIFF*, char [1024]); -LIBTIFF_DLL_IMPEXP int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -LIBTIFF_DLL_IMPEXP int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -LIBTIFF_DLL_IMPEXP void TIFFRGBAImageEnd(TIFFRGBAImage*); -LIBTIFF_DLL_IMPEXP TIFF* TIFFOpen(const char*, const char*); -# ifdef __WIN32__ -LIBTIFF_DLL_IMPEXP TIFF* TIFFOpenW(const wchar_t*, const char*); -# endif /* __WIN32__ */ -LIBTIFF_DLL_IMPEXP TIFF* TIFFFdOpen(int, const char*, const char*); -LIBTIFF_DLL_IMPEXP TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -LIBTIFF_DLL_IMPEXP const char* TIFFFileName(TIFF*); -LIBTIFF_DLL_IMPEXP const char* TIFFSetFileName(TIFF*, const char *); -LIBTIFF_DLL_IMPEXP void TIFFError(const char*, const char*, ...); -LIBTIFF_DLL_IMPEXP void TIFFErrorExt(thandle_t, const char*, const char*, ...); -LIBTIFF_DLL_IMPEXP void TIFFWarning(const char*, const char*, ...); -LIBTIFF_DLL_IMPEXP void TIFFWarningExt(thandle_t, const char*, const char*, ...); -LIBTIFF_DLL_IMPEXP TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -LIBTIFF_DLL_IMPEXP TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -LIBTIFF_DLL_IMPEXP TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -LIBTIFF_DLL_IMPEXP TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -LIBTIFF_DLL_IMPEXP TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -LIBTIFF_DLL_IMPEXP ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP ttile_t TIFFNumberOfTiles(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFReadTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFWriteTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); -LIBTIFF_DLL_IMPEXP tstrip_t TIFFNumberOfStrips(TIFF*); -LIBTIFF_DLL_IMPEXP tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -LIBTIFF_DLL_IMPEXP int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ -LIBTIFF_DLL_IMPEXP void TIFFSetWriteOffset(TIFF*, toff_t); -LIBTIFF_DLL_IMPEXP void TIFFSwabShort(uint16*); -LIBTIFF_DLL_IMPEXP void TIFFSwabLong(uint32*); -LIBTIFF_DLL_IMPEXP void TIFFSwabDouble(double*); -LIBTIFF_DLL_IMPEXP void TIFFSwabArrayOfShort(uint16*, unsigned long); -LIBTIFF_DLL_IMPEXP void TIFFSwabArrayOfTriples(uint8*, unsigned long); -LIBTIFF_DLL_IMPEXP void TIFFSwabArrayOfLong(uint32*, unsigned long); -LIBTIFF_DLL_IMPEXP void TIFFSwabArrayOfDouble(double*, unsigned long); -LIBTIFF_DLL_IMPEXP void TIFFReverseBits(unsigned char *, unsigned long); -LIBTIFF_DLL_IMPEXP const unsigned char* TIFFGetBitRevTable(int); - -#ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -LIBTIFF_DLL_IMPEXP double LogL16toY(int); -LIBTIFF_DLL_IMPEXP double LogL10toY(int); -LIBTIFF_DLL_IMPEXP void XYZtoRGB24(float*, uint8*); -LIBTIFF_DLL_IMPEXP int uv_decode(double*, double*, int); -LIBTIFF_DLL_IMPEXP void LogLuv24toXYZ(uint32, float*); -LIBTIFF_DLL_IMPEXP void LogLuv32toXYZ(uint32, float*); -#if defined(c_plusplus) || defined(__cplusplus) -LIBTIFF_DLL_IMPEXP int LogL16fromY(double, int = SGILOGENCODE_NODITHER); -LIBTIFF_DLL_IMPEXP int LogL10fromY(double, int = SGILOGENCODE_NODITHER); -LIBTIFF_DLL_IMPEXP int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -LIBTIFF_DLL_IMPEXP uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -LIBTIFF_DLL_IMPEXP uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); -#else -LIBTIFF_DLL_IMPEXP int LogL16fromY(double, int); -LIBTIFF_DLL_IMPEXP int LogL10fromY(double, int); -LIBTIFF_DLL_IMPEXP int uv_encode(double, double, int); -LIBTIFF_DLL_IMPEXP uint32 LogLuv24fromXYZ(float*, int); -LIBTIFF_DLL_IMPEXP uint32 LogLuv32fromXYZ(float*, int); -#endif -#endif /* LOGLUV_PUBLIC */ - -LIBTIFF_DLL_IMPEXP int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*); -LIBTIFF_DLL_IMPEXP void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); -LIBTIFF_DLL_IMPEXP void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); - -LIBTIFF_DLL_IMPEXP int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -LIBTIFF_DLL_IMPEXP void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); - -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - -#endif /* _TIFFIO_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/extern/gnuwin32/include/tiffvers.h b/extern/gnuwin32/include/tiffvers.h deleted file mode 100644 index 9744f8d3..00000000 --- a/extern/gnuwin32/include/tiffvers.h +++ /dev/null @@ -1,9 +0,0 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.8.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." -/* - * This define can be used in code that requires - * compilation-related definitions specific to a - * version or versions of the library. Runtime - * version checking should be done based on the - * string returned by TIFFGetVersion. - */ -#define TIFFLIB_VERSION 20060323 diff --git a/extern/gnuwin32/include/zconf.h b/extern/gnuwin32/include/zconf.h deleted file mode 100644 index e3b0c962..00000000 --- a/extern/gnuwin32/include/zconf.h +++ /dev/null @@ -1,332 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define deflateBound z_deflateBound -# define deflatePrime z_deflatePrime -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table -# define zError z_zError - -# define alloc_func z_alloc_func -# define free_func z_free_func -# define in_func z_in_func -# define out_func z_out_func -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/extern/gnuwin32/include/zlib.h b/extern/gnuwin32/include/zlib.h deleted file mode 100644 index 62d0e467..00000000 --- a/extern/gnuwin32/include/zlib.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 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 - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. 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 the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress 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. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - 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 the value returned by - compressBound(sourceLen). 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. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress 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, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/extern/gnuwin32/lib/jpeg.def b/extern/gnuwin32/lib/jpeg.def deleted file mode 100644 index 01d329fa..00000000 --- a/extern/gnuwin32/lib/jpeg.def +++ /dev/null @@ -1,103 +0,0 @@ -; h:\mingw\3.3.1\bin\dlltool.exe --output-def=jpeg.def jcapimin.o jcapistd.o jctrans.o jcparam.o jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o jcprepct.o jccoefct.o jccolor.o jcsample.o jchuff.o jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o jfdctint.o jdapimin.o jdapistd.o jdtrans.o jdatasrc.o jdmaster.o jdinput.o jdmarker.o jdhuff.o jdphuff.o jdmainct.o jdcoefct.o jdpostct.o jddctmgr.o jidctfst.o jidctflt.o jidctint.o jidctred.o jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o jcomapi.o jutils.o jerror.o jmemmgr.o jmemnobs.o jpeg-dllversion.o jpeg-dll-res.o -EXPORTS - jcopy_block_row @ 1 ; - jcopy_sample_rows @ 2 ; - jdiv_round_up @ 3 ; - jinit_1pass_quantizer @ 4 ; - jinit_2pass_quantizer @ 5 ; - jinit_c_coef_controller @ 6 ; - jinit_c_main_controller @ 7 ; - jinit_c_master_control @ 8 ; - jinit_c_prep_controller @ 9 ; - jinit_color_converter @ 10 ; - jinit_color_deconverter @ 11 ; - jinit_compress_master @ 12 ; - jinit_d_coef_controller @ 13 ; - jinit_d_main_controller @ 14 ; - jinit_d_post_controller @ 15 ; - jinit_downsampler @ 16 ; - jinit_forward_dct @ 17 ; - jinit_huff_decoder @ 18 ; - jinit_huff_encoder @ 19 ; - jinit_input_controller @ 20 ; - jinit_inverse_dct @ 21 ; - jinit_marker_reader @ 22 ; - jinit_marker_writer @ 23 ; - jinit_master_decompress @ 24 ; - jinit_memory_mgr @ 25 ; - jinit_merged_upsampler @ 26 ; - jinit_phuff_decoder @ 27 ; - jinit_phuff_encoder @ 28 ; - jinit_upsampler @ 29 ; - jpeg_CreateCompress @ 30 ; - jpeg_CreateDecompress @ 31 ; - jpeg_abort @ 32 ; - jpeg_abort_compress @ 33 ; - jpeg_abort_decompress @ 34 ; - jpeg_add_quant_table @ 35 ; - jpeg_alloc_huff_table @ 36 ; - jpeg_alloc_quant_table @ 37 ; - jpeg_calc_output_dimensions @ 38 ; - jpeg_consume_input @ 39 ; - jpeg_copy_critical_parameters @ 40 ; - jpeg_default_colorspace @ 41 ; - jpeg_destroy @ 42 ; - jpeg_destroy_compress @ 43 ; - jpeg_destroy_decompress @ 44 ; - jpeg_fdct_float @ 45 ; - jpeg_fdct_ifast @ 46 ; - jpeg_fdct_islow @ 47 ; - jpeg_fill_bit_buffer @ 48 ; - jpeg_finish_compress @ 49 ; - jpeg_finish_decompress @ 50 ; - jpeg_finish_output @ 51 ; - jpeg_free_large @ 52 ; - jpeg_free_small @ 53 ; - jpeg_gen_optimal_table @ 54 ; - jpeg_get_large @ 55 ; - jpeg_get_small @ 56 ; - jpeg_has_multiple_scans @ 57 ; - jpeg_huff_decode @ 58 ; - jpeg_idct_1x1 @ 59 ; - jpeg_idct_2x2 @ 60 ; - jpeg_idct_4x4 @ 61 ; - jpeg_idct_float @ 62 ; - jpeg_idct_ifast @ 63 ; - jpeg_idct_islow @ 64 ; - jpeg_input_complete @ 65 ; - jpeg_make_c_derived_tbl @ 66 ; - jpeg_make_d_derived_tbl @ 67 ; - jpeg_mem_available @ 68 ; - jpeg_mem_init @ 69 ; - jpeg_mem_term @ 70 ; - jpeg_new_colormap @ 71 ; - jpeg_open_backing_store @ 72 ; - jpeg_quality_scaling @ 73 ; - jpeg_read_coefficients @ 74 ; - jpeg_read_header @ 75 ; - jpeg_read_raw_data @ 76 ; - jpeg_read_scanlines @ 77 ; - jpeg_resync_to_restart @ 78 ; - jpeg_save_markers @ 79 ; - jpeg_set_colorspace @ 80 ; - jpeg_set_defaults @ 81 ; - jpeg_set_linear_quality @ 82 ; - jpeg_set_marker_processor @ 83 ; - jpeg_set_quality @ 84 ; - jpeg_simple_progression @ 85 ; - jpeg_start_compress @ 86 ; - jpeg_start_decompress @ 87 ; - jpeg_start_output @ 88 ; - jpeg_std_error @ 89 ; - jpeg_stdio_dest @ 90 ; - jpeg_stdio_src @ 91 ; - jpeg_suppress_tables @ 92 ; - jpeg_write_coefficients @ 93 ; - jpeg_write_m_byte @ 94 ; - jpeg_write_m_header @ 95 ; - jpeg_write_marker @ 96 ; - jpeg_write_raw_data @ 97 ; - jpeg_write_scanlines @ 98 ; - jpeg_write_tables @ 99 ; - jround_up @ 100 ; - jzero_far @ 101 ; diff --git a/extern/gnuwin32/lib/jpeg.lib b/extern/gnuwin32/lib/jpeg.lib deleted file mode 100644 index 8fc184aa..00000000 Binary files a/extern/gnuwin32/lib/jpeg.lib and /dev/null differ diff --git a/extern/gnuwin32/lib/libpng.def b/extern/gnuwin32/lib/libpng.def deleted file mode 100644 index 2eee2650..00000000 --- a/extern/gnuwin32/lib/libpng.def +++ /dev/null @@ -1,372 +0,0 @@ -; h:\mingw\3.3.1\bin\dlltool.exe --export-all-symbols --output-def=libpng.def png.dll.o pngset.dll.o pngget.dll.o pngrutil.dll.o pngtrans.dll.o pngwutil.dll.o pngread.dll.o pngrio.dll.o pngwio.dll.o pngwrite.dll.o pngrtran.dll.o pngwtran.dll.o pngmem.dll.o pngerror.dll.o pngpread.dll.o pnggccrd.dll.o libpng-dllversion.dll.o libpng-dll-res.o -EXPORTS - ActiveMask @ 1 DATA ; - ActiveMask2 @ 2 DATA ; - ActiveMaskEnd @ 3 DATA ; - DllGetVersion @ 4 ; - HBClearMask @ 5 DATA ; - LBCarryMask @ 6 DATA ; - ShiftBpp @ 7 DATA ; - ShiftRem @ 8 DATA ; - png_IDAT @ 9 DATA ; - png_IEND @ 10 DATA ; - png_IHDR @ 11 DATA ; - png_PLTE @ 12 DATA ; - png_access_version_number @ 13 ; - png_bKGD @ 14 DATA ; - png_build_gamma_table @ 15 ; - png_build_grayscale_palette @ 16 ; - png_cHRM @ 17 DATA ; - png_calculate_crc @ 18 ; - png_check_chunk_name @ 19 ; - png_check_keyword @ 20 ; - png_check_sig @ 21 ; - png_chunk_error @ 22 ; - png_chunk_warning @ 23 ; - png_combine_row @ 24 ; - png_convert_from_struct_tm @ 25 ; - png_convert_from_time_t @ 26 ; - png_convert_to_rfc1123 @ 27 ; - png_crc_error @ 28 ; - png_crc_finish @ 29 ; - png_crc_read @ 30 ; - png_create_info_struct @ 31 ; - png_create_read_struct @ 32 ; - png_create_read_struct_2 @ 33 ; - png_create_struct @ 34 ; - png_create_struct_2 @ 35 ; - png_create_write_struct @ 36 ; - png_create_write_struct_2 @ 37 ; - png_data_freer @ 38 ; - png_decompress_chunk @ 39 ; - png_default_flush @ 40 ; - png_default_read_data @ 41 ; - png_default_write_data @ 42 ; - png_destroy_info_struct @ 43 ; - png_destroy_read_struct @ 44 ; - png_destroy_struct @ 45 ; - png_destroy_struct_2 @ 46 ; - png_destroy_write_struct @ 47 ; - png_do_background @ 48 ; - png_do_bgr @ 49 ; - png_do_chop @ 50 ; - png_do_dither @ 51 ; - png_do_expand @ 52 ; - png_do_expand_palette @ 53 ; - png_do_gamma @ 54 ; - png_do_gray_to_rgb @ 55 ; - png_do_invert @ 56 ; - png_do_pack @ 57 ; - png_do_packswap @ 58 ; - png_do_read_filler @ 59 ; - png_do_read_interlace @ 60 ; - png_do_read_intrapixel @ 61 ; - png_do_read_invert_alpha @ 62 ; - png_do_read_swap_alpha @ 63 ; - png_do_read_transformations @ 64 ; - png_do_rgb_to_gray @ 65 ; - png_do_shift @ 66 ; - png_do_strip_filler @ 67 ; - png_do_swap @ 68 ; - png_do_unpack @ 69 ; - png_do_unshift @ 70 ; - png_do_write_interlace @ 71 ; - png_do_write_intrapixel @ 72 ; - png_do_write_invert_alpha @ 73 ; - png_do_write_swap_alpha @ 74 ; - png_do_write_transformations @ 75 ; - png_error @ 76 ; - png_flush @ 77 ; - png_free @ 78 ; - png_free_data @ 79 ; - png_free_default @ 80 ; - png_gAMA @ 81 DATA ; - png_get_IHDR @ 82 ; - png_get_PLTE @ 83 ; - png_get_asm_flagmask @ 84 ; - png_get_asm_flags @ 85 ; - png_get_bKGD @ 86 ; - png_get_bit_depth @ 87 ; - png_get_cHRM @ 88 ; - png_get_cHRM_fixed @ 89 ; - png_get_channels @ 90 ; - png_get_color_type @ 91 ; - png_get_compression_buffer_size @ 92 ; - png_get_compression_type @ 93 ; - png_get_copyright @ 94 ; - png_get_error_ptr @ 95 ; - png_get_filter_type @ 96 ; - png_get_gAMA @ 97 ; - png_get_gAMA_fixed @ 98 ; - png_get_hIST @ 99 ; - png_get_header_ver @ 100 ; - png_get_header_version @ 101 ; - png_get_iCCP @ 102 ; - png_get_image_height @ 103 ; - png_get_image_width @ 104 ; - png_get_int_32 @ 105 ; - png_get_interlace_type @ 106 ; - png_get_io_ptr @ 107 ; - png_get_libpng_ver @ 108 ; - png_get_mem_ptr @ 109 ; - png_get_mmx_bitdepth_threshold @ 110 ; - png_get_mmx_flagmask @ 111 ; - png_get_mmx_rowbytes_threshold @ 112 ; - png_get_oFFs @ 113 ; - png_get_pCAL @ 114 ; - png_get_pHYs @ 115 ; - png_get_pixel_aspect_ratio @ 116 ; - png_get_pixels_per_meter @ 117 ; - png_get_progressive_ptr @ 118 ; - png_get_rgb_to_gray_status @ 119 ; - png_get_rowbytes @ 120 ; - png_get_rows @ 121 ; - png_get_sBIT @ 122 ; - png_get_sCAL @ 123 ; - png_get_sPLT @ 124 ; - png_get_sRGB @ 125 ; - png_get_signature @ 126 ; - png_get_tIME @ 127 ; - png_get_tRNS @ 128 ; - png_get_text @ 129 ; - png_get_uint_16 @ 130 ; - png_get_uint_31 @ 131 ; - png_get_uint_32 @ 132 ; - png_get_unknown_chunks @ 133 ; - png_get_user_chunk_ptr @ 134 ; - png_get_user_height_max @ 135 ; - png_get_user_transform_ptr @ 136 ; - png_get_user_width_max @ 137 ; - png_get_valid @ 138 ; - png_get_x_offset_microns @ 139 ; - png_get_x_offset_pixels @ 140 ; - png_get_x_pixels_per_meter @ 141 ; - png_get_y_offset_microns @ 142 ; - png_get_y_offset_pixels @ 143 ; - png_get_y_pixels_per_meter @ 144 ; - png_hIST @ 145 DATA ; - png_handle_IEND @ 146 ; - png_handle_IHDR @ 147 ; - png_handle_PLTE @ 148 ; - png_handle_as_unknown @ 149 ; - png_handle_bKGD @ 150 ; - png_handle_cHRM @ 151 ; - png_handle_gAMA @ 152 ; - png_handle_hIST @ 153 ; - png_handle_iCCP @ 154 ; - png_handle_oFFs @ 155 ; - png_handle_pCAL @ 156 ; - png_handle_pHYs @ 157 ; - png_handle_sBIT @ 158 ; - png_handle_sCAL @ 159 ; - png_handle_sPLT @ 160 ; - png_handle_sRGB @ 161 ; - png_handle_tEXt @ 162 ; - png_handle_tIME @ 163 ; - png_handle_tRNS @ 164 ; - png_handle_unknown @ 165 ; - png_handle_zTXt @ 166 ; - png_iCCP @ 167 DATA ; - png_iTXt @ 168 DATA ; - png_info_destroy @ 169 ; - png_info_init @ 170 ; - png_info_init_3 @ 171 ; - png_init_io @ 172 ; - png_init_mmx_flags @ 173 ; - png_init_read_transformations @ 174 ; - png_libpng_ver @ 175 DATA ; - png_malloc @ 176 ; - png_malloc_default @ 177 ; - png_malloc_warn @ 178 ; - png_memcpy_check @ 179 ; - png_memset_check @ 180 ; - png_mmx_support @ 181 ; - png_oFFs @ 182 DATA ; - png_pCAL @ 183 DATA ; - png_pHYs @ 184 DATA ; - png_pass_dsp_mask @ 185 DATA ; - png_pass_inc @ 186 DATA ; - png_pass_mask @ 187 DATA ; - png_pass_start @ 188 DATA ; - png_pass_width @ 189 DATA ; - png_pass_yinc @ 190 DATA ; - png_pass_ystart @ 191 DATA ; - png_permit_empty_plte @ 192 ; - png_permit_mng_features @ 193 ; - png_process_IDAT_data @ 194 ; - png_process_data @ 195 ; - png_process_some_data @ 196 ; - png_progressive_combine_row @ 197 ; - png_push_crc_finish @ 198 ; - png_push_crc_skip @ 199 ; - png_push_fill_buffer @ 200 ; - png_push_handle_tEXt @ 201 ; - png_push_handle_unknown @ 202 ; - png_push_handle_zTXt @ 203 ; - png_push_have_end @ 204 ; - png_push_have_info @ 205 ; - png_push_have_row @ 206 ; - png_push_process_row @ 207 ; - png_push_read_IDAT @ 208 ; - png_push_read_chunk @ 209 ; - png_push_read_sig @ 210 ; - png_push_read_tEXt @ 211 ; - png_push_read_zTXt @ 212 ; - png_push_restore_buffer @ 213 ; - png_push_save_buffer @ 214 ; - png_read_data @ 215 ; - png_read_destroy @ 216 ; - png_read_end @ 217 ; - png_read_filter_row @ 218 ; - png_read_finish_row @ 219 ; - png_read_image @ 220 ; - png_read_info @ 221 ; - png_read_init @ 222 ; - png_read_init_2 @ 223 ; - png_read_init_3 @ 224 ; - png_read_png @ 225 ; - png_read_push_finish_row @ 226 ; - png_read_row @ 227 ; - png_read_rows @ 228 ; - png_read_start_row @ 229 ; - png_read_transform_info @ 230 ; - png_read_update_info @ 231 ; - png_reset_crc @ 232 ; - png_reset_zstream @ 233 ; - png_sBIT @ 234 DATA ; - png_sCAL @ 235 DATA ; - png_sPLT @ 236 DATA ; - png_sRGB @ 237 DATA ; - png_save_int_32 @ 238 ; - png_save_uint_16 @ 239 ; - png_save_uint_32 @ 240 ; - png_set_IHDR @ 241 ; - png_set_PLTE @ 242 ; - png_set_add_alpha @ 243 ; - png_set_asm_flags @ 244 ; - png_set_bKGD @ 245 ; - png_set_background @ 246 ; - png_set_bgr @ 247 ; - png_set_cHRM @ 248 ; - png_set_cHRM_fixed @ 249 ; - png_set_compression_buffer_size @ 250 ; - png_set_compression_level @ 251 ; - png_set_compression_mem_level @ 252 ; - png_set_compression_method @ 253 ; - png_set_compression_strategy @ 254 ; - png_set_compression_window_bits @ 255 ; - png_set_crc_action @ 256 ; - png_set_dither @ 257 ; - png_set_error_fn @ 258 ; - png_set_expand @ 259 ; - png_set_filler @ 260 ; - png_set_filter @ 261 ; - png_set_filter_heuristics @ 262 ; - png_set_flush @ 263 ; - png_set_gAMA @ 264 ; - png_set_gAMA_fixed @ 265 ; - png_set_gamma @ 266 ; - png_set_gray_1_2_4_to_8 @ 267 ; - png_set_gray_to_rgb @ 268 ; - png_set_hIST @ 269 ; - png_set_iCCP @ 270 ; - png_set_interlace_handling @ 271 ; - png_set_invalid @ 272 ; - png_set_invert_alpha @ 273 ; - png_set_invert_mono @ 274 ; - png_set_keep_unknown_chunks @ 275 ; - png_set_mem_fn @ 276 ; - png_set_mmx_thresholds @ 277 ; - png_set_oFFs @ 278 ; - png_set_pCAL @ 279 ; - png_set_pHYs @ 280 ; - png_set_packing @ 281 ; - png_set_packswap @ 282 ; - png_set_palette_to_rgb @ 283 ; - png_set_progressive_read_fn @ 284 ; - png_set_read_fn @ 285 ; - png_set_read_status_fn @ 286 ; - png_set_read_user_chunk_fn @ 287 ; - png_set_read_user_transform_fn @ 288 ; - png_set_rgb_to_gray @ 289 ; - png_set_rgb_to_gray_fixed @ 290 ; - png_set_rows @ 291 ; - png_set_sBIT @ 292 ; - png_set_sCAL @ 293 ; - png_set_sPLT @ 294 ; - png_set_sRGB @ 295 ; - png_set_sRGB_gAMA_and_cHRM @ 296 ; - png_set_shift @ 297 ; - png_set_sig_bytes @ 298 ; - png_set_strip_16 @ 299 ; - png_set_strip_alpha @ 300 ; - png_set_strip_error_numbers @ 301 ; - png_set_swap @ 302 ; - png_set_swap_alpha @ 303 ; - png_set_tIME @ 304 ; - png_set_tRNS @ 305 ; - png_set_tRNS_to_alpha @ 306 ; - png_set_text @ 307 ; - png_set_text_2 @ 308 ; - png_set_unknown_chunk_location @ 309 ; - png_set_unknown_chunks @ 310 ; - png_set_user_limits @ 311 ; - png_set_user_transform_info @ 312 ; - png_set_write_fn @ 313 ; - png_set_write_status_fn @ 314 ; - png_set_write_user_transform_fn @ 315 ; - png_sig @ 316 DATA ; - png_sig_cmp @ 317 ; - png_squelch_warnings @ 318 ; - png_start_read_image @ 319 ; - png_tEXt @ 320 DATA ; - png_tIME @ 321 DATA ; - png_tRNS @ 322 DATA ; - png_warning @ 323 ; - png_write_IDAT @ 324 ; - png_write_IEND @ 325 ; - png_write_IHDR @ 326 ; - png_write_PLTE @ 327 ; - png_write_bKGD @ 328 ; - png_write_cHRM @ 329 ; - png_write_cHRM_fixed @ 330 ; - png_write_chunk @ 331 ; - png_write_chunk_data @ 332 ; - png_write_chunk_end @ 333 ; - png_write_chunk_start @ 334 ; - png_write_data @ 335 ; - png_write_destroy @ 336 ; - png_write_end @ 337 ; - png_write_filtered_row @ 338 ; - png_write_find_filter @ 339 ; - png_write_finish_row @ 340 ; - png_write_flush @ 341 ; - png_write_gAMA @ 342 ; - png_write_gAMA_fixed @ 343 ; - png_write_hIST @ 344 ; - png_write_iCCP @ 345 ; - png_write_image @ 346 ; - png_write_info @ 347 ; - png_write_info_before_PLTE @ 348 ; - png_write_init @ 349 ; - png_write_init_2 @ 350 ; - png_write_init_3 @ 351 ; - png_write_oFFs @ 352 ; - png_write_pCAL @ 353 ; - png_write_pHYs @ 354 ; - png_write_png @ 355 ; - png_write_row @ 356 ; - png_write_rows @ 357 ; - png_write_sBIT @ 358 ; - png_write_sCAL @ 359 ; - png_write_sPLT @ 360 ; - png_write_sRGB @ 361 ; - png_write_sig @ 362 ; - png_write_start_row @ 363 ; - png_write_tEXt @ 364 ; - png_write_tIME @ 365 ; - png_write_tRNS @ 366 ; - png_write_zTXt @ 367 ; - png_zTXt @ 368 DATA ; - png_zalloc @ 369 ; - png_zfree @ 370 ; diff --git a/extern/gnuwin32/lib/libpng.lib b/extern/gnuwin32/lib/libpng.lib deleted file mode 100644 index 072162f3..00000000 Binary files a/extern/gnuwin32/lib/libpng.lib and /dev/null differ diff --git a/extern/gnuwin32/lib/libpng12.def b/extern/gnuwin32/lib/libpng12.def deleted file mode 100644 index 8045a8f8..00000000 --- a/extern/gnuwin32/lib/libpng12.def +++ /dev/null @@ -1,239 +0,0 @@ -LIBRARY libpng12.dll -EXPORTS -DllGetVersion -png_IDAT DATA -png_IEND DATA -png_IHDR DATA -png_PLTE DATA -png_access_version_number -png_bKGD DATA -png_build_grayscale_palette -png_cHRM DATA -png_check_sig -png_chunk_error -png_chunk_warning -png_convert_from_struct_tm -png_convert_from_time_t -png_convert_to_rfc1123 -png_create_info_struct -png_create_read_struct -png_create_read_struct_2 -png_create_write_struct -png_create_write_struct_2 -png_data_freer -png_destroy_info_struct -png_destroy_read_struct -png_destroy_write_struct -png_error -png_free -png_free_data -png_free_default -png_gAMA DATA -png_get_IHDR -png_get_PLTE -png_get_asm_flagmask -png_get_asm_flags -png_get_bKGD -png_get_bit_depth -png_get_cHRM -png_get_cHRM_fixed -png_get_channels -png_get_color_type -png_get_compression_buffer_size -png_get_compression_type -png_get_copyright -png_get_error_ptr -png_get_filter_type -png_get_gAMA -png_get_gAMA_fixed -png_get_hIST -png_get_header_ver -png_get_header_version -png_get_iCCP -png_get_image_height -png_get_image_width -png_get_int_32 -png_get_interlace_type -png_get_io_ptr -png_get_libpng_ver -png_get_mem_ptr -png_get_mmx_bitdepth_threshold -png_get_mmx_flagmask -png_get_mmx_rowbytes_threshold -png_get_oFFs -png_get_pCAL -png_get_pHYs -png_get_pixel_aspect_ratio -png_get_pixels_per_meter -png_get_progressive_ptr -png_get_rgb_to_gray_status -png_get_rowbytes -png_get_rows -png_get_sBIT -png_get_sCAL -png_get_sPLT -png_get_sRGB -png_get_signature -png_get_tIME -png_get_tRNS -png_get_text -png_get_uint_16 -png_get_uint_31 -png_get_uint_32 -png_get_unknown_chunks -png_get_user_chunk_ptr -png_get_user_height_max -png_get_user_transform_ptr -png_get_user_width_max -png_get_valid -png_get_x_offset_microns -png_get_x_offset_pixels -png_get_x_pixels_per_meter -png_get_y_offset_microns -png_get_y_offset_pixels -png_get_y_pixels_per_meter -png_hIST DATA -png_handle_as_unknown -png_iCCP DATA -png_iTXt DATA -png_info_init -png_info_init_3 -png_init_io -png_libpng_ver DATA -png_malloc -png_malloc_default -png_malloc_warn -png_memcpy_check -png_memset_check -png_mmx_support -png_oFFs DATA -png_pCAL DATA -png_pHYs DATA -png_pass_dsp_mask DATA -png_pass_inc DATA -png_pass_mask DATA -png_pass_start DATA -png_pass_yinc DATA -png_pass_ystart DATA -png_permit_empty_plte -png_permit_mng_features -png_process_data -png_progressive_combine_row -png_read_destroy -png_read_end -png_read_image -png_read_info -png_read_init -png_read_init_2 -png_read_init_3 -png_read_png -png_read_row -png_read_rows -png_read_update_info -png_reset_zstream -png_sBIT DATA -png_sCAL DATA -png_sPLT DATA -png_sRGB DATA -png_save_int_32 -png_save_uint_16 -png_save_uint_32 -png_set_IHDR -png_set_PLTE -png_set_add_alpha -png_set_asm_flags -png_set_bKGD -png_set_background -png_set_bgr -png_set_cHRM -png_set_cHRM_fixed -png_set_compression_buffer_size -png_set_compression_level -png_set_compression_mem_level -png_set_compression_method -png_set_compression_strategy -png_set_compression_window_bits -png_set_crc_action -png_set_dither -png_set_error_fn -png_set_expand -png_set_expand_gray_1_2_4_to_8 -png_set_filler -png_set_filter -png_set_filter_heuristics -png_set_flush -png_set_gAMA -png_set_gAMA_fixed -png_set_gamma -png_set_gray_1_2_4_to_8 -png_set_gray_to_rgb -png_set_hIST -png_set_iCCP -png_set_interlace_handling -png_set_invalid -png_set_invert_alpha -png_set_invert_mono -png_set_keep_unknown_chunks -png_set_mem_fn -png_set_mmx_thresholds -png_set_oFFs -png_set_pCAL -png_set_pHYs -png_set_packing -png_set_packswap -png_set_palette_to_rgb -png_set_progressive_read_fn -png_set_read_fn -png_set_read_status_fn -png_set_read_user_chunk_fn -png_set_read_user_transform_fn -png_set_rgb_to_gray -png_set_rgb_to_gray_fixed -png_set_rows -png_set_sBIT -png_set_sCAL -png_set_sPLT -png_set_sRGB -png_set_sRGB_gAMA_and_cHRM -png_set_shift -png_set_sig_bytes -png_set_strip_16 -png_set_strip_alpha -png_set_strip_error_numbers -png_set_swap -png_set_swap_alpha -png_set_tIME -png_set_tRNS -png_set_tRNS_to_alpha -png_set_text -png_set_unknown_chunk_location -png_set_unknown_chunks -png_set_user_limits -png_set_user_transform_info -png_set_write_fn -png_set_write_status_fn -png_set_write_user_transform_fn -png_sig DATA -png_sig_cmp -png_start_read_image -png_tEXt DATA -png_tIME DATA -png_tRNS DATA -png_warning -png_write_chunk -png_write_chunk_data -png_write_chunk_end -png_write_chunk_start -png_write_destroy -png_write_end -png_write_flush -png_write_image -png_write_info -png_write_info_before_PLTE -png_write_init -png_write_init_2 -png_write_init_3 -png_write_png -png_write_row -png_write_rows -png_zTXt DATA diff --git a/extern/gnuwin32/lib/libtiff.def b/extern/gnuwin32/lib/libtiff.def deleted file mode 100644 index d430edd8..00000000 --- a/extern/gnuwin32/lib/libtiff.def +++ /dev/null @@ -1,154 +0,0 @@ -; g:\mingw\3.3.1\bin\dlltool.exe --output-def=libtiff.def tif_aux.o tif_close.o tif_codec.o tif_color.o tif_compress.o tif_dir.o tif_dirinfo.o tif_dirread.o tif_dirwrite.o tif_dumpmode.o tif_error.o tif_extension.o tif_fax3.o tif_fax3sm.o tif_flush.o tif_getimage.o tif_jpeg.o tif_luv.o tif_lzw.o tif_next.o tif_ojpeg.o tif_open.o tif_packbits.o tif_pixarlog.o tif_predict.o tif_print.o tif_read.o tif_strip.o tif_swab.o tif_thunder.o tif_tile.o tif_unix.o tif_version.o tif_warning.o tif_write.o tif_zip.o libtiff-dllversion.o libtiff-dll-res.o -EXPORTS - DllGetVersion @ 1 ; - LogL10fromY @ 2 ; - LogL10toY @ 3 ; - LogL16fromY @ 4 ; - LogL16toY @ 5 ; - LogLuv24fromXYZ @ 6 ; - LogLuv24toXYZ @ 7 ; - LogLuv32fromXYZ @ 8 ; - LogLuv32toXYZ @ 9 ; - TIFFAccessTagMethods @ 10 ; - TIFFCIELabToRGBInit @ 11 ; - TIFFCIELabToXYZ @ 12 ; - TIFFCheckTile @ 13 ; - TIFFCheckpointDirectory @ 14 ; - TIFFCleanup @ 15 ; - TIFFClientOpen @ 16 ; - TIFFClientdata @ 17 ; - TIFFClose @ 18 ; - TIFFComputeStrip @ 19 ; - TIFFComputeTile @ 20 ; - TIFFCreateDirectory @ 21 ; - TIFFCurrentDirOffset @ 22 ; - TIFFCurrentDirectory @ 23 ; - TIFFCurrentRow @ 24 ; - TIFFCurrentStrip @ 25 ; - TIFFCurrentTile @ 26 ; - TIFFDataWidth @ 27 ; - TIFFDefaultStripSize @ 28 ; - TIFFDefaultTileSize @ 29 ; - TIFFError @ 30 ; - TIFFErrorExt @ 31 ; - TIFFFdOpen @ 32 ; - TIFFFieldWithName @ 33 ; - TIFFFieldWithTag @ 34 ; - TIFFFileName @ 35 ; - TIFFFileno @ 36 ; - TIFFFindCODEC @ 37 ; - TIFFFindFieldInfo @ 38 ; - TIFFFindFieldInfoByName @ 39 ; - TIFFFlush @ 40 ; - TIFFFlushData @ 41 ; - TIFFFreeDirectory @ 42 ; - TIFFGetBitRevTable @ 43 ; - TIFFGetClientInfo @ 44 ; - TIFFGetCloseProc @ 45 ; - TIFFGetConfiguredCODECs @ 46 ; - TIFFGetField @ 47 ; - TIFFGetFieldDefaulted @ 48 ; - TIFFGetMapFileProc @ 49 ; - TIFFGetMode @ 50 ; - TIFFGetReadProc @ 51 ; - TIFFGetSeekProc @ 52 ; - TIFFGetSizeProc @ 53 ; - TIFFGetTagListCount @ 54 ; - TIFFGetTagListEntry @ 55 ; - TIFFGetUnmapFileProc @ 56 ; - TIFFGetVersion @ 57 ; - TIFFGetWriteProc @ 58 ; - TIFFIsBigEndian @ 59 ; - TIFFIsByteSwapped @ 60 ; - TIFFIsCODECConfigured @ 61 ; - TIFFIsMSB2LSB @ 62 ; - TIFFIsTiled @ 63 ; - TIFFIsUpSampled @ 64 ; - TIFFLastDirectory @ 65 ; - TIFFMergeFieldInfo @ 66 ; - TIFFNumberOfDirectories @ 67 ; - TIFFNumberOfStrips @ 68 ; - TIFFNumberOfTiles @ 69 ; - TIFFOpen @ 70 ; - TIFFOpenW @ 71 ; - TIFFPrintDirectory @ 72 ; - TIFFRGBAImageBegin @ 73 ; - TIFFRGBAImageEnd @ 74 ; - TIFFRGBAImageGet @ 75 ; - TIFFRGBAImageOK @ 76 ; - TIFFRasterScanlineSize @ 77 ; - TIFFRawStripSize @ 78 ; - TIFFReadBufferSetup @ 79 ; - TIFFReadCustomDirectory @ 80 ; - TIFFReadDirectory @ 81 ; - TIFFReadEXIFDirectory @ 82 ; - TIFFReadEncodedStrip @ 83 ; - TIFFReadEncodedTile @ 84 ; - TIFFReadRGBAImage @ 85 ; - TIFFReadRGBAImageOriented @ 86 ; - TIFFReadRGBAStrip @ 87 ; - TIFFReadRGBATile @ 88 ; - TIFFReadRawStrip @ 89 ; - TIFFReadRawTile @ 90 ; - TIFFReadScanline @ 91 ; - TIFFReadTile @ 92 ; - TIFFReassignTagToIgnore @ 93 ; - TIFFRegisterCODEC @ 94 ; - TIFFReverseBits @ 95 ; - TIFFRewriteDirectory @ 96 ; - TIFFScanlineSize @ 97 ; - TIFFSetClientInfo @ 98 ; - TIFFSetClientdata @ 99 ; - TIFFSetDirectory @ 100 ; - TIFFSetErrorHandler @ 101 ; - TIFFSetErrorHandlerExt @ 102 ; - TIFFSetField @ 103 ; - TIFFSetFileName @ 104 ; - TIFFSetFileno @ 105 ; - TIFFSetMode @ 106 ; - TIFFSetSubDirectory @ 107 ; - TIFFSetTagExtender @ 108 ; - TIFFSetWarningHandler @ 109 ; - TIFFSetWarningHandlerExt @ 110 ; - TIFFSetWriteOffset @ 111 ; - TIFFSetupStrips @ 112 ; - TIFFStripSize @ 113 ; - TIFFSwabArrayOfDouble @ 114 ; - TIFFSwabArrayOfLong @ 115 ; - TIFFSwabArrayOfShort @ 116 ; - TIFFSwabArrayOfTriples @ 117 ; - TIFFSwabDouble @ 118 ; - TIFFSwabLong @ 119 ; - TIFFSwabShort @ 120 ; - TIFFTileRowSize @ 121 ; - TIFFTileSize @ 122 ; - TIFFUnRegisterCODEC @ 123 ; - TIFFUnlinkDirectory @ 124 ; - TIFFVGetField @ 125 ; - TIFFVGetFieldDefaulted @ 126 ; - TIFFVSetField @ 127 ; - TIFFVStripSize @ 128 ; - TIFFVTileSize @ 129 ; - TIFFWarning @ 130 ; - TIFFWarningExt @ 131 ; - TIFFWriteBufferSetup @ 132 ; - TIFFWriteCheck @ 133 ; - TIFFWriteDirectory @ 134 ; - TIFFWriteEncodedStrip @ 135 ; - TIFFWriteEncodedTile @ 136 ; - TIFFWriteRawStrip @ 137 ; - TIFFWriteRawTile @ 138 ; - TIFFWriteScanline @ 139 ; - TIFFWriteTile @ 140 ; - TIFFXYZToRGB @ 141 ; - TIFFYCbCrToRGBInit @ 142 ; - TIFFYCbCrtoRGB @ 143 ; - XYZtoRGB24 @ 144 ; - _TIFFfree @ 145 ; - _TIFFmalloc @ 146 ; - _TIFFmemcmp @ 147 ; - _TIFFmemcpy @ 148 ; - _TIFFmemset @ 149 ; - _TIFFrealloc @ 150 ; - uv_decode @ 151 ; - uv_encode @ 152 ; diff --git a/extern/gnuwin32/lib/tiff.lib b/extern/gnuwin32/lib/tiff.lib deleted file mode 100644 index 77519673..00000000 Binary files a/extern/gnuwin32/lib/tiff.lib and /dev/null differ diff --git a/extern/gnuwin32/lib/zlib.def b/extern/gnuwin32/lib/zlib.def deleted file mode 100644 index af59b0e6..00000000 --- a/extern/gnuwin32/lib/zlib.def +++ /dev/null @@ -1,75 +0,0 @@ -; h:\mingw\3.3.1\bin\dlltool.exe --export-all-symbols --output-def=zlib.def adler32.pic.o compress.pic.o crc32.pic.o gzio.pic.o uncompr.pic.o deflate.pic.o trees.pic.o zutil.pic.o inflate.pic.o infback.pic.o inftrees.pic.o inffast.pic.o zlib-dllversion.o zlib-dll-res.o -EXPORTS - DllGetVersion @ 1 ; - _dist_code @ 2 DATA ; - _length_code @ 3 DATA ; - _tr_align @ 4 ; - _tr_flush_block @ 5 ; - _tr_init @ 6 ; - _tr_stored_block @ 7 ; - _tr_tally @ 8 ; - adler32 @ 9 ; - adler32_combine @ 10 ; - compress @ 11 ; - compress2 @ 12 ; - compressBound @ 13 ; - crc32 @ 14 ; - crc32_combine @ 15 ; - deflate @ 16 ; - deflateBound @ 17 ; - deflateCopy @ 18 ; - deflateEnd @ 19 ; - deflateInit2_ @ 20 ; - deflateInit_ @ 21 ; - deflateParams @ 22 ; - deflatePrime @ 23 ; - deflateReset @ 24 ; - deflateSetDictionary @ 25 ; - deflateSetHeader @ 26 ; - deflateTune @ 27 ; - deflate_copyright @ 28 DATA ; - get_crc_table @ 29 ; - gzclearerr @ 30 ; - gzclose @ 31 ; - gzdirect @ 32 ; - gzdopen @ 33 ; - gzeof @ 34 ; - gzerror @ 35 ; - gzflush @ 36 ; - gzgetc @ 37 ; - gzgets @ 38 ; - gzopen @ 39 ; - gzprintf @ 40 ; - gzputc @ 41 ; - gzputs @ 42 ; - gzread @ 43 ; - gzrewind @ 44 ; - gzseek @ 45 ; - gzsetparams @ 46 ; - gztell @ 47 ; - gzungetc @ 48 ; - gzwrite @ 49 ; - inflate @ 50 ; - inflateBack @ 51 ; - inflateBackEnd @ 52 ; - inflateBackInit_ @ 53 ; - inflateCopy @ 54 ; - inflateEnd @ 55 ; - inflateGetHeader @ 56 ; - inflateInit2_ @ 57 ; - inflateInit_ @ 58 ; - inflatePrime @ 59 ; - inflateReset @ 60 ; - inflateSetDictionary @ 61 ; - inflateSync @ 62 ; - inflateSyncPoint @ 63 ; - inflate_copyright @ 64 DATA ; - inflate_fast @ 65 ; - inflate_table @ 66 ; - uncompress @ 67 ; - zError @ 68 ; - z_errmsg @ 69 DATA ; - zcalloc @ 70 ; - zcfree @ 71 ; - zlibCompileFlags @ 72 ; - zlibVersion @ 73 ; diff --git a/extern/gnuwin32/lib/zlib.lib b/extern/gnuwin32/lib/zlib.lib deleted file mode 100644 index d43be7f0..00000000 Binary files a/extern/gnuwin32/lib/zlib.lib and /dev/null differ diff --git a/extern/libsquish-1.15/CMakeLists.txt b/extern/libsquish-1.15/CMakeLists.txt new file mode 100644 index 00000000..a36e5744 --- /dev/null +++ b/extern/libsquish-1.15/CMakeLists.txt @@ -0,0 +1,117 @@ +# cmake build file for squish +# by Stefan Roettger (snroettg@gmail.com) +# updated by Simon Brown (si@sjbrown.co.uk) + +# features: +# uses -fopenmp when available +# use BUILD_SQUISH_WITH_OPENMP to override +# Xcode: builds universal binaries, uses SSE2 on i386 and Altivec on ppc +# Unix and VS: SSE2 support is enabled by default +# use BUILD_SQUISH_WITH_SSE2 and BUILD_SQUISH_WITH_ALTIVEC to override + +PROJECT(squish) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) + +OPTION(BUILD_SQUISH_WITH_OPENMP "Build with OpenMP." ON) + +OPTION(BUILD_SQUISH_WITH_SSE2 "Build with SSE2." ON) +OPTION(BUILD_SQUISH_WITH_ALTIVEC "Build with Altivec." OFF) + +OPTION(BUILD_SHARED_LIBS "Build shared libraries." OFF) + +OPTION(BUILD_SQUISH_EXTRA "Build extra source code." OFF) + +IF (BUILD_SQUISH_WITH_OPENMP) + FIND_PACKAGE(OpenMP) + IF (OPENMP_FOUND) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + ADD_DEFINITIONS(-DSQUISH_USE_OPENMP) + ENDIF() +ENDIF() + +IF (CMAKE_GENERATOR STREQUAL "Xcode") + SET(CMAKE_OSX_ARCHITECTURES "i386;ppc") +ELSE (CMAKE_GENERATOR STREQUAL "Xcode") + IF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) + ADD_DEFINITIONS(-DSQUISH_USE_SSE=2 -msse2) + ENDIF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) + IF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) + ADD_DEFINITIONS(-DSQUISH_USE_ALTIVEC=1 -maltivec) + ENDIF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) +ENDIF (CMAKE_GENERATOR STREQUAL "Xcode") + +SET(SQUISH_HDRS + squish.h + ) + +SET(SQUISH_SRCS + alpha.cpp + alpha.h + clusterfit.cpp + clusterfit.h + colourblock.cpp + colourblock.h + colourfit.cpp + colourfit.h + colourset.cpp + colourset.h + maths.cpp + maths.h + rangefit.cpp + rangefit.h + simd.h + simd_float.h + simd_sse.h + simd_ve.h + singlecolourfit.cpp + singlecolourfit.h + singlecolourlookup.inl + squish.cpp + ) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +ADD_LIBRARY(squish ${SQUISH_SRCS} ${SQUISH_HDRS}) + +SET_TARGET_PROPERTIES( + squish PROPERTIES + PUBLIC_HEADER "${SQUISH_HDRS}" + VERSION 0.0 + SOVERSION 0.0 + DEBUG_POSTFIX "d" + XCODE_ATTRIBUTE_GCC_PREPROCESSOR_DEFINITIONS "$(SQUISH_CPP_$(CURRENT_ARCH))" + XCODE_ATTRIBUTE_OTHER_CFLAGS "$(SQUISH_CFLAGS_$(CURRENT_ARCH))" + XCODE_ATTRIBUTE_SQUISH_CPP_i386 "SQUISH_USE_SSE=2" + XCODE_ATTRIBUTE_SQUISH_CFLAGS_i386 "" + XCODE_ATTRIBUTE_SQUISH_CPP_ppc "SQUISH_USE_ALTIVEC=1" + XCODE_ATTRIBUTE_SQUISH_CFLAGS_ppc "-maltivec" + ) + +IF (BUILD_SQUISH_EXTRA) + SET(SQUISHTEST_SRCS extra/squishtest.cpp) + + ADD_EXECUTABLE(squishtest ${SQUISHTEST_SRCS}) + SET_TARGET_PROPERTIES(squishtest PROPERTIES DEBUG_POSTFIX "d") + TARGET_LINK_LIBRARIES(squishtest squish) + + SET(SQUISHPNG_SRCS extra/squishpng.cpp) + + FIND_PACKAGE(PNG) + + IF (PNG_FOUND) + SET(CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES) + INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR}) + ADD_EXECUTABLE(squishpng ${SQUISHPNG_SRCS}) + SET_TARGET_PROPERTIES(squishpng PROPERTIES DEBUG_POSTFIX "d") + TARGET_LINK_LIBRARIES(squishpng squish ${PNG_LIBRARIES}) + ENDIF (PNG_FOUND) +ENDIF (BUILD_SQUISH_EXTRA) + +INSTALL( + TARGETS squish + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) diff --git a/extern/libsquish-1.15/CMakeModules/FindlibSquish.cmake b/extern/libsquish-1.15/CMakeModules/FindlibSquish.cmake new file mode 100644 index 00000000..a8d7cfed --- /dev/null +++ b/extern/libsquish-1.15/CMakeModules/FindlibSquish.cmake @@ -0,0 +1,14 @@ +# Defines +# LIBSQUISH_FOUND +# LIBSQUISH_INCLUDE_DIR +# LIBSQUISH_LIBRARIES + +FIND_PATH(LIBSQUISH_INCLUDE_DIR squish.h PATHS . squish .. ../squish DOC "Directory containing libSquish headers") +FIND_LIBRARY(LIBSQUISH_LIBRARY NAMES squish libsquish PATHS . squish .. ../squish PATH_SUFFIXES lib lib64 release minsizerel relwithdebinfo DOC "Path to libSquish library") + +SET(LIBSQUISH_LIBRARIES ${LIBSQUISH_LIBRARY}) + +IF (LIBSQUISH_LIBRARY AND LIBSQUISH_INCLUDE_DIR) + SET(LIBSQUISH_FOUND TRUE) + MESSAGE(STATUS "Found libSquish: ${LIBSQUISH_LIBRARY}") +ENDIF (LIBSQUISH_LIBRARY AND LIBSQUISH_INCLUDE_DIR) diff --git a/extern/libsquish-1.15/ChangeLog.txt b/extern/libsquish-1.15/ChangeLog.txt new file mode 100644 index 00000000..f6c8c6d3 --- /dev/null +++ b/extern/libsquish-1.15/ChangeLog.txt @@ -0,0 +1,66 @@ +1.15 +* parallel compression using openmp with cmake (Marian Krivos / Stefan Roettger) +* parallel decompression using openmp with cmake (Stefan Roettger) + +1.14 +* backport BGRA support +* backport BC4 and BC5 support +* backport BlockMSE support + +1.11-1.13 +* added support for CMake and QMake (Stefan Roettger) +* misc. minor changes on the build system (Stefan Roettger) +* added svg icon (Stefan Roettger) + +1.10 +* Iterative cluster fit is now considered to be a new compression mode +* The core cluster fit is now 4x faster using contributions by Ignacio +Castano from NVIDIA +* The single colour lookup table has been halved by exploiting symmetry + +1.9 +* Added contributed SSE1 truncate implementation +* Changed use of SQUISH_USE_SSE to be 1 for SSE and 2 for SSE2 instructions +* Cluster fit is now iterative to further reduce image error + +1.8 +* Switched from using floor to trunc for much better SSE performance (again) +* Xcode build now expects libpng in /usr/local for extra/squishpng + +1.7 +* Fixed floating-point equality issue in clusterfit sort (x86 affected only) +* Implemented proper SSE(2) floor function for 50% speedup on SSE builds +* The range fit implementation now uses the correct colour metric + +1.6 +* Fixed bug in CompressImage where masked pixels were not skipped over +* DXT3 and DXT5 alpha compression now properly use the mask to ignore pixels +* Fixed major DXT1 bug that can generate unexpected transparent pixels + +1.5 +* Added CompressMasked function to handle incomplete DXT blocks more cleanly +* Added kWeightColourByAlpha flag for better quality images when alpha blending + +1.4 +* Fixed stack overflow in rangefit + +1.3 +* Worked around SSE floor implementation bug, proper fix needed! +* This release has visual studio and makefile builds that work + +1.2 +* Added provably optimal single colour compressor +* Added extra/squishgen.cpp that generates single colour lookup tables + +1.1 +* Fixed a DXT1 colour output bug +* Changed argument order for Decompress function to match Compress +* Added GetStorageRequirements function +* Added CompressImage function +* Added DecompressImage function +* Moved squishtool.cpp to extra/squishpng.cpp +* Added extra/squishtest.cpp + +1.0 +* Initial release + diff --git a/extern/libsquish-1.15/Doxyfile b/extern/libsquish-1.15/Doxyfile new file mode 100644 index 00000000..3c54d29e --- /dev/null +++ b/extern/libsquish-1.15/Doxyfile @@ -0,0 +1,214 @@ +# Doxyfile 1.4.6 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = squish +PROJECT_NUMBER = 1.14 +OUTPUT_DIRECTORY = docs +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = squish.h +FILE_PATTERNS = +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOTFILE_DIRS = +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/extern/libsquish-1.15/LICENSE.txt b/extern/libsquish-1.15/LICENSE.txt new file mode 100644 index 00000000..ed1c78d9 --- /dev/null +++ b/extern/libsquish-1.15/LICENSE.txt @@ -0,0 +1,20 @@ + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/extern/libsquish-1.15/Makefile b/extern/libsquish-1.15/Makefile new file mode 100644 index 00000000..fd7d6c8f --- /dev/null +++ b/extern/libsquish-1.15/Makefile @@ -0,0 +1,65 @@ +include config + +VER = 1.15 +SOVER = 0 + +SRC = alpha.cpp clusterfit.cpp colourblock.cpp colourfit.cpp colourset.cpp maths.cpp rangefit.cpp singlecolourfit.cpp squish.cpp + +HDR = alpha.h clusterfit.h colourblock.h colourfit.h colourset.h maths.h rangefit.h singlecolourfit.h squish.h +HDR += config.h simd.h simd_float.h simd_sse.h simd_ve.h singlecolourlookup.inl + +OBJ = $(SRC:%.cpp=%.o) + +SOLIB = libsquish.so.$(SOVER) +LIB = $(SOLIB).0 +CPPFLAGS += -fPIC +LIBA = libsquish.a + +.PHONY: all install uninstall docs tgz clean + +all: $(LIB) $(LIBA) docs libsquish.pc + +install: $(LIB) $(LIBA) libsquish.pc + $(INSTALL_DIRECTORY) $(INSTALL_DIR)/include $(INSTALL_DIR)/$(LIB_PATH) + $(INSTALL_FILE) squish.h $(INSTALL_DIR)/include + $(INSTALL_FILE) $(LIBA) $(INSTALL_DIR)/$(LIB_PATH) +ifneq ($(USE_SHARED),0) + $(INSTALL_FILE) $(LIB) $(INSTALL_DIR)/$(LIB_PATH) + ln -s $(LIB) $(INSTALL_DIR)/$(LIB_PATH)/$(SOLIB) + ln -s $(LIB) $(INSTALL_DIR)/$(LIB_PATH)/libsquish.so + $(INSTALL_DIRECTORY) $(INSTALL_DIR)/$(LIB_PATH)/pkgconfig + $(INSTALL_FILE) libsquish.pc $(INSTALL_DIR)/$(LIB_PATH)/pkgconfig +endif + +uninstall: + $(RM) $(INSTALL_DIR)/include/squish.h + $(RM) $(INSTALL_DIR)/$(LIB_PATH)/$(LIBA) + -$(RM) $(INSTALL_DIR)/$(LIB_PATH)/$(LIB) + -$(RM) $(INSTALL_DIR)/$(LIB_PATH)/$(SOLIB) + -$(RM) $(INSTALL_DIR)/$(LIB_PATH)/libsquish.so + -$(RM) $(INSTALL_DIR)/$(LIB_PATH)/pkgconfig/libsquish.pc + +$(LIB): $(OBJ) +ifneq ($(USE_SHARED),0) + $(CXX) $(LDFLAGS) -shared -Wl,-soname,$(SOLIB) -o $@ $(OBJ) +endif + +$(LIBA): $(OBJ) + $(AR) cr $@ $? + @ranlib $@ + +docs: $(SRC) $(HDR) + @if [ -x "`command -v doxygen`" ]; then doxygen; fi + +libsquish.pc: libsquish.pc.in + @sed 's|@PREFIX@|$(PREFIX)|;s|@LIB_PATH@|$(LIB_PATH)|' $@.in > $@ + +tgz: clean + tar zcf libsquish-$(VER).tgz $(SRC) $(HDR) Makefile config CMakeLists.txt CMakeModules libSquish.* README.txt LICENSE.txt ChangeLog.txt Doxyfile libsquish.pc.in extra --exclude \*.svn\* + +%.o: %.cpp + $(CXX) $(CPPFLAGS) -I. $(CXXFLAGS) -o $@ -c $< + +clean: + $(RM) $(OBJ) $(LIB) $(LIBA) libsquish.pc + @-$(RM) -rf docs diff --git a/extern/libsquish-1.15/README.txt b/extern/libsquish-1.15/README.txt new file mode 100644 index 00000000..60380eee --- /dev/null +++ b/extern/libsquish-1.15/README.txt @@ -0,0 +1,18 @@ +LICENSE +------- + +The squish library is distributed under the terms and conditions of the MIT +license. This license is specified at the top of each source file and must be +preserved in its entirety. + +BUILDING AND INSTALLING THE LIBRARY +----------------------------------- + +The preferred way to install the library on Unix/Mac (and Windows) is via cmake: + cmake . && make && sudo make install + +REPORTING BUGS OR FEATURE REQUESTS +---------------------------------- + +Feedback can be sent to Simon Brown (the developer) at si@sjbrown.co.uk +Feedback can also be sent to Stefan Roettger (the maintainer) at snroettg@gmail.com diff --git a/extern/libsquish-1.15/alpha.cpp b/extern/libsquish-1.15/alpha.cpp new file mode 100644 index 00000000..7039c1a3 --- /dev/null +++ b/extern/libsquish-1.15/alpha.cpp @@ -0,0 +1,350 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "alpha.h" + +#include +#include + +namespace squish { + +static int FloatToInt( float a, int limit ) +{ + // use ANSI round-to-zero behaviour to get round-to-nearest + int i = ( int )( a + 0.5f ); + + // clamp to the limit + if( i < 0 ) + i = 0; + else if( i > limit ) + i = limit; + + // done + return i; +} + +void CompressAlphaDxt3( u8 const* rgba, int mask, void* block ) +{ + u8* bytes = reinterpret_cast< u8* >( block ); + + // quantise and pack the alpha values pairwise + for( int i = 0; i < 8; ++i ) + { + // quantise down to 4 bits + float alpha1 = ( float )rgba[8*i + 3] * ( 15.0f/255.0f ); + float alpha2 = ( float )rgba[8*i + 7] * ( 15.0f/255.0f ); + int quant1 = FloatToInt( alpha1, 15 ); + int quant2 = FloatToInt( alpha2, 15 ); + + // set alpha to zero where masked + int bit1 = 1 << ( 2*i ); + int bit2 = 1 << ( 2*i + 1 ); + if( ( mask & bit1 ) == 0 ) + quant1 = 0; + if( ( mask & bit2 ) == 0 ) + quant2 = 0; + + // pack into the byte + bytes[i] = ( u8 )( quant1 | ( quant2 << 4 ) ); + } +} + +void DecompressAlphaDxt3( u8* rgba, void const* block ) +{ + u8 const* bytes = reinterpret_cast< u8 const* >( block ); + + // unpack the alpha values pairwise + for( int i = 0; i < 8; ++i ) + { + // quantise down to 4 bits + u8 quant = bytes[i]; + + // unpack the values + u8 lo = quant & 0x0f; + u8 hi = quant & 0xf0; + + // convert back up to bytes + rgba[8*i + 3] = lo | ( lo << 4 ); + rgba[8*i + 7] = hi | ( hi >> 4 ); + } +} + +static void FixRange( int& min, int& max, int steps ) +{ + if( max - min < steps ) + max = std::min( min + steps, 255 ); + if( max - min < steps ) + min = std::max( 0, max - steps ); +} + +static int FitCodes( u8 const* rgba, int mask, u8 const* codes, u8* indices ) +{ + // fit each alpha value to the codebook + int err = 0; + for( int i = 0; i < 16; ++i ) + { + // check this pixel is valid + int bit = 1 << i; + if( ( mask & bit ) == 0 ) + { + // use the first code + indices[i] = 0; + continue; + } + + // find the least error and corresponding index + int value = rgba[4*i + 3]; + int least = INT_MAX; + int index = 0; + for( int j = 0; j < 8; ++j ) + { + // get the squared error from this code + int dist = ( int )value - ( int )codes[j]; + dist *= dist; + + // compare with the best so far + if( dist < least ) + { + least = dist; + index = j; + } + } + + // save this index and accumulate the error + indices[i] = ( u8 )index; + err += least; + } + + // return the total error + return err; +} + +static void WriteAlphaBlock( int alpha0, int alpha1, u8 const* indices, void* block ) +{ + u8* bytes = reinterpret_cast< u8* >( block ); + + // write the first two bytes + bytes[0] = ( u8 )alpha0; + bytes[1] = ( u8 )alpha1; + + // pack the indices with 3 bits each + u8* dest = bytes + 2; + u8 const* src = indices; + for( int i = 0; i < 2; ++i ) + { + // pack 8 3-bit values + int value = 0; + for( int j = 0; j < 8; ++j ) + { + int index = *src++; + value |= ( index << 3*j ); + } + + // store in 3 bytes + for( int j = 0; j < 3; ++j ) + { + int byte = ( value >> 8*j ) & 0xff; + *dest++ = ( u8 )byte; + } + } +} + +static void WriteAlphaBlock5( int alpha0, int alpha1, u8 const* indices, void* block ) +{ + // check the relative values of the endpoints + if( alpha0 > alpha1 ) + { + // swap the indices + u8 swapped[16]; + for( int i = 0; i < 16; ++i ) + { + u8 index = indices[i]; + if( index == 0 ) + swapped[i] = 1; + else if( index == 1 ) + swapped[i] = 0; + else if( index <= 5 ) + swapped[i] = 7 - index; + else + swapped[i] = index; + } + + // write the block + WriteAlphaBlock( alpha1, alpha0, swapped, block ); + } + else + { + // write the block + WriteAlphaBlock( alpha0, alpha1, indices, block ); + } +} + +static void WriteAlphaBlock7( int alpha0, int alpha1, u8 const* indices, void* block ) +{ + // check the relative values of the endpoints + if( alpha0 < alpha1 ) + { + // swap the indices + u8 swapped[16]; + for( int i = 0; i < 16; ++i ) + { + u8 index = indices[i]; + if( index == 0 ) + swapped[i] = 1; + else if( index == 1 ) + swapped[i] = 0; + else + swapped[i] = 9 - index; + } + + // write the block + WriteAlphaBlock( alpha1, alpha0, swapped, block ); + } + else + { + // write the block + WriteAlphaBlock( alpha0, alpha1, indices, block ); + } +} + +void CompressAlphaDxt5( u8 const* rgba, int mask, void* block ) +{ + // get the range for 5-alpha and 7-alpha interpolation + int min5 = 255; + int max5 = 0; + int min7 = 255; + int max7 = 0; + for( int i = 0; i < 16; ++i ) + { + // check this pixel is valid + int bit = 1 << i; + if( ( mask & bit ) == 0 ) + continue; + + // incorporate into the min/max + int value = rgba[4*i + 3]; + if( value < min7 ) + min7 = value; + if( value > max7 ) + max7 = value; + if( value != 0 && value < min5 ) + min5 = value; + if( value != 255 && value > max5 ) + max5 = value; + } + + // handle the case that no valid range was found + if( min5 > max5 ) + min5 = max5; + if( min7 > max7 ) + min7 = max7; + + // fix the range to be the minimum in each case + FixRange( min5, max5, 5 ); + FixRange( min7, max7, 7 ); + + // set up the 5-alpha code book + u8 codes5[8]; + codes5[0] = ( u8 )min5; + codes5[1] = ( u8 )max5; + for( int i = 1; i < 5; ++i ) + codes5[1 + i] = ( u8 )( ( ( 5 - i )*min5 + i*max5 )/5 ); + codes5[6] = 0; + codes5[7] = 255; + + // set up the 7-alpha code book + u8 codes7[8]; + codes7[0] = ( u8 )min7; + codes7[1] = ( u8 )max7; + for( int i = 1; i < 7; ++i ) + codes7[1 + i] = ( u8 )( ( ( 7 - i )*min7 + i*max7 )/7 ); + + // fit the data to both code books + u8 indices5[16]; + u8 indices7[16]; + int err5 = FitCodes( rgba, mask, codes5, indices5 ); + int err7 = FitCodes( rgba, mask, codes7, indices7 ); + + // save the block with least error + if( err5 <= err7 ) + WriteAlphaBlock5( min5, max5, indices5, block ); + else + WriteAlphaBlock7( min7, max7, indices7, block ); +} + +void DecompressAlphaDxt5( u8* rgba, void const* block ) +{ + // get the two alpha values + u8 const* bytes = reinterpret_cast< u8 const* >( block ); + int alpha0 = bytes[0]; + int alpha1 = bytes[1]; + + // compare the values to build the codebook + u8 codes[8]; + codes[0] = ( u8 )alpha0; + codes[1] = ( u8 )alpha1; + if( alpha0 <= alpha1 ) + { + // use 5-alpha codebook + for( int i = 1; i < 5; ++i ) + codes[1 + i] = ( u8 )( ( ( 5 - i )*alpha0 + i*alpha1 )/5 ); + codes[6] = 0; + codes[7] = 255; + } + else + { + // use 7-alpha codebook + for( int i = 1; i < 7; ++i ) + codes[1 + i] = ( u8 )( ( ( 7 - i )*alpha0 + i*alpha1 )/7 ); + } + + // decode the indices + u8 indices[16]; + u8 const* src = bytes + 2; + u8* dest = indices; + for( int i = 0; i < 2; ++i ) + { + // grab 3 bytes + int value = 0; + for( int j = 0; j < 3; ++j ) + { + int byte = *src++; + value |= ( byte << 8*j ); + } + + // unpack 8 3-bit values from it + for( int j = 0; j < 8; ++j ) + { + int index = ( value >> 3*j ) & 0x7; + *dest++ = ( u8 )index; + } + } + + // write out the indexed codebook values + for( int i = 0; i < 16; ++i ) + rgba[4*i + 3] = codes[indices[i]]; +} + +} // namespace squish diff --git a/extern/libsquish-1.15/alpha.h b/extern/libsquish-1.15/alpha.h new file mode 100644 index 00000000..a1fffd40 --- /dev/null +++ b/extern/libsquish-1.15/alpha.h @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_ALPHA_H +#define SQUISH_ALPHA_H + +#include "squish.h" + +namespace squish { + +void CompressAlphaDxt3( u8 const* rgba, int mask, void* block ); +void CompressAlphaDxt5( u8 const* rgba, int mask, void* block ); + +void DecompressAlphaDxt3( u8* rgba, void const* block ); +void DecompressAlphaDxt5( u8* rgba, void const* block ); + +} // namespace squish + +#endif // ndef SQUISH_ALPHA_H diff --git a/extern/libsquish-1.15/clusterfit.cpp b/extern/libsquish-1.15/clusterfit.cpp new file mode 100644 index 00000000..1610ecb5 --- /dev/null +++ b/extern/libsquish-1.15/clusterfit.cpp @@ -0,0 +1,392 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + Copyright (c) 2007 Ignacio Castano icastano@nvidia.com + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "clusterfit.h" +#include "colourset.h" +#include "colourblock.h" +#include + +namespace squish { + +ClusterFit::ClusterFit( ColourSet const* colours, int flags, float* metric ) + : ColourFit( colours, flags ) +{ + // set the iteration count + m_iterationCount = ( m_flags & kColourIterativeClusterFit ) ? kMaxIterations : 1; + + // initialise the metric (old perceptual = 0.2126f, 0.7152f, 0.0722f) + if( metric ) + m_metric = Vec4( metric[0], metric[1], metric[2], 1.0f ); + else + m_metric = VEC4_CONST( 1.0f ); + + // initialise the best error + m_besterror = VEC4_CONST( FLT_MAX ); + + // cache some values + int const count = m_colours->GetCount(); + Vec3 const* values = m_colours->GetPoints(); + + // get the covariance matrix + Sym3x3 covariance = ComputeWeightedCovariance( count, values, m_colours->GetWeights() ); + + // compute the principle component + m_principle = ComputePrincipleComponent( covariance ); +} + +bool ClusterFit::ConstructOrdering( Vec3 const& axis, int iteration ) +{ + // cache some values + int const count = m_colours->GetCount(); + Vec3 const* values = m_colours->GetPoints(); + + // build the list of dot products + float dps[16]; + u8* order = ( u8* )m_order + 16*iteration; + for( int i = 0; i < count; ++i ) + { + dps[i] = Dot( values[i], axis ); + order[i] = ( u8 )i; + } + + // stable sort using them + for( int i = 0; i < count; ++i ) + { + for( int j = i; j > 0 && dps[j] < dps[j - 1]; --j ) + { + std::swap( dps[j], dps[j - 1] ); + std::swap( order[j], order[j - 1] ); + } + } + + // check this ordering is unique + for( int it = 0; it < iteration; ++it ) + { + u8 const* prev = ( u8* )m_order + 16*it; + bool same = true; + for( int i = 0; i < count; ++i ) + { + if( order[i] != prev[i] ) + { + same = false; + break; + } + } + if( same ) + return false; + } + + // copy the ordering and weight all the points + Vec3 const* unweighted = m_colours->GetPoints(); + float const* weights = m_colours->GetWeights(); + m_xsum_wsum = VEC4_CONST( 0.0f ); + for( int i = 0; i < count; ++i ) + { + int j = order[i]; + Vec4 p( unweighted[j].X(), unweighted[j].Y(), unweighted[j].Z(), 1.0f ); + Vec4 w( weights[j] ); + Vec4 x = p*w; + m_points_weights[i] = x; + m_xsum_wsum += x; + } + return true; +} + +void ClusterFit::Compress3( void* block ) +{ + // declare variables + int const count = m_colours->GetCount(); + Vec4 const two = VEC4_CONST( 2.0 ); + Vec4 const one = VEC4_CONST( 1.0f ); + Vec4 const half_half2( 0.5f, 0.5f, 0.5f, 0.25f ); + Vec4 const zero = VEC4_CONST( 0.0f ); + Vec4 const half = VEC4_CONST( 0.5f ); + Vec4 const grid( 31.0f, 63.0f, 31.0f, 0.0f ); + Vec4 const gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f, 0.0f ); + + // prepare an ordering using the principle axis + ConstructOrdering( m_principle, 0 ); + + // check all possible clusters and iterate on the total order + Vec4 beststart = VEC4_CONST( 0.0f ); + Vec4 bestend = VEC4_CONST( 0.0f ); + Vec4 besterror = m_besterror; + u8 bestindices[16]; + int bestiteration = 0; + int besti = 0, bestj = 0; + + // loop over iterations (we avoid the case that all points in first or last cluster) + for( int iterationIndex = 0;; ) + { + // first cluster [0,i) is at the start + Vec4 part0 = VEC4_CONST( 0.0f ); + for( int i = 0; i < count; ++i ) + { + // second cluster [i,j) is half along + Vec4 part1 = ( i == 0 ) ? m_points_weights[0] : VEC4_CONST( 0.0f ); + int jmin = ( i == 0 ) ? 1 : i; + for( int j = jmin;; ) + { + // last cluster [j,count) is at the end + Vec4 part2 = m_xsum_wsum - part1 - part0; + + // compute least squares terms directly + Vec4 alphax_sum = MultiplyAdd( part1, half_half2, part0 ); + Vec4 alpha2_sum = alphax_sum.SplatW(); + + Vec4 betax_sum = MultiplyAdd( part1, half_half2, part2 ); + Vec4 beta2_sum = betax_sum.SplatW(); + + Vec4 alphabeta_sum = ( part1*half_half2 ).SplatW(); + + // compute the least-squares optimal points + Vec4 factor = Reciprocal( NegativeMultiplySubtract( alphabeta_sum, alphabeta_sum, alpha2_sum*beta2_sum ) ); + Vec4 a = NegativeMultiplySubtract( betax_sum, alphabeta_sum, alphax_sum*beta2_sum )*factor; + Vec4 b = NegativeMultiplySubtract( alphax_sum, alphabeta_sum, betax_sum*alpha2_sum )*factor; + + // clamp to the grid + a = Min( one, Max( zero, a ) ); + b = Min( one, Max( zero, b ) ); + a = Truncate( MultiplyAdd( grid, a, half ) )*gridrcp; + b = Truncate( MultiplyAdd( grid, b, half ) )*gridrcp; + + // compute the error (we skip the constant xxsum) + Vec4 e1 = MultiplyAdd( a*a, alpha2_sum, b*b*beta2_sum ); + Vec4 e2 = NegativeMultiplySubtract( a, alphax_sum, a*b*alphabeta_sum ); + Vec4 e3 = NegativeMultiplySubtract( b, betax_sum, e2 ); + Vec4 e4 = MultiplyAdd( two, e3, e1 ); + + // apply the metric to the error term + Vec4 e5 = e4*m_metric; + Vec4 error = e5.SplatX() + e5.SplatY() + e5.SplatZ(); + + // keep the solution if it wins + if( CompareAnyLessThan( error, besterror ) ) + { + beststart = a; + bestend = b; + besti = i; + bestj = j; + besterror = error; + bestiteration = iterationIndex; + } + + // advance + if( j == count ) + break; + part1 += m_points_weights[j]; + ++j; + } + + // advance + part0 += m_points_weights[i]; + } + + // stop if we didn't improve in this iteration + if( bestiteration != iterationIndex ) + break; + + // advance if possible + ++iterationIndex; + if( iterationIndex == m_iterationCount ) + break; + + // stop if a new iteration is an ordering that has already been tried + Vec3 axis = ( bestend - beststart ).GetVec3(); + if( !ConstructOrdering( axis, iterationIndex ) ) + break; + } + + // save the block if necessary + if( CompareAnyLessThan( besterror, m_besterror ) ) + { + // remap the indices + u8 const* order = ( u8* )m_order + 16*bestiteration; + + u8 unordered[16]; + for( int m = 0; m < besti; ++m ) + unordered[order[m]] = 0; + for( int m = besti; m < bestj; ++m ) + unordered[order[m]] = 2; + for( int m = bestj; m < count; ++m ) + unordered[order[m]] = 1; + + m_colours->RemapIndices( unordered, bestindices ); + + // save the block + WriteColourBlock3( beststart.GetVec3(), bestend.GetVec3(), bestindices, block ); + + // save the error + m_besterror = besterror; + } +} + +void ClusterFit::Compress4( void* block ) +{ + // declare variables + int const count = m_colours->GetCount(); + Vec4 const two = VEC4_CONST( 2.0f ); + Vec4 const one = VEC4_CONST( 1.0f ); + Vec4 const onethird_onethird2( 1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f, 1.0f/9.0f ); + Vec4 const twothirds_twothirds2( 2.0f/3.0f, 2.0f/3.0f, 2.0f/3.0f, 4.0f/9.0f ); + Vec4 const twonineths = VEC4_CONST( 2.0f/9.0f ); + Vec4 const zero = VEC4_CONST( 0.0f ); + Vec4 const half = VEC4_CONST( 0.5f ); + Vec4 const grid( 31.0f, 63.0f, 31.0f, 0.0f ); + Vec4 const gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f, 0.0f ); + + // prepare an ordering using the principle axis + ConstructOrdering( m_principle, 0 ); + + // check all possible clusters and iterate on the total order + Vec4 beststart = VEC4_CONST( 0.0f ); + Vec4 bestend = VEC4_CONST( 0.0f ); + Vec4 besterror = m_besterror; + u8 bestindices[16]; + int bestiteration = 0; + int besti = 0, bestj = 0, bestk = 0; + + // loop over iterations (we avoid the case that all points in first or last cluster) + for( int iterationIndex = 0;; ) + { + // first cluster [0,i) is at the start + Vec4 part0 = VEC4_CONST( 0.0f ); + for( int i = 0; i < count; ++i ) + { + // second cluster [i,j) is one third along + Vec4 part1 = VEC4_CONST( 0.0f ); + for( int j = i;; ) + { + // third cluster [j,k) is two thirds along + Vec4 part2 = ( j == 0 ) ? m_points_weights[0] : VEC4_CONST( 0.0f ); + int kmin = ( j == 0 ) ? 1 : j; + for( int k = kmin;; ) + { + // last cluster [k,count) is at the end + Vec4 part3 = m_xsum_wsum - part2 - part1 - part0; + + // compute least squares terms directly + Vec4 const alphax_sum = MultiplyAdd( part2, onethird_onethird2, MultiplyAdd( part1, twothirds_twothirds2, part0 ) ); + Vec4 const alpha2_sum = alphax_sum.SplatW(); + + Vec4 const betax_sum = MultiplyAdd( part1, onethird_onethird2, MultiplyAdd( part2, twothirds_twothirds2, part3 ) ); + Vec4 const beta2_sum = betax_sum.SplatW(); + + Vec4 const alphabeta_sum = twonineths*( part1 + part2 ).SplatW(); + + // compute the least-squares optimal points + Vec4 factor = Reciprocal( NegativeMultiplySubtract( alphabeta_sum, alphabeta_sum, alpha2_sum*beta2_sum ) ); + Vec4 a = NegativeMultiplySubtract( betax_sum, alphabeta_sum, alphax_sum*beta2_sum )*factor; + Vec4 b = NegativeMultiplySubtract( alphax_sum, alphabeta_sum, betax_sum*alpha2_sum )*factor; + + // clamp to the grid + a = Min( one, Max( zero, a ) ); + b = Min( one, Max( zero, b ) ); + a = Truncate( MultiplyAdd( grid, a, half ) )*gridrcp; + b = Truncate( MultiplyAdd( grid, b, half ) )*gridrcp; + + // compute the error (we skip the constant xxsum) + Vec4 e1 = MultiplyAdd( a*a, alpha2_sum, b*b*beta2_sum ); + Vec4 e2 = NegativeMultiplySubtract( a, alphax_sum, a*b*alphabeta_sum ); + Vec4 e3 = NegativeMultiplySubtract( b, betax_sum, e2 ); + Vec4 e4 = MultiplyAdd( two, e3, e1 ); + + // apply the metric to the error term + Vec4 e5 = e4*m_metric; + Vec4 error = e5.SplatX() + e5.SplatY() + e5.SplatZ(); + + // keep the solution if it wins + if( CompareAnyLessThan( error, besterror ) ) + { + beststart = a; + bestend = b; + besterror = error; + besti = i; + bestj = j; + bestk = k; + bestiteration = iterationIndex; + } + + // advance + if( k == count ) + break; + part2 += m_points_weights[k]; + ++k; + } + + // advance + if( j == count ) + break; + part1 += m_points_weights[j]; + ++j; + } + + // advance + part0 += m_points_weights[i]; + } + + // stop if we didn't improve in this iteration + if( bestiteration != iterationIndex ) + break; + + // advance if possible + ++iterationIndex; + if( iterationIndex == m_iterationCount ) + break; + + // stop if a new iteration is an ordering that has already been tried + Vec3 axis = ( bestend - beststart ).GetVec3(); + if( !ConstructOrdering( axis, iterationIndex ) ) + break; + } + + // save the block if necessary + if( CompareAnyLessThan( besterror, m_besterror ) ) + { + // remap the indices + u8 const* order = ( u8* )m_order + 16*bestiteration; + + u8 unordered[16]; + for( int m = 0; m < besti; ++m ) + unordered[order[m]] = 0; + for( int m = besti; m < bestj; ++m ) + unordered[order[m]] = 2; + for( int m = bestj; m < bestk; ++m ) + unordered[order[m]] = 3; + for( int m = bestk; m < count; ++m ) + unordered[order[m]] = 1; + + m_colours->RemapIndices( unordered, bestindices ); + + // save the block + WriteColourBlock4( beststart.GetVec3(), bestend.GetVec3(), bestindices, block ); + + // save the error + m_besterror = besterror; + } +} + +} // namespace squish diff --git a/extern/libsquish-1.15/clusterfit.h b/extern/libsquish-1.15/clusterfit.h new file mode 100644 index 00000000..999396b2 --- /dev/null +++ b/extern/libsquish-1.15/clusterfit.h @@ -0,0 +1,61 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + Copyright (c) 2007 Ignacio Castano icastano@nvidia.com + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_CLUSTERFIT_H +#define SQUISH_CLUSTERFIT_H + +#include "squish.h" +#include "maths.h" +#include "simd.h" +#include "colourfit.h" + +namespace squish { + +class ClusterFit : public ColourFit +{ +public: + ClusterFit( ColourSet const* colours, int flags, float* metric ); + +private: + bool ConstructOrdering( Vec3 const& axis, int iteration ); + + virtual void Compress3( void* block ); + virtual void Compress4( void* block ); + + enum { kMaxIterations = 8 }; + + int m_iterationCount; + Vec3 m_principle; + u8 m_order[16*kMaxIterations]; + Vec4 m_points_weights[16]; + Vec4 m_xsum_wsum; + Vec4 m_metric; + Vec4 m_besterror; +}; + +} // namespace squish + +#endif // ndef SQUISH_CLUSTERFIT_H diff --git a/extern/libsquish-1.15/colourblock.cpp b/extern/libsquish-1.15/colourblock.cpp new file mode 100644 index 00000000..af8b9803 --- /dev/null +++ b/extern/libsquish-1.15/colourblock.cpp @@ -0,0 +1,214 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "colourblock.h" + +namespace squish { + +static int FloatToInt( float a, int limit ) +{ + // use ANSI round-to-zero behaviour to get round-to-nearest + int i = ( int )( a + 0.5f ); + + // clamp to the limit + if( i < 0 ) + i = 0; + else if( i > limit ) + i = limit; + + // done + return i; +} + +static int FloatTo565( Vec3::Arg colour ) +{ + // get the components in the correct range + int r = FloatToInt( 31.0f*colour.X(), 31 ); + int g = FloatToInt( 63.0f*colour.Y(), 63 ); + int b = FloatToInt( 31.0f*colour.Z(), 31 ); + + // pack into a single value + return ( r << 11 ) | ( g << 5 ) | b; +} + +static void WriteColourBlock( int a, int b, u8* indices, void* block ) +{ + // get the block as bytes + u8* bytes = ( u8* )block; + + // write the endpoints + bytes[0] = ( u8 )( a & 0xff ); + bytes[1] = ( u8 )( a >> 8 ); + bytes[2] = ( u8 )( b & 0xff ); + bytes[3] = ( u8 )( b >> 8 ); + + // write the indices + for( int i = 0; i < 4; ++i ) + { + u8 const* ind = indices + 4*i; + bytes[4 + i] = ind[0] | ( ind[1] << 2 ) | ( ind[2] << 4 ) | ( ind[3] << 6 ); + } +} + +void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ) +{ + // get the packed values + int a = FloatTo565( start ); + int b = FloatTo565( end ); + + // remap the indices + u8 remapped[16]; + if( a <= b ) + { + // use the indices directly + for( int i = 0; i < 16; ++i ) + remapped[i] = indices[i]; + } + else + { + // swap a and b + std::swap( a, b ); + for( int i = 0; i < 16; ++i ) + { + if( indices[i] == 0 ) + remapped[i] = 1; + else if( indices[i] == 1 ) + remapped[i] = 0; + else + remapped[i] = indices[i]; + } + } + + // write the block + WriteColourBlock( a, b, remapped, block ); +} + +void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ) +{ + // get the packed values + int a = FloatTo565( start ); + int b = FloatTo565( end ); + + // remap the indices + u8 remapped[16]; + if( a < b ) + { + // swap a and b + std::swap( a, b ); + for( int i = 0; i < 16; ++i ) + remapped[i] = ( indices[i] ^ 0x1 ) & 0x3; + } + else if( a == b ) + { + // use index 0 + for( int i = 0; i < 16; ++i ) + remapped[i] = 0; + } + else + { + // use the indices directly + for( int i = 0; i < 16; ++i ) + remapped[i] = indices[i]; + } + + // write the block + WriteColourBlock( a, b, remapped, block ); +} + +static int Unpack565( u8 const* packed, u8* colour ) +{ + // build the packed value + int value = ( int )packed[0] | ( ( int )packed[1] << 8 ); + + // get the components in the stored range + u8 red = ( u8 )( ( value >> 11 ) & 0x1f ); + u8 green = ( u8 )( ( value >> 5 ) & 0x3f ); + u8 blue = ( u8 )( value & 0x1f ); + + // scale up to 8 bits + colour[0] = ( red << 3 ) | ( red >> 2 ); + colour[1] = ( green << 2 ) | ( green >> 4 ); + colour[2] = ( blue << 3 ) | ( blue >> 2 ); + colour[3] = 255; + + // return the value + return value; +} + +void DecompressColour( u8* rgba, void const* block, bool isDxt1 ) +{ + // get the block bytes + u8 const* bytes = reinterpret_cast< u8 const* >( block ); + + // unpack the endpoints + u8 codes[16]; + int a = Unpack565( bytes, codes ); + int b = Unpack565( bytes + 2, codes + 4 ); + + // generate the midpoints + for( int i = 0; i < 3; ++i ) + { + int c = codes[i]; + int d = codes[4 + i]; + + if( isDxt1 && a <= b ) + { + codes[8 + i] = ( u8 )( ( c + d )/2 ); + codes[12 + i] = 0; + } + else + { + codes[8 + i] = ( u8 )( ( 2*c + d )/3 ); + codes[12 + i] = ( u8 )( ( c + 2*d )/3 ); + } + } + + // fill in alpha for the intermediate values + codes[8 + 3] = 255; + codes[12 + 3] = ( isDxt1 && a <= b ) ? 0 : 255; + + // unpack the indices + u8 indices[16]; + for( int i = 0; i < 4; ++i ) + { + u8* ind = indices + 4*i; + u8 packed = bytes[4 + i]; + + ind[0] = packed & 0x3; + ind[1] = ( packed >> 2 ) & 0x3; + ind[2] = ( packed >> 4 ) & 0x3; + ind[3] = ( packed >> 6 ) & 0x3; + } + + // store out the colours + for( int i = 0; i < 16; ++i ) + { + u8 offset = 4*indices[i]; + for( int j = 0; j < 4; ++j ) + rgba[4*i + j] = codes[offset + j]; + } +} + +} // namespace squish diff --git a/extern/libsquish-1.15/colourblock.h b/extern/libsquish-1.15/colourblock.h new file mode 100644 index 00000000..fee2cd7c --- /dev/null +++ b/extern/libsquish-1.15/colourblock.h @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_COLOURBLOCK_H +#define SQUISH_COLOURBLOCK_H + +#include "squish.h" +#include "maths.h" + +namespace squish { + +void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); +void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); + +void DecompressColour( u8* rgba, void const* block, bool isDxt1 ); + +} // namespace squish + +#endif // ndef SQUISH_COLOURBLOCK_H diff --git a/extern/libsquish-1.15/colourfit.cpp b/extern/libsquish-1.15/colourfit.cpp new file mode 100644 index 00000000..e45b6565 --- /dev/null +++ b/extern/libsquish-1.15/colourfit.cpp @@ -0,0 +1,54 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "colourfit.h" +#include "colourset.h" + +namespace squish { + +ColourFit::ColourFit( ColourSet const* colours, int flags ) + : m_colours( colours ), + m_flags( flags ) +{ +} + +ColourFit::~ColourFit() +{ +} + +void ColourFit::Compress( void* block ) +{ + bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 ); + if( isDxt1 ) + { + Compress3( block ); + if( !m_colours->IsTransparent() ) + Compress4( block ); + } + else + Compress4( block ); +} + +} // namespace squish diff --git a/extern/libsquish-1.15/colourfit.h b/extern/libsquish-1.15/colourfit.h new file mode 100644 index 00000000..e73dceb2 --- /dev/null +++ b/extern/libsquish-1.15/colourfit.h @@ -0,0 +1,56 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_COLOURFIT_H +#define SQUISH_COLOURFIT_H + +#include "squish.h" +#include "maths.h" + +#include + +namespace squish { + +class ColourSet; + +class ColourFit +{ +public: + ColourFit( ColourSet const* colours, int flags ); + virtual ~ColourFit(); + + void Compress( void* block ); + +protected: + virtual void Compress3( void* block ) = 0; + virtual void Compress4( void* block ) = 0; + + ColourSet const* m_colours; + int m_flags; +}; + +} // namespace squish + +#endif // ndef SQUISH_COLOURFIT_H diff --git a/extern/libsquish-1.15/colourset.cpp b/extern/libsquish-1.15/colourset.cpp new file mode 100644 index 00000000..e9005564 --- /dev/null +++ b/extern/libsquish-1.15/colourset.cpp @@ -0,0 +1,121 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "colourset.h" + +namespace squish { + +ColourSet::ColourSet( u8 const* rgba, int mask, int flags ) + : m_count( 0 ), + m_transparent( false ) +{ + // check the compression mode for dxt1 + bool isDxt1 = ( ( flags & kDxt1 ) != 0 ); + bool weightByAlpha = ( ( flags & kWeightColourByAlpha ) != 0 ); + + // create the minimal set + for( int i = 0; i < 16; ++i ) + { + // check this pixel is enabled + int bit = 1 << i; + if( ( mask & bit ) == 0 ) + { + m_remap[i] = -1; + continue; + } + + // check for transparent pixels when using dxt1 + if( isDxt1 && rgba[4*i + 3] < 128 ) + { + m_remap[i] = -1; + m_transparent = true; + continue; + } + + // loop over previous points for a match + for( int j = 0;; ++j ) + { + // allocate a new point + if( j == i ) + { + // normalise coordinates to [0,1] + float x = ( float )rgba[4*i] / 255.0f; + float y = ( float )rgba[4*i + 1] / 255.0f; + float z = ( float )rgba[4*i + 2] / 255.0f; + + // ensure there is always non-zero weight even for zero alpha + float w = ( float )( rgba[4*i + 3] + 1 ) / 256.0f; + + // add the point + m_points[m_count] = Vec3( x, y, z ); + m_weights[m_count] = ( weightByAlpha ? w : 1.0f ); + m_remap[i] = m_count; + + // advance + ++m_count; + break; + } + + // check for a match + int oldbit = 1 << j; + bool match = ( ( mask & oldbit ) != 0 ) + && ( rgba[4*i] == rgba[4*j] ) + && ( rgba[4*i + 1] == rgba[4*j + 1] ) + && ( rgba[4*i + 2] == rgba[4*j + 2] ) + && ( rgba[4*j + 3] >= 128 || !isDxt1 ); + if( match ) + { + // get the index of the match + int index = m_remap[j]; + + // ensure there is always non-zero weight even for zero alpha + float w = ( float )( rgba[4*i + 3] + 1 ) / 256.0f; + + // map to this point and increase the weight + m_weights[index] += ( weightByAlpha ? w : 1.0f ); + m_remap[i] = index; + break; + } + } + } + + // square root the weights + for( int i = 0; i < m_count; ++i ) + m_weights[i] = std::sqrt( m_weights[i] ); +} + +void ColourSet::RemapIndices( u8 const* source, u8* target ) const +{ + for( int i = 0; i < 16; ++i ) + { + int j = m_remap[i]; + if( j == -1 ) + target[i] = 3; + else + target[i] = source[j]; + } +} + +} // namespace squish diff --git a/extern/libsquish-1.15/colourset.h b/extern/libsquish-1.15/colourset.h new file mode 100644 index 00000000..e13bb6fc --- /dev/null +++ b/extern/libsquish-1.15/colourset.h @@ -0,0 +1,58 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_COLOURSET_H +#define SQUISH_COLOURSET_H + +#include "squish.h" +#include "maths.h" + +namespace squish { + +/*! @brief Represents a set of block colours +*/ +class ColourSet +{ +public: + ColourSet( u8 const* rgba, int mask, int flags ); + + int GetCount() const { return m_count; } + Vec3 const* GetPoints() const { return m_points; } + float const* GetWeights() const { return m_weights; } + bool IsTransparent() const { return m_transparent; } + + void RemapIndices( u8 const* source, u8* target ) const; + +private: + int m_count; + Vec3 m_points[16]; + float m_weights[16]; + int m_remap[16]; + bool m_transparent; +}; + +} // namespace sqish + +#endif // ndef SQUISH_COLOURSET_H diff --git a/extern/libsquish-1.15/config b/extern/libsquish-1.15/config new file mode 100644 index 00000000..da6de8d1 --- /dev/null +++ b/extern/libsquish-1.15/config @@ -0,0 +1,38 @@ +# config file for GNUmake + +# define to 1 to use OpenMP parallelization +USE_OPENMP ?= 0 + +# define to 1 to install shared library +USE_SHARED ?= 0 + +# define to 1 to use Altivec instructions +USE_ALTIVEC ?= 0 + +# define to 1 to use SSE2 instructions +USE_SSE ?= 0 + +# default flags +CXXFLAGS ?= -O2 -Wall +ifeq ($(USE_OPENMP),1) + CPPFLAGS += -DSQUISH_USE_OPENMP + CXXFLAGS += -fopenmp +endif +ifeq ($(USE_ALTIVEC),1) + CPPFLAGS += -DSQUISH_USE_ALTIVEC=1 + CXXFLAGS += -maltivec +endif +ifeq ($(USE_SSE),1) + CPPFLAGS += -DSQUISH_USE_SSE=2 + CXXFLAGS += -msse +endif + +# install options +INSTALL = install +INSTALL_FILE = $(INSTALL) -p -m 644 +INSTALL_PROGRAM = $(INSTALL) -p -m 755 +INSTALL_DIRECTORY = $(INSTALL) -d -m 755 + +# where should we install to +INSTALL_DIR ?= /usr/local +LIB_PATH ?= lib diff --git a/extern/libsquish-1.15/config.h b/extern/libsquish-1.15/config.h new file mode 100644 index 00000000..9f1f4b17 --- /dev/null +++ b/extern/libsquish-1.15/config.h @@ -0,0 +1,49 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_CONFIG_H +#define SQUISH_CONFIG_H + +// Set to 1 when building squish to use Altivec instructions. +#ifndef SQUISH_USE_ALTIVEC +#define SQUISH_USE_ALTIVEC 0 +#endif + +// Set to 1 or 2 when building squish to use SSE or SSE2 instructions. +#ifndef SQUISH_USE_SSE +#define SQUISH_USE_SSE 2 +#endif + +// Internally set SQUISH_USE_SIMD when either Altivec or SSE is available. +#if SQUISH_USE_ALTIVEC && SQUISH_USE_SSE +#error "Cannot enable both Altivec and SSE!" +#endif +#if SQUISH_USE_ALTIVEC || SQUISH_USE_SSE +#define SQUISH_USE_SIMD 1 +#else +#define SQUISH_USE_SIMD 0 +#endif + +#endif // ndef SQUISH_CONFIG_H diff --git a/extern/libsquish-1.15/extra/squishgen.cpp b/extern/libsquish-1.15/extra/squishgen.cpp new file mode 100644 index 00000000..1fcbd2a1 --- /dev/null +++ b/extern/libsquish-1.15/extra/squishgen.cpp @@ -0,0 +1,151 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include + +struct SourceBlock +{ + int start; + int end; + int error; +}; + +struct TargetValue +{ + SourceBlock sources[2]; +}; + +static void GenerateData( std::string const& name, int bits, int colours ) +{ + TargetValue values[256]; + + // initialise the data + for( int target = 0; target < 256; ++target ) + for( int index = 0; index < colours; ++index ) + values[target].sources[index].error = 255; + + // loop over all possible source points + int count = ( 1 << bits ); + for( int value1 = 0; value1 < count; ++value1 ) + { + for( int value2 = 0; value2 < count; ++value2 ) + { + // compute the 8-bit endpoints + int a = ( value1 << ( 8 - bits ) ) | ( value1 >> ( 2*bits - 8 ) ); + int b = ( value2 << ( 8 - bits ) ) | ( value2 >> ( 2*bits - 8 ) ); + + // fill in the codebook with the these and intermediates + int codes[2]; + codes[0] = a; + if( colours == 3 ) + codes[1] = ( a + b )/2; + else + codes[1] = ( 2*a + b )/3; + + // mark each target point with the endpoints and index needed for it + for( int index = 0; index < 2; ++index ) + { + int target = codes[index]; + + SourceBlock& block = values[target].sources[index]; + if( block.error != 0 ) + { + block.start = value1; + block.end = value2; + block.error = 0; + } + } + } + } + + // iteratively fill in the missing values + for( ;; ) + { + bool stable = true; + for( int index = 0; index < 2; ++index ) + { + for( int target = 0; target < 256; ++target ) + { + if( target != 255 ) + { + SourceBlock& current = values[target].sources[index]; + SourceBlock& next = values[target + 1].sources[index]; + if( current.error > next.error + 1 ) + { + current.start = next.start; + current.end = next.end; + current.error = next.error + 1; + stable = false; + } + } + if( target != 0 ) + { + SourceBlock& current = values[target].sources[index]; + SourceBlock& previous = values[target - 1].sources[index]; + if( current.error > previous.error + 1 ) + { + current.start = previous.start; + current.end = previous.end; + current.error = previous.error + 1; + stable = false; + } + } + } + } + if( stable ) + break; + } + + // debug + std::cout << "\nstatic SingleColourLookup const " << name << "[] = \n{\n"; + for( int i = 0;; ) + { + std::cout << "\t{ { "; + for( int j = 0;; ) + { + SourceBlock const& block = values[i].sources[j]; + if( j < colours ) + std::cout << "{ " << block.start << ", " << block.end << ", " << block.error << " }"; + else + std::cout << "{ 0, 0, 0 }"; + if( ++j == 2 ) + break; + std::cout << ", "; + } + std::cout << " } }"; + if( ++i == 256 ) + break; + std::cout << ",\n"; + } + std::cout << "\n};\n"; +} + +int main() +{ + GenerateData( "lookup_5_3", 5, 3 ); + GenerateData( "lookup_6_3", 6, 3 ); + GenerateData( "lookup_5_4", 5, 4 ); + GenerateData( "lookup_6_4", 6, 4 ); +} diff --git a/extern/libsquish-1.15/extra/squishpng.cpp b/extern/libsquish-1.15/extra/squishpng.cpp new file mode 100644 index 00000000..5d45b0c3 --- /dev/null +++ b/extern/libsquish-1.15/extra/squishpng.cpp @@ -0,0 +1,546 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +/*! @file + + @brief Test program that compresses images loaded using the PNG format. + + This program requires libpng for PNG input and output, and is designed to + test the RMS error for DXT compression for a set of test images. + + This program uses the high-level image compression and decompression + functions that process an entire image at a time. +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning( disable: 4511 4512 ) +#endif // def _MSC_VER + +using namespace squish; + +//! Simple exception class. +class Error : public std::exception +{ +public: + Error( std::string const& excuse ) : m_excuse( excuse ) {} + ~Error() throw() {} + + virtual char const* what() const throw() { return m_excuse.c_str(); } + +private: + std::string m_excuse; +}; + +//! Base class to make derived classes non-copyable +class NonCopyable +{ +public: + NonCopyable() {} + +private: + NonCopyable( NonCopyable const& ); + NonCopyable& operator=( NonCopyable const& ); +}; + +//! Memory object. +class Mem : NonCopyable +{ +public: + Mem() : m_p( 0 ) {} + explicit Mem( int size ) : m_p( new u8[size] ) {} + ~Mem() { delete[] m_p; } + + void Reset( int size ) + { + u8 *p = new u8[size]; + delete m_p; + m_p = p; + } + + u8* Get() const { return m_p; } + +private: + u8* m_p; +}; + +//! File object. +class File : NonCopyable +{ +public: + explicit File( FILE* fp ) : m_fp( fp ) {} + ~File() { if( m_fp ) fclose( m_fp ); } + + bool IsValid() const { return m_fp != 0; } + FILE* Get() const { return m_fp; } + +private: + FILE* m_fp; +}; + +//! PNG read object. +class PngReadStruct : NonCopyable +{ +public: + PngReadStruct() + : m_png( 0 ), + m_info( 0 ), + m_end( 0 ) + { + m_png = png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 ); + if( !m_png ) + throw Error( "failed to create png read struct" ); + + m_info = png_create_info_struct( m_png ); + m_end = png_create_info_struct( m_png ); + if( !m_info || !m_end ) + { + png_infopp info = m_info ? &m_info : 0; + png_infopp end = m_end ? &m_end : 0; + png_destroy_read_struct( &m_png, info, end ); + throw Error( "failed to create png info structs" ); + } + } + + ~PngReadStruct() + { + png_destroy_read_struct( &m_png, &m_info, &m_end ); + } + + png_structp GetPng() const { return m_png; } + png_infop GetInfo() const { return m_info; } + +private: + png_structp m_png; + png_infop m_info, m_end; +}; + +//! PNG write object. +class PngWriteStruct : NonCopyable +{ +public: + PngWriteStruct() + : m_png( 0 ), + m_info( 0 ) + { + m_png = png_create_write_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 ); + if( !m_png ) + throw Error( "failed to create png read struct" ); + + m_info = png_create_info_struct( m_png ); + if( !m_info ) + { + png_infopp info = m_info ? &m_info : 0; + png_destroy_write_struct( &m_png, info ); + throw Error( "failed to create png info structs" ); + } + } + + ~PngWriteStruct() + { + png_destroy_write_struct( &m_png, &m_info ); + } + + png_structp GetPng() const { return m_png; } + png_infop GetInfo() const { return m_info; } + +private: + png_structp m_png; + png_infop m_info; +}; + +//! PNG rows object. +class PngRows : NonCopyable +{ +public: + PngRows( int pitch, int height ) : m_height( height ) + { + m_rows = new png_bytep[m_height]; + for( int i = 0; i < m_height; ++i ) + m_rows[i] = new png_byte[pitch]; + } + + ~PngRows() + { + for( int i = 0; i < m_height; ++i ) + delete[] m_rows[i]; + delete[] m_rows; + } + + png_bytep* Get() const { return m_rows; } + + png_bytep operator[](int y) const { return m_rows[y]; } + +private: + png_bytep* m_rows; + int m_height; +}; + +//! Represents a DXT compressed image in memory. +struct DxtData +{ + int width; + int height; + int format; //!< Either kDxt1, kDxt3 or kDxt5. + Mem data; + bool isColour; + bool isAlpha; +}; + +//! Represents an uncompressed RGBA image in memory. +class Image +{ +public: + Image(); + + void LoadPng( std::string const& fileName ); + void SavePng( std::string const& fileName ) const; + + void Decompress( DxtData const& dxt ); + void Compress( DxtData& dxt, int flags ) const; + + double GetRmsError( Image const& image ) const; + +private: + int m_width; + int m_height; + bool m_isColour; //!< Either colour or luminance. + bool m_isAlpha; //!< Either alpha or not. + Mem m_pixels; +}; + +Image::Image() + : m_width( 0 ), + m_height( 0 ), + m_isColour( false ), + m_isAlpha( false ) +{ +} + +void Image::LoadPng( std::string const& fileName ) +{ + // open the source file + File file( fopen( fileName.c_str(), "rb" ) ); + if( !file.IsValid() ) + { + std::ostringstream oss; + oss << "failed to open \"" << fileName << "\" for reading"; + throw Error( oss.str() ); + } + + // check the signature bytes + png_byte header[8]; + size_t check = fread( header, 1, 8, file.Get() ); + if( check != 8 ) + throw Error( "file read error" ); + if( png_sig_cmp( header, 0, 8 ) ) + { + std::ostringstream oss; + oss << "\"" << fileName << "\" does not look like a png file"; + throw Error( oss.str() ); + } + + // read the image into memory + PngReadStruct png; + png_init_io( png.GetPng(), file.Get() ); + png_set_sig_bytes( png.GetPng(), 8 ); + png_read_png( png.GetPng(), png.GetInfo(), PNG_TRANSFORM_EXPAND, 0 ); + + // get the image info + png_uint_32 width; + png_uint_32 height; + int bitDepth; + int colourType; + png_get_IHDR( png.GetPng(), png.GetInfo(), &width, &height, &bitDepth, &colourType, 0, 0, 0 ); + + // check the image is 8 bit + if( bitDepth != 8 ) + { + std::ostringstream oss; + oss << "cannot process " << bitDepth << "-bit image (bit depth must be 8)"; + throw Error( oss.str() ); + } + + // copy the data into a contiguous array + m_width = width; + m_height = height; + m_isColour = ( ( colourType & PNG_COLOR_MASK_COLOR ) != 0 ); + m_isAlpha = ( ( colourType & PNG_COLOR_MASK_ALPHA ) != 0 ); + m_pixels.Reset(4*width*height); + + // get the image rows + png_bytep const *rows = png_get_rows( png.GetPng(), png.GetInfo() ); + if( !rows ) + throw Error( "failed to get image rows" ); + + // copy the pixels into the storage + u8 *dest = m_pixels.Get(); + for( int y = 0; y < m_height; ++y ) + { + u8 const *src = rows[y]; + for( int x = 0; x < m_width; ++x ) + { + if( m_isColour ) + { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + src += 3; + } + else + { + u8 lum = *src++; + dest[0] = lum; + dest[1] = lum; + dest[2] = lum; + } + + if( m_isAlpha ) + dest[3] = *src++; + else + dest[3] = 255; + + dest += 4; + } + } +} + +void Image::SavePng( std::string const& fileName ) const +{ + // create the target rows + int const pixelSize = ( m_isColour ? 3 : 1 ) + ( m_isAlpha ? 1 : 0 ); + PngRows rows( m_width*pixelSize, m_height ); + + // fill the rows with pixel data + u8 const *src = m_pixels.Get(); + for( int y = 0; y < m_height; ++y ) + { + u8 *dest = rows[y]; + for( int x = 0; x < m_width; ++x ) + { + if( m_isColour ) + { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; + dest += 3; + } + else + *dest++ = src[1]; + + if( m_isAlpha ) + *dest++ = src[3]; + + src += 4; + } + } + + // set up the image + PngWriteStruct png; + png_set_IHDR( + png.GetPng(), png.GetInfo(), m_width, m_height, + 8, ( m_isColour ? PNG_COLOR_MASK_COLOR : 0) | ( m_isAlpha ? PNG_COLOR_MASK_ALPHA : 0 ), + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT + ); + + // open the target file + File file( fopen( fileName.c_str(), "wb" ) ); + if( !file.IsValid() ) + { + std::ostringstream oss; + oss << "failed to open \"" << fileName << "\" for writing"; + throw Error( oss.str() ); + } + + // write the image + png_set_rows( png.GetPng(), png.GetInfo(), rows.Get() ); + png_init_io( png.GetPng(), file.Get() ); + png_write_png( png.GetPng(), png.GetInfo(), PNG_TRANSFORM_IDENTITY, 0 ); +} + +void Image::Decompress( DxtData const& dxt ) +{ + // allocate storage + m_width = dxt.width; + m_height = dxt.height; + m_isColour = dxt.isColour; + m_isAlpha = dxt.isAlpha; + m_pixels.Reset( 4*m_width*m_height ); + + // use the whole image decompression function to do the work + DecompressImage( m_pixels.Get(), m_width, m_height, dxt.data.Get(), dxt.format ); +} + +void Image::Compress( DxtData& dxt, int flags ) const +{ + // work out how much memory we need + int storageSize = GetStorageRequirements( m_width, m_height, flags ); + + // set the structure fields and allocate it + dxt.width = m_width; + dxt.height = m_height; + dxt.format = flags & ( kDxt1 | kDxt3 | kDxt5 ); + dxt.isColour = m_isColour; + dxt.isAlpha = m_isAlpha; + dxt.data.Reset( storageSize ); + + // use the whole image compression function to do the work + CompressImage( m_pixels.Get(), m_width, m_height, dxt.data.Get(), flags ); +} + +double Image::GetRmsError( Image const& image ) const +{ + if( m_width != image.m_width || m_height != image.m_height ) + throw Error( "image dimensions mismatch when computing RMS error" ); + + // accumulate colour error + double difference = 0; + u8 const *a = m_pixels.Get(); + u8 const *b = image.m_pixels.Get(); + for( int y = 0; y < m_height; ++y ) + { + for( int x = 0; x < m_width; ++x ) + { + int d0 = ( int )a[0] - ( int )b[0]; + int d1 = ( int )a[1] - ( int )b[1]; + int d2 = ( int )a[2] - ( int )b[2]; + difference += ( double )( d0*d0 + d1*d1 + d2*d2 ); + a += 4; + b += 4; + } + } + return std::sqrt( difference/( double )( m_width*m_height ) ); +} + +int main( int argc, char* argv[] ) +{ + try + { + // parse the command-line + std::string sourceFileName; + std::string targetFileName; + int format = kDxt1; + int fit = kColourClusterFit; + int extra = 0; + bool help = false; + bool arguments = true; + bool error = false; + for( int i = 1; i < argc; ++i ) + { + // check for options + char const* word = argv[i]; + if( arguments && word[0] == '-' ) + { + for( int j = 1; word[j] != '\0'; ++j ) + { + switch( word[j] ) + { + case 'h': help = true; break; + case '1': format = kDxt1; break; + case '3': format = kDxt3; break; + case '5': format = kDxt5; break; + case 'r': fit = kColourRangeFit; break; + case 'i': fit = kColourIterativeClusterFit; break; + case 'w': extra = kWeightColourByAlpha; break; + case '-': arguments = false; break; + default: + std::cerr << "squishpng error: unknown option '" << word[j] << "'" << std::endl; + error = true; + } + } + } + else + { + if( sourceFileName.empty() ) + sourceFileName.assign( word ); + else if( targetFileName.empty() ) + targetFileName.assign( word ); + else + { + std::cerr << "squishpng error: unexpected argument \"" << word << "\"" << std::endl; + error = true; + } + } + } + + // check arguments + if( sourceFileName.empty() ) + { + std::cerr << "squishpng error: no source file given" << std::endl; + error = true; + } + if( help || error ) + { + std::cout + << "SYNTAX" << std::endl + << "\tsquishpng [-135riw] []" << std::endl + << "OPTIONS" << std::endl + << "\t-h\tPrint this help message" << std::endl + << "\t-135\tSpecifies whether to use DXT1 (default), DXT3 or DXT5 compression" << std::endl + << "\t-r\tUse the fast but inferior range-based colour compressor" << std::endl + << "\t-i\tUse the very slow but slightly better iterative colour compressor" << std::endl + << "\t-w\tWeight colour values by alpha in the cluster colour compressor" << std::endl + ; + + return error ? -1 : 0; + } + + // load the source image + Image sourceImage; + sourceImage.LoadPng( sourceFileName ); + + // compress to DXT + DxtData dxt; + sourceImage.Compress( dxt, format | fit | extra ); + + // decompress back + Image targetImage; + targetImage.Decompress( dxt ); + + // compare the images + double rmsError = sourceImage.GetRmsError( targetImage ); + std::cout << sourceFileName << " " << rmsError << std::endl; + + // save the target image if necessary + if( !targetFileName.empty() ) + targetImage.SavePng( targetFileName ); + } + catch( std::exception& excuse ) + { + // complain + std::cerr << "squishpng error: " << excuse.what() << std::endl; + return -1; + } + + // done + return 0; +} diff --git a/extern/libsquish-1.15/extra/squishtest.cpp b/extern/libsquish-1.15/extra/squishtest.cpp new file mode 100644 index 00000000..e4362fe2 --- /dev/null +++ b/extern/libsquish-1.15/extra/squishtest.cpp @@ -0,0 +1,206 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +/*! @file + + @brief This program tests the error for 1 and 2-colour DXT compression. + + This tests the effectiveness of the DXT compression algorithm for all + possible 1 and 2-colour blocks of pixels. +*/ + +#include +#include +#include +#include +#include + +using namespace squish; + +double GetColourError( u8 const* a, u8 const* b ) +{ + double error = 0.0; + for( int i = 0; i < 16; ++i ) + { + for( int j = 0; j < 3; ++j ) + { + int index = 4*i + j; + int diff = ( int )a[index] - ( int )b[index]; + error += ( double )( diff*diff ); + } + } + return error / 16.0; +} + +void TestOneColour( int flags ) +{ + u8 input[4*16]; + u8 output[4*16]; + u8 block[16]; + + double avg = 0.0, min = DBL_MAX, max = -DBL_MAX; + int counter = 0; + + // test all single-channel colours + for( int i = 0; i < 16*4; ++i ) + input[i] = ( ( i % 4 ) == 3 ) ? 255 : 0; + for( int channel = 0; channel < 3; ++channel ) + { + for( int value = 0; value < 255; ++value ) + { + // set the channnel value + for( int i = 0; i < 16; ++i ) + input[4*i + channel] = ( u8 )value; + + // compress and decompress + Compress( input, block, flags ); + Decompress( output, block, flags ); + + // test the results + double rm = GetColourError( input, output ); + double rms = std::sqrt( rm ); + + // accumulate stats + min = std::min( min, rms ); + max = std::max( max, rms ); + avg += rm; + ++counter; + } + + // reset the channel value + for( int i = 0; i < 16; ++i ) + input[4*i + channel] = 0; + } + + // finish stats + avg = std::sqrt( avg/counter ); + + // show stats + std::cout << "one colour error (min, max, avg): " + << min << ", " << max << ", " << avg << std::endl; +} + +void TestOneColourRandom( int flags ) +{ + u8 input[4*16]; + u8 output[4*16]; + u8 block[16]; + + double avg = 0.0, min = DBL_MAX, max = -DBL_MAX; + int counter = 0; + + // test all single-channel colours + for( int test = 0; test < 1000; ++test ) + { + // set a constant random colour + for( int channel = 0; channel < 3; ++channel ) + { + u8 value = ( u8 )( rand() & 0xff ); + for( int i = 0; i < 16; ++i ) + input[4*i + channel] = value; + } + for( int i = 0; i < 16; ++i ) + input[4*i + 3] = 255; + + // compress and decompress + Compress( input, block, flags ); + Decompress( output, block, flags ); + + // test the results + double rm = GetColourError( input, output ); + double rms = std::sqrt( rm ); + + // accumulate stats + min = std::min( min, rms ); + max = std::max( max, rms ); + avg += rm; + ++counter; + } + + // finish stats + avg = std::sqrt( avg/counter ); + + // show stats + std::cout << "random one colour error (min, max, avg): " + << min << ", " << max << ", " << avg << std::endl; +} + +void TestTwoColour( int flags ) +{ + u8 input[4*16]; + u8 output[4*16]; + u8 block[16]; + + double avg = 0.0, min = DBL_MAX, max = -DBL_MAX; + int counter = 0; + + // test all single-channel colours + for( int i = 0; i < 16*4; ++i ) + input[i] = ( ( i % 4 ) == 3 ) ? 255 : 0; + for( int channel = 0; channel < 3; ++channel ) + { + for( int value1 = 0; value1 < 255; ++value1 ) + { + for( int value2 = value1 + 1; value2 < 255; ++value2 ) + { + // set the channnel value + for( int i = 0; i < 16; ++i ) + input[4*i + channel] = ( u8 )( ( i < 8 ) ? value1 : value2 ); + + // compress and decompress + Compress( input, block, flags ); + Decompress( output, block, flags ); + + // test the results + double rm = GetColourError( input, output ); + double rms = std::sqrt( rm ); + + // accumulate stats + min = std::min( min, rms ); + max = std::max( max, rms ); + avg += rm; + ++counter; + } + } + + // reset the channel value + for( int i = 0; i < 16; ++i ) + input[4*i + channel] = 0; + } + + // finish stats + avg = std::sqrt( avg/counter ); + + // show stats + std::cout << "two colour error (min, max, avg): " + << min << ", " << max << ", " << avg << std::endl; +} + +int main() +{ + TestOneColourRandom( kDxt1 | kColourRangeFit ); + TestOneColour( kDxt1 ); + TestTwoColour( kDxt1 ); +} diff --git a/extern/libsquish-1.15/libSquish.png b/extern/libsquish-1.15/libSquish.png new file mode 100644 index 00000000..7f37a4e0 Binary files /dev/null and b/extern/libsquish-1.15/libSquish.png differ diff --git a/extern/libsquish-1.15/libSquish.pri b/extern/libsquish-1.15/libSquish.pri new file mode 100644 index 00000000..0313db0d --- /dev/null +++ b/extern/libsquish-1.15/libSquish.pri @@ -0,0 +1,26 @@ +HEADERS += \ + squish.h + +SOURCES += \ + alpha.cpp \ + alpha.h \ + clusterfit.cpp \ + clusterfit.h \ + colourblock.cpp \ + colourblock.h \ + colourfit.cpp \ + colourfit.h \ + colourset.cpp \ + colourset.h \ + maths.cpp \ + maths.h \ + rangefit.cpp \ + rangefit.h \ + simd.h \ + simd_float.h \ + simd_sse.h \ + simd_ve.h \ + singlecolourfit.cpp \ + singlecolourfit.h \ + singlecolourlookup.inl \ + squish.cpp diff --git a/extern/libsquish-1.15/libSquish.pro b/extern/libsquish-1.15/libSquish.pro new file mode 100644 index 00000000..054faa25 --- /dev/null +++ b/extern/libsquish-1.15/libSquish.pro @@ -0,0 +1,32 @@ +TARGET = squish +TEMPLATE = lib + +include(libSquish.pri) + +QT -= gui + +CONFIG += staticlib thread +CONFIG += debug_and_release + +CONFIG(debug, debug|release) { + unix:TARGET = $$join(TARGET,,,_debug) +} + +MOC_DIR = mocs +OBJECTS_DIR = objs +RCC_DIR = rccs +UI_DIR = uics + +CONFIG(debug, debug|release) { + unix:MOC_DIR = $$join(MOC_DIR,,,_debug) + unix:OBJECTS_DIR = $$join(OBJECTS_DIR,,,_debug) + unix:RCC_DIR = $$join(RCC_DIR,,,_debug) + unix:UI_DIR = $$join(UI_DIR,,,_debug) + win32:MOC_DIR = $$join(MOC_DIR,,,d) + win32:OBJECTS_DIR = $$join(OBJECTS_DIR,,,d) + win32:RCC_DIR = $$join(RCC_DIR,,,d) + win32:UI_DIR = $$join(UI_DIR,,,d) +} + +unix:QMAKE_CXXFLAGS += -DSQUISH_USE_OPENMP -fopenmp + diff --git a/extern/libsquish-1.15/libSquish.svg b/extern/libsquish-1.15/libSquish.svg new file mode 100644 index 00000000..efdcee7d --- /dev/null +++ b/extern/libsquish-1.15/libSquish.svg @@ -0,0 +1,238 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lib + + + + + Squish + + diff --git a/extern/libsquish-1.15/libsquish.pc.in b/extern/libsquish-1.15/libsquish.pc.in new file mode 100644 index 00000000..d3b95bd8 --- /dev/null +++ b/extern/libsquish-1.15/libsquish.pc.in @@ -0,0 +1,13 @@ +prefix=@PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/@LIB_PATH@ +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: libsquish +Description: squish DXT library +Version: 1.14 + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -llibsquish +Cflags: -I${includedir} diff --git a/extern/libsquish-1.15/maths.cpp b/extern/libsquish-1.15/maths.cpp new file mode 100644 index 00000000..4fa0bcfb --- /dev/null +++ b/extern/libsquish-1.15/maths.cpp @@ -0,0 +1,259 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +/*! @file + + The symmetric eigensystem solver algorithm is from + http://www.geometrictools.com/Documentation/EigenSymmetric3x3.pdf +*/ + +#include "maths.h" +#include "simd.h" +#include + +namespace squish { + +Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights ) +{ + // compute the centroid + float total = 0.0f; + Vec3 centroid( 0.0f ); + for( int i = 0; i < n; ++i ) + { + total += weights[i]; + centroid += weights[i]*points[i]; + } + if( total > FLT_EPSILON ) + centroid /= total; + + // accumulate the covariance matrix + Sym3x3 covariance( 0.0f ); + for( int i = 0; i < n; ++i ) + { + Vec3 a = points[i] - centroid; + Vec3 b = weights[i]*a; + + covariance[0] += a.X()*b.X(); + covariance[1] += a.X()*b.Y(); + covariance[2] += a.X()*b.Z(); + covariance[3] += a.Y()*b.Y(); + covariance[4] += a.Y()*b.Z(); + covariance[5] += a.Z()*b.Z(); + } + + // return it + return covariance; +} + +#if 0 + +static Vec3 GetMultiplicity1Evector( Sym3x3 const& matrix, float evalue ) +{ + // compute M + Sym3x3 m; + m[0] = matrix[0] - evalue; + m[1] = matrix[1]; + m[2] = matrix[2]; + m[3] = matrix[3] - evalue; + m[4] = matrix[4]; + m[5] = matrix[5] - evalue; + + // compute U + Sym3x3 u; + u[0] = m[3]*m[5] - m[4]*m[4]; + u[1] = m[2]*m[4] - m[1]*m[5]; + u[2] = m[1]*m[4] - m[2]*m[3]; + u[3] = m[0]*m[5] - m[2]*m[2]; + u[4] = m[1]*m[2] - m[4]*m[0]; + u[5] = m[0]*m[3] - m[1]*m[1]; + + // find the largest component + float mc = std::fabs( u[0] ); + int mi = 0; + for( int i = 1; i < 6; ++i ) + { + float c = std::fabs( u[i] ); + if( c > mc ) + { + mc = c; + mi = i; + } + } + + // pick the column with this component + switch( mi ) + { + case 0: + return Vec3( u[0], u[1], u[2] ); + + case 1: + case 3: + return Vec3( u[1], u[3], u[4] ); + + default: + return Vec3( u[2], u[4], u[5] ); + } +} + +static Vec3 GetMultiplicity2Evector( Sym3x3 const& matrix, float evalue ) +{ + // compute M + Sym3x3 m; + m[0] = matrix[0] - evalue; + m[1] = matrix[1]; + m[2] = matrix[2]; + m[3] = matrix[3] - evalue; + m[4] = matrix[4]; + m[5] = matrix[5] - evalue; + + // find the largest component + float mc = std::fabs( m[0] ); + int mi = 0; + for( int i = 1; i < 6; ++i ) + { + float c = std::fabs( m[i] ); + if( c > mc ) + { + mc = c; + mi = i; + } + } + + // pick the first eigenvector based on this index + switch( mi ) + { + case 0: + case 1: + return Vec3( -m[1], m[0], 0.0f ); + + case 2: + return Vec3( m[2], 0.0f, -m[0] ); + + case 3: + case 4: + return Vec3( 0.0f, -m[4], m[3] ); + + default: + return Vec3( 0.0f, -m[5], m[4] ); + } +} + +Vec3 ComputePrincipleComponent( Sym3x3 const& matrix ) +{ + // compute the cubic coefficients + float c0 = matrix[0]*matrix[3]*matrix[5] + + 2.0f*matrix[1]*matrix[2]*matrix[4] + - matrix[0]*matrix[4]*matrix[4] + - matrix[3]*matrix[2]*matrix[2] + - matrix[5]*matrix[1]*matrix[1]; + float c1 = matrix[0]*matrix[3] + matrix[0]*matrix[5] + matrix[3]*matrix[5] + - matrix[1]*matrix[1] - matrix[2]*matrix[2] - matrix[4]*matrix[4]; + float c2 = matrix[0] + matrix[3] + matrix[5]; + + // compute the quadratic coefficients + float a = c1 - ( 1.0f/3.0f )*c2*c2; + float b = ( -2.0f/27.0f )*c2*c2*c2 + ( 1.0f/3.0f )*c1*c2 - c0; + + // compute the root count check + float Q = 0.25f*b*b + ( 1.0f/27.0f )*a*a*a; + + // test the multiplicity + if( FLT_EPSILON < Q ) + { + // only one root, which implies we have a multiple of the identity + return Vec3( 1.0f ); + } + else if( Q < -FLT_EPSILON ) + { + // three distinct roots + float theta = std::atan2( std::sqrt( -Q ), -0.5f*b ); + float rho = std::sqrt( 0.25f*b*b - Q ); + + float rt = std::pow( rho, 1.0f/3.0f ); + float ct = std::cos( theta/3.0f ); + float st = std::sin( theta/3.0f ); + + float l1 = ( 1.0f/3.0f )*c2 + 2.0f*rt*ct; + float l2 = ( 1.0f/3.0f )*c2 - rt*( ct + ( float )sqrt( 3.0f )*st ); + float l3 = ( 1.0f/3.0f )*c2 - rt*( ct - ( float )sqrt( 3.0f )*st ); + + // pick the larger + if( std::fabs( l2 ) > std::fabs( l1 ) ) + l1 = l2; + if( std::fabs( l3 ) > std::fabs( l1 ) ) + l1 = l3; + + // get the eigenvector + return GetMultiplicity1Evector( matrix, l1 ); + } + else // if( -FLT_EPSILON <= Q && Q <= FLT_EPSILON ) + { + // two roots + float rt; + if( b < 0.0f ) + rt = -std::pow( -0.5f*b, 1.0f/3.0f ); + else + rt = std::pow( 0.5f*b, 1.0f/3.0f ); + + float l1 = ( 1.0f/3.0f )*c2 + rt; // repeated + float l2 = ( 1.0f/3.0f )*c2 - 2.0f*rt; + + // get the eigenvector + if( std::fabs( l1 ) > std::fabs( l2 ) ) + return GetMultiplicity2Evector( matrix, l1 ); + else + return GetMultiplicity1Evector( matrix, l2 ); + } +} + +#else + +#define POWER_ITERATION_COUNT 8 + +Vec3 ComputePrincipleComponent( Sym3x3 const& matrix ) +{ + Vec4 const row0( matrix[0], matrix[1], matrix[2], 0.0f ); + Vec4 const row1( matrix[1], matrix[3], matrix[4], 0.0f ); + Vec4 const row2( matrix[2], matrix[4], matrix[5], 0.0f ); + Vec4 v = VEC4_CONST( 1.0f ); + for( int i = 0; i < POWER_ITERATION_COUNT; ++i ) + { + // matrix multiply + Vec4 w = row0*v.SplatX(); + w = MultiplyAdd(row1, v.SplatY(), w); + w = MultiplyAdd(row2, v.SplatZ(), w); + + // get max component from xyz in all channels + Vec4 a = Max(w.SplatX(), Max(w.SplatY(), w.SplatZ())); + + // divide through and advance + v = w*Reciprocal(a); + } + return v.GetVec3(); +} + +#endif + +} // namespace squish diff --git a/extern/libsquish-1.15/maths.h b/extern/libsquish-1.15/maths.h new file mode 100644 index 00000000..59c32196 --- /dev/null +++ b/extern/libsquish-1.15/maths.h @@ -0,0 +1,233 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_MATHS_H +#define SQUISH_MATHS_H + +#include +#include +#include "config.h" + +namespace squish { + +class Vec3 +{ +public: + typedef Vec3 const& Arg; + + Vec3() + { + } + + explicit Vec3( float s ) + { + m_x = s; + m_y = s; + m_z = s; + } + + Vec3( float x, float y, float z ) + { + m_x = x; + m_y = y; + m_z = z; + } + + float X() const { return m_x; } + float Y() const { return m_y; } + float Z() const { return m_z; } + + Vec3 operator-() const + { + return Vec3( -m_x, -m_y, -m_z ); + } + + Vec3& operator+=( Arg v ) + { + m_x += v.m_x; + m_y += v.m_y; + m_z += v.m_z; + return *this; + } + + Vec3& operator-=( Arg v ) + { + m_x -= v.m_x; + m_y -= v.m_y; + m_z -= v.m_z; + return *this; + } + + Vec3& operator*=( Arg v ) + { + m_x *= v.m_x; + m_y *= v.m_y; + m_z *= v.m_z; + return *this; + } + + Vec3& operator*=( float s ) + { + m_x *= s; + m_y *= s; + m_z *= s; + return *this; + } + + Vec3& operator/=( Arg v ) + { + m_x /= v.m_x; + m_y /= v.m_y; + m_z /= v.m_z; + return *this; + } + + Vec3& operator/=( float s ) + { + float t = 1.0f/s; + m_x *= t; + m_y *= t; + m_z *= t; + return *this; + } + + friend Vec3 operator+( Arg left, Arg right ) + { + Vec3 copy( left ); + return copy += right; + } + + friend Vec3 operator-( Arg left, Arg right ) + { + Vec3 copy( left ); + return copy -= right; + } + + friend Vec3 operator*( Arg left, Arg right ) + { + Vec3 copy( left ); + return copy *= right; + } + + friend Vec3 operator*( Arg left, float right ) + { + Vec3 copy( left ); + return copy *= right; + } + + friend Vec3 operator*( float left, Arg right ) + { + Vec3 copy( right ); + return copy *= left; + } + + friend Vec3 operator/( Arg left, Arg right ) + { + Vec3 copy( left ); + return copy /= right; + } + + friend Vec3 operator/( Arg left, float right ) + { + Vec3 copy( left ); + return copy /= right; + } + + friend float Dot( Arg left, Arg right ) + { + return left.m_x*right.m_x + left.m_y*right.m_y + left.m_z*right.m_z; + } + + friend Vec3 Min( Arg left, Arg right ) + { + return Vec3( + std::min( left.m_x, right.m_x ), + std::min( left.m_y, right.m_y ), + std::min( left.m_z, right.m_z ) + ); + } + + friend Vec3 Max( Arg left, Arg right ) + { + return Vec3( + std::max( left.m_x, right.m_x ), + std::max( left.m_y, right.m_y ), + std::max( left.m_z, right.m_z ) + ); + } + + friend Vec3 Truncate( Arg v ) + { + return Vec3( + v.m_x > 0.0f ? std::floor( v.m_x ) : std::ceil( v.m_x ), + v.m_y > 0.0f ? std::floor( v.m_y ) : std::ceil( v.m_y ), + v.m_z > 0.0f ? std::floor( v.m_z ) : std::ceil( v.m_z ) + ); + } + +private: + float m_x; + float m_y; + float m_z; +}; + +inline float LengthSquared( Vec3::Arg v ) +{ + return Dot( v, v ); +} + +class Sym3x3 +{ +public: + Sym3x3() + { + } + + Sym3x3( float s ) + { + for( int i = 0; i < 6; ++i ) + m_x[i] = s; + } + + float operator[]( int index ) const + { + return m_x[index]; + } + + float& operator[]( int index ) + { + return m_x[index]; + } + +private: + float m_x[6]; +}; + +Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights ); +Vec3 ComputePrincipleComponent( Sym3x3 const& matrix ); + +} // namespace squish + +#endif // ndef SQUISH_MATHS_H diff --git a/extern/libsquish-1.15/rangefit.cpp b/extern/libsquish-1.15/rangefit.cpp new file mode 100644 index 00000000..adc07ed7 --- /dev/null +++ b/extern/libsquish-1.15/rangefit.cpp @@ -0,0 +1,201 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "rangefit.h" +#include "colourset.h" +#include "colourblock.h" +#include + +namespace squish { + +RangeFit::RangeFit( ColourSet const* colours, int flags, float* metric ) + : ColourFit( colours, flags ) +{ + // initialise the metric (old perceptual = 0.2126f, 0.7152f, 0.0722f) + if( metric ) + m_metric = Vec3( metric[0], metric[1], metric[2] ); + else + m_metric = Vec3( 1.0f ); + + // initialise the best error + m_besterror = FLT_MAX; + + // cache some values + int const count = m_colours->GetCount(); + Vec3 const* values = m_colours->GetPoints(); + float const* weights = m_colours->GetWeights(); + + // get the covariance matrix + Sym3x3 covariance = ComputeWeightedCovariance( count, values, weights ); + + // compute the principle component + Vec3 principle = ComputePrincipleComponent( covariance ); + + // get the min and max range as the codebook endpoints + Vec3 start( 0.0f ); + Vec3 end( 0.0f ); + if( count > 0 ) + { + float min, max; + + // compute the range + start = end = values[0]; + min = max = Dot( values[0], principle ); + for( int i = 1; i < count; ++i ) + { + float val = Dot( values[i], principle ); + if( val < min ) + { + start = values[i]; + min = val; + } + else if( val > max ) + { + end = values[i]; + max = val; + } + } + } + + // clamp the output to [0, 1] + Vec3 const one( 1.0f ); + Vec3 const zero( 0.0f ); + start = Min( one, Max( zero, start ) ); + end = Min( one, Max( zero, end ) ); + + // clamp to the grid and save + Vec3 const grid( 31.0f, 63.0f, 31.0f ); + Vec3 const gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f ); + Vec3 const half( 0.5f ); + m_start = Truncate( grid*start + half )*gridrcp; + m_end = Truncate( grid*end + half )*gridrcp; +} + +void RangeFit::Compress3( void* block ) +{ + // cache some values + int const count = m_colours->GetCount(); + Vec3 const* values = m_colours->GetPoints(); + + // create a codebook + Vec3 codes[3]; + codes[0] = m_start; + codes[1] = m_end; + codes[2] = 0.5f*m_start + 0.5f*m_end; + + // match each point to the closest code + u8 closest[16]; + float error = 0.0f; + for( int i = 0; i < count; ++i ) + { + // find the closest code + float dist = FLT_MAX; + int idx = 0; + for( int j = 0; j < 3; ++j ) + { + float d = LengthSquared( m_metric*( values[i] - codes[j] ) ); + if( d < dist ) + { + dist = d; + idx = j; + } + } + + // save the index + closest[i] = ( u8 )idx; + + // accumulate the error + error += dist; + } + + // save this scheme if it wins + if( error < m_besterror ) + { + // remap the indices + u8 indices[16]; + m_colours->RemapIndices( closest, indices ); + + // save the block + WriteColourBlock3( m_start, m_end, indices, block ); + + // save the error + m_besterror = error; + } +} + +void RangeFit::Compress4( void* block ) +{ + // cache some values + int const count = m_colours->GetCount(); + Vec3 const* values = m_colours->GetPoints(); + + // create a codebook + Vec3 codes[4]; + codes[0] = m_start; + codes[1] = m_end; + codes[2] = ( 2.0f/3.0f )*m_start + ( 1.0f/3.0f )*m_end; + codes[3] = ( 1.0f/3.0f )*m_start + ( 2.0f/3.0f )*m_end; + + // match each point to the closest code + u8 closest[16]; + float error = 0.0f; + for( int i = 0; i < count; ++i ) + { + // find the closest code + float dist = FLT_MAX; + int idx = 0; + for( int j = 0; j < 4; ++j ) + { + float d = LengthSquared( m_metric*( values[i] - codes[j] ) ); + if( d < dist ) + { + dist = d; + idx = j; + } + } + + // save the index + closest[i] = ( u8 )idx; + + // accumulate the error + error += dist; + } + + // save this scheme if it wins + if( error < m_besterror ) + { + // remap the indices + u8 indices[16]; + m_colours->RemapIndices( closest, indices ); + + // save the block + WriteColourBlock4( m_start, m_end, indices, block ); + + // save the error + m_besterror = error; + } +} + +} // namespace squish diff --git a/extern/libsquish-1.15/rangefit.h b/extern/libsquish-1.15/rangefit.h new file mode 100644 index 00000000..bdb21a90 --- /dev/null +++ b/extern/libsquish-1.15/rangefit.h @@ -0,0 +1,54 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_RANGEFIT_H +#define SQUISH_RANGEFIT_H + +#include "squish.h" +#include "colourfit.h" +#include "maths.h" + +namespace squish { + +class ColourSet; + +class RangeFit : public ColourFit +{ +public: + RangeFit( ColourSet const* colours, int flags, float* metric ); + +private: + virtual void Compress3( void* block ); + virtual void Compress4( void* block ); + + Vec3 m_metric; + Vec3 m_start; + Vec3 m_end; + float m_besterror; +}; + +} // squish + +#endif // ndef SQUISH_RANGEFIT_H diff --git a/extern/libsquish-1.15/simd.h b/extern/libsquish-1.15/simd.h new file mode 100644 index 00000000..1e02fa16 --- /dev/null +++ b/extern/libsquish-1.15/simd.h @@ -0,0 +1,40 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_SIMD_H +#define SQUISH_SIMD_H + +#include "maths.h" + +#if SQUISH_USE_ALTIVEC +#include "simd_ve.h" +#elif SQUISH_USE_SSE +#include "simd_sse.h" +#else +#include "simd_float.h" +#endif + + +#endif // ndef SQUISH_SIMD_H diff --git a/extern/libsquish-1.15/simd_float.h b/extern/libsquish-1.15/simd_float.h new file mode 100644 index 00000000..030ea709 --- /dev/null +++ b/extern/libsquish-1.15/simd_float.h @@ -0,0 +1,183 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_SIMD_FLOAT_H +#define SQUISH_SIMD_FLOAT_H + +#include + +namespace squish { + +#define VEC4_CONST( X ) Vec4( X ) + +class Vec4 +{ +public: + typedef Vec4 const& Arg; + + Vec4() {} + + explicit Vec4( float s ) + : m_x( s ), + m_y( s ), + m_z( s ), + m_w( s ) + { + } + + Vec4( float x, float y, float z, float w ) + : m_x( x ), + m_y( y ), + m_z( z ), + m_w( w ) + { + } + + Vec3 GetVec3() const + { + return Vec3( m_x, m_y, m_z ); + } + + Vec4 SplatX() const { return Vec4( m_x ); } + Vec4 SplatY() const { return Vec4( m_y ); } + Vec4 SplatZ() const { return Vec4( m_z ); } + Vec4 SplatW() const { return Vec4( m_w ); } + + Vec4& operator+=( Arg v ) + { + m_x += v.m_x; + m_y += v.m_y; + m_z += v.m_z; + m_w += v.m_w; + return *this; + } + + Vec4& operator-=( Arg v ) + { + m_x -= v.m_x; + m_y -= v.m_y; + m_z -= v.m_z; + m_w -= v.m_w; + return *this; + } + + Vec4& operator*=( Arg v ) + { + m_x *= v.m_x; + m_y *= v.m_y; + m_z *= v.m_z; + m_w *= v.m_w; + return *this; + } + + friend Vec4 operator+( Vec4::Arg left, Vec4::Arg right ) + { + Vec4 copy( left ); + return copy += right; + } + + friend Vec4 operator-( Vec4::Arg left, Vec4::Arg right ) + { + Vec4 copy( left ); + return copy -= right; + } + + friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right ) + { + Vec4 copy( left ); + return copy *= right; + } + + //! Returns a*b + c + friend Vec4 MultiplyAdd( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) + { + return a*b + c; + } + + //! Returns -( a*b - c ) + friend Vec4 NegativeMultiplySubtract( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) + { + return c - a*b; + } + + friend Vec4 Reciprocal( Vec4::Arg v ) + { + return Vec4( + 1.0f/v.m_x, + 1.0f/v.m_y, + 1.0f/v.m_z, + 1.0f/v.m_w + ); + } + + friend Vec4 Min( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( + std::min( left.m_x, right.m_x ), + std::min( left.m_y, right.m_y ), + std::min( left.m_z, right.m_z ), + std::min( left.m_w, right.m_w ) + ); + } + + friend Vec4 Max( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( + std::max( left.m_x, right.m_x ), + std::max( left.m_y, right.m_y ), + std::max( left.m_z, right.m_z ), + std::max( left.m_w, right.m_w ) + ); + } + + friend Vec4 Truncate( Vec4::Arg v ) + { + return Vec4( + v.m_x > 0.0f ? std::floor( v.m_x ) : std::ceil( v.m_x ), + v.m_y > 0.0f ? std::floor( v.m_y ) : std::ceil( v.m_y ), + v.m_z > 0.0f ? std::floor( v.m_z ) : std::ceil( v.m_z ), + v.m_w > 0.0f ? std::floor( v.m_w ) : std::ceil( v.m_w ) + ); + } + + friend bool CompareAnyLessThan( Vec4::Arg left, Vec4::Arg right ) + { + return left.m_x < right.m_x + || left.m_y < right.m_y + || left.m_z < right.m_z + || left.m_w < right.m_w; + } + +private: + float m_x; + float m_y; + float m_z; + float m_w; +}; + +} // namespace squish + +#endif // ndef SQUISH_SIMD_FLOAT_H + diff --git a/extern/libsquish-1.15/simd_sse.h b/extern/libsquish-1.15/simd_sse.h new file mode 100644 index 00000000..2e8be4ca --- /dev/null +++ b/extern/libsquish-1.15/simd_sse.h @@ -0,0 +1,180 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_SIMD_SSE_H +#define SQUISH_SIMD_SSE_H + +#include +#if ( SQUISH_USE_SSE > 1 ) +#include +#endif + +#define SQUISH_SSE_SPLAT( a ) \ + ( ( a ) | ( ( a ) << 2 ) | ( ( a ) << 4 ) | ( ( a ) << 6 ) ) + +#define SQUISH_SSE_SHUF( x, y, z, w ) \ + ( ( x ) | ( ( y ) << 2 ) | ( ( z ) << 4 ) | ( ( w ) << 6 ) ) + +namespace squish { + +#define VEC4_CONST( X ) Vec4( X ) + +class Vec4 +{ +public: + typedef Vec4 const& Arg; + + Vec4() {} + + explicit Vec4( __m128 v ) : m_v( v ) {} + + Vec4( Vec4 const& arg ) : m_v( arg.m_v ) {} + + Vec4& operator=( Vec4 const& arg ) + { + m_v = arg.m_v; + return *this; + } + + explicit Vec4( float s ) : m_v( _mm_set1_ps( s ) ) {} + + Vec4( float x, float y, float z, float w ) : m_v( _mm_setr_ps( x, y, z, w ) ) {} + + Vec3 GetVec3() const + { +#ifdef __GNUC__ + __attribute__ ((__aligned__ (16))) float c[4]; +#else + __declspec(align(16)) float c[4]; +#endif + _mm_store_ps( c, m_v ); + return Vec3( c[0], c[1], c[2] ); + } + + Vec4 SplatX() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 0 ) ) ); } + Vec4 SplatY() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 1 ) ) ); } + Vec4 SplatZ() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 2 ) ) ); } + Vec4 SplatW() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 3 ) ) ); } + + Vec4& operator+=( Arg v ) + { + m_v = _mm_add_ps( m_v, v.m_v ); + return *this; + } + + Vec4& operator-=( Arg v ) + { + m_v = _mm_sub_ps( m_v, v.m_v ); + return *this; + } + + Vec4& operator*=( Arg v ) + { + m_v = _mm_mul_ps( m_v, v.m_v ); + return *this; + } + + friend Vec4 operator+( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( _mm_add_ps( left.m_v, right.m_v ) ); + } + + friend Vec4 operator-( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( _mm_sub_ps( left.m_v, right.m_v ) ); + } + + friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( _mm_mul_ps( left.m_v, right.m_v ) ); + } + + //! Returns a*b + c + friend Vec4 MultiplyAdd( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) + { + return Vec4( _mm_add_ps( _mm_mul_ps( a.m_v, b.m_v ), c.m_v ) ); + } + + //! Returns -( a*b - c ) + friend Vec4 NegativeMultiplySubtract( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) + { + return Vec4( _mm_sub_ps( c.m_v, _mm_mul_ps( a.m_v, b.m_v ) ) ); + } + + friend Vec4 Reciprocal( Vec4::Arg v ) + { + // get the reciprocal estimate + __m128 estimate = _mm_rcp_ps( v.m_v ); + + // one round of Newton-Rhaphson refinement + __m128 diff = _mm_sub_ps( _mm_set1_ps( 1.0f ), _mm_mul_ps( estimate, v.m_v ) ); + return Vec4( _mm_add_ps( _mm_mul_ps( diff, estimate ), estimate ) ); + } + + friend Vec4 Min( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( _mm_min_ps( left.m_v, right.m_v ) ); + } + + friend Vec4 Max( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( _mm_max_ps( left.m_v, right.m_v ) ); + } + + friend Vec4 Truncate( Vec4::Arg v ) + { +#if ( SQUISH_USE_SSE == 1 ) + // convert to ints + __m128 input = v.m_v; + __m64 lo = _mm_cvttps_pi32( input ); + __m64 hi = _mm_cvttps_pi32( _mm_movehl_ps( input, input ) ); + + // convert to floats + __m128 part = _mm_movelh_ps( input, _mm_cvtpi32_ps( input, hi ) ); + __m128 truncated = _mm_cvtpi32_ps( part, lo ); + + // clear out the MMX multimedia state to allow FP calls later + _mm_empty(); + return Vec4( truncated ); +#else + // use SSE2 instructions + return Vec4( _mm_cvtepi32_ps( _mm_cvttps_epi32( v.m_v ) ) ); +#endif + } + + friend bool CompareAnyLessThan( Vec4::Arg left, Vec4::Arg right ) + { + __m128 bits = _mm_cmplt_ps( left.m_v, right.m_v ); + int value = _mm_movemask_ps( bits ); + return value != 0; + } + +private: + __m128 m_v; +}; + +} // namespace squish + +#endif // ndef SQUISH_SIMD_SSE_H diff --git a/extern/libsquish-1.15/simd_ve.h b/extern/libsquish-1.15/simd_ve.h new file mode 100644 index 00000000..08a15375 --- /dev/null +++ b/extern/libsquish-1.15/simd_ve.h @@ -0,0 +1,166 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_SIMD_VE_H +#define SQUISH_SIMD_VE_H + +#include +#undef bool + +namespace squish { + +#define VEC4_CONST( X ) Vec4( ( vector float ){ X } ) + +class Vec4 +{ +public: + typedef Vec4 Arg; + + Vec4() {} + + explicit Vec4( vector float v ) : m_v( v ) {} + + Vec4( Vec4 const& arg ) : m_v( arg.m_v ) {} + + Vec4& operator=( Vec4 const& arg ) + { + m_v = arg.m_v; + return *this; + } + + explicit Vec4( float s ) + { + union { vector float v; float c[4]; } u; + u.c[0] = s; + u.c[1] = s; + u.c[2] = s; + u.c[3] = s; + m_v = u.v; + } + + Vec4( float x, float y, float z, float w ) + { + union { vector float v; float c[4]; } u; + u.c[0] = x; + u.c[1] = y; + u.c[2] = z; + u.c[3] = w; + m_v = u.v; + } + + Vec3 GetVec3() const + { + union { vector float v; float c[4]; } u; + u.v = m_v; + return Vec3( u.c[0], u.c[1], u.c[2] ); + } + + Vec4 SplatX() const { return Vec4( vec_splat( m_v, 0 ) ); } + Vec4 SplatY() const { return Vec4( vec_splat( m_v, 1 ) ); } + Vec4 SplatZ() const { return Vec4( vec_splat( m_v, 2 ) ); } + Vec4 SplatW() const { return Vec4( vec_splat( m_v, 3 ) ); } + + Vec4& operator+=( Arg v ) + { + m_v = vec_add( m_v, v.m_v ); + return *this; + } + + Vec4& operator-=( Arg v ) + { + m_v = vec_sub( m_v, v.m_v ); + return *this; + } + + Vec4& operator*=( Arg v ) + { + m_v = vec_madd( m_v, v.m_v, ( vector float ){ -0.0f } ); + return *this; + } + + friend Vec4 operator+( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( vec_add( left.m_v, right.m_v ) ); + } + + friend Vec4 operator-( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( vec_sub( left.m_v, right.m_v ) ); + } + + friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( vec_madd( left.m_v, right.m_v, ( vector float ){ -0.0f } ) ); + } + + //! Returns a*b + c + friend Vec4 MultiplyAdd( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) + { + return Vec4( vec_madd( a.m_v, b.m_v, c.m_v ) ); + } + + //! Returns -( a*b - c ) + friend Vec4 NegativeMultiplySubtract( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) + { + return Vec4( vec_nmsub( a.m_v, b.m_v, c.m_v ) ); + } + + friend Vec4 Reciprocal( Vec4::Arg v ) + { + // get the reciprocal estimate + vector float estimate = vec_re( v.m_v ); + + // one round of Newton-Rhaphson refinement + vector float diff = vec_nmsub( estimate, v.m_v, ( vector float ){ 1.0f } ); + return Vec4( vec_madd( diff, estimate, estimate ) ); + } + + friend Vec4 Min( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( vec_min( left.m_v, right.m_v ) ); + } + + friend Vec4 Max( Vec4::Arg left, Vec4::Arg right ) + { + return Vec4( vec_max( left.m_v, right.m_v ) ); + } + + friend Vec4 Truncate( Vec4::Arg v ) + { + return Vec4( vec_trunc( v.m_v ) ); + } + + friend bool CompareAnyLessThan( Vec4::Arg left, Vec4::Arg right ) + { + return vec_any_lt( left.m_v, right.m_v ) != 0; + } + +private: + vector float m_v; +}; + +} // namespace squish + +#endif // ndef SQUISH_SIMD_VE_H diff --git a/extern/libsquish-1.15/singlecolourfit.cpp b/extern/libsquish-1.15/singlecolourfit.cpp new file mode 100644 index 00000000..cef0ebc4 --- /dev/null +++ b/extern/libsquish-1.15/singlecolourfit.cpp @@ -0,0 +1,172 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include "singlecolourfit.h" +#include "colourset.h" +#include "colourblock.h" + +namespace squish { + +struct SourceBlock +{ + u8 start; + u8 end; + u8 error; +}; + +struct SingleColourLookup +{ + SourceBlock sources[2]; +}; + +#include "singlecolourlookup.inl" + +static int FloatToInt( float a, int limit ) +{ + // use ANSI round-to-zero behaviour to get round-to-nearest + int i = ( int )( a + 0.5f ); + + // clamp to the limit + if( i < 0 ) + i = 0; + else if( i > limit ) + i = limit; + + // done + return i; +} + +SingleColourFit::SingleColourFit( ColourSet const* colours, int flags ) + : ColourFit( colours, flags ) +{ + // grab the single colour + Vec3 const* values = m_colours->GetPoints(); + m_colour[0] = ( u8 )FloatToInt( 255.0f*values->X(), 255 ); + m_colour[1] = ( u8 )FloatToInt( 255.0f*values->Y(), 255 ); + m_colour[2] = ( u8 )FloatToInt( 255.0f*values->Z(), 255 ); + + // initialise the best error + m_besterror = INT_MAX; +} + +void SingleColourFit::Compress3( void* block ) +{ + // build the table of lookups + SingleColourLookup const* const lookups[] = + { + lookup_5_3, + lookup_6_3, + lookup_5_3 + }; + + // find the best end-points and index + ComputeEndPoints( lookups ); + + // build the block if we win + if( m_error < m_besterror ) + { + // remap the indices + u8 indices[16]; + m_colours->RemapIndices( &m_index, indices ); + + // save the block + WriteColourBlock3( m_start, m_end, indices, block ); + + // save the error + m_besterror = m_error; + } +} + +void SingleColourFit::Compress4( void* block ) +{ + // build the table of lookups + SingleColourLookup const* const lookups[] = + { + lookup_5_4, + lookup_6_4, + lookup_5_4 + }; + + // find the best end-points and index + ComputeEndPoints( lookups ); + + // build the block if we win + if( m_error < m_besterror ) + { + // remap the indices + u8 indices[16]; + m_colours->RemapIndices( &m_index, indices ); + + // save the block + WriteColourBlock4( m_start, m_end, indices, block ); + + // save the error + m_besterror = m_error; + } +} + +void SingleColourFit::ComputeEndPoints( SingleColourLookup const* const* lookups ) +{ + // check each index combination (endpoint or intermediate) + m_error = INT_MAX; + for( int index = 0; index < 2; ++index ) + { + // check the error for this codebook index + SourceBlock const* sources[3]; + int error = 0; + for( int channel = 0; channel < 3; ++channel ) + { + // grab the lookup table and index for this channel + SingleColourLookup const* lookup = lookups[channel]; + int target = m_colour[channel]; + + // store a pointer to the source for this channel + sources[channel] = lookup[target].sources + index; + + // accumulate the error + int diff = sources[channel]->error; + error += diff*diff; + } + + // keep it if the error is lower + if( error < m_error ) + { + m_start = Vec3( + ( float )sources[0]->start/31.0f, + ( float )sources[1]->start/63.0f, + ( float )sources[2]->start/31.0f + ); + m_end = Vec3( + ( float )sources[0]->end/31.0f, + ( float )sources[1]->end/63.0f, + ( float )sources[2]->end/31.0f + ); + m_index = ( u8 )( 2*index ); + m_error = error; + } + } +} + +} // namespace squish diff --git a/extern/libsquish-1.15/singlecolourfit.h b/extern/libsquish-1.15/singlecolourfit.h new file mode 100644 index 00000000..974ce772 --- /dev/null +++ b/extern/libsquish-1.15/singlecolourfit.h @@ -0,0 +1,58 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_SINGLECOLOURFIT_H +#define SQUISH_SINGLECOLOURFIT_H + +#include "squish.h" +#include "colourfit.h" + +namespace squish { + +class ColourSet; +struct SingleColourLookup; + +class SingleColourFit : public ColourFit +{ +public: + SingleColourFit( ColourSet const* colours, int flags ); + +private: + virtual void Compress3( void* block ); + virtual void Compress4( void* block ); + + void ComputeEndPoints( SingleColourLookup const* const* lookups ); + + u8 m_colour[3]; + Vec3 m_start; + Vec3 m_end; + u8 m_index; + int m_error; + int m_besterror; +}; + +} // namespace squish + +#endif // ndef SQUISH_SINGLECOLOURFIT_H diff --git a/extern/libsquish-1.15/singlecolourlookup.inl b/extern/libsquish-1.15/singlecolourlookup.inl new file mode 100644 index 00000000..5b44a1e5 --- /dev/null +++ b/extern/libsquish-1.15/singlecolourlookup.inl @@ -0,0 +1,1064 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +static SingleColourLookup const lookup_5_3[] = +{ + { { { 0, 0, 0 }, { 0, 0, 0 } } }, + { { { 0, 0, 1 }, { 0, 0, 1 } } }, + { { { 0, 0, 2 }, { 0, 0, 2 } } }, + { { { 0, 0, 3 }, { 0, 1, 1 } } }, + { { { 0, 0, 4 }, { 0, 1, 0 } } }, + { { { 1, 0, 3 }, { 0, 1, 1 } } }, + { { { 1, 0, 2 }, { 0, 1, 2 } } }, + { { { 1, 0, 1 }, { 0, 2, 1 } } }, + { { { 1, 0, 0 }, { 0, 2, 0 } } }, + { { { 1, 0, 1 }, { 0, 2, 1 } } }, + { { { 1, 0, 2 }, { 0, 2, 2 } } }, + { { { 1, 0, 3 }, { 0, 3, 1 } } }, + { { { 1, 0, 4 }, { 0, 3, 0 } } }, + { { { 2, 0, 3 }, { 0, 3, 1 } } }, + { { { 2, 0, 2 }, { 0, 3, 2 } } }, + { { { 2, 0, 1 }, { 0, 4, 1 } } }, + { { { 2, 0, 0 }, { 0, 4, 0 } } }, + { { { 2, 0, 1 }, { 0, 4, 1 } } }, + { { { 2, 0, 2 }, { 0, 4, 2 } } }, + { { { 2, 0, 3 }, { 0, 5, 1 } } }, + { { { 2, 0, 4 }, { 0, 5, 0 } } }, + { { { 3, 0, 3 }, { 0, 5, 1 } } }, + { { { 3, 0, 2 }, { 0, 5, 2 } } }, + { { { 3, 0, 1 }, { 0, 6, 1 } } }, + { { { 3, 0, 0 }, { 0, 6, 0 } } }, + { { { 3, 0, 1 }, { 0, 6, 1 } } }, + { { { 3, 0, 2 }, { 0, 6, 2 } } }, + { { { 3, 0, 3 }, { 0, 7, 1 } } }, + { { { 3, 0, 4 }, { 0, 7, 0 } } }, + { { { 4, 0, 4 }, { 0, 7, 1 } } }, + { { { 4, 0, 3 }, { 0, 7, 2 } } }, + { { { 4, 0, 2 }, { 1, 7, 1 } } }, + { { { 4, 0, 1 }, { 1, 7, 0 } } }, + { { { 4, 0, 0 }, { 0, 8, 0 } } }, + { { { 4, 0, 1 }, { 0, 8, 1 } } }, + { { { 4, 0, 2 }, { 2, 7, 1 } } }, + { { { 4, 0, 3 }, { 2, 7, 0 } } }, + { { { 4, 0, 4 }, { 0, 9, 0 } } }, + { { { 5, 0, 3 }, { 0, 9, 1 } } }, + { { { 5, 0, 2 }, { 3, 7, 1 } } }, + { { { 5, 0, 1 }, { 3, 7, 0 } } }, + { { { 5, 0, 0 }, { 0, 10, 0 } } }, + { { { 5, 0, 1 }, { 0, 10, 1 } } }, + { { { 5, 0, 2 }, { 0, 10, 2 } } }, + { { { 5, 0, 3 }, { 0, 11, 1 } } }, + { { { 5, 0, 4 }, { 0, 11, 0 } } }, + { { { 6, 0, 3 }, { 0, 11, 1 } } }, + { { { 6, 0, 2 }, { 0, 11, 2 } } }, + { { { 6, 0, 1 }, { 0, 12, 1 } } }, + { { { 6, 0, 0 }, { 0, 12, 0 } } }, + { { { 6, 0, 1 }, { 0, 12, 1 } } }, + { { { 6, 0, 2 }, { 0, 12, 2 } } }, + { { { 6, 0, 3 }, { 0, 13, 1 } } }, + { { { 6, 0, 4 }, { 0, 13, 0 } } }, + { { { 7, 0, 3 }, { 0, 13, 1 } } }, + { { { 7, 0, 2 }, { 0, 13, 2 } } }, + { { { 7, 0, 1 }, { 0, 14, 1 } } }, + { { { 7, 0, 0 }, { 0, 14, 0 } } }, + { { { 7, 0, 1 }, { 0, 14, 1 } } }, + { { { 7, 0, 2 }, { 0, 14, 2 } } }, + { { { 7, 0, 3 }, { 0, 15, 1 } } }, + { { { 7, 0, 4 }, { 0, 15, 0 } } }, + { { { 8, 0, 4 }, { 0, 15, 1 } } }, + { { { 8, 0, 3 }, { 0, 15, 2 } } }, + { { { 8, 0, 2 }, { 1, 15, 1 } } }, + { { { 8, 0, 1 }, { 1, 15, 0 } } }, + { { { 8, 0, 0 }, { 0, 16, 0 } } }, + { { { 8, 0, 1 }, { 0, 16, 1 } } }, + { { { 8, 0, 2 }, { 2, 15, 1 } } }, + { { { 8, 0, 3 }, { 2, 15, 0 } } }, + { { { 8, 0, 4 }, { 0, 17, 0 } } }, + { { { 9, 0, 3 }, { 0, 17, 1 } } }, + { { { 9, 0, 2 }, { 3, 15, 1 } } }, + { { { 9, 0, 1 }, { 3, 15, 0 } } }, + { { { 9, 0, 0 }, { 0, 18, 0 } } }, + { { { 9, 0, 1 }, { 0, 18, 1 } } }, + { { { 9, 0, 2 }, { 0, 18, 2 } } }, + { { { 9, 0, 3 }, { 0, 19, 1 } } }, + { { { 9, 0, 4 }, { 0, 19, 0 } } }, + { { { 10, 0, 3 }, { 0, 19, 1 } } }, + { { { 10, 0, 2 }, { 0, 19, 2 } } }, + { { { 10, 0, 1 }, { 0, 20, 1 } } }, + { { { 10, 0, 0 }, { 0, 20, 0 } } }, + { { { 10, 0, 1 }, { 0, 20, 1 } } }, + { { { 10, 0, 2 }, { 0, 20, 2 } } }, + { { { 10, 0, 3 }, { 0, 21, 1 } } }, + { { { 10, 0, 4 }, { 0, 21, 0 } } }, + { { { 11, 0, 3 }, { 0, 21, 1 } } }, + { { { 11, 0, 2 }, { 0, 21, 2 } } }, + { { { 11, 0, 1 }, { 0, 22, 1 } } }, + { { { 11, 0, 0 }, { 0, 22, 0 } } }, + { { { 11, 0, 1 }, { 0, 22, 1 } } }, + { { { 11, 0, 2 }, { 0, 22, 2 } } }, + { { { 11, 0, 3 }, { 0, 23, 1 } } }, + { { { 11, 0, 4 }, { 0, 23, 0 } } }, + { { { 12, 0, 4 }, { 0, 23, 1 } } }, + { { { 12, 0, 3 }, { 0, 23, 2 } } }, + { { { 12, 0, 2 }, { 1, 23, 1 } } }, + { { { 12, 0, 1 }, { 1, 23, 0 } } }, + { { { 12, 0, 0 }, { 0, 24, 0 } } }, + { { { 12, 0, 1 }, { 0, 24, 1 } } }, + { { { 12, 0, 2 }, { 2, 23, 1 } } }, + { { { 12, 0, 3 }, { 2, 23, 0 } } }, + { { { 12, 0, 4 }, { 0, 25, 0 } } }, + { { { 13, 0, 3 }, { 0, 25, 1 } } }, + { { { 13, 0, 2 }, { 3, 23, 1 } } }, + { { { 13, 0, 1 }, { 3, 23, 0 } } }, + { { { 13, 0, 0 }, { 0, 26, 0 } } }, + { { { 13, 0, 1 }, { 0, 26, 1 } } }, + { { { 13, 0, 2 }, { 0, 26, 2 } } }, + { { { 13, 0, 3 }, { 0, 27, 1 } } }, + { { { 13, 0, 4 }, { 0, 27, 0 } } }, + { { { 14, 0, 3 }, { 0, 27, 1 } } }, + { { { 14, 0, 2 }, { 0, 27, 2 } } }, + { { { 14, 0, 1 }, { 0, 28, 1 } } }, + { { { 14, 0, 0 }, { 0, 28, 0 } } }, + { { { 14, 0, 1 }, { 0, 28, 1 } } }, + { { { 14, 0, 2 }, { 0, 28, 2 } } }, + { { { 14, 0, 3 }, { 0, 29, 1 } } }, + { { { 14, 0, 4 }, { 0, 29, 0 } } }, + { { { 15, 0, 3 }, { 0, 29, 1 } } }, + { { { 15, 0, 2 }, { 0, 29, 2 } } }, + { { { 15, 0, 1 }, { 0, 30, 1 } } }, + { { { 15, 0, 0 }, { 0, 30, 0 } } }, + { { { 15, 0, 1 }, { 0, 30, 1 } } }, + { { { 15, 0, 2 }, { 0, 30, 2 } } }, + { { { 15, 0, 3 }, { 0, 31, 1 } } }, + { { { 15, 0, 4 }, { 0, 31, 0 } } }, + { { { 16, 0, 4 }, { 0, 31, 1 } } }, + { { { 16, 0, 3 }, { 0, 31, 2 } } }, + { { { 16, 0, 2 }, { 1, 31, 1 } } }, + { { { 16, 0, 1 }, { 1, 31, 0 } } }, + { { { 16, 0, 0 }, { 4, 28, 0 } } }, + { { { 16, 0, 1 }, { 4, 28, 1 } } }, + { { { 16, 0, 2 }, { 2, 31, 1 } } }, + { { { 16, 0, 3 }, { 2, 31, 0 } } }, + { { { 16, 0, 4 }, { 4, 29, 0 } } }, + { { { 17, 0, 3 }, { 4, 29, 1 } } }, + { { { 17, 0, 2 }, { 3, 31, 1 } } }, + { { { 17, 0, 1 }, { 3, 31, 0 } } }, + { { { 17, 0, 0 }, { 4, 30, 0 } } }, + { { { 17, 0, 1 }, { 4, 30, 1 } } }, + { { { 17, 0, 2 }, { 4, 30, 2 } } }, + { { { 17, 0, 3 }, { 4, 31, 1 } } }, + { { { 17, 0, 4 }, { 4, 31, 0 } } }, + { { { 18, 0, 3 }, { 4, 31, 1 } } }, + { { { 18, 0, 2 }, { 4, 31, 2 } } }, + { { { 18, 0, 1 }, { 5, 31, 1 } } }, + { { { 18, 0, 0 }, { 5, 31, 0 } } }, + { { { 18, 0, 1 }, { 5, 31, 1 } } }, + { { { 18, 0, 2 }, { 5, 31, 2 } } }, + { { { 18, 0, 3 }, { 6, 31, 1 } } }, + { { { 18, 0, 4 }, { 6, 31, 0 } } }, + { { { 19, 0, 3 }, { 6, 31, 1 } } }, + { { { 19, 0, 2 }, { 6, 31, 2 } } }, + { { { 19, 0, 1 }, { 7, 31, 1 } } }, + { { { 19, 0, 0 }, { 7, 31, 0 } } }, + { { { 19, 0, 1 }, { 7, 31, 1 } } }, + { { { 19, 0, 2 }, { 7, 31, 2 } } }, + { { { 19, 0, 3 }, { 8, 31, 1 } } }, + { { { 19, 0, 4 }, { 8, 31, 0 } } }, + { { { 20, 0, 4 }, { 8, 31, 1 } } }, + { { { 20, 0, 3 }, { 8, 31, 2 } } }, + { { { 20, 0, 2 }, { 9, 31, 1 } } }, + { { { 20, 0, 1 }, { 9, 31, 0 } } }, + { { { 20, 0, 0 }, { 12, 28, 0 } } }, + { { { 20, 0, 1 }, { 12, 28, 1 } } }, + { { { 20, 0, 2 }, { 10, 31, 1 } } }, + { { { 20, 0, 3 }, { 10, 31, 0 } } }, + { { { 20, 0, 4 }, { 12, 29, 0 } } }, + { { { 21, 0, 3 }, { 12, 29, 1 } } }, + { { { 21, 0, 2 }, { 11, 31, 1 } } }, + { { { 21, 0, 1 }, { 11, 31, 0 } } }, + { { { 21, 0, 0 }, { 12, 30, 0 } } }, + { { { 21, 0, 1 }, { 12, 30, 1 } } }, + { { { 21, 0, 2 }, { 12, 30, 2 } } }, + { { { 21, 0, 3 }, { 12, 31, 1 } } }, + { { { 21, 0, 4 }, { 12, 31, 0 } } }, + { { { 22, 0, 3 }, { 12, 31, 1 } } }, + { { { 22, 0, 2 }, { 12, 31, 2 } } }, + { { { 22, 0, 1 }, { 13, 31, 1 } } }, + { { { 22, 0, 0 }, { 13, 31, 0 } } }, + { { { 22, 0, 1 }, { 13, 31, 1 } } }, + { { { 22, 0, 2 }, { 13, 31, 2 } } }, + { { { 22, 0, 3 }, { 14, 31, 1 } } }, + { { { 22, 0, 4 }, { 14, 31, 0 } } }, + { { { 23, 0, 3 }, { 14, 31, 1 } } }, + { { { 23, 0, 2 }, { 14, 31, 2 } } }, + { { { 23, 0, 1 }, { 15, 31, 1 } } }, + { { { 23, 0, 0 }, { 15, 31, 0 } } }, + { { { 23, 0, 1 }, { 15, 31, 1 } } }, + { { { 23, 0, 2 }, { 15, 31, 2 } } }, + { { { 23, 0, 3 }, { 16, 31, 1 } } }, + { { { 23, 0, 4 }, { 16, 31, 0 } } }, + { { { 24, 0, 4 }, { 16, 31, 1 } } }, + { { { 24, 0, 3 }, { 16, 31, 2 } } }, + { { { 24, 0, 2 }, { 17, 31, 1 } } }, + { { { 24, 0, 1 }, { 17, 31, 0 } } }, + { { { 24, 0, 0 }, { 20, 28, 0 } } }, + { { { 24, 0, 1 }, { 20, 28, 1 } } }, + { { { 24, 0, 2 }, { 18, 31, 1 } } }, + { { { 24, 0, 3 }, { 18, 31, 0 } } }, + { { { 24, 0, 4 }, { 20, 29, 0 } } }, + { { { 25, 0, 3 }, { 20, 29, 1 } } }, + { { { 25, 0, 2 }, { 19, 31, 1 } } }, + { { { 25, 0, 1 }, { 19, 31, 0 } } }, + { { { 25, 0, 0 }, { 20, 30, 0 } } }, + { { { 25, 0, 1 }, { 20, 30, 1 } } }, + { { { 25, 0, 2 }, { 20, 30, 2 } } }, + { { { 25, 0, 3 }, { 20, 31, 1 } } }, + { { { 25, 0, 4 }, { 20, 31, 0 } } }, + { { { 26, 0, 3 }, { 20, 31, 1 } } }, + { { { 26, 0, 2 }, { 20, 31, 2 } } }, + { { { 26, 0, 1 }, { 21, 31, 1 } } }, + { { { 26, 0, 0 }, { 21, 31, 0 } } }, + { { { 26, 0, 1 }, { 21, 31, 1 } } }, + { { { 26, 0, 2 }, { 21, 31, 2 } } }, + { { { 26, 0, 3 }, { 22, 31, 1 } } }, + { { { 26, 0, 4 }, { 22, 31, 0 } } }, + { { { 27, 0, 3 }, { 22, 31, 1 } } }, + { { { 27, 0, 2 }, { 22, 31, 2 } } }, + { { { 27, 0, 1 }, { 23, 31, 1 } } }, + { { { 27, 0, 0 }, { 23, 31, 0 } } }, + { { { 27, 0, 1 }, { 23, 31, 1 } } }, + { { { 27, 0, 2 }, { 23, 31, 2 } } }, + { { { 27, 0, 3 }, { 24, 31, 1 } } }, + { { { 27, 0, 4 }, { 24, 31, 0 } } }, + { { { 28, 0, 4 }, { 24, 31, 1 } } }, + { { { 28, 0, 3 }, { 24, 31, 2 } } }, + { { { 28, 0, 2 }, { 25, 31, 1 } } }, + { { { 28, 0, 1 }, { 25, 31, 0 } } }, + { { { 28, 0, 0 }, { 28, 28, 0 } } }, + { { { 28, 0, 1 }, { 28, 28, 1 } } }, + { { { 28, 0, 2 }, { 26, 31, 1 } } }, + { { { 28, 0, 3 }, { 26, 31, 0 } } }, + { { { 28, 0, 4 }, { 28, 29, 0 } } }, + { { { 29, 0, 3 }, { 28, 29, 1 } } }, + { { { 29, 0, 2 }, { 27, 31, 1 } } }, + { { { 29, 0, 1 }, { 27, 31, 0 } } }, + { { { 29, 0, 0 }, { 28, 30, 0 } } }, + { { { 29, 0, 1 }, { 28, 30, 1 } } }, + { { { 29, 0, 2 }, { 28, 30, 2 } } }, + { { { 29, 0, 3 }, { 28, 31, 1 } } }, + { { { 29, 0, 4 }, { 28, 31, 0 } } }, + { { { 30, 0, 3 }, { 28, 31, 1 } } }, + { { { 30, 0, 2 }, { 28, 31, 2 } } }, + { { { 30, 0, 1 }, { 29, 31, 1 } } }, + { { { 30, 0, 0 }, { 29, 31, 0 } } }, + { { { 30, 0, 1 }, { 29, 31, 1 } } }, + { { { 30, 0, 2 }, { 29, 31, 2 } } }, + { { { 30, 0, 3 }, { 30, 31, 1 } } }, + { { { 30, 0, 4 }, { 30, 31, 0 } } }, + { { { 31, 0, 3 }, { 30, 31, 1 } } }, + { { { 31, 0, 2 }, { 30, 31, 2 } } }, + { { { 31, 0, 1 }, { 31, 31, 1 } } }, + { { { 31, 0, 0 }, { 31, 31, 0 } } } +}; + +static SingleColourLookup const lookup_6_3[] = +{ + { { { 0, 0, 0 }, { 0, 0, 0 } } }, + { { { 0, 0, 1 }, { 0, 1, 1 } } }, + { { { 0, 0, 2 }, { 0, 1, 0 } } }, + { { { 1, 0, 1 }, { 0, 2, 1 } } }, + { { { 1, 0, 0 }, { 0, 2, 0 } } }, + { { { 1, 0, 1 }, { 0, 3, 1 } } }, + { { { 1, 0, 2 }, { 0, 3, 0 } } }, + { { { 2, 0, 1 }, { 0, 4, 1 } } }, + { { { 2, 0, 0 }, { 0, 4, 0 } } }, + { { { 2, 0, 1 }, { 0, 5, 1 } } }, + { { { 2, 0, 2 }, { 0, 5, 0 } } }, + { { { 3, 0, 1 }, { 0, 6, 1 } } }, + { { { 3, 0, 0 }, { 0, 6, 0 } } }, + { { { 3, 0, 1 }, { 0, 7, 1 } } }, + { { { 3, 0, 2 }, { 0, 7, 0 } } }, + { { { 4, 0, 1 }, { 0, 8, 1 } } }, + { { { 4, 0, 0 }, { 0, 8, 0 } } }, + { { { 4, 0, 1 }, { 0, 9, 1 } } }, + { { { 4, 0, 2 }, { 0, 9, 0 } } }, + { { { 5, 0, 1 }, { 0, 10, 1 } } }, + { { { 5, 0, 0 }, { 0, 10, 0 } } }, + { { { 5, 0, 1 }, { 0, 11, 1 } } }, + { { { 5, 0, 2 }, { 0, 11, 0 } } }, + { { { 6, 0, 1 }, { 0, 12, 1 } } }, + { { { 6, 0, 0 }, { 0, 12, 0 } } }, + { { { 6, 0, 1 }, { 0, 13, 1 } } }, + { { { 6, 0, 2 }, { 0, 13, 0 } } }, + { { { 7, 0, 1 }, { 0, 14, 1 } } }, + { { { 7, 0, 0 }, { 0, 14, 0 } } }, + { { { 7, 0, 1 }, { 0, 15, 1 } } }, + { { { 7, 0, 2 }, { 0, 15, 0 } } }, + { { { 8, 0, 1 }, { 0, 16, 1 } } }, + { { { 8, 0, 0 }, { 0, 16, 0 } } }, + { { { 8, 0, 1 }, { 0, 17, 1 } } }, + { { { 8, 0, 2 }, { 0, 17, 0 } } }, + { { { 9, 0, 1 }, { 0, 18, 1 } } }, + { { { 9, 0, 0 }, { 0, 18, 0 } } }, + { { { 9, 0, 1 }, { 0, 19, 1 } } }, + { { { 9, 0, 2 }, { 0, 19, 0 } } }, + { { { 10, 0, 1 }, { 0, 20, 1 } } }, + { { { 10, 0, 0 }, { 0, 20, 0 } } }, + { { { 10, 0, 1 }, { 0, 21, 1 } } }, + { { { 10, 0, 2 }, { 0, 21, 0 } } }, + { { { 11, 0, 1 }, { 0, 22, 1 } } }, + { { { 11, 0, 0 }, { 0, 22, 0 } } }, + { { { 11, 0, 1 }, { 0, 23, 1 } } }, + { { { 11, 0, 2 }, { 0, 23, 0 } } }, + { { { 12, 0, 1 }, { 0, 24, 1 } } }, + { { { 12, 0, 0 }, { 0, 24, 0 } } }, + { { { 12, 0, 1 }, { 0, 25, 1 } } }, + { { { 12, 0, 2 }, { 0, 25, 0 } } }, + { { { 13, 0, 1 }, { 0, 26, 1 } } }, + { { { 13, 0, 0 }, { 0, 26, 0 } } }, + { { { 13, 0, 1 }, { 0, 27, 1 } } }, + { { { 13, 0, 2 }, { 0, 27, 0 } } }, + { { { 14, 0, 1 }, { 0, 28, 1 } } }, + { { { 14, 0, 0 }, { 0, 28, 0 } } }, + { { { 14, 0, 1 }, { 0, 29, 1 } } }, + { { { 14, 0, 2 }, { 0, 29, 0 } } }, + { { { 15, 0, 1 }, { 0, 30, 1 } } }, + { { { 15, 0, 0 }, { 0, 30, 0 } } }, + { { { 15, 0, 1 }, { 0, 31, 1 } } }, + { { { 15, 0, 2 }, { 0, 31, 0 } } }, + { { { 16, 0, 2 }, { 1, 31, 1 } } }, + { { { 16, 0, 1 }, { 1, 31, 0 } } }, + { { { 16, 0, 0 }, { 0, 32, 0 } } }, + { { { 16, 0, 1 }, { 2, 31, 0 } } }, + { { { 16, 0, 2 }, { 0, 33, 0 } } }, + { { { 17, 0, 1 }, { 3, 31, 0 } } }, + { { { 17, 0, 0 }, { 0, 34, 0 } } }, + { { { 17, 0, 1 }, { 4, 31, 0 } } }, + { { { 17, 0, 2 }, { 0, 35, 0 } } }, + { { { 18, 0, 1 }, { 5, 31, 0 } } }, + { { { 18, 0, 0 }, { 0, 36, 0 } } }, + { { { 18, 0, 1 }, { 6, 31, 0 } } }, + { { { 18, 0, 2 }, { 0, 37, 0 } } }, + { { { 19, 0, 1 }, { 7, 31, 0 } } }, + { { { 19, 0, 0 }, { 0, 38, 0 } } }, + { { { 19, 0, 1 }, { 8, 31, 0 } } }, + { { { 19, 0, 2 }, { 0, 39, 0 } } }, + { { { 20, 0, 1 }, { 9, 31, 0 } } }, + { { { 20, 0, 0 }, { 0, 40, 0 } } }, + { { { 20, 0, 1 }, { 10, 31, 0 } } }, + { { { 20, 0, 2 }, { 0, 41, 0 } } }, + { { { 21, 0, 1 }, { 11, 31, 0 } } }, + { { { 21, 0, 0 }, { 0, 42, 0 } } }, + { { { 21, 0, 1 }, { 12, 31, 0 } } }, + { { { 21, 0, 2 }, { 0, 43, 0 } } }, + { { { 22, 0, 1 }, { 13, 31, 0 } } }, + { { { 22, 0, 0 }, { 0, 44, 0 } } }, + { { { 22, 0, 1 }, { 14, 31, 0 } } }, + { { { 22, 0, 2 }, { 0, 45, 0 } } }, + { { { 23, 0, 1 }, { 15, 31, 0 } } }, + { { { 23, 0, 0 }, { 0, 46, 0 } } }, + { { { 23, 0, 1 }, { 0, 47, 1 } } }, + { { { 23, 0, 2 }, { 0, 47, 0 } } }, + { { { 24, 0, 1 }, { 0, 48, 1 } } }, + { { { 24, 0, 0 }, { 0, 48, 0 } } }, + { { { 24, 0, 1 }, { 0, 49, 1 } } }, + { { { 24, 0, 2 }, { 0, 49, 0 } } }, + { { { 25, 0, 1 }, { 0, 50, 1 } } }, + { { { 25, 0, 0 }, { 0, 50, 0 } } }, + { { { 25, 0, 1 }, { 0, 51, 1 } } }, + { { { 25, 0, 2 }, { 0, 51, 0 } } }, + { { { 26, 0, 1 }, { 0, 52, 1 } } }, + { { { 26, 0, 0 }, { 0, 52, 0 } } }, + { { { 26, 0, 1 }, { 0, 53, 1 } } }, + { { { 26, 0, 2 }, { 0, 53, 0 } } }, + { { { 27, 0, 1 }, { 0, 54, 1 } } }, + { { { 27, 0, 0 }, { 0, 54, 0 } } }, + { { { 27, 0, 1 }, { 0, 55, 1 } } }, + { { { 27, 0, 2 }, { 0, 55, 0 } } }, + { { { 28, 0, 1 }, { 0, 56, 1 } } }, + { { { 28, 0, 0 }, { 0, 56, 0 } } }, + { { { 28, 0, 1 }, { 0, 57, 1 } } }, + { { { 28, 0, 2 }, { 0, 57, 0 } } }, + { { { 29, 0, 1 }, { 0, 58, 1 } } }, + { { { 29, 0, 0 }, { 0, 58, 0 } } }, + { { { 29, 0, 1 }, { 0, 59, 1 } } }, + { { { 29, 0, 2 }, { 0, 59, 0 } } }, + { { { 30, 0, 1 }, { 0, 60, 1 } } }, + { { { 30, 0, 0 }, { 0, 60, 0 } } }, + { { { 30, 0, 1 }, { 0, 61, 1 } } }, + { { { 30, 0, 2 }, { 0, 61, 0 } } }, + { { { 31, 0, 1 }, { 0, 62, 1 } } }, + { { { 31, 0, 0 }, { 0, 62, 0 } } }, + { { { 31, 0, 1 }, { 0, 63, 1 } } }, + { { { 31, 0, 2 }, { 0, 63, 0 } } }, + { { { 32, 0, 2 }, { 1, 63, 1 } } }, + { { { 32, 0, 1 }, { 1, 63, 0 } } }, + { { { 32, 0, 0 }, { 16, 48, 0 } } }, + { { { 32, 0, 1 }, { 2, 63, 0 } } }, + { { { 32, 0, 2 }, { 16, 49, 0 } } }, + { { { 33, 0, 1 }, { 3, 63, 0 } } }, + { { { 33, 0, 0 }, { 16, 50, 0 } } }, + { { { 33, 0, 1 }, { 4, 63, 0 } } }, + { { { 33, 0, 2 }, { 16, 51, 0 } } }, + { { { 34, 0, 1 }, { 5, 63, 0 } } }, + { { { 34, 0, 0 }, { 16, 52, 0 } } }, + { { { 34, 0, 1 }, { 6, 63, 0 } } }, + { { { 34, 0, 2 }, { 16, 53, 0 } } }, + { { { 35, 0, 1 }, { 7, 63, 0 } } }, + { { { 35, 0, 0 }, { 16, 54, 0 } } }, + { { { 35, 0, 1 }, { 8, 63, 0 } } }, + { { { 35, 0, 2 }, { 16, 55, 0 } } }, + { { { 36, 0, 1 }, { 9, 63, 0 } } }, + { { { 36, 0, 0 }, { 16, 56, 0 } } }, + { { { 36, 0, 1 }, { 10, 63, 0 } } }, + { { { 36, 0, 2 }, { 16, 57, 0 } } }, + { { { 37, 0, 1 }, { 11, 63, 0 } } }, + { { { 37, 0, 0 }, { 16, 58, 0 } } }, + { { { 37, 0, 1 }, { 12, 63, 0 } } }, + { { { 37, 0, 2 }, { 16, 59, 0 } } }, + { { { 38, 0, 1 }, { 13, 63, 0 } } }, + { { { 38, 0, 0 }, { 16, 60, 0 } } }, + { { { 38, 0, 1 }, { 14, 63, 0 } } }, + { { { 38, 0, 2 }, { 16, 61, 0 } } }, + { { { 39, 0, 1 }, { 15, 63, 0 } } }, + { { { 39, 0, 0 }, { 16, 62, 0 } } }, + { { { 39, 0, 1 }, { 16, 63, 1 } } }, + { { { 39, 0, 2 }, { 16, 63, 0 } } }, + { { { 40, 0, 1 }, { 17, 63, 1 } } }, + { { { 40, 0, 0 }, { 17, 63, 0 } } }, + { { { 40, 0, 1 }, { 18, 63, 1 } } }, + { { { 40, 0, 2 }, { 18, 63, 0 } } }, + { { { 41, 0, 1 }, { 19, 63, 1 } } }, + { { { 41, 0, 0 }, { 19, 63, 0 } } }, + { { { 41, 0, 1 }, { 20, 63, 1 } } }, + { { { 41, 0, 2 }, { 20, 63, 0 } } }, + { { { 42, 0, 1 }, { 21, 63, 1 } } }, + { { { 42, 0, 0 }, { 21, 63, 0 } } }, + { { { 42, 0, 1 }, { 22, 63, 1 } } }, + { { { 42, 0, 2 }, { 22, 63, 0 } } }, + { { { 43, 0, 1 }, { 23, 63, 1 } } }, + { { { 43, 0, 0 }, { 23, 63, 0 } } }, + { { { 43, 0, 1 }, { 24, 63, 1 } } }, + { { { 43, 0, 2 }, { 24, 63, 0 } } }, + { { { 44, 0, 1 }, { 25, 63, 1 } } }, + { { { 44, 0, 0 }, { 25, 63, 0 } } }, + { { { 44, 0, 1 }, { 26, 63, 1 } } }, + { { { 44, 0, 2 }, { 26, 63, 0 } } }, + { { { 45, 0, 1 }, { 27, 63, 1 } } }, + { { { 45, 0, 0 }, { 27, 63, 0 } } }, + { { { 45, 0, 1 }, { 28, 63, 1 } } }, + { { { 45, 0, 2 }, { 28, 63, 0 } } }, + { { { 46, 0, 1 }, { 29, 63, 1 } } }, + { { { 46, 0, 0 }, { 29, 63, 0 } } }, + { { { 46, 0, 1 }, { 30, 63, 1 } } }, + { { { 46, 0, 2 }, { 30, 63, 0 } } }, + { { { 47, 0, 1 }, { 31, 63, 1 } } }, + { { { 47, 0, 0 }, { 31, 63, 0 } } }, + { { { 47, 0, 1 }, { 32, 63, 1 } } }, + { { { 47, 0, 2 }, { 32, 63, 0 } } }, + { { { 48, 0, 2 }, { 33, 63, 1 } } }, + { { { 48, 0, 1 }, { 33, 63, 0 } } }, + { { { 48, 0, 0 }, { 48, 48, 0 } } }, + { { { 48, 0, 1 }, { 34, 63, 0 } } }, + { { { 48, 0, 2 }, { 48, 49, 0 } } }, + { { { 49, 0, 1 }, { 35, 63, 0 } } }, + { { { 49, 0, 0 }, { 48, 50, 0 } } }, + { { { 49, 0, 1 }, { 36, 63, 0 } } }, + { { { 49, 0, 2 }, { 48, 51, 0 } } }, + { { { 50, 0, 1 }, { 37, 63, 0 } } }, + { { { 50, 0, 0 }, { 48, 52, 0 } } }, + { { { 50, 0, 1 }, { 38, 63, 0 } } }, + { { { 50, 0, 2 }, { 48, 53, 0 } } }, + { { { 51, 0, 1 }, { 39, 63, 0 } } }, + { { { 51, 0, 0 }, { 48, 54, 0 } } }, + { { { 51, 0, 1 }, { 40, 63, 0 } } }, + { { { 51, 0, 2 }, { 48, 55, 0 } } }, + { { { 52, 0, 1 }, { 41, 63, 0 } } }, + { { { 52, 0, 0 }, { 48, 56, 0 } } }, + { { { 52, 0, 1 }, { 42, 63, 0 } } }, + { { { 52, 0, 2 }, { 48, 57, 0 } } }, + { { { 53, 0, 1 }, { 43, 63, 0 } } }, + { { { 53, 0, 0 }, { 48, 58, 0 } } }, + { { { 53, 0, 1 }, { 44, 63, 0 } } }, + { { { 53, 0, 2 }, { 48, 59, 0 } } }, + { { { 54, 0, 1 }, { 45, 63, 0 } } }, + { { { 54, 0, 0 }, { 48, 60, 0 } } }, + { { { 54, 0, 1 }, { 46, 63, 0 } } }, + { { { 54, 0, 2 }, { 48, 61, 0 } } }, + { { { 55, 0, 1 }, { 47, 63, 0 } } }, + { { { 55, 0, 0 }, { 48, 62, 0 } } }, + { { { 55, 0, 1 }, { 48, 63, 1 } } }, + { { { 55, 0, 2 }, { 48, 63, 0 } } }, + { { { 56, 0, 1 }, { 49, 63, 1 } } }, + { { { 56, 0, 0 }, { 49, 63, 0 } } }, + { { { 56, 0, 1 }, { 50, 63, 1 } } }, + { { { 56, 0, 2 }, { 50, 63, 0 } } }, + { { { 57, 0, 1 }, { 51, 63, 1 } } }, + { { { 57, 0, 0 }, { 51, 63, 0 } } }, + { { { 57, 0, 1 }, { 52, 63, 1 } } }, + { { { 57, 0, 2 }, { 52, 63, 0 } } }, + { { { 58, 0, 1 }, { 53, 63, 1 } } }, + { { { 58, 0, 0 }, { 53, 63, 0 } } }, + { { { 58, 0, 1 }, { 54, 63, 1 } } }, + { { { 58, 0, 2 }, { 54, 63, 0 } } }, + { { { 59, 0, 1 }, { 55, 63, 1 } } }, + { { { 59, 0, 0 }, { 55, 63, 0 } } }, + { { { 59, 0, 1 }, { 56, 63, 1 } } }, + { { { 59, 0, 2 }, { 56, 63, 0 } } }, + { { { 60, 0, 1 }, { 57, 63, 1 } } }, + { { { 60, 0, 0 }, { 57, 63, 0 } } }, + { { { 60, 0, 1 }, { 58, 63, 1 } } }, + { { { 60, 0, 2 }, { 58, 63, 0 } } }, + { { { 61, 0, 1 }, { 59, 63, 1 } } }, + { { { 61, 0, 0 }, { 59, 63, 0 } } }, + { { { 61, 0, 1 }, { 60, 63, 1 } } }, + { { { 61, 0, 2 }, { 60, 63, 0 } } }, + { { { 62, 0, 1 }, { 61, 63, 1 } } }, + { { { 62, 0, 0 }, { 61, 63, 0 } } }, + { { { 62, 0, 1 }, { 62, 63, 1 } } }, + { { { 62, 0, 2 }, { 62, 63, 0 } } }, + { { { 63, 0, 1 }, { 63, 63, 1 } } }, + { { { 63, 0, 0 }, { 63, 63, 0 } } } +}; + +static SingleColourLookup const lookup_5_4[] = +{ + { { { 0, 0, 0 }, { 0, 0, 0 } } }, + { { { 0, 0, 1 }, { 0, 1, 1 } } }, + { { { 0, 0, 2 }, { 0, 1, 0 } } }, + { { { 0, 0, 3 }, { 0, 1, 1 } } }, + { { { 0, 0, 4 }, { 0, 2, 1 } } }, + { { { 1, 0, 3 }, { 0, 2, 0 } } }, + { { { 1, 0, 2 }, { 0, 2, 1 } } }, + { { { 1, 0, 1 }, { 0, 3, 1 } } }, + { { { 1, 0, 0 }, { 0, 3, 0 } } }, + { { { 1, 0, 1 }, { 1, 2, 1 } } }, + { { { 1, 0, 2 }, { 1, 2, 0 } } }, + { { { 1, 0, 3 }, { 0, 4, 0 } } }, + { { { 1, 0, 4 }, { 0, 5, 1 } } }, + { { { 2, 0, 3 }, { 0, 5, 0 } } }, + { { { 2, 0, 2 }, { 0, 5, 1 } } }, + { { { 2, 0, 1 }, { 0, 6, 1 } } }, + { { { 2, 0, 0 }, { 0, 6, 0 } } }, + { { { 2, 0, 1 }, { 2, 3, 1 } } }, + { { { 2, 0, 2 }, { 2, 3, 0 } } }, + { { { 2, 0, 3 }, { 0, 7, 0 } } }, + { { { 2, 0, 4 }, { 1, 6, 1 } } }, + { { { 3, 0, 3 }, { 1, 6, 0 } } }, + { { { 3, 0, 2 }, { 0, 8, 0 } } }, + { { { 3, 0, 1 }, { 0, 9, 1 } } }, + { { { 3, 0, 0 }, { 0, 9, 0 } } }, + { { { 3, 0, 1 }, { 0, 9, 1 } } }, + { { { 3, 0, 2 }, { 0, 10, 1 } } }, + { { { 3, 0, 3 }, { 0, 10, 0 } } }, + { { { 3, 0, 4 }, { 2, 7, 1 } } }, + { { { 4, 0, 4 }, { 2, 7, 0 } } }, + { { { 4, 0, 3 }, { 0, 11, 0 } } }, + { { { 4, 0, 2 }, { 1, 10, 1 } } }, + { { { 4, 0, 1 }, { 1, 10, 0 } } }, + { { { 4, 0, 0 }, { 0, 12, 0 } } }, + { { { 4, 0, 1 }, { 0, 13, 1 } } }, + { { { 4, 0, 2 }, { 0, 13, 0 } } }, + { { { 4, 0, 3 }, { 0, 13, 1 } } }, + { { { 4, 0, 4 }, { 0, 14, 1 } } }, + { { { 5, 0, 3 }, { 0, 14, 0 } } }, + { { { 5, 0, 2 }, { 2, 11, 1 } } }, + { { { 5, 0, 1 }, { 2, 11, 0 } } }, + { { { 5, 0, 0 }, { 0, 15, 0 } } }, + { { { 5, 0, 1 }, { 1, 14, 1 } } }, + { { { 5, 0, 2 }, { 1, 14, 0 } } }, + { { { 5, 0, 3 }, { 0, 16, 0 } } }, + { { { 5, 0, 4 }, { 0, 17, 1 } } }, + { { { 6, 0, 3 }, { 0, 17, 0 } } }, + { { { 6, 0, 2 }, { 0, 17, 1 } } }, + { { { 6, 0, 1 }, { 0, 18, 1 } } }, + { { { 6, 0, 0 }, { 0, 18, 0 } } }, + { { { 6, 0, 1 }, { 2, 15, 1 } } }, + { { { 6, 0, 2 }, { 2, 15, 0 } } }, + { { { 6, 0, 3 }, { 0, 19, 0 } } }, + { { { 6, 0, 4 }, { 1, 18, 1 } } }, + { { { 7, 0, 3 }, { 1, 18, 0 } } }, + { { { 7, 0, 2 }, { 0, 20, 0 } } }, + { { { 7, 0, 1 }, { 0, 21, 1 } } }, + { { { 7, 0, 0 }, { 0, 21, 0 } } }, + { { { 7, 0, 1 }, { 0, 21, 1 } } }, + { { { 7, 0, 2 }, { 0, 22, 1 } } }, + { { { 7, 0, 3 }, { 0, 22, 0 } } }, + { { { 7, 0, 4 }, { 2, 19, 1 } } }, + { { { 8, 0, 4 }, { 2, 19, 0 } } }, + { { { 8, 0, 3 }, { 0, 23, 0 } } }, + { { { 8, 0, 2 }, { 1, 22, 1 } } }, + { { { 8, 0, 1 }, { 1, 22, 0 } } }, + { { { 8, 0, 0 }, { 0, 24, 0 } } }, + { { { 8, 0, 1 }, { 0, 25, 1 } } }, + { { { 8, 0, 2 }, { 0, 25, 0 } } }, + { { { 8, 0, 3 }, { 0, 25, 1 } } }, + { { { 8, 0, 4 }, { 0, 26, 1 } } }, + { { { 9, 0, 3 }, { 0, 26, 0 } } }, + { { { 9, 0, 2 }, { 2, 23, 1 } } }, + { { { 9, 0, 1 }, { 2, 23, 0 } } }, + { { { 9, 0, 0 }, { 0, 27, 0 } } }, + { { { 9, 0, 1 }, { 1, 26, 1 } } }, + { { { 9, 0, 2 }, { 1, 26, 0 } } }, + { { { 9, 0, 3 }, { 0, 28, 0 } } }, + { { { 9, 0, 4 }, { 0, 29, 1 } } }, + { { { 10, 0, 3 }, { 0, 29, 0 } } }, + { { { 10, 0, 2 }, { 0, 29, 1 } } }, + { { { 10, 0, 1 }, { 0, 30, 1 } } }, + { { { 10, 0, 0 }, { 0, 30, 0 } } }, + { { { 10, 0, 1 }, { 2, 27, 1 } } }, + { { { 10, 0, 2 }, { 2, 27, 0 } } }, + { { { 10, 0, 3 }, { 0, 31, 0 } } }, + { { { 10, 0, 4 }, { 1, 30, 1 } } }, + { { { 11, 0, 3 }, { 1, 30, 0 } } }, + { { { 11, 0, 2 }, { 4, 24, 0 } } }, + { { { 11, 0, 1 }, { 1, 31, 1 } } }, + { { { 11, 0, 0 }, { 1, 31, 0 } } }, + { { { 11, 0, 1 }, { 1, 31, 1 } } }, + { { { 11, 0, 2 }, { 2, 30, 1 } } }, + { { { 11, 0, 3 }, { 2, 30, 0 } } }, + { { { 11, 0, 4 }, { 2, 31, 1 } } }, + { { { 12, 0, 4 }, { 2, 31, 0 } } }, + { { { 12, 0, 3 }, { 4, 27, 0 } } }, + { { { 12, 0, 2 }, { 3, 30, 1 } } }, + { { { 12, 0, 1 }, { 3, 30, 0 } } }, + { { { 12, 0, 0 }, { 4, 28, 0 } } }, + { { { 12, 0, 1 }, { 3, 31, 1 } } }, + { { { 12, 0, 2 }, { 3, 31, 0 } } }, + { { { 12, 0, 3 }, { 3, 31, 1 } } }, + { { { 12, 0, 4 }, { 4, 30, 1 } } }, + { { { 13, 0, 3 }, { 4, 30, 0 } } }, + { { { 13, 0, 2 }, { 6, 27, 1 } } }, + { { { 13, 0, 1 }, { 6, 27, 0 } } }, + { { { 13, 0, 0 }, { 4, 31, 0 } } }, + { { { 13, 0, 1 }, { 5, 30, 1 } } }, + { { { 13, 0, 2 }, { 5, 30, 0 } } }, + { { { 13, 0, 3 }, { 8, 24, 0 } } }, + { { { 13, 0, 4 }, { 5, 31, 1 } } }, + { { { 14, 0, 3 }, { 5, 31, 0 } } }, + { { { 14, 0, 2 }, { 5, 31, 1 } } }, + { { { 14, 0, 1 }, { 6, 30, 1 } } }, + { { { 14, 0, 0 }, { 6, 30, 0 } } }, + { { { 14, 0, 1 }, { 6, 31, 1 } } }, + { { { 14, 0, 2 }, { 6, 31, 0 } } }, + { { { 14, 0, 3 }, { 8, 27, 0 } } }, + { { { 14, 0, 4 }, { 7, 30, 1 } } }, + { { { 15, 0, 3 }, { 7, 30, 0 } } }, + { { { 15, 0, 2 }, { 8, 28, 0 } } }, + { { { 15, 0, 1 }, { 7, 31, 1 } } }, + { { { 15, 0, 0 }, { 7, 31, 0 } } }, + { { { 15, 0, 1 }, { 7, 31, 1 } } }, + { { { 15, 0, 2 }, { 8, 30, 1 } } }, + { { { 15, 0, 3 }, { 8, 30, 0 } } }, + { { { 15, 0, 4 }, { 10, 27, 1 } } }, + { { { 16, 0, 4 }, { 10, 27, 0 } } }, + { { { 16, 0, 3 }, { 8, 31, 0 } } }, + { { { 16, 0, 2 }, { 9, 30, 1 } } }, + { { { 16, 0, 1 }, { 9, 30, 0 } } }, + { { { 16, 0, 0 }, { 12, 24, 0 } } }, + { { { 16, 0, 1 }, { 9, 31, 1 } } }, + { { { 16, 0, 2 }, { 9, 31, 0 } } }, + { { { 16, 0, 3 }, { 9, 31, 1 } } }, + { { { 16, 0, 4 }, { 10, 30, 1 } } }, + { { { 17, 0, 3 }, { 10, 30, 0 } } }, + { { { 17, 0, 2 }, { 10, 31, 1 } } }, + { { { 17, 0, 1 }, { 10, 31, 0 } } }, + { { { 17, 0, 0 }, { 12, 27, 0 } } }, + { { { 17, 0, 1 }, { 11, 30, 1 } } }, + { { { 17, 0, 2 }, { 11, 30, 0 } } }, + { { { 17, 0, 3 }, { 12, 28, 0 } } }, + { { { 17, 0, 4 }, { 11, 31, 1 } } }, + { { { 18, 0, 3 }, { 11, 31, 0 } } }, + { { { 18, 0, 2 }, { 11, 31, 1 } } }, + { { { 18, 0, 1 }, { 12, 30, 1 } } }, + { { { 18, 0, 0 }, { 12, 30, 0 } } }, + { { { 18, 0, 1 }, { 14, 27, 1 } } }, + { { { 18, 0, 2 }, { 14, 27, 0 } } }, + { { { 18, 0, 3 }, { 12, 31, 0 } } }, + { { { 18, 0, 4 }, { 13, 30, 1 } } }, + { { { 19, 0, 3 }, { 13, 30, 0 } } }, + { { { 19, 0, 2 }, { 16, 24, 0 } } }, + { { { 19, 0, 1 }, { 13, 31, 1 } } }, + { { { 19, 0, 0 }, { 13, 31, 0 } } }, + { { { 19, 0, 1 }, { 13, 31, 1 } } }, + { { { 19, 0, 2 }, { 14, 30, 1 } } }, + { { { 19, 0, 3 }, { 14, 30, 0 } } }, + { { { 19, 0, 4 }, { 14, 31, 1 } } }, + { { { 20, 0, 4 }, { 14, 31, 0 } } }, + { { { 20, 0, 3 }, { 16, 27, 0 } } }, + { { { 20, 0, 2 }, { 15, 30, 1 } } }, + { { { 20, 0, 1 }, { 15, 30, 0 } } }, + { { { 20, 0, 0 }, { 16, 28, 0 } } }, + { { { 20, 0, 1 }, { 15, 31, 1 } } }, + { { { 20, 0, 2 }, { 15, 31, 0 } } }, + { { { 20, 0, 3 }, { 15, 31, 1 } } }, + { { { 20, 0, 4 }, { 16, 30, 1 } } }, + { { { 21, 0, 3 }, { 16, 30, 0 } } }, + { { { 21, 0, 2 }, { 18, 27, 1 } } }, + { { { 21, 0, 1 }, { 18, 27, 0 } } }, + { { { 21, 0, 0 }, { 16, 31, 0 } } }, + { { { 21, 0, 1 }, { 17, 30, 1 } } }, + { { { 21, 0, 2 }, { 17, 30, 0 } } }, + { { { 21, 0, 3 }, { 20, 24, 0 } } }, + { { { 21, 0, 4 }, { 17, 31, 1 } } }, + { { { 22, 0, 3 }, { 17, 31, 0 } } }, + { { { 22, 0, 2 }, { 17, 31, 1 } } }, + { { { 22, 0, 1 }, { 18, 30, 1 } } }, + { { { 22, 0, 0 }, { 18, 30, 0 } } }, + { { { 22, 0, 1 }, { 18, 31, 1 } } }, + { { { 22, 0, 2 }, { 18, 31, 0 } } }, + { { { 22, 0, 3 }, { 20, 27, 0 } } }, + { { { 22, 0, 4 }, { 19, 30, 1 } } }, + { { { 23, 0, 3 }, { 19, 30, 0 } } }, + { { { 23, 0, 2 }, { 20, 28, 0 } } }, + { { { 23, 0, 1 }, { 19, 31, 1 } } }, + { { { 23, 0, 0 }, { 19, 31, 0 } } }, + { { { 23, 0, 1 }, { 19, 31, 1 } } }, + { { { 23, 0, 2 }, { 20, 30, 1 } } }, + { { { 23, 0, 3 }, { 20, 30, 0 } } }, + { { { 23, 0, 4 }, { 22, 27, 1 } } }, + { { { 24, 0, 4 }, { 22, 27, 0 } } }, + { { { 24, 0, 3 }, { 20, 31, 0 } } }, + { { { 24, 0, 2 }, { 21, 30, 1 } } }, + { { { 24, 0, 1 }, { 21, 30, 0 } } }, + { { { 24, 0, 0 }, { 24, 24, 0 } } }, + { { { 24, 0, 1 }, { 21, 31, 1 } } }, + { { { 24, 0, 2 }, { 21, 31, 0 } } }, + { { { 24, 0, 3 }, { 21, 31, 1 } } }, + { { { 24, 0, 4 }, { 22, 30, 1 } } }, + { { { 25, 0, 3 }, { 22, 30, 0 } } }, + { { { 25, 0, 2 }, { 22, 31, 1 } } }, + { { { 25, 0, 1 }, { 22, 31, 0 } } }, + { { { 25, 0, 0 }, { 24, 27, 0 } } }, + { { { 25, 0, 1 }, { 23, 30, 1 } } }, + { { { 25, 0, 2 }, { 23, 30, 0 } } }, + { { { 25, 0, 3 }, { 24, 28, 0 } } }, + { { { 25, 0, 4 }, { 23, 31, 1 } } }, + { { { 26, 0, 3 }, { 23, 31, 0 } } }, + { { { 26, 0, 2 }, { 23, 31, 1 } } }, + { { { 26, 0, 1 }, { 24, 30, 1 } } }, + { { { 26, 0, 0 }, { 24, 30, 0 } } }, + { { { 26, 0, 1 }, { 26, 27, 1 } } }, + { { { 26, 0, 2 }, { 26, 27, 0 } } }, + { { { 26, 0, 3 }, { 24, 31, 0 } } }, + { { { 26, 0, 4 }, { 25, 30, 1 } } }, + { { { 27, 0, 3 }, { 25, 30, 0 } } }, + { { { 27, 0, 2 }, { 28, 24, 0 } } }, + { { { 27, 0, 1 }, { 25, 31, 1 } } }, + { { { 27, 0, 0 }, { 25, 31, 0 } } }, + { { { 27, 0, 1 }, { 25, 31, 1 } } }, + { { { 27, 0, 2 }, { 26, 30, 1 } } }, + { { { 27, 0, 3 }, { 26, 30, 0 } } }, + { { { 27, 0, 4 }, { 26, 31, 1 } } }, + { { { 28, 0, 4 }, { 26, 31, 0 } } }, + { { { 28, 0, 3 }, { 28, 27, 0 } } }, + { { { 28, 0, 2 }, { 27, 30, 1 } } }, + { { { 28, 0, 1 }, { 27, 30, 0 } } }, + { { { 28, 0, 0 }, { 28, 28, 0 } } }, + { { { 28, 0, 1 }, { 27, 31, 1 } } }, + { { { 28, 0, 2 }, { 27, 31, 0 } } }, + { { { 28, 0, 3 }, { 27, 31, 1 } } }, + { { { 28, 0, 4 }, { 28, 30, 1 } } }, + { { { 29, 0, 3 }, { 28, 30, 0 } } }, + { { { 29, 0, 2 }, { 30, 27, 1 } } }, + { { { 29, 0, 1 }, { 30, 27, 0 } } }, + { { { 29, 0, 0 }, { 28, 31, 0 } } }, + { { { 29, 0, 1 }, { 29, 30, 1 } } }, + { { { 29, 0, 2 }, { 29, 30, 0 } } }, + { { { 29, 0, 3 }, { 29, 30, 1 } } }, + { { { 29, 0, 4 }, { 29, 31, 1 } } }, + { { { 30, 0, 3 }, { 29, 31, 0 } } }, + { { { 30, 0, 2 }, { 29, 31, 1 } } }, + { { { 30, 0, 1 }, { 30, 30, 1 } } }, + { { { 30, 0, 0 }, { 30, 30, 0 } } }, + { { { 30, 0, 1 }, { 30, 31, 1 } } }, + { { { 30, 0, 2 }, { 30, 31, 0 } } }, + { { { 30, 0, 3 }, { 30, 31, 1 } } }, + { { { 30, 0, 4 }, { 31, 30, 1 } } }, + { { { 31, 0, 3 }, { 31, 30, 0 } } }, + { { { 31, 0, 2 }, { 31, 30, 1 } } }, + { { { 31, 0, 1 }, { 31, 31, 1 } } }, + { { { 31, 0, 0 }, { 31, 31, 0 } } } +}; + +static SingleColourLookup const lookup_6_4[] = +{ + { { { 0, 0, 0 }, { 0, 0, 0 } } }, + { { { 0, 0, 1 }, { 0, 1, 0 } } }, + { { { 0, 0, 2 }, { 0, 2, 0 } } }, + { { { 1, 0, 1 }, { 0, 3, 1 } } }, + { { { 1, 0, 0 }, { 0, 3, 0 } } }, + { { { 1, 0, 1 }, { 0, 4, 0 } } }, + { { { 1, 0, 2 }, { 0, 5, 0 } } }, + { { { 2, 0, 1 }, { 0, 6, 1 } } }, + { { { 2, 0, 0 }, { 0, 6, 0 } } }, + { { { 2, 0, 1 }, { 0, 7, 0 } } }, + { { { 2, 0, 2 }, { 0, 8, 0 } } }, + { { { 3, 0, 1 }, { 0, 9, 1 } } }, + { { { 3, 0, 0 }, { 0, 9, 0 } } }, + { { { 3, 0, 1 }, { 0, 10, 0 } } }, + { { { 3, 0, 2 }, { 0, 11, 0 } } }, + { { { 4, 0, 1 }, { 0, 12, 1 } } }, + { { { 4, 0, 0 }, { 0, 12, 0 } } }, + { { { 4, 0, 1 }, { 0, 13, 0 } } }, + { { { 4, 0, 2 }, { 0, 14, 0 } } }, + { { { 5, 0, 1 }, { 0, 15, 1 } } }, + { { { 5, 0, 0 }, { 0, 15, 0 } } }, + { { { 5, 0, 1 }, { 0, 16, 0 } } }, + { { { 5, 0, 2 }, { 1, 15, 0 } } }, + { { { 6, 0, 1 }, { 0, 17, 0 } } }, + { { { 6, 0, 0 }, { 0, 18, 0 } } }, + { { { 6, 0, 1 }, { 0, 19, 0 } } }, + { { { 6, 0, 2 }, { 3, 14, 0 } } }, + { { { 7, 0, 1 }, { 0, 20, 0 } } }, + { { { 7, 0, 0 }, { 0, 21, 0 } } }, + { { { 7, 0, 1 }, { 0, 22, 0 } } }, + { { { 7, 0, 2 }, { 4, 15, 0 } } }, + { { { 8, 0, 1 }, { 0, 23, 0 } } }, + { { { 8, 0, 0 }, { 0, 24, 0 } } }, + { { { 8, 0, 1 }, { 0, 25, 0 } } }, + { { { 8, 0, 2 }, { 6, 14, 0 } } }, + { { { 9, 0, 1 }, { 0, 26, 0 } } }, + { { { 9, 0, 0 }, { 0, 27, 0 } } }, + { { { 9, 0, 1 }, { 0, 28, 0 } } }, + { { { 9, 0, 2 }, { 7, 15, 0 } } }, + { { { 10, 0, 1 }, { 0, 29, 0 } } }, + { { { 10, 0, 0 }, { 0, 30, 0 } } }, + { { { 10, 0, 1 }, { 0, 31, 0 } } }, + { { { 10, 0, 2 }, { 9, 14, 0 } } }, + { { { 11, 0, 1 }, { 0, 32, 0 } } }, + { { { 11, 0, 0 }, { 0, 33, 0 } } }, + { { { 11, 0, 1 }, { 2, 30, 0 } } }, + { { { 11, 0, 2 }, { 0, 34, 0 } } }, + { { { 12, 0, 1 }, { 0, 35, 0 } } }, + { { { 12, 0, 0 }, { 0, 36, 0 } } }, + { { { 12, 0, 1 }, { 3, 31, 0 } } }, + { { { 12, 0, 2 }, { 0, 37, 0 } } }, + { { { 13, 0, 1 }, { 0, 38, 0 } } }, + { { { 13, 0, 0 }, { 0, 39, 0 } } }, + { { { 13, 0, 1 }, { 5, 30, 0 } } }, + { { { 13, 0, 2 }, { 0, 40, 0 } } }, + { { { 14, 0, 1 }, { 0, 41, 0 } } }, + { { { 14, 0, 0 }, { 0, 42, 0 } } }, + { { { 14, 0, 1 }, { 6, 31, 0 } } }, + { { { 14, 0, 2 }, { 0, 43, 0 } } }, + { { { 15, 0, 1 }, { 0, 44, 0 } } }, + { { { 15, 0, 0 }, { 0, 45, 0 } } }, + { { { 15, 0, 1 }, { 8, 30, 0 } } }, + { { { 15, 0, 2 }, { 0, 46, 0 } } }, + { { { 16, 0, 2 }, { 0, 47, 0 } } }, + { { { 16, 0, 1 }, { 1, 46, 0 } } }, + { { { 16, 0, 0 }, { 0, 48, 0 } } }, + { { { 16, 0, 1 }, { 0, 49, 0 } } }, + { { { 16, 0, 2 }, { 0, 50, 0 } } }, + { { { 17, 0, 1 }, { 2, 47, 0 } } }, + { { { 17, 0, 0 }, { 0, 51, 0 } } }, + { { { 17, 0, 1 }, { 0, 52, 0 } } }, + { { { 17, 0, 2 }, { 0, 53, 0 } } }, + { { { 18, 0, 1 }, { 4, 46, 0 } } }, + { { { 18, 0, 0 }, { 0, 54, 0 } } }, + { { { 18, 0, 1 }, { 0, 55, 0 } } }, + { { { 18, 0, 2 }, { 0, 56, 0 } } }, + { { { 19, 0, 1 }, { 5, 47, 0 } } }, + { { { 19, 0, 0 }, { 0, 57, 0 } } }, + { { { 19, 0, 1 }, { 0, 58, 0 } } }, + { { { 19, 0, 2 }, { 0, 59, 0 } } }, + { { { 20, 0, 1 }, { 7, 46, 0 } } }, + { { { 20, 0, 0 }, { 0, 60, 0 } } }, + { { { 20, 0, 1 }, { 0, 61, 0 } } }, + { { { 20, 0, 2 }, { 0, 62, 0 } } }, + { { { 21, 0, 1 }, { 8, 47, 0 } } }, + { { { 21, 0, 0 }, { 0, 63, 0 } } }, + { { { 21, 0, 1 }, { 1, 62, 0 } } }, + { { { 21, 0, 2 }, { 1, 63, 0 } } }, + { { { 22, 0, 1 }, { 10, 46, 0 } } }, + { { { 22, 0, 0 }, { 2, 62, 0 } } }, + { { { 22, 0, 1 }, { 2, 63, 0 } } }, + { { { 22, 0, 2 }, { 3, 62, 0 } } }, + { { { 23, 0, 1 }, { 11, 47, 0 } } }, + { { { 23, 0, 0 }, { 3, 63, 0 } } }, + { { { 23, 0, 1 }, { 4, 62, 0 } } }, + { { { 23, 0, 2 }, { 4, 63, 0 } } }, + { { { 24, 0, 1 }, { 13, 46, 0 } } }, + { { { 24, 0, 0 }, { 5, 62, 0 } } }, + { { { 24, 0, 1 }, { 5, 63, 0 } } }, + { { { 24, 0, 2 }, { 6, 62, 0 } } }, + { { { 25, 0, 1 }, { 14, 47, 0 } } }, + { { { 25, 0, 0 }, { 6, 63, 0 } } }, + { { { 25, 0, 1 }, { 7, 62, 0 } } }, + { { { 25, 0, 2 }, { 7, 63, 0 } } }, + { { { 26, 0, 1 }, { 16, 45, 0 } } }, + { { { 26, 0, 0 }, { 8, 62, 0 } } }, + { { { 26, 0, 1 }, { 8, 63, 0 } } }, + { { { 26, 0, 2 }, { 9, 62, 0 } } }, + { { { 27, 0, 1 }, { 16, 48, 0 } } }, + { { { 27, 0, 0 }, { 9, 63, 0 } } }, + { { { 27, 0, 1 }, { 10, 62, 0 } } }, + { { { 27, 0, 2 }, { 10, 63, 0 } } }, + { { { 28, 0, 1 }, { 16, 51, 0 } } }, + { { { 28, 0, 0 }, { 11, 62, 0 } } }, + { { { 28, 0, 1 }, { 11, 63, 0 } } }, + { { { 28, 0, 2 }, { 12, 62, 0 } } }, + { { { 29, 0, 1 }, { 16, 54, 0 } } }, + { { { 29, 0, 0 }, { 12, 63, 0 } } }, + { { { 29, 0, 1 }, { 13, 62, 0 } } }, + { { { 29, 0, 2 }, { 13, 63, 0 } } }, + { { { 30, 0, 1 }, { 16, 57, 0 } } }, + { { { 30, 0, 0 }, { 14, 62, 0 } } }, + { { { 30, 0, 1 }, { 14, 63, 0 } } }, + { { { 30, 0, 2 }, { 15, 62, 0 } } }, + { { { 31, 0, 1 }, { 16, 60, 0 } } }, + { { { 31, 0, 0 }, { 15, 63, 0 } } }, + { { { 31, 0, 1 }, { 24, 46, 0 } } }, + { { { 31, 0, 2 }, { 16, 62, 0 } } }, + { { { 32, 0, 2 }, { 16, 63, 0 } } }, + { { { 32, 0, 1 }, { 17, 62, 0 } } }, + { { { 32, 0, 0 }, { 25, 47, 0 } } }, + { { { 32, 0, 1 }, { 17, 63, 0 } } }, + { { { 32, 0, 2 }, { 18, 62, 0 } } }, + { { { 33, 0, 1 }, { 18, 63, 0 } } }, + { { { 33, 0, 0 }, { 27, 46, 0 } } }, + { { { 33, 0, 1 }, { 19, 62, 0 } } }, + { { { 33, 0, 2 }, { 19, 63, 0 } } }, + { { { 34, 0, 1 }, { 20, 62, 0 } } }, + { { { 34, 0, 0 }, { 28, 47, 0 } } }, + { { { 34, 0, 1 }, { 20, 63, 0 } } }, + { { { 34, 0, 2 }, { 21, 62, 0 } } }, + { { { 35, 0, 1 }, { 21, 63, 0 } } }, + { { { 35, 0, 0 }, { 30, 46, 0 } } }, + { { { 35, 0, 1 }, { 22, 62, 0 } } }, + { { { 35, 0, 2 }, { 22, 63, 0 } } }, + { { { 36, 0, 1 }, { 23, 62, 0 } } }, + { { { 36, 0, 0 }, { 31, 47, 0 } } }, + { { { 36, 0, 1 }, { 23, 63, 0 } } }, + { { { 36, 0, 2 }, { 24, 62, 0 } } }, + { { { 37, 0, 1 }, { 24, 63, 0 } } }, + { { { 37, 0, 0 }, { 32, 47, 0 } } }, + { { { 37, 0, 1 }, { 25, 62, 0 } } }, + { { { 37, 0, 2 }, { 25, 63, 0 } } }, + { { { 38, 0, 1 }, { 26, 62, 0 } } }, + { { { 38, 0, 0 }, { 32, 50, 0 } } }, + { { { 38, 0, 1 }, { 26, 63, 0 } } }, + { { { 38, 0, 2 }, { 27, 62, 0 } } }, + { { { 39, 0, 1 }, { 27, 63, 0 } } }, + { { { 39, 0, 0 }, { 32, 53, 0 } } }, + { { { 39, 0, 1 }, { 28, 62, 0 } } }, + { { { 39, 0, 2 }, { 28, 63, 0 } } }, + { { { 40, 0, 1 }, { 29, 62, 0 } } }, + { { { 40, 0, 0 }, { 32, 56, 0 } } }, + { { { 40, 0, 1 }, { 29, 63, 0 } } }, + { { { 40, 0, 2 }, { 30, 62, 0 } } }, + { { { 41, 0, 1 }, { 30, 63, 0 } } }, + { { { 41, 0, 0 }, { 32, 59, 0 } } }, + { { { 41, 0, 1 }, { 31, 62, 0 } } }, + { { { 41, 0, 2 }, { 31, 63, 0 } } }, + { { { 42, 0, 1 }, { 32, 61, 0 } } }, + { { { 42, 0, 0 }, { 32, 62, 0 } } }, + { { { 42, 0, 1 }, { 32, 63, 0 } } }, + { { { 42, 0, 2 }, { 41, 46, 0 } } }, + { { { 43, 0, 1 }, { 33, 62, 0 } } }, + { { { 43, 0, 0 }, { 33, 63, 0 } } }, + { { { 43, 0, 1 }, { 34, 62, 0 } } }, + { { { 43, 0, 2 }, { 42, 47, 0 } } }, + { { { 44, 0, 1 }, { 34, 63, 0 } } }, + { { { 44, 0, 0 }, { 35, 62, 0 } } }, + { { { 44, 0, 1 }, { 35, 63, 0 } } }, + { { { 44, 0, 2 }, { 44, 46, 0 } } }, + { { { 45, 0, 1 }, { 36, 62, 0 } } }, + { { { 45, 0, 0 }, { 36, 63, 0 } } }, + { { { 45, 0, 1 }, { 37, 62, 0 } } }, + { { { 45, 0, 2 }, { 45, 47, 0 } } }, + { { { 46, 0, 1 }, { 37, 63, 0 } } }, + { { { 46, 0, 0 }, { 38, 62, 0 } } }, + { { { 46, 0, 1 }, { 38, 63, 0 } } }, + { { { 46, 0, 2 }, { 47, 46, 0 } } }, + { { { 47, 0, 1 }, { 39, 62, 0 } } }, + { { { 47, 0, 0 }, { 39, 63, 0 } } }, + { { { 47, 0, 1 }, { 40, 62, 0 } } }, + { { { 47, 0, 2 }, { 48, 46, 0 } } }, + { { { 48, 0, 2 }, { 40, 63, 0 } } }, + { { { 48, 0, 1 }, { 41, 62, 0 } } }, + { { { 48, 0, 0 }, { 41, 63, 0 } } }, + { { { 48, 0, 1 }, { 48, 49, 0 } } }, + { { { 48, 0, 2 }, { 42, 62, 0 } } }, + { { { 49, 0, 1 }, { 42, 63, 0 } } }, + { { { 49, 0, 0 }, { 43, 62, 0 } } }, + { { { 49, 0, 1 }, { 48, 52, 0 } } }, + { { { 49, 0, 2 }, { 43, 63, 0 } } }, + { { { 50, 0, 1 }, { 44, 62, 0 } } }, + { { { 50, 0, 0 }, { 44, 63, 0 } } }, + { { { 50, 0, 1 }, { 48, 55, 0 } } }, + { { { 50, 0, 2 }, { 45, 62, 0 } } }, + { { { 51, 0, 1 }, { 45, 63, 0 } } }, + { { { 51, 0, 0 }, { 46, 62, 0 } } }, + { { { 51, 0, 1 }, { 48, 58, 0 } } }, + { { { 51, 0, 2 }, { 46, 63, 0 } } }, + { { { 52, 0, 1 }, { 47, 62, 0 } } }, + { { { 52, 0, 0 }, { 47, 63, 0 } } }, + { { { 52, 0, 1 }, { 48, 61, 0 } } }, + { { { 52, 0, 2 }, { 48, 62, 0 } } }, + { { { 53, 0, 1 }, { 56, 47, 0 } } }, + { { { 53, 0, 0 }, { 48, 63, 0 } } }, + { { { 53, 0, 1 }, { 49, 62, 0 } } }, + { { { 53, 0, 2 }, { 49, 63, 0 } } }, + { { { 54, 0, 1 }, { 58, 46, 0 } } }, + { { { 54, 0, 0 }, { 50, 62, 0 } } }, + { { { 54, 0, 1 }, { 50, 63, 0 } } }, + { { { 54, 0, 2 }, { 51, 62, 0 } } }, + { { { 55, 0, 1 }, { 59, 47, 0 } } }, + { { { 55, 0, 0 }, { 51, 63, 0 } } }, + { { { 55, 0, 1 }, { 52, 62, 0 } } }, + { { { 55, 0, 2 }, { 52, 63, 0 } } }, + { { { 56, 0, 1 }, { 61, 46, 0 } } }, + { { { 56, 0, 0 }, { 53, 62, 0 } } }, + { { { 56, 0, 1 }, { 53, 63, 0 } } }, + { { { 56, 0, 2 }, { 54, 62, 0 } } }, + { { { 57, 0, 1 }, { 62, 47, 0 } } }, + { { { 57, 0, 0 }, { 54, 63, 0 } } }, + { { { 57, 0, 1 }, { 55, 62, 0 } } }, + { { { 57, 0, 2 }, { 55, 63, 0 } } }, + { { { 58, 0, 1 }, { 56, 62, 1 } } }, + { { { 58, 0, 0 }, { 56, 62, 0 } } }, + { { { 58, 0, 1 }, { 56, 63, 0 } } }, + { { { 58, 0, 2 }, { 57, 62, 0 } } }, + { { { 59, 0, 1 }, { 57, 63, 1 } } }, + { { { 59, 0, 0 }, { 57, 63, 0 } } }, + { { { 59, 0, 1 }, { 58, 62, 0 } } }, + { { { 59, 0, 2 }, { 58, 63, 0 } } }, + { { { 60, 0, 1 }, { 59, 62, 1 } } }, + { { { 60, 0, 0 }, { 59, 62, 0 } } }, + { { { 60, 0, 1 }, { 59, 63, 0 } } }, + { { { 60, 0, 2 }, { 60, 62, 0 } } }, + { { { 61, 0, 1 }, { 60, 63, 1 } } }, + { { { 61, 0, 0 }, { 60, 63, 0 } } }, + { { { 61, 0, 1 }, { 61, 62, 0 } } }, + { { { 61, 0, 2 }, { 61, 63, 0 } } }, + { { { 62, 0, 1 }, { 62, 62, 1 } } }, + { { { 62, 0, 0 }, { 62, 62, 0 } } }, + { { { 62, 0, 1 }, { 62, 63, 0 } } }, + { { { 62, 0, 2 }, { 63, 62, 0 } } }, + { { { 63, 0, 1 }, { 63, 63, 1 } } }, + { { { 63, 0, 0 }, { 63, 63, 0 } } } +}; diff --git a/extern/libsquish-1.15/squish.cpp b/extern/libsquish-1.15/squish.cpp new file mode 100644 index 00000000..1d22a64a --- /dev/null +++ b/extern/libsquish-1.15/squish.cpp @@ -0,0 +1,403 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#include +#include "squish.h" +#include "colourset.h" +#include "maths.h" +#include "rangefit.h" +#include "clusterfit.h" +#include "colourblock.h" +#include "alpha.h" +#include "singlecolourfit.h" + +namespace squish { + +static int FixFlags( int flags ) +{ + // grab the flag bits + int method = flags & ( kDxt1 | kDxt3 | kDxt5 | kBc4 | kBc5 ); + int fit = flags & ( kColourIterativeClusterFit | kColourClusterFit | kColourRangeFit ); + int extra = flags & kWeightColourByAlpha; + + // set defaults + if ( method != kDxt3 + && method != kDxt5 + && method != kBc4 + && method != kBc5 ) + { + method = kDxt1; + } + if( fit != kColourRangeFit && fit != kColourIterativeClusterFit ) + fit = kColourClusterFit; + + // done + return method | fit | extra; +} + +void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric ) +{ + // fix any bad flags + flags = FixFlags( flags ); + + if ( ( flags & ( kBc4 | kBc5 ) ) != 0 ) + { + u8 alpha[16*4]; + for( int i = 0; i < 16; ++i ) + { + alpha[i*4 + 3] = rgba[i*4 + 0]; // copy R to A + } + + u8* rBlock = reinterpret_cast< u8* >( block ); + CompressAlphaDxt5( alpha, mask, rBlock ); + + if ( ( flags & ( kBc5 ) ) != 0 ) + { + for( int i = 0; i < 16; ++i ) + { + alpha[i*4 + 3] = rgba[i*4 + 1]; // copy G to A + } + + u8* gBlock = reinterpret_cast< u8* >( block ) + 8; + CompressAlphaDxt5( alpha, mask, gBlock ); + } + + return; + } + + // get the block locations + void* colourBlock = block; + void* alphaBlock = block; + if( ( flags & ( kDxt3 | kDxt5 ) ) != 0 ) + colourBlock = reinterpret_cast< u8* >( block ) + 8; + + // create the minimal point set + ColourSet colours( rgba, mask, flags ); + + // check the compression type and compress colour + if( colours.GetCount() == 1 ) + { + // always do a single colour fit + SingleColourFit fit( &colours, flags ); + fit.Compress( colourBlock ); + } + else if( ( flags & kColourRangeFit ) != 0 || colours.GetCount() == 0 ) + { + // do a range fit + RangeFit fit( &colours, flags, metric ); + fit.Compress( colourBlock ); + } + else + { + // default to a cluster fit (could be iterative or not) + ClusterFit fit( &colours, flags, metric ); + fit.Compress( colourBlock ); + } + + // compress alpha separately if necessary + if( ( flags & kDxt3 ) != 0 ) + CompressAlphaDxt3( rgba, mask, alphaBlock ); + else if( ( flags & kDxt5 ) != 0 ) + CompressAlphaDxt5( rgba, mask, alphaBlock ); +} + +void Decompress( u8* rgba, void const* block, int flags ) +{ + // fix any bad flags + flags = FixFlags( flags ); + + // get the block locations + void const* colourBlock = block; + void const* alphaBlock = block; + if( ( flags & ( kDxt3 | kDxt5 ) ) != 0 ) + colourBlock = reinterpret_cast< u8 const* >( block ) + 8; + + // decompress colour + DecompressColour( rgba, colourBlock, ( flags & kDxt1 ) != 0 ); + + // decompress alpha separately if necessary + if( ( flags & kDxt3 ) != 0 ) + DecompressAlphaDxt3( rgba, alphaBlock ); + else if( ( flags & kDxt5 ) != 0 ) + DecompressAlphaDxt5( rgba, alphaBlock ); +} + +int GetStorageRequirements( int width, int height, int flags ) +{ + // fix any bad flags + flags = FixFlags( flags ); + + // compute the storage requirements + int blockcount = ( ( width + 3 )/4 ) * ( ( height + 3 )/4 ); + int blocksize = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; + return blockcount*blocksize; +} + +void CopyRGBA( u8 const* source, u8* dest, int flags ) +{ + if (flags & kSourceBGRA) + { + // convert from bgra to rgba + dest[0] = source[2]; + dest[1] = source[1]; + dest[2] = source[0]; + dest[3] = source[3]; + } + else + { + for( int i = 0; i < 4; ++i ) + *dest++ = *source++; + } +} + +void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric ) +{ + // fix any bad flags + flags = FixFlags( flags ); + + // loop over blocks +#ifdef SQUISH_USE_OPENMP +# pragma omp parallel for +#endif + for( int y = 0; y < height; y += 4 ) + { + // initialise the block output + u8* targetBlock = reinterpret_cast< u8* >( blocks ); + int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; + targetBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock; + + for( int x = 0; x < width; x += 4 ) + { + // build the 4x4 block of pixels + u8 sourceRgba[16*4]; + u8* targetPixel = sourceRgba; + int mask = 0; + for( int py = 0; py < 4; ++py ) + { + for( int px = 0; px < 4; ++px ) + { + // get the source pixel in the image + int sx = x + px; + int sy = y + py; + + // enable if we're in the image + if( sx < width && sy < height ) + { + // copy the rgba value + u8 const* sourcePixel = rgba + pitch*sy + 4*sx; + CopyRGBA(sourcePixel, targetPixel, flags); + // enable this pixel + mask |= ( 1 << ( 4*py + px ) ); + } + + // advance to the next pixel + targetPixel += 4; + } + } + + // compress it into the output + CompressMasked( sourceRgba, mask, targetBlock, flags, metric ); + + // advance + targetBlock += bytesPerBlock; + } + } +} + +void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric ) +{ + CompressImage(rgba, width, height, width*4, blocks, flags, metric); +} + +void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ) +{ + // fix any bad flags + flags = FixFlags( flags ); + + // loop over blocks +#ifdef SQUISH_USE_OPENMP +# pragma omp parallel for +#endif + for( int y = 0; y < height; y += 4 ) + { + // initialise the block input + u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks ); + int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; + sourceBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock; + + for( int x = 0; x < width; x += 4 ) + { + // decompress the block + u8 targetRgba[4*16]; + Decompress( targetRgba, sourceBlock, flags ); + + // write the decompressed pixels to the correct image locations + u8 const* sourcePixel = targetRgba; + for( int py = 0; py < 4; ++py ) + { + for( int px = 0; px < 4; ++px ) + { + // get the target location + int sx = x + px; + int sy = y + py; + + // write if we're in the image + if( sx < width && sy < height ) + { + // copy the rgba value + u8* targetPixel = rgba + pitch*sy + 4*sx; + CopyRGBA(sourcePixel, targetPixel, flags); + } + + // advance to the next pixel + sourcePixel += 4; + } + } + + // advance + sourceBlock += bytesPerBlock; + } + } +} + +void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ) +{ + DecompressImage( rgba, width, height, width*4, blocks, flags ); +} + +static double ErrorSq(double x, double y) +{ + return (x - y) * (x - y); +} + +static void ComputeBlockWMSE(u8 const *original, u8 const *compressed, unsigned int w, unsigned int h, double &cmse, double &amse) +{ + // Computes the MSE for the block and weights it by the variance of the original block. + // If the variance of the original block is less than 4 (i.e. a standard deviation of 1 per channel) + // then the block is close to being a single colour. Quantisation errors in single colour blocks + // are easier to see than similar errors in blocks that contain more colours, particularly when there + // are many such blocks in a large area (eg a blue sky background) as they cause banding. Given that + // banding is easier to see than small errors in "complex" blocks, we weight the errors by a factor + // of 5. This implies that images with large, single colour areas will have a higher potential WMSE + // than images with lots of detail. + + cmse = amse = 0; + unsigned int sum_p[4]; // per channel sum of pixels + unsigned int sum_p2[4]; // per channel sum of pixels squared + memset(sum_p, 0, sizeof(sum_p)); + memset(sum_p2, 0, sizeof(sum_p2)); + for( unsigned int py = 0; py < 4; ++py ) + { + for( unsigned int px = 0; px < 4; ++px ) + { + if( px < w && py < h ) + { + double pixelCMSE = 0; + for( int i = 0; i < 3; ++i ) + { + pixelCMSE += ErrorSq(original[i], compressed[i]); + sum_p[i] += original[i]; + sum_p2[i] += (unsigned int)original[i]*original[i]; + } + if( original[3] == 0 && compressed[3] == 0 ) + pixelCMSE = 0; // transparent in both, so colour is inconsequential + amse += ErrorSq(original[3], compressed[3]); + cmse += pixelCMSE; + sum_p[3] += original[3]; + sum_p2[3] += (unsigned int)original[3]*original[3]; + } + original += 4; + compressed += 4; + } + } + unsigned int variance = 0; + for( int i = 0; i < 4; ++i ) + variance += w*h*sum_p2[i] - sum_p[i]*sum_p[i]; + if( variance < 4 * w * w * h * h ) + { + amse *= 5; + cmse *= 5; + } +} + +void ComputeMSE( u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE ) +{ + // fix any bad flags + flags = FixFlags( flags ); + colourMSE = alphaMSE = 0; + + // initialise the block input + squish::u8 const* sourceBlock = dxt; + int bytesPerBlock = ( ( flags & squish::kDxt1 ) != 0 ) ? 8 : 16; + + // loop over blocks + for( int y = 0; y < height; y += 4 ) + { + for( int x = 0; x < width; x += 4 ) + { + // decompress the block + u8 targetRgba[4*16]; + Decompress( targetRgba, sourceBlock, flags ); + u8 const* sourcePixel = targetRgba; + + // copy across to a similar pixel block + u8 originalRgba[4*16]; + u8* originalPixel = originalRgba; + + for( int py = 0; py < 4; ++py ) + { + for( int px = 0; px < 4; ++px ) + { + int sx = x + px; + int sy = y + py; + if( sx < width && sy < height ) + { + u8 const* targetPixel = rgba + pitch*sy + 4*sx; + CopyRGBA(targetPixel, originalPixel, flags); + } + sourcePixel += 4; + originalPixel += 4; + } + } + + // compute the weighted MSE of the block + double blockCMSE, blockAMSE; + ComputeBlockWMSE(originalRgba, targetRgba, std::min(4, width - x), std::min(4, height - y), blockCMSE, blockAMSE); + colourMSE += blockCMSE; + alphaMSE += blockAMSE; + // advance + sourceBlock += bytesPerBlock; + } + } + colourMSE /= (width * height * 3); + alphaMSE /= (width * height); +} + +void ComputeMSE( u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE ) +{ + ComputeMSE(rgba, width, height, width*4, dxt, flags, colourMSE, alphaMSE); +} + +} // namespace squish diff --git a/extern/libsquish-1.15/squish.h b/extern/libsquish-1.15/squish.h new file mode 100644 index 00000000..14c9bb59 --- /dev/null +++ b/extern/libsquish-1.15/squish.h @@ -0,0 +1,309 @@ +/* ----------------------------------------------------------------------------- + + Copyright (c) 2006 Simon Brown si@sjbrown.co.uk + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + -------------------------------------------------------------------------- */ + +#ifndef SQUISH_H +#define SQUISH_H + +//! All squish API functions live in this namespace. +namespace squish { + +// ----------------------------------------------------------------------------- + +//! Typedef a quantity that is a single unsigned byte. +typedef unsigned char u8; + +// ----------------------------------------------------------------------------- + +enum +{ + //! Use DXT1 compression. + kDxt1 = ( 1 << 0 ), + + //! Use DXT3 compression. + kDxt3 = ( 1 << 1 ), + + //! Use DXT5 compression. + kDxt5 = ( 1 << 2 ), + + //! Use BC4 compression. + kBc4 = ( 1 << 3 ), + + //! Use BC5 compression. + kBc5 = ( 1 << 4 ), + + //! Use a slow but high quality colour compressor (the default). + kColourClusterFit = ( 1 << 5 ), + + //! Use a fast but low quality colour compressor. + kColourRangeFit = ( 1 << 6 ), + + //! Weight the colour by alpha during cluster fit (disabled by default). + kWeightColourByAlpha = ( 1 << 7 ), + + //! Use a very slow but very high quality colour compressor. + kColourIterativeClusterFit = ( 1 << 8 ), + + //! Source is BGRA rather than RGBA + kSourceBGRA = ( 1 << 9 ) +}; + +// ----------------------------------------------------------------------------- + +/*! @brief Compresses a 4x4 block of pixels. + + @param rgba The rgba values of the 16 source pixels. + @param mask The valid pixel mask. + @param block Storage for the compressed DXT block. + @param flags Compression flags. + @param metric An optional perceptual metric. + + The source pixels should be presented as a contiguous array of 16 rgba + values, with each component as 1 byte each. In memory this should be: + + { r1, g1, b1, a1, .... , r16, g16, b16, a16 } + + The mask parameter enables only certain pixels within the block. The lowest + bit enables the first pixel and so on up to the 16th bit. Bits beyond the + 16th bit are ignored. Pixels that are not enabled are allowed to take + arbitrary colours in the output block. An example of how this can be used + is in the CompressImage function to disable pixels outside the bounds of + the image when the width or height is not divisible by 4. + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. When using DXT1 + compression, 8 bytes of storage are required for the compressed DXT block. + DXT3 and DXT5 compression require 16 bytes of storage per block. + + The flags parameter can also specify a preferred colour compressor to use + when fitting the RGB components of the data. Possible colour compressors + are: kColourClusterFit (the default), kColourRangeFit (very fast, low + quality) or kColourIterativeClusterFit (slowest, best quality). + + When using kColourClusterFit or kColourIterativeClusterFit, an additional + flag can be specified to weight the importance of each pixel by its alpha + value. For images that are rendered using alpha blending, this can + significantly increase the perceived quality. + + The metric parameter can be used to weight the relative importance of each + colour channel, or pass NULL to use the default uniform weight of + { 1.0f, 1.0f, 1.0f }. This replaces the previous flag-based control that + allowed either uniform or "perceptual" weights with the fixed values + { 0.2126f, 0.7152f, 0.0722f }. If non-NULL, the metric should point to a + contiguous array of 3 floats. +*/ +void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 ); + +// ----------------------------------------------------------------------------- + +/*! @brief Compresses a 4x4 block of pixels. + + @param rgba The rgba values of the 16 source pixels. + @param block Storage for the compressed DXT block. + @param flags Compression flags. + @param metric An optional perceptual metric. + + The source pixels should be presented as a contiguous array of 16 rgba + values, with each component as 1 byte each. In memory this should be: + + { r1, g1, b1, a1, .... , r16, g16, b16, a16 } + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. When using DXT1 + compression, 8 bytes of storage are required for the compressed DXT block. + DXT3 and DXT5 compression require 16 bytes of storage per block. + + The flags parameter can also specify a preferred colour compressor to use + when fitting the RGB components of the data. Possible colour compressors + are: kColourClusterFit (the default), kColourRangeFit (very fast, low + quality) or kColourIterativeClusterFit (slowest, best quality). + + When using kColourClusterFit or kColourIterativeClusterFit, an additional + flag can be specified to weight the importance of each pixel by its alpha + value. For images that are rendered using alpha blending, this can + significantly increase the perceived quality. + + The metric parameter can be used to weight the relative importance of each + colour channel, or pass NULL to use the default uniform weight of + { 1.0f, 1.0f, 1.0f }. This replaces the previous flag-based control that + allowed either uniform or "perceptual" weights with the fixed values + { 0.2126f, 0.7152f, 0.0722f }. If non-NULL, the metric should point to a + contiguous array of 3 floats. + + This method is an inline that calls CompressMasked with a mask of 0xffff, + provided for compatibility with older versions of squish. +*/ +inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 ) +{ + CompressMasked( rgba, 0xffff, block, flags, metric ); +} + +// ----------------------------------------------------------------------------- + +/*! @brief Decompresses a 4x4 block of pixels. + + @param rgba Storage for the 16 decompressed pixels. + @param block The compressed DXT block. + @param flags Compression flags. + + The decompressed pixels will be written as a contiguous array of 16 rgba + values, with each component as 1 byte each. In memory this is: + + { r1, g1, b1, a1, .... , r16, g16, b16, a16 } + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. All other flags + are ignored. +*/ +void Decompress( u8* rgba, void const* block, int flags ); + +// ----------------------------------------------------------------------------- + +/*! @brief Computes the amount of compressed storage required. + + @param width The width of the image. + @param height The height of the image. + @param flags Compression flags. + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. All other flags + are ignored. + + Most DXT images will be a multiple of 4 in each dimension, but this + function supports arbitrary size images by allowing the outer blocks to + be only partially used. +*/ +int GetStorageRequirements( int width, int height, int flags ); + +// ----------------------------------------------------------------------------- + +/*! @brief Compresses an image in memory. + + @param rgba The pixels of the source. + @param width The width of the source image. + @param height The height of the source image. + @param pitch The pitch of the source image. + @param blocks Storage for the compressed output. + @param flags Compression flags. + @param metric An optional perceptual metric. + + The source pixels should be presented as a contiguous array of width*height + rgba values, with each component as 1 byte each. In memory this should be: + + { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. When using DXT1 + compression, 8 bytes of storage are required for each compressed DXT block. + DXT3 and DXT5 compression require 16 bytes of storage per block. + + The flags parameter can also specify a preferred colour compressor to use + when fitting the RGB components of the data. Possible colour compressors + are: kColourClusterFit (the default), kColourRangeFit (very fast, low + quality) or kColourIterativeClusterFit (slowest, best quality). + + When using kColourClusterFit or kColourIterativeClusterFit, an additional + flag can be specified to weight the importance of each pixel by its alpha + value. For images that are rendered using alpha blending, this can + significantly increase the perceived quality. + + The metric parameter can be used to weight the relative importance of each + colour channel, or pass NULL to use the default uniform weight of + { 1.0f, 1.0f, 1.0f }. This replaces the previous flag-based control that + allowed either uniform or "perceptual" weights with the fixed values + { 0.2126f, 0.7152f, 0.0722f }. If non-NULL, the metric should point to a + contiguous array of 3 floats. + + Internally this function calls squish::CompressMasked for each block, which + allows for pixels outside the image to take arbitrary values. The function + squish::GetStorageRequirements can be called to compute the amount of memory + to allocate for the compressed output. + + Note on compression quality: When compressing textures with + libsquish it is recommended to apply a gamma-correction + beforehand. This will reduce the blockiness in dark areas. The + level of necessary gamma-correction is platform dependent. For + example, a gamma correction with gamma = 0.5 before compression + and gamma = 2.0 after decompression yields good results on the + Windows platform but for other platforms like MacOS X a different + gamma value may be more suitable. +*/ +void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); +void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); + +// ----------------------------------------------------------------------------- + +/*! @brief Decompresses an image in memory. + + @param rgba Storage for the decompressed pixels. + @param width The width of the source image. + @param height The height of the source image. + @param pitch The pitch of the decompressed pixels. + @param blocks The compressed DXT blocks. + @param flags Compression flags. + + The decompressed pixels will be written as a contiguous array of width*height + 16 rgba values, with each component as 1 byte each. In memory this is: + + { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. All other flags + are ignored. + + Internally this function calls squish::Decompress for each block. +*/ +void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags ); +void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ); + +// ----------------------------------------------------------------------------- + +/*! @brief Computes MSE of an compressed image in memory. + + @param rgba The original image pixels. + @param width The width of the source image. + @param height The height of the source image. + @param pitch The pitch of the source image. + @param dxt The compressed dxt blocks + @param flags Compression flags. + @param colourMSE The MSE of the colour values. + @param alphaMSE The MSE of the alpha values. + + The colour MSE and alpha MSE are computed across all pixels. The colour MSE is + averaged across all rgb values (i.e. colourMSE = sum sum_k ||dxt.k - rgba.k||/3) + + The flags parameter should specify kDxt1, kDxt3, kDxt5, kBc4, or kBc5 compression, + however, DXT1 will be used by default if none is specified. All other flags + are ignored. + + Internally this function calls squish::Decompress for each block. +*/ +void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); +void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE); + +// ----------------------------------------------------------------------------- + +} // namespace squish + +#endif // ndef SQUISH_H diff --git a/extern/poshlib/posh.h b/extern/poshlib/posh.h index 716607d2..6cfb6c8e 100644 --- a/extern/poshlib/posh.h +++ b/extern/poshlib/posh.h @@ -87,6 +87,7 @@ GNU GCC/G++: - m68000: 68K - m68k: 68K - __palmos__: PalmOS + - __e2k__: on MCST Elbrus 2000 processor platforms Intel C/C++ Compiler: - __ECC : compiler version, IA64 only @@ -206,6 +207,11 @@ HP-UX C/C++ Compiler: LLVM: - __llvm__ - __clang__ + +LCC predefines the following: + - __LCC__: + if also defined e2k it is MCST eLbrus C Compiler + else it is Local (or Little) C Compiler */ /* @@ -549,6 +555,11 @@ HP-UX C/C++ Compiler: # define POSH_CPU_STRING "PA-RISC" #endif +#if defined __e2k__ +# define POSH_CPU_E2K 1 +# define POSH_CPU_STRING "MCST Elbrus 2000" +#endif + #if !defined POSH_CPU_STRING # error POSH cannot determine target CPU # define POSH_CPU_STRING "Unknown" /* this is here for Doxygen's benefit */ @@ -686,7 +697,7 @@ HP-UX C/C++ Compiler: ** the MIPS series, so we have to be careful about those. ** ---------------------------------------------------------------------------- */ -#if defined POSH_CPU_X86 || defined POSH_CPU_AXP || defined POSH_CPU_STRONGARM || defined POSH_CPU_AARCH64 || defined POSH_OS_WIN32 || defined POSH_OS_WINCE || defined __MIPSEL__ || defined __ORDER_LITTLE_ENDIAN__ +#if defined POSH_CPU_X86 || defined POSH_CPU_AXP || defined POSH_CPU_STRONGARM || defined POSH_CPU_AARCH64 || defined POSH_OS_WIN32 || defined POSH_OS_WINCE || defined __MIPSEL__ || defined __ORDER_LITTLE_ENDIAN__ || defined POSH_CPU_E2K # define POSH_ENDIAN_STRING "little" # define POSH_LITTLE_ENDIAN 1 #else @@ -714,7 +725,7 @@ HP-UX C/C++ Compiler: ** for 64-bit support, we ignore the POSH_USE_LIMITS_H directive. ** ---------------------------------------------------------------------------- */ -#if defined ( __LP64__ ) || defined ( __powerpc64__ ) || defined POSH_CPU_SPARC64 +#if defined ( __LP64__ ) || defined ( __powerpc64__ ) || defined POSH_CPU_SPARC64 || defined POSH_CPU_E2K # define POSH_64BIT_INTEGER 1 typedef long posh_i64_t; typedef unsigned long posh_u64_t; @@ -883,7 +894,7 @@ POSH_COMPILE_TIME_ASSERT(posh_i32_t, sizeof(posh_i32_t) == 4); # define POSH_64BIT_POINTER 1 #endif -#if defined POSH_CPU_SPARC64 || defined POSH_OS_WIN64 || defined __64BIT__ || defined __LP64 || defined _LP64 || defined __LP64__ || defined _ADDR64 || defined _CRAYC +#if defined POSH_CPU_SPARC64 || defined POSH_OS_WIN64 || defined __64BIT__ || defined __LP64 || defined _LP64 || defined __LP64__ || defined _ADDR64 || defined _CRAYC || defined POSH_CPU_E2K # define POSH_64BIT_POINTER 1 #endif diff --git a/extern/rg/rgbcx.h b/extern/rg/rgbcx.h new file mode 100644 index 00000000..e9abc3c9 --- /dev/null +++ b/extern/rg/rgbcx.h @@ -0,0 +1,4220 @@ +// rgbcx.h v1.12 +// High-performance scalar BC1-5 encoders. Public Domain or MIT license (you choose - see below), written by Richard Geldreich 2020 . +// +// Influential references: +// http://sjbrown.co.uk/2006/01/19/dxt-compression-techniques/ +// https://github.com/nothings/stb/blob/master/stb_dxt.h +// https://gist.github.com/castano/c92c7626f288f9e99e158520b14a61cf +// https://github.com/castano/icbc/blob/master/icbc.h +// http://www.humus.name/index.php?page=3D&ID=79 +// +// This is a single header file library. Be sure to "#define RGBCX_IMPLEMENTATION" in one .cpp file somewhere. +// +// Instructions: +// +// The library MUST be initialized by calling this function at least once before using any encoder or decoder functions: +// +// void rgbcx::init(bc1_approx_mode mode = cBC1Ideal); +// +// This function manipulates global state, so it is not thread safe. +// You can call it multiple times to change the global BC1 approximation mode. +// Important: BC1/3 textures encoded using non-ideal BC1 approximation modes should only be sampled on parts from that vendor. +// If you encode for AMD, average error on AMD parts will go down, but average error on NVidia parts will go up and vice versa. +// If in doubt, encode in ideal BC1 mode. +// +// Call these functions to encode BC1-5: +// void rgbcx::encode_bc1(uint32_t level, void* pDst, const uint8_t* pPixels, bool allow_3color, bool use_transparent_texels_for_black); +// void rgbcx::encode_bc3(uint32_t level, void* pDst, const uint8_t* pPixels); +// void rgbcx::encode_bc4(void* pDst, const uint8_t* pPixels, uint32_t stride = 4); +// void rgbcx::encode_bc5(void* pDst, const uint8_t* pPixels, uint32_t chan0 = 0, uint32_t chan1 = 1, uint32_t stride = 4); +// +// - level ranges from MIN_LEVEL to MAX_LEVEL. The higher the level, the slower the encoder goes, but the higher the average quality. +// levels [0,4] are fast and compete against stb_dxt (default and HIGHQUAL). The remaining levels compete against squish/NVTT/icbc and icbc HQ. +// If in doubt just use level 10, set allow_3color to true and use_transparent_texels_for_black to false, and adjust as needed. +// +// - pDst is a pointer to the 8-byte (BC1/4) or 16-byte (BC3/5) destination block. +// +// - pPixels is a pointer to the 32-bpp pixels, in either RGBX or RGBA format (R is first in memory). +// Alpha is always ignored by encode_bc1(). +// +// - allow_3color: If true the encoder will use 3-color blocks. This flag is ignored unless level is >= 5 (because lower levels compete against stb_dxt and it doesn't support 3-color blocks). +// Do not enable on BC3-5 textures. 3-color block usage slows down encoding. +// +// - use_transparent_texels_for_black: If true the encoder will use 3-color block transparent black pixels to code very dark or black texels. Your engine/shader MUST ignore the sampled +// alpha value for textures encoded in this mode. This is how NVidia's classic "nvdxt" encoder (used by many original Xbox titles) used to work by default on DXT1C textures. It increases +// average quality substantially (because dark texels/black are very common) and is highly recommended. +// Do not enable on BC3-5 textures. +// +// - stride is the source pixel stride, in bytes. It's typically 4. +// +// - chan0 and chan1 are the source channels. Typically they will be 0 and 1. +// +// All encoding and decoding functions are threade-safe. +// +// To reduce the compiled size of the encoder, set #define RGBCX_USE_SMALLER_TABLES to 1 before including this header. +// +#ifndef RGBCX_INCLUDE_H +#define RGBCX_INCLUDE_H + +#include +#include +#include +#include +#include + +// By default, the table used to accelerate cluster fit on 4 color blocks uses a 969x128 entry table. +// To reduce the executable size, set RGBCX_USE_SMALLER_TABLES to 1, which selects the smaller 969x32 entry table. +#ifndef RGBCX_USE_SMALLER_TABLES +#define RGBCX_USE_SMALLER_TABLES 0 +#endif + +namespace rgbcx +{ + enum class bc1_approx_mode + { + // The default mode. No rounding for 4-color colors 2,3. My older tools/compressors use this mode. + // This matches the D3D10 docs on BC1. + cBC1Ideal = 0, + + // NVidia GPU mode. + cBC1NVidia = 1, + + // AMD GPU mode. + cBC1AMD = 2, + + // This mode matches AMD Compressonator's output. It rounds 4-color colors 2,3 (not 3-color color 2). + // This matches the D3D9 docs on DXT1. + cBC1IdealRound4 = 3 + }; + + // init() MUST be called once before using the BC1 encoder. + // This function may be called multiple times to change the BC1 approximation mode. + // This function initializes global state, so don't call it while other threads inside the encoder. + // Important: If you encode textures for a specific vendor's GPU's, beware that using that texture data on other GPU's may result in ugly artifacts. + // Encode to cBC1Ideal unless you know the texture data will only be deployed or used on a specific vendor's GPU. + void init(bc1_approx_mode mode = bc1_approx_mode::cBC1Ideal); + + // Optimally encodes a solid color block to BC1 format. + void encode_bc1_solid_block(void* pDst, uint32_t fr, uint32_t fg, uint32_t fb, bool allow_3color); + + // BC1 low-level API encoder flags. You can ignore this if you use the simple level API. + enum + { + // Try to improve quality using the most likely total orderings. + // The total_orderings_to_try parameter will then control the number of total orderings to try for 4 color blocks, and the + // total_orderings_to_try3 parameter will control the number of total orderings to try for 3 color blocks (if they are enabled). + cEncodeBC1UseLikelyTotalOrderings = 2, + + // Use 2 least squares pass, instead of one (same as stb_dxt's HIGHQUAL option). + // Recommended if you're enabling cEncodeBC1UseLikelyTotalOrderings. + cEncodeBC1TwoLeastSquaresPasses = 4, + + // cEncodeBC1Use3ColorBlocksForBlackPixels allows the BC1 encoder to use 3-color blocks for blocks containing black or very dark pixels. + // You shader/engine MUST ignore the alpha channel on textures encoded with this flag. + // Average quality goes up substantially for my 100 texture corpus (~.5 dB), so it's worth using if you can. + // Note the BC1 encoder does not actually support transparency in 3-color mode. + // Don't set when encoding to BC3. + cEncodeBC1Use3ColorBlocksForBlackPixels = 8, + + // If cEncodeBC1Use3ColorBlocks is set, the encoder can use 3-color mode for a small but noticeable gain in average quality, but lower perf. + // If you also specify the cEncodeBC1UseLikelyTotalOrderings flag, set the total_orderings_to_try3 paramter to the number of total orderings to try. + // Don't set when encoding to BC3. + cEncodeBC1Use3ColorBlocks = 16, + + // cEncodeBC1Iterative will greatly increase encode time, but is very slightly higher quality. + // Same as squish's iterative cluster fit option. Not really worth the tiny boost in quality, unless you just don't care about perf. at all. + cEncodeBC1Iterative = 32, + + // cEncodeBC1BoundingBox enables a fast all-integer PCA approximation on 4-color blocks. + // At level 0 options (no other flags), this is ~15% faster, and higher *average* quality. + cEncodeBC1BoundingBox = 64, + + // Use a slightly lower quality, but ~30% faster MSE evaluation function for 4-color blocks. + cEncodeBC1UseFasterMSEEval = 128, + + // Examine all colors to compute selectors/MSE (slower than default) + cEncodeBC1UseFullMSEEval = 256, + + // Use 2D least squares+inset+optimal rounding (the method used in Humus's GPU texture encoding demo), instead of PCA. + // Around 18% faster, very slightly lower average quality to better (depends on the content). + cEncodeBC1Use2DLS = 512, + + // Use 6 power iterations vs. 4 for PCA. + cEncodeBC1Use6PowerIters = 2048, + + // Check all total orderings - *very* slow. The encoder is not designed to be used in this way. + cEncodeBC1Exhaustive = 8192, + + // Try 2 different ways of choosing the initial endpoints. + cEncodeBC1TryAllInitialEndponts = 16384, + + // Same as cEncodeBC1BoundingBox, but implemented using integer math (faster, slightly less quality) + cEncodeBC1BoundingBoxInt = 32768, + + // Try refining the final endpoints by examining nearby colors. + cEncodeBC1EndpointSearchRoundsShift = 22, + cEncodeBC1EndpointSearchRoundsMask = 1023U << cEncodeBC1EndpointSearchRoundsShift, + }; + + const uint32_t MIN_TOTAL_ORDERINGS = 1; + const uint32_t MAX_TOTAL_ORDERINGS3 = 32; + +#if RGBCX_USE_SMALLER_TABLES + const uint32_t MAX_TOTAL_ORDERINGS4 = 32; +#else + const uint32_t MAX_TOTAL_ORDERINGS4 = 128; +#endif + + // DEFAULT_TOTAL_ORDERINGS_TO_TRY is around 3x faster than libsquish at slightly higher average quality. 10-16 is a good range to start to compete against libsquish. + const uint32_t DEFAULT_TOTAL_ORDERINGS_TO_TRY = 10; + + const uint32_t DEFAULT_TOTAL_ORDERINGS_TO_TRY3 = 1; + + // Encodes a 4x4 block of RGBX (X=ignored) pixels to BC1 format. + // This is the simplified interface for BC1 encoding, which accepts a level parameter and converts that to the best overall flags. + // The pixels are in RGBA format, where R is first in memory. The BC1 encoder completely ignores the alpha channel (i.e. there is no punchthrough alpha support). + // This is the recommended function to use for BC1 encoding, becuase it configures the encoder for you in the best possible way (on average). + // Note that the 3 color modes won't be used at all until level 5 or higher. + // No transparency supported, however if you set use_transparent_texels_for_black to true the encocer will use transparent selectors on very dark/black texels to reduce MSE. + const uint32_t MIN_LEVEL = 0, MAX_LEVEL = 18; + void encode_bc1(uint32_t level, void* pDst, const uint8_t* pPixels, bool allow_3color, bool use_transparent_texels_for_black); + + // Low-level interface for BC1 encoding. + // Always returns a 4 color block, unless cEncodeBC1Use3ColorBlocksForBlackPixels or cEncodeBC1Use3ColorBlock flags are specified. + // total_orderings_to_try controls the perf. vs. quality tradeoff on 4-color blocks when the cEncodeBC1UseLikelyTotalOrderings flag is used. It must range between [MIN_TOTAL_ORDERINGS, MAX_TOTAL_ORDERINGS4]. + // total_orderings_to_try3 controls the perf. vs. quality tradeoff on 3-color bocks when the cEncodeBC1UseLikelyTotalOrderings and the cEncodeBC1Use3ColorBlocks flags are used. Valid range is [0,MAX_TOTAL_ORDERINGS3] (0=disabled). + void encode_bc1(void* pDst, const uint8_t* pPixels, uint32_t flags = 0, uint32_t total_orderings_to_try = DEFAULT_TOTAL_ORDERINGS_TO_TRY, uint32_t total_orderings_to_try3 = DEFAULT_TOTAL_ORDERINGS_TO_TRY3); + + // Encodes a 4x4 block of RGBA pixels to BC3 format. + // There are two encode_bc3() functions. + // The first is the recommended function, which accepts a level parameter. + // The second is a low-level version that allows fine control over BC1 encoding. + void encode_bc3(uint32_t level, void* pDst, const uint8_t* pPixels); + void encode_bc3(void* pDst, const uint8_t* pPixels, uint32_t flags = 0, uint32_t total_orderings_to_try = DEFAULT_TOTAL_ORDERINGS_TO_TRY); + + // Encodes a single channel to BC4. + // stride is the source pixel stride in bytes. + void encode_bc4(void* pDst, const uint8_t* pPixels, uint32_t stride = 4); + + // Encodes two channels to BC5. + // chan0/chan1 control which channels, stride is the source pixel stride in bytes. + void encode_bc5(void* pDst, const uint8_t* pPixels, uint32_t chan0 = 0, uint32_t chan1 = 1, uint32_t stride = 4); + + // Decompression functions. + + // Returns true if the block uses 3 color punchthrough alpha mode. + bool unpack_bc1(const void* pBlock_bits, void* pPixels, bool set_alpha = true, bc1_approx_mode mode = bc1_approx_mode::cBC1Ideal); + + void unpack_bc4(const void* pBlock_bits, uint8_t* pPixels, uint32_t stride = 4); + + // Returns true if the block uses 3 color punchthrough alpha mode. + bool unpack_bc3(const void* pBlock_bits, void* pPixels, bc1_approx_mode mode = bc1_approx_mode::cBC1Ideal); + + void unpack_bc5(const void* pBlock_bits, void* pPixels, uint32_t chan0 = 0, uint32_t chan1 = 1, uint32_t stride = 4); +} +#endif // #ifndef RGBCX_INCLUDE_H + +#ifdef RGBCX_IMPLEMENTATION +namespace rgbcx +{ + const uint32_t NUM_UNIQUE_TOTAL_ORDERINGS4 = 969; + + // All total orderings for 16 pixels 2-bit selectors. + // BC1 selector order 0, 2, 3, 1 (i.e. the selectors are reordered into linear order). + static uint8_t g_unique_total_orders4[NUM_UNIQUE_TOTAL_ORDERINGS4][4] = + { + {0,8,2,6},{4,3,9,0},{4,8,1,3},{12,0,3,1},{11,3,2,0},{6,4,6,0},{7,5,0,4},{6,0,8,2},{1,0,0,15},{3,0,8,5},{1,1,13,1},{13,1,2,0},{0,14,1,1},{0,15,1,0},{0,13,0,3},{16,0,0,0},{4,3,4,5},{8,6,0,2},{0,10,0,6},{10,0,4,2},{7,2,1,6},{4,7,5,0},{1,4,7,4},{0,14,2,0},{2,7,2,5},{9,0,5,2},{9,2,2,3},{10,0,5,1},{2,3,7,4},{4,9,0,3},{1,5,0,10},{1,1,6,8}, + {6,6,4,0},{11,5,0,0},{11,2,0,3},{4,0,10,2},{2,3,10,1},{1,13,1,1},{0,14,0,2},{2,3,3,8},{12,3,1,0},{14,0,0,2},{9,1,3,3},{6,4,0,6},{1,1,5,9},{5,9,0,2},{2,10,1,3},{12,0,0,4},{4,6,6,0},{0,6,4,6},{3,7,4,2},{0,13,3,0},{3,10,0,3},{10,2,1,3},{1,12,1,2},{2,0,13,1},{11,0,5,0},{12,1,3,0},{6,4,5,1},{10,4,2,0},{3,6,1,6},{7,3,6,0},{10,4,0,2},{10,0,2,4}, + {0,5,9,2},{0,9,3,4},{6,4,2,4},{3,4,7,2},{3,3,5,5},{4,2,9,1},{6,2,8,0},{3,5,3,5},{4,10,1,1},{10,1,3,2},{5,7,0,4},{5,3,7,1},{6,8,1,1},{8,8,0,0},{11,1,0,4},{14,1,0,1},{9,3,2,2},{8,2,1,5},{0,0,2,14},{3,3,9,1},{10,1,5,0},{8,3,1,4},{1,5,8,2},{6,1,9,0},{3,2,1,10},{3,11,1,1},{7,6,3,0},{9,0,3,4},{5,2,5,4},{0,2,3,11},{15,0,0,1},{0,6,6,4}, + {3,4,9,0},{4,7,0,5},{0,4,4,8},{0,13,2,1},{2,4,1,9},{3,2,5,6},{10,6,0,0},{3,5,6,2},{8,0,4,4},{1,3,6,6},{7,7,0,2},{6,1,4,5},{0,11,1,4},{2,2,8,4},{0,1,2,13},{15,0,1,0},{7,2,6,1},{8,1,7,0},{1,8,4,3},{2,13,1,0},{1,0,7,8},{14,2,0,0},{1,8,1,6},{9,3,3,1},{0,0,7,9},{4,4,1,7},{9,0,6,1},{10,2,4,0},{1,7,3,5},{0,3,8,5},{5,2,4,5},{1,2,5,8}, + {0,8,7,1},{10,3,2,1},{12,0,4,0},{2,1,4,9},{5,2,2,7},{1,9,3,3},{15,1,0,0},{6,3,4,3},{9,5,0,2},{1,6,9,0},{6,6,0,4},{13,2,1,0},{5,1,8,2},{0,5,11,0},{7,1,0,8},{1,2,12,1},{0,3,3,10},{7,4,2,3},{5,1,4,6},{7,0,3,6},{3,12,0,1},{3,4,5,4},{1,10,0,5},{7,4,3,2},{10,5,0,1},{13,3,0,0},{2,5,4,5},{3,10,1,2},{5,1,2,8},{14,0,1,1},{1,5,4,6},{1,4,5,6}, + {2,3,11,0},{11,0,4,1},{11,2,2,1},{5,3,8,0},{1,3,10,2},{0,1,13,2},{3,1,4,8},{4,2,4,6},{1,5,6,4},{2,1,11,2},{1,2,9,4},{4,7,3,2},{6,2,5,3},{7,2,2,5},{8,1,4,3},{3,2,8,3},{12,1,0,3},{7,8,1,0},{7,0,2,7},{5,10,0,1},{0,2,14,0},{2,9,3,2},{7,0,0,9},{11,1,4,0},{10,4,1,1},{2,2,9,3},{5,7,2,2},{1,3,1,11},{13,2,0,1},{4,2,8,2},{2,3,1,10},{4,2,5,5}, + {7,0,7,2},{10,0,0,6},{0,8,5,3},{4,4,0,8},{12,4,0,0},{0,1,14,1},{8,0,1,7},{5,1,5,5},{11,0,3,2},{0,4,1,11},{0,8,8,0},{0,2,5,9},{7,3,2,4},{7,8,0,1},{1,0,3,12},{7,4,5,0},{1,6,7,2},{7,6,1,2},{9,6,1,0},{12,2,0,2},{4,1,6,5},{4,0,1,11},{8,4,4,0},{13,0,1,2},{8,6,2,0},{4,12,0,0},{2,7,5,2},{2,0,5,9},{5,4,5,2},{3,8,5,0},{7,3,3,3},{4,4,8,0}, + {2,1,3,10},{5,0,1,10},{6,4,3,3},{4,9,1,2},{1,4,0,11},{11,3,1,1},{4,0,12,0},{13,0,0,3},{6,1,6,3},{9,0,4,3},{8,0,0,8},{8,4,0,4},{0,12,1,3},{0,4,10,2},{3,4,8,1},{1,3,8,4},{9,2,5,0},{5,7,4,0},{1,0,11,4},{4,10,0,2},{1,3,12,0},{6,9,0,1},{5,0,9,2},{5,9,2,0},{13,1,0,2},{9,3,4,0},{9,4,0,3},{3,1,12,0},{2,4,3,7},{1,2,13,0},{2,2,4,8},{6,8,0,2}, + {9,2,1,4},{9,5,1,1},{2,0,4,10},{5,4,0,7},{0,0,6,10},{1,2,0,13},{4,7,2,3},{6,5,5,0},{3,3,1,9},{1,6,1,8},{12,2,1,1},{4,4,5,3},{1,0,6,9},{0,6,10,0},{4,8,3,1},{4,3,2,7},{2,1,7,6},{1,9,1,5},{3,1,3,9},{8,7,1,0},{1,2,3,10},{14,1,1,0},{5,4,4,3},{3,7,0,6},{7,4,1,4},{3,7,5,1},{1,1,0,14},{0,10,3,3},{0,4,3,9},{1,7,7,1},{2,0,10,4},{5,8,0,3}, + {6,7,3,0},{0,8,4,4},{5,7,3,1},{7,9,0,0},{7,6,2,1},{0,4,5,7},{6,3,5,2},{1,2,1,12},{5,2,0,9},{8,5,0,3},{4,6,1,5},{1,1,7,7},{10,5,1,0},{1,2,8,5},{1,8,2,5},{5,1,0,10},{6,9,1,0},{13,0,2,1},{8,3,5,0},{6,3,6,1},{2,11,3,0},{3,7,3,3},{1,5,2,8},{7,5,2,2},{0,6,7,3},{13,1,1,1},{5,3,4,4},{7,2,7,0},{5,8,3,0},{3,13,0,0},{0,7,9,0},{8,0,3,5}, + {1,3,7,5},{4,0,2,10},{12,0,1,3},{1,7,6,2},{3,9,0,4},{7,2,0,7},{0,1,7,8},{2,1,8,5},{0,13,1,2},{0,8,1,7},{5,0,11,0},{5,6,2,3},{0,3,0,13},{2,3,4,7},{5,6,3,2},{4,2,10,0},{3,3,7,3},{7,2,5,2},{1,1,11,3},{12,3,0,1},{5,1,1,9},{1,15,0,0},{9,7,0,0},{9,1,2,4},{0,7,3,6},{3,0,13,0},{3,0,11,2},{0,6,5,5},{8,2,2,4},{6,10,0,0},{4,8,4,0},{0,0,3,13}, + {0,4,12,0},{7,1,6,2},{3,5,0,8},{8,0,6,2},{6,2,3,5},{2,10,0,4},{4,11,0,1},{6,1,5,4},{5,1,3,7},{0,11,3,2},{4,6,0,6},{2,6,0,8},{3,1,7,5},{2,14,0,0},{2,9,2,3},{0,3,4,9},{11,0,1,4},{13,0,3,0},{8,3,0,5},{0,5,3,8},{5,11,0,0},{0,1,4,11},{2,1,9,4},{3,4,4,5},{7,1,2,6},{12,2,2,0},{9,4,1,2},{6,0,2,8},{4,6,2,4},{11,2,3,0},{3,2,2,9},{10,3,1,2}, + {1,1,2,12},{0,5,2,9},{0,1,11,4},{6,2,4,4},{2,8,2,4},{0,9,4,3},{11,0,2,3},{0,2,11,3},{6,0,7,3},{0,3,6,7},{4,5,5,2},{1,2,6,7},{7,5,1,3},{9,0,2,5},{2,6,4,4},{4,1,9,2},{4,8,2,2},{1,12,3,0},{0,9,6,1},{0,10,6,0},{3,1,5,7},{2,13,0,1},{2,2,1,11},{3,6,0,7},{5,6,5,0},{5,5,4,2},{4,0,3,9},{3,4,1,8},{0,11,2,3},{2,12,1,1},{7,1,3,5},{7,0,9,0}, + {8,0,8,0},{1,0,2,13},{3,3,10,0},{2,4,4,6},{2,3,8,3},{1,10,5,0},{7,3,0,6},{2,9,0,5},{1,4,6,5},{6,6,3,1},{5,6,0,5},{6,3,0,7},{3,10,2,1},{2,5,5,4},{3,8,4,1},{1,14,0,1},{10,3,3,0},{3,5,7,1},{1,1,3,11},{2,4,0,10},{9,3,1,3},{5,10,1,0},{3,0,6,7},{3,1,9,3},{11,2,1,2},{5,3,3,5},{0,5,1,10},{4,1,11,0},{10,2,0,4},{7,6,0,3},{2,7,0,7},{4,2,2,8}, + {6,1,7,2},{4,9,2,1},{0,0,8,8},{3,7,2,4},{9,6,0,1},{0,12,4,0},{6,7,1,2},{0,7,2,7},{1,0,10,5},{0,0,14,2},{2,7,3,4},{5,0,0,11},{7,7,1,1},{6,2,7,1},{4,5,3,4},{3,5,1,7},{5,9,1,1},{6,2,1,7},{3,2,0,11},{0,11,0,5},{3,11,2,0},{10,1,4,1},{7,0,4,5},{11,4,0,1},{10,3,0,3},{0,2,4,10},{0,15,0,1},{0,11,5,0},{6,7,2,1},{1,12,2,1},{4,1,3,8},{1,0,13,2}, + {1,8,5,2},{7,0,1,8},{3,12,1,0},{9,2,4,1},{1,7,4,4},{11,4,1,0},{4,3,8,1},{2,8,4,2},{1,11,3,1},{1,1,4,10},{4,10,2,0},{8,2,5,1},{1,0,9,6},{5,3,2,6},{0,9,7,0},{10,2,2,2},{5,8,1,2},{8,7,0,1},{0,3,12,1},{1,0,1,14},{4,8,0,4},{3,8,0,5},{4,6,5,1},{0,9,5,2},{10,2,3,1},{2,3,9,2},{1,0,12,3},{11,3,0,2},{4,5,2,5},{0,2,12,2},{9,1,0,6},{9,2,0,5}, + {1,2,7,6},{4,7,4,1},{0,12,2,2},{0,0,0,16},{2,8,3,3},{3,6,2,5},{0,6,3,7},{7,5,4,0},{3,3,3,7},{3,3,0,10},{5,0,6,5},{0,0,10,6},{8,5,3,0},{8,1,5,2},{6,0,9,1},{11,1,2,2},{2,11,2,1},{9,5,2,0},{3,0,4,9},{2,2,12,0},{2,6,6,2},{2,1,13,0},{6,0,5,5},{2,0,14,0},{2,11,1,2},{4,4,7,1},{2,0,11,3},{3,1,1,11},{2,9,4,1},{3,7,6,0},{14,0,2,0},{1,10,4,1}, + {8,0,7,1},{3,6,5,2},{0,3,11,2},{2,5,6,3},{11,1,3,1},{6,5,3,2},{3,8,1,4},{0,2,7,7},{2,10,2,2},{1,6,2,7},{11,0,0,5},{12,1,1,2},{12,1,2,1},{0,7,1,8},{0,3,9,4},{0,2,1,13},{7,1,4,4},{10,1,0,5},{4,0,8,4},{5,2,7,2},{0,2,0,14},{4,3,7,2},{2,7,1,6},{1,2,2,11},{6,3,3,4},{1,14,1,0},{2,4,6,4},{5,3,6,2},{5,3,5,3},{8,4,1,3},{1,3,0,12},{3,5,2,6}, + {1,8,7,0},{0,7,4,5},{2,1,6,7},{4,11,1,0},{7,2,4,3},{6,1,3,6},{4,5,4,3},{2,11,0,3},{1,5,7,3},{12,0,2,2},{5,0,4,7},{1,13,0,2},{7,7,2,0},{4,1,7,4},{4,5,0,7},{5,0,5,6},{6,5,4,1},{2,4,2,8},{1,10,1,4},{6,3,1,6},{3,3,8,2},{0,7,7,2},{4,4,2,6},{1,1,8,6},{1,12,0,3},{2,1,12,1},{1,9,2,4},{1,11,0,4},{2,5,2,7},{10,0,3,3},{4,6,3,3},{3,7,1,5}, + {1,9,0,6},{7,1,7,1},{1,6,5,4},{9,2,3,2},{6,2,2,6},{2,2,2,10},{8,3,3,2},{0,1,8,7},{2,0,8,6},{0,3,1,12},{9,4,2,1},{9,4,3,0},{6,2,6,2},{1,8,0,7},{5,1,10,0},{0,5,5,6},{8,2,4,2},{2,3,2,9},{6,0,3,7},{2,2,6,6},{2,6,2,6},{1,13,2,0},{9,3,0,4},{7,3,5,1},{6,5,2,3},{5,2,6,3},{2,0,12,2},{5,7,1,3},{8,1,3,4},{3,1,10,2},{1,0,15,0},{0,8,0,8}, + {5,0,7,4},{4,4,6,2},{0,1,0,15},{10,0,1,5},{7,3,4,2},{4,9,3,0},{2,5,7,2},{3,4,2,7},{8,3,2,3},{5,1,6,4},{0,10,2,4},{6,6,1,3},{6,0,0,10},{4,4,3,5},{1,3,9,3},{7,5,3,1},{3,0,7,6},{1,8,6,1},{4,3,0,9},{3,11,0,2},{6,0,6,4},{0,1,3,12},{0,4,2,10},{5,5,6,0},{4,1,4,7},{8,1,6,1},{5,6,4,1},{8,4,2,2},{4,3,1,8},{3,0,2,11},{1,11,4,0},{0,8,3,5}, + {5,1,7,3},{7,0,8,1},{4,3,5,4},{4,6,4,2},{3,2,4,7},{1,6,3,6},{0,7,8,1},{3,0,1,12},{9,1,4,2},{7,4,0,5},{1,7,0,8},{5,4,1,6},{9,1,5,1},{1,1,9,5},{4,1,1,10},{5,3,0,8},{2,2,5,7},{4,0,0,12},{9,0,7,0},{3,4,0,9},{0,2,6,8},{8,2,0,6},{3,2,6,5},{4,2,6,4},{3,6,4,3},{2,8,6,0},{5,0,3,8},{0,4,0,12},{0,16,0,0},{0,9,2,5},{4,0,11,1},{1,6,4,5}, + {0,1,6,9},{3,4,6,3},{3,0,10,3},{7,0,6,3},{1,4,9,2},{1,5,3,7},{8,5,2,1},{0,12,0,4},{7,2,3,4},{0,5,6,5},{11,1,1,3},{6,5,0,5},{2,1,5,8},{1,4,11,0},{9,1,1,5},{0,0,13,3},{5,8,2,1},{2,12,0,2},{3,3,6,4},{4,1,10,1},{4,0,5,7},{8,1,0,7},{5,1,9,1},{4,3,3,6},{0,2,2,12},{6,3,2,5},{0,0,12,4},{1,5,1,9},{2,6,5,3},{3,6,3,4},{2,12,2,0},{1,6,8,1}, + {10,1,1,4},{1,3,4,8},{7,4,4,1},{1,11,1,3},{1,2,10,3},{3,9,3,1},{8,5,1,2},{2,10,4,0},{4,2,0,10},{2,7,6,1},{8,2,3,3},{1,5,5,5},{3,1,0,12},{3,10,3,0},{8,0,5,3},{0,6,8,2},{0,3,13,0},{0,0,16,0},{1,9,4,2},{4,1,8,3},{1,6,6,3},{0,10,5,1},{0,1,12,3},{4,0,6,6},{3,8,3,2},{0,5,4,7},{1,0,14,1},{0,4,6,6},{3,9,1,3},{3,5,8,0},{3,6,6,1},{5,4,7,0}, + {3,0,12,1},{8,6,1,1},{2,9,5,0},{6,1,1,8},{4,1,2,9},{3,9,4,0},{5,2,9,0},{0,12,3,1},{1,4,10,1},{4,0,7,5},{3,1,2,10},{5,4,2,5},{5,5,5,1},{4,2,3,7},{1,7,5,3},{2,8,0,6},{8,1,2,5},{3,8,2,3},{6,1,2,7},{3,9,2,2},{9,0,0,7},{0,8,6,2},{8,4,3,1},{0,2,8,6},{6,5,1,4},{2,3,5,6},{2,10,3,1},{0,7,0,9},{4,2,7,3},{2,4,8,2},{7,1,1,7},{2,4,7,3}, + {2,4,10,0},{0,1,10,5},{4,7,1,4},{0,10,4,2},{9,0,1,6},{1,9,6,0},{3,3,4,6},{4,5,7,0},{5,5,2,4},{2,8,1,5},{2,3,6,5},{0,1,1,14},{3,2,3,8},{10,1,2,3},{9,1,6,0},{3,4,3,6},{2,2,0,12},{0,0,9,7},{4,0,9,3},{7,0,5,4},{4,5,6,1},{2,5,1,8},{2,5,9,0},{3,5,4,4},{1,3,11,1},{7,1,5,3},{3,2,7,4},{1,4,2,9},{1,11,2,2},{2,2,3,9},{5,0,10,1},{3,2,11,0}, + {1,10,3,2},{8,3,4,1},{3,6,7,0},{0,7,5,4},{1,3,3,9},{2,2,10,2},{1,9,5,1},{0,5,0,11},{3,0,3,10},{0,4,8,4},{2,7,7,0},{2,0,2,12},{1,2,11,2},{6,3,7,0},{0,6,2,8},{0,10,1,5},{0,9,0,7},{6,4,4,2},{6,0,1,9},{1,5,10,0},{5,4,6,1},{5,5,3,3},{0,0,4,12},{0,3,2,11},{1,4,1,10},{3,0,9,4},{5,5,0,6},{1,7,8,0},{2,0,3,11},{6,4,1,5},{10,0,6,0},{0,6,0,10}, + {0,4,11,1},{3,1,6,6},{2,5,8,1},{0,2,10,4},{3,1,11,1},{6,6,2,2},{1,1,10,4},{2,1,2,11},{6,1,8,1},{0,2,13,1},{0,7,6,3},{6,8,2,0},{3,0,0,13},{4,4,4,4},{6,2,0,8},{7,3,1,5},{0,11,4,1},{6,7,0,3},{2,6,3,5},{5,2,1,8},{7,1,8,0},{5,5,1,5},{1,8,3,4},{8,2,6,0},{6,0,10,0},{5,6,1,4},{1,4,4,7},{2,7,4,3},{1,4,8,3},{5,4,3,4},{1,10,2,3},{2,9,1,4}, + {2,2,11,1},{2,5,0,9},{0,0,1,15},{0,0,11,5},{0,4,7,5},{0,1,15,0},{2,1,0,13},{0,3,10,3},{8,0,2,6},{3,3,2,8},{3,5,5,3},{1,7,1,7},{1,3,2,10},{4,0,4,8},{2,0,9,5},{1,1,1,13},{2,2,7,5},{2,1,10,3},{4,2,1,9},{4,3,6,3},{1,3,5,7},{2,5,3,6},{1,0,8,7},{5,0,2,9},{2,8,5,1},{1,6,0,9},{0,0,5,11},{0,4,9,3},{2,0,7,7},{1,7,2,6},{2,1,1,12},{2,4,9,1}, + {0,5,7,4},{6,0,4,6},{3,2,10,1},{0,6,1,9},{2,6,1,7},{0,5,8,3},{4,1,0,11},{1,2,4,9},{4,1,5,6},{6,1,0,9},{1,4,3,8},{4,5,1,6},{1,0,5,10},{5,3,1,7},{0,9,1,6},{2,0,1,13},{2,0,6,8},{8,1,1,6},{1,5,9,1},{0,6,9,1},{0,3,5,8},{0,2,9,5},{5,2,8,1},{1,1,14,0},{3,2,9,2},{5,0,8,3},{0,5,10,1},{5,2,3,6},{2,6,7,1},{2,3,0,11},{0,1,9,6},{1,0,4,11}, + {3,0,5,8},{0,0,15,1},{2,4,5,5},{0,3,7,6},{2,0,0,14},{1,1,12,2},{2,6,8,0},{3,1,8,4},{0,1,5,10} + }; + + // All total orderings for 16 pixels [0,2] 2-bit selectors. + // BC1 selector order: 0, 1, 2 + // Note this is different from g_unique_total_orders4[], which reorders the selectors into linear order. + const uint32_t NUM_UNIQUE_TOTAL_ORDERINGS3 = 153; + static uint8_t g_unique_total_orders3[NUM_UNIQUE_TOTAL_ORDERINGS3][3] = + { + {6,0,10},{3,6,7},{3,0,13},{13,3,0},{12,4,0},{9,1,6},{2,13,1},{4,7,5},{7,5,4},{9,6,1},{7,4,5},{8,6,2},{16,0,0},{10,6,0},{2,7,7}, + {0,0,16},{0,3,13},{1,15,0},{0,2,14},{1,4,11},{15,1,0},{1,12,3},{9,2,5},{14,1,1},{8,2,6},{3,3,10},{4,2,10},{14,0,2},{0,14,2},{1,7,8},{6,6,4}, + {11,5,0},{6,4,6},{11,3,2},{4,3,9},{7,1,8},{10,4,2},{12,1,3},{11,0,5},{9,3,4},{1,0,15},{9,0,7},{2,6,8},{12,2,2},{6,2,8},{6,8,2},{15,0,1}, + {4,8,4},{0,4,12},{8,5,3},{5,9,2},{11,2,3},{12,3,1},{6,3,7},{1,1,14},{2,9,5},{1,8,7},{4,10,2},{7,7,2},{13,1,2},{0,15,1},{3,2,11},{7,0,9}, + {4,4,8},{3,8,5},{0,5,11},{13,2,1},{1,10,5},{4,11,1},{3,10,3},{5,10,1},{10,2,4},{0,6,10},{14,2,0},{11,4,1},{3,12,1},{1,13,2},{1,5,10},{5,11,0}, + {12,0,4},{8,1,7},{6,10,0},{3,13,0},{7,2,7},{0,7,9},{5,8,3},{0,12,4},{11,1,4},{13,0,3},{0,16,0},{5,7,4},{10,3,3},{10,0,6},{0,13,3},{4,6,6}, + {2,8,6},{2,5,9},{7,8,1},{2,1,13},{2,0,14},{7,3,6},{5,1,10},{3,11,2},{5,4,7},{8,3,5},{10,5,1},{6,9,1},{1,3,12},{4,5,7},{2,2,12},{4,1,11}, + {0,8,8},{4,12,0},{6,5,5},{8,7,1},{5,5,6},{3,7,6},{7,9,0},{4,9,3},{0,10,6},{8,0,8},{5,3,8},{10,1,5},{6,1,9},{7,6,3},{9,5,2},{0,1,15}, + {9,7,0},{2,14,0},{3,4,9},{8,4,4},{9,4,3},{0,9,7},{1,9,6},{3,9,4},{5,2,9},{2,3,11},{5,6,5},{1,14,1},{6,7,3},{2,4,10},{2,12,2},{8,8,0}, + {2,10,4},{4,0,12},{0,11,5},{2,11,3},{1,11,4},{3,5,8},{5,0,11},{3,1,12},{1,2,13},{1,6,9} + }; + + // For each total ordering, this table indicates which other total orderings are likely to improve quality using a least squares pass. Each array is sorted by usefulness. + static uint16_t g_best_total_orderings4[NUM_UNIQUE_TOTAL_ORDERINGS4][MAX_TOTAL_ORDERINGS4] = + { +#if RGBCX_USE_SMALLER_TABLES + { 202,120,13,318,15,23,403,450,5,51,260,128,77,21,33,494,515,523,4,141,269,1,2,700,137,49,48,102,7,64,753,82 }, + { 13,141,23,217,115,51,77,2,64,21,0,4,5,317,137,269,202,33,318,7,291,352,9,10,3,180,32,6,365,102,341,349 }, + { 29,58,262,1,52,74,6,171,5,287,151,334,27,500,75,26,331,223,53,635,220,19,50,45,46,17,14,396,163,409,324,70 }, + { 40,51,33,453,14,23,62,56,12,196,730,475,153,99,403,775,117,130,585,34,4,17,162,11,139,57,102,38,108,47,123,440 }, + { 33,23,51,13,102,64,202,128,12,40,15,196,153,10,1,2,77,99,141,0,515,5,117,3,120,403,700,165,22,14,269,453 }, + { 13,23,51,4,77,141,202,33,115,64,32,128,0,11,177,40,15,102,2,217,7,137,269,21,90,59,515,1,180,403,22,6 }, + { 26,235,19,47,648,624,78,145,27,112,122,64,444,6,630,453,25,42,65,130,711,85,390,113,416,108,665,29,730,138,644,95 }, + { 64,141,352,751,217,247,237,437,177,269,86,954,947,875,32,318,95,77,304,92,597,180,232,291,128,864,349,588,372,202,312,1 }, + { 642,898,180,638,901,341,82,197,10,951,15,515,165,762,700,253,811,753,752,365,143,479,244,569,8,110,351,873,55,31,499,116 }, + { 221,23,51,125,438,254,13,21,39,49,308,656,0,115,530,159,158,401,30,166,912,386,165,688,518,9,105,627,424,22,421,33 }, + { 143,31,1,44,197,8,180,125,116,55,13,498,23,341,638,242,93,15,2,141,0,901,752,115,36,206,165,479,338,365,515,762 }, + { 12,23,51,13,14,15,37,99,515,38,700,117,2,196,134,153,753,64,54,33,128,120,21,0,328,5,139,82,453,719,457,1 }, + { 13,15,23,515,961,700,457,753,51,115,4,165,197,2,38,569,1,474,0,37,99,719,5,12,629,14,11,3,33,77,64,10 }, + { 15,515,700,753,1,0,2,4,3,23,134,12,961,5,10,197,11,33,82,120,457,51,165,7,6,341,217,21,77,9,40,180 }, + { 13,51,23,457,719,961,730,401,165,453,0,117,386,15,134,1,758,153,12,54,515,99,11,2,700,5,753,4,308,33,6,899 }, + { 134,898,82,117,13,33,77,102,23,260,341,351,120,901,197,153,961,111,196,110,180,457,854,10,450,8,165,40,4,115,0,365 }, + { 60,18,126,167,35,16,191,71,24,92,121,271,68,107,212,146,118,150,199,7,21,1,9,575,727,5,566,48,0,132,108,273 }, + { 62,136,129,123,128,41,162,17,249,211,214,789,618,710,38,678,248,507,57,64,152,269,119,3,177,183,597,106,4,179,216,90 }, + { 403,523,51,475,494,453,817,899,202,23,450,13,421,120,102,730,33,128,4,1,805,5,7,153,757,260,318,196,77,457,326,65 }, + { 4,59,3,62,12,33,56,193,27,21,102,17,40,77,76,84,32,0,6,123,119,177,128,11,18,611,605,25,13,51,73,210 }, + { 43,20,319,422,414,945,0,7,819,61,5,376,325,173,804,904,470,693,97,707,14,49,22,104,147,107,95,32,426,1,330,577 }, + { 13,23,51,2,0,115,4,141,217,33,10,77,1,15,64,180,3,515,7,6,22,102,11,5,40,9,165,700,202,197,317,341 }, + { 28,49,0,105,1,24,65,159,35,55,95,239,16,2,109,7,9,14,170,320,347,168,424,158,10,301,124,5,67,21,64,36 }, + { 15,515,700,753,0,1,13,2,117,4,12,10,5,165,457,3,9,134,11,7,6,51,77,64,961,82,33,197,14,341,120,141 }, + { 7,71,14,149,97,18,60,16,150,92,398,189,140,124,24,273,35,2,69,302,154,68,0,336,517,43,66,28,118,251,230,1 }, + { 4,102,33,77,40,59,11,624,210,12,128,342,5,503,91,139,64,32,25,494,202,678,416,0,403,275,21,450,196,318,523,177 }, + { 25,19,42,6,122,813,256,235,85,26,436,53,297,573,680,390,445,63,27,416,80,233,65,73,389,283,45,605,194,17,250,343 }, + { 402,102,202,128,33,300,403,23,12,77,40,21,342,117,483,99,25,494,6,4,63,32,84,569,139,757,475,318,19,26,196,134 }, + { 158,9,0,109,39,49,65,22,35,168,55,24,68,124,159,16,185,344,333,154,254,272,175,289,1,577,95,28,105,810,30,169 }, + { 197,180,115,237,498,165,2,5,287,546,400,3,61,34,509,13,297,80,341,52,45,186,58,881,23,873,468,176,64,17,311,250 }, + { 120,968,373,260,704,110,450,202,137,318,77,95,269,326,217,717,661,652,851,349,93,1,518,98,827,291,21,177,82,33,848,719 }, + { 44,116,144,268,434,489,367,384,98,127,918,93,948,31,206,940,855,0,203,137,9,22,617,141,332,105,393,492,959,282,299,131 }, + { 13,77,23,33,51,0,64,141,102,4,2,115,1,6,202,15,10,128,269,7,177,180,3,40,22,11,515,217,117,318,700,137 }, + { 15,515,700,753,4,11,141,40,165,23,64,180,13,202,32,3,51,125,5,197,21,128,0,93,77,1,120,82,269,117,110,59 }, + { 176,231,585,62,34,14,412,161,56,236,527,57,17,3,51,202,4,23,369,283,128,13,472,440,84,361,136,457,381,130,719,53 }, + { 9,0,180,217,237,101,141,352,88,100,230,64,175,317,115,498,68,39,30,1,702,83,213,36,365,208,752,13,252,321,952,546 }, + { 28,9,22,1,49,0,109,39,83,95,86,30,13,105,128,55,141,168,158,67,31,159,208,12,96,5,185,2,160,64,137,23 }, + { 72,4,38,12,51,89,477,11,57,76,401,308,23,474,99,148,413,179,59,13,431,152,54,569,17,3,205,629,197,421,405,15 }, + { 457,13,23,961,15,51,515,700,165,12,753,629,11,1,719,117,0,3,2,37,569,197,40,328,33,5,153,134,99,64,38,196 }, + { 254,100,310,9,30,1,39,625,166,265,190,0,272,557,131,731,31,98,578,688,404,93,101,88,49,21,127,264,44,36,252,478 }, + { 51,23,12,13,15,128,99,120,10,202,515,153,64,82,700,33,165,2,5,117,403,1,141,0,3,196,37,453,753,197,260,93 }, + { 38,99,542,139,453,117,196,23,457,13,328,111,37,134,961,11,12,51,40,775,587,401,474,54,153,477,41,629,33,475,14,277 }, + { 6,85,25,233,343,91,26,63,138,29,19,65,283,4,81,235,42,122,605,64,648,256,174,370,74,389,718,59,45,194,445,416 }, + { 49,5,97,20,197,21,18,193,0,64,408,729,173,350,43,422,165,7,14,104,61,32,509,713,523,102,120,95,125,397,35,232 }, + { 144,116,268,434,384,489,367,206,93,855,940,44,98,332,617,127,959,911,137,282,203,31,22,219,141,9,131,276,417,0,1,120 }, + { 17,106,64,62,32,255,136,292,476,162,129,241,123,141,41,237,720,214,209,352,519,211,186,148,752,247,507,90,21,77,197,119 }, + { 2,29,52,50,5,58,14,6,27,1,366,357,45,53,17,19,171,151,26,181,133,38,218,764,287,583,61,113,3,487,600,281 }, + { 130,59,196,412,381,730,711,236,77,210,202,402,453,99,401,108,361,803,291,283,153,4,57,51,128,183,14,719,503,117,23,11 }, + { 13,23,51,141,77,4,33,64,115,0,217,10,180,202,2,102,11,9,15,165,40,21,128,352,22,7,197,3,317,515,269,1 }, + { 23,13,202,51,120,15,21,5,141,1,128,269,137,515,64,102,125,48,98,33,260,523,318,93,700,165,450,77,2,12,403,82 }, + { 1,2,14,46,29,67,38,52,5,171,58,24,103,69,96,70,83,181,54,75,163,223,16,45,112,309,155,0,186,35,18,108 }, + { 15,515,700,753,13,0,1,2,153,5,23,10,117,3,9,7,134,165,12,6,341,33,4,14,77,457,115,21,719,180,217,82 }, + { 197,165,509,13,391,180,308,115,23,546,5,498,2,29,3,401,901,61,34,80,14,457,250,569,237,873,38,297,45,15,468,386 }, + { 19,73,27,250,200,714,444,472,26,53,34,17,813,322,283,390,128,297,78,123,432,14,436,136,106,690,57,122,389,80,503,3 }, + { 3,17,21,45,62,32,38,12,155,14,2,328,5,99,401,536,828,13,227,488,106,51,719,119,540,76,165,221,115,629,209,41 }, + { 115,341,873,197,365,13,901,180,569,752,317,1,10,498,143,634,261,0,509,15,943,237,44,31,116,601,165,127,282,23,141,64 }, + { 453,51,23,403,33,421,475,102,15,153,196,515,13,700,117,523,12,40,753,21,4,134,0,494,670,899,22,801,730,10,11,401 }, + { 23,13,51,33,12,117,153,134,453,196,15,99,515,40,14,700,128,102,11,753,77,64,403,202,0,401,475,37,65,2,3,38 }, + { 2,7,5,14,70,1,29,61,52,45,6,112,66,16,21,32,592,46,38,135,87,58,186,315,290,128,113,0,64,48,227,23 }, + { 33,23,102,51,128,13,64,202,141,1,77,10,153,40,196,117,2,3,0,5,15,269,403,12,137,134,318,165,120,6,453,99 }, + { 16,92,7,20,43,35,126,71,60,14,107,18,68,97,0,121,279,149,24,246,191,48,118,575,55,140,362,783,230,150,375,566 }, + { 13,23,4,33,77,64,51,102,141,128,32,10,0,202,40,115,59,22,90,11,177,21,291,6,7,318,180,117,137,2,95,165 }, + { 507,162,129,41,4,211,62,38,123,59,57,248,183,130,99,11,3,361,202,17,402,556,266,305,803,210,128,184,152,136,313,117 }, + { 643,123,193,650,802,18,25,389,718,256,65,289,84,91,619,511,415,90,235,63,57,510,324,216,862,102,6,183,108,397,217,736 }, + { 13,23,15,1,515,51,0,2,700,5,753,165,141,115,12,3,4,180,21,197,457,7,6,10,120,9,33,202,77,32,8,11 }, + { 23,51,13,453,64,403,12,21,5,202,128,475,165,141,523,95,125,115,3,1,4,730,120,32,2,494,180,719,457,197,450,401 }, + { 204,74,135,66,6,174,192,7,138,172,85,353,348,580,280,97,95,500,29,64,426,32,87,889,65,81,25,2,52,43,568,673 }, + { 35,0,68,69,24,9,1,16,65,103,149,133,18,114,28,50,83,2,189,7,46,14,101,336,175,124,251,55,71,218,38,238 }, + { 16,101,0,118,9,18,24,68,35,154,71,124,60,212,191,520,55,806,694,167,28,39,364,375,1,346,252,65,604,302,22,21 }, + { 0,9,16,35,1,24,68,18,65,21,103,67,13,149,28,189,71,23,101,238,114,7,335,133,486,141,22,212,48,50,30,118 }, + { 13,202,23,77,33,51,128,5,21,141,115,32,102,64,4,0,318,269,10,15,291,2,494,177,11,217,3,515,22,137,6,700 }, + { 16,92,60,35,7,18,24,68,150,149,14,71,0,375,97,126,118,107,230,191,246,273,140,55,175,653,9,575,2,28,566,517 }, + { 76,90,21,179,316,148,205,32,464,288,184,257,245,1,89,2,460,57,152,45,38,358,645,5,12,449,350,48,37,17,4,14 }, + { 19,27,26,813,80,297,17,495,436,53,73,200,4,378,250,59,106,25,45,128,361,42,113,469,122,390,77,40,736,6,11,136 }, + { 6,26,235,138,19,145,112,70,331,262,25,42,52,624,27,453,122,47,500,78,648,85,29,2,630,632,409,113,50,226,108,75 }, + { 7,16,14,24,92,35,18,2,46,9,60,140,0,87,50,5,54,13,12,38,171,23,126,21,58,64,1,70,128,71,220,163 }, + { 90,205,257,184,32,179,460,5,245,45,2,288,769,524,57,21,152,229,17,1,497,4,292,59,619,452,432,76,476,11,266,14 }, + { 15,515,700,753,4,5,11,141,13,1,33,3,0,128,202,23,180,21,2,64,269,32,117,134,120,40,102,318,153,17,137,352 }, + { 47,130,711,108,453,412,730,196,390,283,78,27,51,183,381,236,128,200,719,14,153,472,503,34,59,250,3,4,57,803,123,432 }, + { 12,277,51,474,111,153,23,99,13,37,961,94,629,542,569,431,79,139,38,134,117,453,33,188,196,40,115,15,11,157,401,515 }, + { 17,495,469,106,26,378,80,27,161,483,19,742,527,436,383,862,73,136,53,814,297,6,119,84,62,56,25,3,209,611,4,128 }, + { 81,681,636,91,0,750,370,104,718,138,18,693,173,784,29,397,348,74,192,673,174,65,6,207,64,280,306,52,671,32,355,319 }, + { 15,515,700,753,33,77,4,102,115,117,40,13,1,153,134,11,5,217,23,196,2,21,3,317,32,365,0,341,291,59,12,51 }, + { 0,9,28,35,68,1,65,67,101,39,69,175,16,238,13,22,96,124,18,24,251,30,55,12,23,2,50,141,114,5,154,103 }, + { 23,33,77,13,117,40,11,102,64,4,51,403,153,453,10,0,196,134,128,65,12,291,86,99,95,59,15,141,202,180,137,719 }, + { 214,90,289,6,874,64,25,65,235,42,751,249,256,312,194,85,746,875,174,32,525,288,519,835,247,348,233,544,217,524,437,352 }, + { 1,22,2,0,36,67,28,5,49,95,12,50,168,83,105,55,7,9,14,194,103,23,114,21,584,46,10,13,38,69,208,159 }, + { 269,141,13,202,33,180,318,77,291,137,102,352,128,23,349,51,31,217,372,317,125,197,44,21,11,5,901,1,18,0,4,494 }, + { 435,144,274,88,203,418,30,1,190,410,96,778,100,530,521,326,466,795,686,166,960,321,382,264,367,822,131,31,692,9,213,93 }, + { 76,72,90,21,37,179,12,205,32,428,148,38,308,405,4,413,57,184,749,245,316,221,54,645,288,1,152,155,464,257,2,14 }, + { 77,33,64,102,13,141,23,2,40,1,51,10,0,115,6,180,202,128,4,3,177,269,15,7,22,165,291,14,217,318,137,11 }, + { 397,81,4,32,65,788,693,804,681,11,249,21,91,64,690,494,3,0,422,56,348,725,194,123,23,59,523,319,61,510,95,90 }, + { 60,126,16,7,92,121,314,246,35,107,150,132,14,146,24,18,199,298,232,71,359,140,672,97,392,649,5,423,95,21,22,388 }, + { 15,515,141,217,115,700,13,23,120,317,753,180,33,260,110,137,341,51,1,365,4,77,64,202,0,40,36,352,197,269,10,21 }, + { 111,134,117,474,23,13,961,12,569,431,37,15,51,115,515,700,277,99,753,38,197,405,457,4,72,94,629,45,11,89,54,148 }, + { 23,13,51,5,1,15,2,21,12,202,141,0,515,165,120,32,4,64,700,3,115,197,269,125,753,7,9,128,6,180,453,403 }, + { 13,141,4,23,5,2,115,217,202,51,180,137,269,352,77,1,317,3,21,318,0,15,9,64,10,197,11,341,33,515,752,7 }, + { 165,125,197,13,391,21,23,558,48,380,97,120,298,33,14,426,66,115,32,386,900,180,6,98,357,237,326,509,51,278,221,457 }, + { 120,82,15,260,515,1,351,77,450,700,13,21,141,23,753,202,217,93,110,33,51,854,5,128,326,102,137,180,817,48,269,352 }, + { 23,13,15,51,515,700,961,753,0,457,1,2,4,115,10,453,569,5,33,165,11,719,14,40,64,197,3,21,474,629,38,401 }, + { 264,166,39,30,9,100,435,254,93,921,190,363,1,625,411,382,897,656,203,478,404,812,438,110,473,88,18,691,156,141,274,272 }, + { 9,0,252,100,166,39,101,265,364,68,88,329,520,18,419,676,118,167,404,604,16,1,21,30,212,158,553,49,382,274,48,13 }, + { 15,515,700,753,4,11,141,5,3,13,202,1,180,21,2,165,269,23,40,64,0,318,12,32,128,51,77,117,523,197,120,457 }, + { 24,1,2,69,35,16,67,18,14,50,0,46,68,9,38,7,133,71,83,149,28,108,189,218,65,114,238,29,75,54,5,96 }, + { 90,289,214,64,874,13,77,712,66,751,4,23,51,192,32,0,202,194,312,177,33,65,234,104,875,288,59,5,835,416,102,95 }, + { 0,9,49,127,98,31,301,28,371,159,1,395,512,737,158,761,916,623,16,44,242,39,170,18,293,105,24,272,101,22,23,385 }, + { 17,62,136,214,123,129,32,292,119,209,710,106,141,162,128,64,45,4,77,249,11,618,211,3,207,130,519,183,38,177,21,269 }, + { 5,107,581,356,279,32,441,362,493,660,13,298,0,534,49,147,21,22,132,121,97,423,7,590,259,683,14,786,126,508,60,246 }, + { 51,13,15,730,453,23,515,719,386,457,12,700,403,475,899,1,6,523,753,421,99,401,165,33,2,19,361,5,0,670,120,27 }, + { 49,28,9,159,272,22,254,131,158,327,95,105,0,39,35,168,347,286,374,55,65,627,424,912,68,578,1,24,239,175,688,169 }, + { 15,515,700,33,753,4,77,141,341,317,1,10,13,180,102,22,40,117,115,365,5,901,23,197,134,11,217,351,64,82,21,137 }, + { 134,15,13,515,23,700,12,753,51,474,37,961,197,10,457,569,4,0,99,2,115,38,165,153,94,3,139,11,1,82,33,5 }, + { 7,2,20,58,5,14,128,66,6,29,32,43,21,52,16,38,631,61,74,97,46,135,113,25,202,192,13,0,884,45,112,87 }, + { 77,13,33,202,23,128,102,4,141,342,117,0,269,318,134,22,11,21,32,153,403,291,49,64,137,51,40,15,494,5,196,98 }, + { 2,1,14,6,46,38,29,65,5,36,67,0,103,7,22,86,133,50,108,208,52,83,24,323,283,69,28,18,10,25,23,75 }, + { 15,515,700,753,1,5,4,2,3,13,0,11,180,341,12,33,10,197,134,365,77,23,21,901,6,117,165,7,37,32,17,102 }, + { 203,268,206,93,417,940,31,8,120,137,44,499,959,473,202,692,728,559,0,260,10,326,141,564,817,127,341,1,450,22,110,23 }, + { 15,82,515,120,700,0,10,753,33,8,64,165,110,31,260,93,13,197,23,22,40,4,351,44,77,9,11,153,102,51,1,196 }, + { 60,0,16,7,14,43,20,71,28,10,2,22,154,18,13,24,92,1,51,576,35,615,805,925,68,126,124,149,97,64,23,55 }, + { 19,6,26,80,5,84,27,17,25,2,504,129,45,240,56,123,4,119,618,1,76,106,64,51,14,3,128,65,32,710,0,42 }, + { 15,515,700,753,13,4,77,23,33,51,0,5,8,10,11,31,44,1,82,22,202,64,110,102,93,21,291,40,141,180,9,49 }, + { 195,98,271,223,132,167,146,407,1,360,121,834,393,591,212,199,293,259,522,107,354,147,156,191,807,590,48,18,125,16,765,541 }, + { 128,202,77,210,402,318,33,102,6,40,403,29,342,269,196,757,99,139,2,111,42,4,494,117,275,300,13,12,678,0,177,122 }, + { 13,33,23,40,51,102,4,117,77,64,134,0,128,153,202,196,453,11,15,12,1,22,403,141,59,14,10,475,515,65,700,95 }, + { 7,16,14,24,18,2,28,0,92,71,1,22,6,35,60,20,168,10,154,118,5,302,124,69,97,109,703,158,420,12,149,66 }, + { 15,1,515,23,0,13,700,2,51,753,180,5,120,165,197,21,115,4,33,9,141,7,12,6,3,457,386,202,260,523,8,31 }, + { 60,107,121,132,146,126,199,279,150,92,16,649,441,35,955,7,21,0,423,5,18,195,598,298,493,356,32,653,22,362,953,10 }, + { 31,44,98,276,284,299,116,935,9,201,0,131,39,127,144,662,1,137,371,492,567,489,93,254,49,268,22,28,30,293,434,737 }, + { 13,15,23,515,700,0,1,51,753,4,2,10,77,202,5,115,3,165,197,457,9,12,11,961,33,120,22,141,180,7,6,40 }, + { 123,162,184,257,17,183,229,130,129,3,84,136,99,152,556,383,57,497,12,205,4,62,56,452,80,266,128,14,40,119,27,106 }, + { 196,33,117,40,153,23,134,13,51,102,453,0,15,475,12,14,515,2,22,700,4,21,753,64,401,670,730,1,9,11,10,99 }, + { 224,219,187,131,258,385,442,871,836,31,98,908,44,574,127,944,137,839,116,36,613,1,254,39,926,160,829,96,93,371,860,827 }, + { 121,195,156,132,146,360,590,407,786,522,883,591,259,929,626,941,150,687,5,55,296,379,467,178,586,465,279,21,1,13,60,354 }, + { 2,1,14,29,6,5,46,52,38,19,114,75,26,65,108,96,25,50,36,70,103,309,17,236,218,74,12,86,0,3,10,112 }, + { 15,515,82,700,120,753,10,0,8,197,260,165,351,64,13,110,117,93,31,1,9,33,22,23,457,44,450,77,102,898,40,49 }, + { 7,66,97,2,172,74,226,52,29,135,192,232,43,324,92,5,38,20,222,14,6,568,87,107,353,620,580,16,138,174,448,32 }, + { 62,129,123,162,136,249,618,183,507,57,4,152,17,59,11,184,117,77,3,128,211,41,130,205,12,40,33,106,64,229,38,313 }, + { 1,13,15,2,4,515,23,0,3,115,700,5,51,77,341,141,753,180,33,217,197,202,901,6,21,165,11,365,318,317,10,102 }, + { 6,26,235,19,145,47,112,78,64,27,453,95,29,444,25,624,85,108,648,70,32,130,74,42,711,630,632,138,65,122,113,730 }, + { 23,51,12,15,13,99,515,153,117,10,700,37,120,82,165,2,753,64,128,0,403,3,5,1,134,197,453,31,202,457,110,21 }, + { 16,24,18,71,64,35,92,7,246,146,9,108,60,118,199,5,140,2,267,0,230,830,32,133,1,68,50,330,247,563,36,12 }, + { 15,515,700,753,0,1,13,2,23,3,4,217,51,5,115,8,9,180,341,10,7,6,317,77,33,372,901,197,365,11,120,165 }, + { 234,639,178,202,77,142,5,455,450,49,416,0,147,427,198,21,315,329,13,318,325,557,120,344,113,259,22,128,61,105,23,494 }, + { 1,31,36,44,141,180,55,2,64,22,98,116,13,352,0,115,10,127,5,164,253,498,237,165,341,197,4,86,15,170,125,23 }, + { 15,120,13,141,23,260,217,515,1,77,51,110,180,700,317,82,269,137,115,202,21,753,64,5,351,291,0,450,352,93,36,326 }, + { 26,6,112,396,19,145,25,122,648,287,42,74,624,222,416,45,138,66,644,151,113,651,29,573,64,280,445,27,525,85,70,58 }, + { 156,360,5,146,121,21,271,522,354,132,49,13,18,195,16,340,60,591,446,586,727,0,107,407,167,48,1,463,199,566,32,23 }, + { 5,61,49,147,178,612,660,120,21,182,23,427,259,683,33,4,77,70,13,3,376,98,64,0,481,344,48,595,291,263,141,51 }, + { 89,79,468,179,358,205,94,405,115,498,72,180,365,431,37,111,341,734,188,317,482,217,11,4,245,152,413,216,12,474,490,752 }, + { 24,16,35,68,18,71,7,92,0,108,9,14,118,101,336,175,375,302,28,124,154,55,149,60,398,1,65,2,140,273,345,230 }, + { 51,730,421,801,453,386,23,523,13,475,719,401,670,365,899,403,115,457,758,165,33,494,450,6,423,805,629,56,569,514,958,388 }, + { 113,45,6,311,29,2,151,614,145,491,112,80,5,27,61,74,315,66,209,631,19,25,58,17,73,26,1,243,70,64,611,287 }, + { 4,339,188,471,11,59,79,12,377,94,99,33,77,102,51,111,37,152,13,961,474,542,40,342,3,23,128,403,202,177,184,57 }, + { 15,4,515,11,700,33,82,40,0,120,753,10,8,110,13,93,23,165,77,260,64,31,22,51,44,102,351,1,125,9,197,21 }, + { 16,24,18,0,35,68,28,71,124,118,60,7,9,55,14,92,109,101,419,175,22,252,154,375,149,302,158,346,2,49,1,126 }, + { 17,45,227,21,106,3,2,243,209,5,48,32,221,62,207,50,29,186,290,270,263,52,14,496,400,119,46,255,54,430,38,721 }, + { 340,354,586,658,156,195,698,668,1,296,9,18,883,363,447,379,303,98,411,13,31,163,51,5,371,48,919,846,121,21,360,70 }, + { 277,153,111,12,23,51,474,99,38,37,139,117,41,457,79,453,542,13,11,33,134,157,629,188,961,14,196,401,102,569,15,94 }, + { 0,18,16,159,49,24,9,105,35,68,7,28,22,1,60,344,55,101,109,2,14,158,13,23,71,118,455,286,272,424,5,327 }, + { 0,105,9,49,16,18,158,28,518,24,101,320,1,68,170,301,272,127,7,286,35,890,109,39,159,98,21,344,31,55,371,23 }, + { 141,1,180,15,13,2,365,217,515,352,317,115,341,0,4,5,269,700,23,21,3,752,197,77,753,51,31,901,10,202,8,64 }, + { 4,23,51,33,19,17,102,153,485,880,40,403,196,26,300,453,27,117,78,0,12,200,47,5,11,14,342,99,53,77,475,2 }, + { 62,184,56,440,130,229,183,3,556,152,99,162,12,266,17,548,136,57,305,161,123,14,452,4,383,403,257,34,40,84,33,139 }, + { 13,23,77,141,64,202,33,51,269,115,0,102,21,4,217,128,5,32,318,137,291,9,15,2,180,10,3,317,177,515,7,6 }, + { 1,22,36,105,170,0,86,2,31,28,239,64,55,5,10,98,9,44,127,95,654,67,301,143,13,12,49,23,320,141,83,21 }, + { 15,515,700,753,0,1,13,2,23,901,5,8,51,82,9,180,457,4,7,12,3,6,10,120,341,141,22,898,197,351,115,260 }, + { 1,39,274,98,100,265,190,30,438,310,166,223,88,96,909,31,264,625,530,9,382,812,21,252,593,0,254,539,44,131,23,778 }, + { 18,212,167,118,363,1,447,411,146,60,271,16,781,121,647,9,621,562,21,478,664,68,815,5,354,98,48,101,24,446,777,463 }, + { 24,28,22,0,7,1,2,16,14,65,35,49,158,95,109,159,55,105,10,18,124,9,67,5,239,149,12,289,108,68,21,424 }, + { 105,22,131,272,286,98,55,239,1,31,320,9,127,327,36,185,28,374,86,219,0,64,187,44,578,164,224,913,535,115,601,13 }, + { 22,31,28,301,127,98,44,0,105,1,512,395,9,293,109,299,95,338,239,125,242,116,36,320,55,841,900,685,599,23,13,763 }, + { 2,1,58,29,5,14,52,46,186,334,45,155,151,50,400,75,38,69,502,61,48,227,223,7,163,17,262,67,549,21,70,113 }, + { 7,107,135,232,97,14,2,92,66,16,172,192,278,387,298,356,38,35,448,52,46,43,60,29,20,126,324,526,357,359,64,5 }, + { 20,43,104,426,173,7,560,414,707,784,319,81,0,861,422,819,38,74,715,52,376,97,879,32,330,22,49,64,66,95,192,526 }, + { 104,74,636,66,204,0,355,81,222,25,29,319,145,784,20,65,90,4,174,194,7,64,6,746,138,173,750,715,91,43,192,32 }, + { 0,9,101,35,68,39,65,28,252,124,67,154,364,336,100,166,30,1,289,55,149,346,16,114,158,88,439,24,429,22,570,194 }, + { 57,14,4,231,236,585,176,59,369,23,361,13,719,51,300,342,12,457,56,3,62,38,202,401,34,46,2,322,11,215,210,507 }, + { 1,2,15,3,141,0,515,5,33,700,13,64,77,180,6,128,753,10,4,269,102,202,11,7,134,197,352,120,117,318,12,291 }, + { 5,1,21,202,13,32,48,23,0,61,259,22,494,120,70,49,51,18,137,128,465,12,178,115,2,453,403,141,58,3,90,450 }, + { 141,205,4,72,59,79,245,11,352,94,152,76,247,216,21,188,452,217,497,12,89,37,111,339,588,77,64,875,864,115,358,464 }, + { 15,515,700,753,0,1,2,13,5,4,23,3,8,341,365,51,115,10,120,457,6,141,77,197,31,7,165,9,202,450,961,260 }, + { 5,2,50,14,58,38,171,46,29,1,45,186,17,52,155,218,48,281,61,487,54,36,67,21,328,334,151,227,760,114,400,133 }, + { 457,120,70,125,318,64,23,48,795,291,202,761,751,415,77,846,269,758,21,237,96,260,391,165,87,1,128,5,221,13,137,763 }, + { 13,23,51,33,4,40,117,102,453,64,153,196,0,77,15,11,12,475,1,65,134,10,515,22,21,14,700,59,403,141,2,753 }, + { 229,152,57,266,452,381,432,12,313,184,99,471,17,4,62,339,157,3,129,59,128,11,369,37,77,38,40,123,5,497,188,257 }, + { 49,28,109,22,159,9,272,95,105,131,55,35,254,168,39,327,169,0,1,286,175,374,347,158,420,67,36,194,312,424,627,346 }, + { 5,2,61,29,45,58,80,311,1,17,209,227,52,243,106,869,454,151,592,496,48,334,14,155,6,186,46,171,75,21,255,667 }, + { 244,44,110,141,260,30,269,352,839,131,574,228,373,276,1,406,219,717,217,137,253,224,120,93,36,31,567,116,661,187,341,88 }, + { 12,99,79,139,11,453,196,51,277,474,111,23,542,37,94,188,33,13,401,775,40,961,313,102,4,339,153,485,629,134,300,431 }, + { 16,35,9,0,68,24,149,69,67,18,1,114,65,230,71,7,103,133,50,167,212,118,101,191,140,64,399,28,124,283,55,565 }, + { 88,30,274,435,131,613,190,100,93,829,166,1,187,795,530,127,382,957,960,160,31,137,466,264,39,800,406,254,28,473,521,219 }, + { 167,16,18,118,212,24,60,71,101,68,191,9,375,411,363,35,0,1,589,199,302,21,447,55,146,126,92,271,647,121,562,48 }, + { 64,141,86,177,77,128,147,597,304,95,269,102,275,4,352,49,120,5,372,194,465,13,588,237,947,216,202,180,612,751,107,534 }, + { 18,65,90,403,523,289,240,214,194,102,701,475,202,217,283,862,389,51,33,0,494,421,453,817,84,64,847,899,352,13,23,437 }, + { 13,51,23,202,5,12,21,128,15,115,0,1,141,120,64,32,4,2,515,403,165,457,3,10,700,99,453,318,719,450,308,401 }, + { 98,223,393,31,1,271,834,791,167,44,202,64,93,697,5,116,77,125,450,446,212,18,541,293,51,120,195,132,284,13,807,765 }, + { 15,515,700,753,4,11,23,13,40,51,82,165,0,110,93,33,141,64,120,5,10,77,3,102,180,32,202,125,8,197,31,21 }, + { 15,515,700,753,0,1,13,2,901,23,5,341,3,51,82,8,4,180,961,9,115,10,12,6,898,7,351,141,134,22,31,120 }, + { 234,416,77,5,315,639,325,202,147,198,113,49,450,61,455,142,0,21,22,342,329,494,178,58,102,427,318,230,13,120,43,470 }, + { 60,146,16,18,156,126,121,271,199,360,132,24,167,0,640,10,71,522,21,92,5,340,107,354,118,150,22,195,446,35,28,212 }, + { 4,361,11,14,56,368,377,161,27,12,300,77,59,200,17,554,202,33,40,494,495,21,210,80,757,25,128,23,19,38,444,53 }, + { 141,82,217,351,15,352,120,1,180,260,515,64,854,36,700,317,752,372,13,269,77,753,922,21,349,23,202,110,93,137,51,373 }, + { 15,515,700,753,77,13,0,1,23,33,102,2,51,4,3,5,291,217,10,9,450,120,341,7,317,6,11,117,115,8,260,180 }, + { 15,515,120,13,700,23,77,141,1,260,0,753,180,51,137,202,115,365,110,291,217,5,128,9,21,341,197,269,2,450,317,165 }, + { 174,6,348,85,138,74,280,204,66,233,192,355,289,65,81,580,636,353,25,91,104,343,673,214,64,95,42,712,792,32,194,90 }, + { 152,497,452,59,4,216,11,79,94,77,128,188,269,339,588,33,76,529,318,32,141,471,12,202,111,21,5,51,37,90,72,177 }, + { 417,499,10,141,253,244,110,559,8,564,180,260,728,120,352,638,642,341,951,206,143,752,901,93,137,661,922,373,44,31,811,197 }, + { 13,77,23,33,4,51,0,102,128,59,141,40,64,115,177,10,137,22,202,2,7,11,90,1,117,180,269,14,49,6,134,3 }, + { 1,2,22,0,36,5,67,50,14,28,12,86,38,46,83,168,194,65,103,114,49,7,10,95,21,69,23,24,128,51,55,13 }, + { 17,106,119,207,255,306,742,378,84,62,136,45,3,5,240,80,61,56,209,383,311,790,655,32,2,440,76,151,58,29,179,263 }, + { 3,128,1,141,2,202,33,5,64,15,0,515,102,13,269,10,700,180,134,51,120,6,77,318,23,137,17,117,753,197,82,153 }, + { 514,38,377,328,11,57,41,248,880,266,556,4,152,361,471,757,485,403,305,102,3,211,313,99,457,130,12,14,157,40,23,54 }, + { 68,0,167,101,9,118,264,520,16,18,21,478,562,1,124,212,100,936,664,777,191,88,806,154,48,24,759,604,35,252,265,65 }, + { 230,689,699,213,466,352,217,831,30,443,418,144,854,201,840,855,1,251,203,317,530,957,96,93,822,539,36,752,351,137,83,800 }, + { 33,77,102,117,15,82,13,134,23,64,0,515,120,153,51,4,40,128,700,260,202,141,196,22,753,11,351,10,1,326,95,269 }, + { 11,40,33,51,117,13,542,328,14,134,38,153,23,12,485,231,102,54,775,37,3,377,111,139,211,4,457,403,369,475,99,719 }, + { 33,64,77,128,141,2,1,202,102,13,23,117,0,15,3,153,51,134,10,40,6,5,515,269,137,180,318,165,700,7,196,753 }, + { 15,515,700,753,4,1,5,11,13,21,33,180,93,141,64,2,23,77,82,3,0,102,32,40,352,341,10,197,98,110,117,901 }, + { 1,2,14,67,50,46,38,24,103,83,0,5,36,28,29,133,114,96,65,52,18,75,54,108,22,7,238,58,160,9,361,69 }, + { 258,201,276,137,160,860,116,261,295,843,567,144,131,44,187,268,943,219,284,31,202,935,141,98,662,203,127,96,36,93,224,1 }, + { 7,2,14,16,46,87,75,52,92,278,29,38,140,70,1,5,35,294,24,262,135,69,171,172,58,409,112,60,50,66,97,12 }, + { 13,23,0,2,51,1,33,4,115,10,15,141,77,3,5,180,217,515,9,7,64,11,700,6,102,40,197,22,317,753,165,202 }, + { 74,145,6,66,25,204,42,29,222,337,138,26,7,525,192,174,746,287,544,135,415,2,609,632,112,64,87,0,85,45,712,396 }, + { 77,33,102,15,217,13,23,141,202,515,51,700,291,4,269,753,317,180,21,64,318,115,128,0,275,2,352,196,3,5,137,11 }, + { 187,219,258,871,44,442,160,574,137,224,908,116,839,131,36,926,276,201,93,228,202,860,31,613,144,531,406,1,902,30,190,318 }, + { 1,372,141,5,21,77,225,744,96,30,23,349,13,291,269,284,69,442,459,144,303,839,217,622,160,330,260,48,120,410,189,352 }, + { 66,222,2,74,29,87,135,6,7,145,52,25,294,337,226,172,138,331,42,70,97,112,26,1,632,192,43,5,415,609,461,353 }, + { 45,17,106,209,5,2,21,29,48,207,3,186,243,155,255,263,454,119,400,496,270,14,290,62,425,1,171,32,659,52,38,56 }, + { 93,88,141,120,30,213,260,373,100,717,459,82,110,1,166,450,180,321,217,372,36,269,131,225,22,352,326,466,473,187,244,410 }, + { 266,57,152,381,313,471,12,229,99,369,339,62,157,3,4,37,77,38,188,17,11,162,40,184,129,59,475,775,128,452,403,453 }, + { 217,352,317,141,752,15,180,515,372,365,700,341,753,349,77,21,291,1,115,244,64,120,13,98,269,82,5,498,864,351,23,144 }, + { 14,514,369,102,403,377,51,719,880,153,23,13,457,11,485,4,401,12,328,453,33,40,117,57,629,38,730,236,134,670,361,961 }, + { 107,7,172,14,92,135,2,359,60,314,46,16,126,278,232,150,279,32,38,392,298,5,35,97,24,192,259,288,330,52,356,312 }, + { 0,4,25,13,59,90,65,23,26,19,18,12,5,216,91,51,389,33,77,11,22,85,27,81,21,177,746,45,42,194,37,123 }, + { 5,49,315,202,416,77,455,639,450,21,197,137,350,13,408,0,329,318,494,344,61,402,64,509,347,120,113,48,95,713,308,401 }, + { 130,47,381,390,59,90,200,214,289,6,65,472,29,64,874,648,50,751,624,26,52,32,4,194,875,714,85,249,247,33,881,19 }, + { 51,23,453,13,719,12,457,165,37,730,99,4,386,197,401,17,11,2,3,15,5,961,475,6,515,64,54,700,32,115,0,403 }, + { 15,515,1,13,700,2,23,0,753,5,3,180,51,4,165,12,141,21,197,457,7,115,6,9,352,10,120,202,8,341,11,77 }, + { 0,9,1,67,35,28,68,16,24,65,18,69,50,114,103,12,22,13,5,101,2,96,23,83,149,21,39,55,7,175,433,124 }, + { 28,105,22,0,1,320,170,9,49,301,109,95,127,31,98,55,65,35,2,24,168,159,36,713,16,740,13,338,21,44,512,23 }, + { 13,77,4,51,23,33,102,202,128,59,40,0,64,141,117,403,115,11,15,318,153,269,22,515,475,134,10,494,177,1,90,210 }, + { 13,23,0,51,77,33,2,141,4,10,1,64,115,102,3,6,22,15,217,11,180,7,40,515,165,202,177,9,269,128,700,5 }, + { 456,116,492,8,949,268,867,391,203,51,499,13,719,386,31,791,457,918,125,10,23,93,479,685,417,0,22,338,506,551,870,730 }, + { 17,237,45,180,106,62,32,64,115,41,136,498,255,21,197,129,241,13,3,227,23,352,165,752,350,365,449,155,4,546,476,38 }, + { 1,15,180,515,0,2,341,700,901,352,4,141,13,3,752,5,753,217,317,115,365,23,197,21,51,165,31,6,269,202,77,7 }, + { 205,141,216,269,497,4,588,76,59,152,128,452,79,77,875,11,72,94,188,217,352,12,247,37,90,64,32,1,474,23,947,372 }, + { 64,247,217,237,317,180,752,115,349,141,498,13,437,304,23,372,352,164,579,291,33,864,177,197,0,490,72,10,482,77,269,51 }, + { 2,1,0,13,15,141,3,77,5,515,64,33,23,180,6,700,4,117,217,7,10,11,102,165,753,197,115,134,40,352,12,269 }, + { 11,40,38,328,33,542,12,313,41,339,23,157,377,117,369,51,471,99,775,485,13,305,457,57,14,475,37,248,4,54,188,719 }, + { 33,77,102,40,13,23,0,51,4,128,64,202,117,141,22,196,153,10,134,15,59,269,1,137,65,11,403,318,453,86,515,177 }, + { 472,80,34,250,495,161,17,14,469,176,128,4,389,106,283,436,216,527,3,297,483,177,53,56,231,194,119,84,719,57,255,59 }, + { 317,352,180,141,217,752,115,341,365,244,1,269,202,901,253,15,21,498,372,4,137,515,13,2,700,318,5,197,23,143,753,349 }, + { 9,39,101,18,265,100,333,520,252,16,0,329,593,1,553,364,68,167,310,30,121,254,118,158,363,166,60,604,272,24,286,404 }, + { 15,515,1,180,700,901,0,2,753,341,752,4,3,13,115,365,317,5,23,197,141,217,165,352,6,22,36,9,137,51,7,10 }, + { 131,39,9,829,166,613,578,827,1,30,716,254,100,98,31,224,0,406,228,310,616,219,44,846,127,190,938,96,265,371,856,438 }, + { 17,64,62,106,141,751,136,292,32,129,352,41,38,476,86,128,214,237,5,177,123,209,217,45,269,954,162,710,180,3,90,4 }, + { 25,42,235,65,650,736,605,6,630,85,123,343,233,256,26,122,63,389,141,249,416,444,368,194,19,108,138,174,90,0,544,511 }, + { 184,229,152,57,266,432,497,452,17,381,619,257,313,12,4,205,59,3,99,471,157,128,5,129,339,369,77,11,32,45,202,2 }, + { 137,202,160,860,141,30,93,567,36,276,295,261,131,39,9,964,201,843,1,98,800,318,116,22,943,187,10,219,206,44,269,535 }, + { 0,493,125,64,49,9,279,10,35,18,93,55,293,31,14,13,194,165,325,48,22,132,21,107,98,389,44,581,342,259,174,137 }, + { 15,515,700,753,4,33,13,77,23,5,51,32,102,40,93,11,349,141,21,8,82,202,64,31,110,10,117,0,1,44,3,318 }, + { 110,253,854,811,352,141,244,951,180,642,661,384,498,143,752,317,911,10,269,206,559,351,261,120,902,533,922,959,365,160,332,217 }, + { 2,29,70,1,75,52,6,220,26,112,145,331,74,163,19,69,38,324,46,58,14,5,25,21,278,223,50,307,66,7,67,409 }, + { 13,23,77,33,51,4,64,141,115,102,0,2,128,177,40,11,202,10,6,180,7,15,269,1,32,217,59,22,291,3,137,515 }, + { 340,897,691,478,658,264,914,382,100,812,363,1,724,156,166,698,88,521,39,404,682,447,296,96,303,411,30,909,9,274,656,772 }, + { 9,18,310,101,265,159,326,120,105,158,33,363,77,195,51,55,13,39,354,132,23,7,28,639,16,137,98,1,252,272,709,49 }, + { 57,313,471,12,99,369,157,339,266,152,38,37,475,453,328,775,11,40,59,188,77,514,401,403,342,4,139,33,377,51,229,14 }, + { 16,7,24,14,35,140,60,92,18,69,71,2,189,1,46,230,108,388,150,38,21,172,278,67,246,267,50,309,236,135,451,0 }, + { 206,417,93,940,959,473,499,203,8,137,559,728,31,202,44,120,450,141,10,260,116,564,22,326,269,318,268,244,0,1,253,638 }, + { 15,515,700,753,1,0,13,2,23,4,3,51,5,217,7,77,341,115,8,9,10,33,6,180,317,349,291,120,11,165,457,901 }, + { 1,2,5,14,48,21,290,32,50,45,38,46,263,207,155,72,76,29,17,408,425,171,89,52,7,0,292,449,3,227,513,428 }, + { 121,132,354,167,271,223,146,98,18,463,1,668,446,195,407,60,212,447,781,48,360,363,411,522,156,393,807,9,21,16,293,13 }, + { 131,578,105,371,219,224,716,616,187,49,9,254,737,159,385,98,258,127,272,761,0,916,623,910,28,286,39,31,22,518,924,242 }, + { 302,467,97,6,273,1,24,484,124,51,36,18,2,398,453,421,523,69,7,23,13,403,386,150,66,0,298,65,426,165,22,158 }, + { 30,190,530,88,1,100,778,539,625,274,382,410,96,731,960,39,795,321,9,131,264,144,840,748,44,166,669,957,36,31,435,228 }, + { 141,1,2,128,64,33,15,202,3,0,180,5,13,77,515,134,269,102,197,700,10,137,318,6,120,165,753,352,4,82,23,117 }, + { 44,201,567,116,131,224,295,662,489,268,219,31,434,144,187,276,110,384,93,261,699,137,36,442,120,1,613,30,228,64,141,244 }, + { 12,15,51,23,515,37,99,13,700,0,10,117,753,38,165,82,134,120,11,453,197,64,115,569,1,629,401,22,457,474,110,153 }, + { 7,135,2,92,172,14,66,140,38,52,97,46,29,74,16,324,278,226,6,87,1,571,262,5,357,232,35,380,69,314,24,330 }, + { 125,386,23,963,949,60,51,391,165,221,13,197,118,21,719,193,541,421,517,150,393,7,401,453,308,5,791,551,326,558,48,173 }, + { 6,85,42,25,138,222,174,235,280,256,525,289,26,214,64,746,90,32,544,65,204,19,66,337,355,95,348,415,74,29,5,312 }, + { 1,14,5,50,2,67,24,0,46,69,48,21,58,103,16,12,18,38,54,96,83,7,502,45,36,181,35,9,430,28,10,155 }, + { 811,351,642,180,951,752,110,638,253,10,82,352,197,341,365,564,499,854,873,55,9,417,282,901,244,22,559,143,206,141,28,898 }, + { 23,13,51,15,12,453,403,165,4,515,115,719,475,457,700,523,2,21,0,99,202,197,14,5,386,753,128,401,37,308,33,117 }, + { 120,13,23,77,141,1,15,93,217,82,260,51,137,202,110,515,21,180,165,5,128,102,64,351,291,700,269,352,326,203,177,0 }, + { 1,5,0,22,12,2,36,21,10,23,86,13,28,51,9,128,48,14,32,50,7,3,96,137,54,4,202,49,37,65,208,323 }, + { 219,98,23,127,301,51,258,308,170,910,13,165,22,105,293,616,125,242,276,401,201,395,964,115,55,284,31,374,327,206,512,900 }, + { 64,180,80,165,5,237,2,250,34,58,297,61,197,17,22,29,186,498,231,445,247,3,752,311,95,32,483,153,27,45,115,469 }, + { 13,77,23,33,0,2,1,64,141,51,102,10,15,3,115,40,180,6,515,128,7,22,269,202,4,217,700,5,177,117,14,165 }, + { 15,120,51,515,13,450,23,700,202,153,196,753,260,64,128,141,730,4,326,386,21,523,33,318,5,457,95,32,403,1,77,269 }, + { 2,1,5,29,32,45,207,263,14,425,58,72,76,21,7,408,48,46,52,186,17,292,38,6,61,89,476,50,155,720,119,3 }, + { 15,515,700,753,4,13,11,5,1,23,33,21,3,141,32,2,40,180,117,64,269,202,102,197,0,165,120,51,341,352,153,12 }, + { 76,5,214,129,2,123,45,710,17,249,618,460,179,32,1,257,205,519,90,207,245,184,162,61,769,209,292,106,6,29,14,128 }, + { 1,15,23,13,120,141,51,515,202,21,700,165,0,180,137,2,5,77,128,93,753,260,269,197,326,33,110,352,82,102,318,48 }, + { 7,2,135,14,29,87,66,52,97,172,70,112,5,58,46,337,92,16,20,43,1,38,232,155,74,294,6,461,409,151,262,32 }, + { 574,187,384,926,860,110,258,434,269,531,141,244,160,261,253,116,699,959,940,717,533,36,219,31,902,661,871,295,201,352,10,260 }, + { 156,354,296,1,182,586,64,379,340,937,850,698,31,48,98,44,120,18,163,23,30,658,195,125,77,284,223,291,774,481,96,39 }, + { 250,80,34,472,17,495,176,469,33,194,64,483,4,297,141,14,161,27,53,667,56,833,73,527,585,231,106,51,84,814,2,59 }, + { 97,7,81,140,66,92,172,192,24,298,43,6,74,69,314,426,462,14,501,16,21,508,60,189,267,232,230,104,48,20,135,330 }, + { 31,44,116,144,268,393,492,434,367,489,127,98,918,0,384,9,22,206,948,105,93,203,1,456,332,940,299,28,137,49,293,125 }, + { 15,128,33,3,13,51,141,1,202,64,23,2,515,120,102,0,5,82,10,700,165,197,269,153,403,110,753,137,196,318,117,12 }, + { 31,98,127,9,0,105,22,28,44,512,293,395,299,1,242,49,685,763,320,599,125,116,109,276,284,95,870,159,23,456,36,900 }, + { 7,24,124,1,6,97,2,69,14,18,23,92,21,67,66,16,5,484,43,20,118,65,36,22,28,0,51,140,13,71,29,150 }, + { 1,64,442,303,284,349,202,141,622,67,154,447,260,44,652,429,9,335,237,919,197,98,167,33,682,269,547,77,863,411,340,201 }, + { 1,15,2,141,515,0,700,13,3,180,10,753,5,64,77,33,4,6,7,197,102,269,165,23,134,11,352,341,291,349,22,120 }, + { 99,139,12,453,196,277,775,40,475,33,23,401,215,51,11,14,77,111,313,130,38,211,37,266,129,15,339,153,719,3,369,515 }, + { 33,77,102,4,23,128,13,141,202,64,51,0,40,59,269,115,117,137,153,1,318,11,10,177,15,134,22,90,196,2,403,32 }, + { 7,2,14,58,70,112,16,5,87,38,46,52,6,128,135,1,32,21,155,29,66,64,0,97,92,186,172,294,13,23,20,37 }, + { 15,13,515,1,700,2,23,0,753,5,3,4,51,10,341,115,365,180,11,33,317,77,6,7,217,12,197,165,117,9,64,102 }, + { 2,1,14,29,75,69,67,6,52,46,38,24,103,220,83,25,70,87,262,74,96,267,50,366,26,16,226,394,357,66,108,19 }, + { 9,105,18,39,1,0,16,557,101,272,252,890,326,49,265,21,137,100,23,938,13,310,159,5,31,24,254,51,30,128,202,132 }, + { 80,209,45,61,667,17,6,106,5,2,151,29,483,255,454,833,27,311,112,19,738,378,1,58,113,26,25,469,119,887,32,64 }, + { 13,23,51,15,5,1,515,0,21,2,12,141,700,165,202,115,753,32,180,4,3,197,10,120,457,9,269,128,64,341,7,33 }, + { 99,12,453,277,139,157,369,474,339,51,38,23,37,196,188,401,775,111,11,313,328,475,153,266,4,471,79,40,33,629,102,14 }, + { 7,92,16,232,97,140,126,14,60,107,66,35,298,387,314,104,246,462,441,150,0,38,24,2,172,357,230,330,5,633,22,289 }, + { 13,77,23,202,318,141,33,4,51,269,102,177,115,403,137,2,40,494,90,11,342,128,31,117,21,32,7,12,64,134,14,10 }, + { 13,2,0,23,141,1,77,3,180,33,6,64,15,10,115,51,4,5,217,197,7,165,515,102,22,11,700,269,40,352,177,14 }, + { 15,515,700,753,4,11,1,93,13,5,180,110,82,21,120,23,2,33,10,141,3,165,197,102,901,0,32,341,117,40,153,12 }, + { 15,515,700,753,1,13,0,2,23,4,77,51,3,5,341,291,7,33,6,115,10,9,8,217,11,177,120,180,102,165,197,365 }, + { 20,43,198,325,173,904,104,234,66,147,77,319,416,422,97,426,5,0,7,450,861,202,712,725,2,32,639,376,38,324,945,315 }, + { 105,0,9,28,49,301,170,1,127,159,22,16,31,98,512,623,24,109,158,395,35,68,371,65,713,55,2,242,293,21,44,18 }, + { 213,88,689,466,230,30,321,435,699,352,217,201,795,831,144,854,1,443,96,539,530,840,418,251,855,190,93,100,669,31,957,662 }, + { 130,453,47,196,4,57,14,59,236,711,51,153,730,77,412,381,23,202,108,128,361,13,283,117,11,719,200,46,34,78,210,2 }, + { 1,2,5,14,0,50,36,22,38,46,65,67,12,86,114,28,103,29,208,7,10,128,21,83,218,23,96,54,194,6,133,51 }, + { 6,26,74,19,165,453,14,730,1,125,197,50,29,51,138,357,13,2,108,391,70,719,46,457,47,500,386,262,112,23,235,52 }, + { 9,10,376,20,43,0,49,18,30,120,2,33,325,104,501,470,77,788,725,102,523,39,858,5,904,414,174,55,137,37,342,13 }, + { 15,515,700,753,0,1,13,23,51,77,120,202,341,82,5,4,9,260,2,137,141,128,115,351,901,8,180,10,197,21,450,33 }, + { 105,131,272,578,9,49,371,219,159,616,286,320,224,187,716,98,28,22,0,623,127,258,910,737,385,31,239,347,254,109,424,95 }, + { 457,51,13,23,961,12,719,99,453,15,4,515,165,401,629,3,700,11,17,14,2,37,753,41,57,569,38,45,0,33,5,32 }, + { 202,120,5,33,318,77,450,102,1,260,403,128,494,21,165,13,269,12,326,23,342,523,402,2,817,64,15,141,125,82,457,475 }, + { 141,269,352,217,180,64,349,137,202,160,317,15,372,515,700,752,318,753,244,13,437,291,165,864,22,237,5,82,954,21,77,418 }, + { 70,29,2,145,74,112,26,6,75,52,19,66,632,1,87,220,5,135,163,287,307,25,226,7,58,396,294,278,113,409,69,151 }, + { 82,351,317,15,752,180,898,352,141,901,515,341,10,700,365,1,753,498,0,217,253,115,55,854,33,5,143,32,21,160,36,197 }, + { 39,9,310,254,0,30,101,49,252,272,100,265,105,455,159,557,190,333,286,688,18,166,1,158,709,16,625,627,31,131,327,329 }, + { 2,58,29,5,1,151,186,52,70,45,7,549,14,75,112,400,113,155,61,46,227,163,311,315,66,6,307,27,17,220,287,74 }, + { 141,217,13,21,352,23,269,77,180,115,317,64,202,15,349,137,5,51,165,291,318,752,372,4,0,102,33,365,197,32,341,125 }, + { 68,35,0,9,65,101,149,124,24,154,175,16,28,7,67,1,18,189,114,398,55,14,345,39,118,133,69,2,230,429,71,283 }, + { 66,7,29,2,112,52,20,43,97,151,74,192,135,5,173,525,337,45,145,58,415,25,14,32,644,70,544,226,222,21,6,580 }, + { 31,125,44,22,116,299,242,55,1,170,64,36,479,870,456,685,10,599,558,0,268,506,28,740,23,903,492,164,393,206,2,86 }, + { 188,11,79,12,99,377,94,33,542,339,40,474,111,37,4,51,102,453,139,775,13,475,23,961,277,471,134,57,431,266,115,117 }, + { 658,698,340,98,296,303,1,31,850,363,156,919,44,774,586,385,120,77,82,10,223,30,354,291,23,914,478,87,260,163,48,13 }, + { 15,515,700,753,82,4,1,13,901,33,197,11,5,10,23,165,2,0,180,3,21,77,51,120,365,115,217,40,117,102,32,401 }, + { 15,515,700,753,4,11,5,13,1,141,3,180,23,202,21,2,269,64,165,33,40,32,0,318,120,128,12,197,117,352,51,17 }, + { 91,6,233,85,370,718,81,65,25,256,63,343,42,74,235,123,138,511,397,249,26,194,650,355,64,87,544,18,90,643,66,214 }, + { 23,13,202,51,21,120,1,5,141,128,450,64,318,403,15,137,260,33,12,48,32,31,125,494,269,102,165,515,77,2,197,14 }, + { 180,317,365,341,752,217,115,352,901,482,372,498,1,141,15,253,515,244,2,700,0,21,13,82,23,4,579,351,753,291,269,77 }, + { 13,115,197,341,9,352,468,237,64,498,23,165,22,509,901,546,482,180,28,569,317,51,365,873,391,95,86,217,49,837,752,706 }, + { 13,23,51,1,141,5,165,202,21,120,64,125,180,15,2,33,197,115,128,32,260,269,12,82,4,515,137,7,318,93,0,700 }, + { 214,289,90,174,874,6,138,280,65,81,64,85,355,751,194,233,312,348,835,91,0,32,343,636,249,29,875,288,519,104,247,74 }, + { 15,515,700,753,4,5,11,13,1,33,23,21,2,3,102,32,141,77,180,117,31,64,0,40,134,196,120,352,12,44,197,6 }, + { 33,15,13,515,117,23,700,217,134,753,0,51,153,77,141,2,4,64,196,1,3,180,10,115,5,102,6,11,22,202,165,7 }, + { 15,515,700,753,33,4,77,102,1,40,13,117,11,115,134,5,21,153,23,217,3,32,2,317,120,196,180,141,51,12,59,260 }, + { 15,515,700,753,13,0,1,23,2,217,51,3,4,5,8,317,115,9,341,10,202,180,6,365,7,82,457,22,120,901,33,291 }, + { 7,2,135,20,97,14,66,52,337,673,192,29,43,355,353,5,16,294,107,376,147,226,331,560,64,470,222,104,415,32,4,324 }, + { 195,132,142,167,146,77,363,271,121,354,202,120,647,178,786,212,687,0,101,878,16,522,60,5,450,411,35,55,98,639,259,318 }, + { 202,77,20,0,318,66,104,128,102,269,177,43,33,7,216,291,494,5,2,342,74,173,97,112,450,22,337,10,234,52,64,678 }, + { 107,362,612,356,359,97,414,43,259,20,392,7,298,147,819,683,465,173,729,660,319,14,5,779,581,595,246,35,501,92,0,230 }, + { 6,165,14,453,13,51,19,23,386,457,74,391,308,2,26,401,47,758,603,108,719,366,1,29,309,730,324,197,133,70,115,867 }, + { 179,72,205,180,247,245,4,490,352,59,317,152,79,498,94,217,148,76,752,864,11,216,141,405,89,452,197,111,497,188,37,21 }, + { 107,7,298,314,14,359,32,392,232,279,172,97,60,581,387,126,121,0,534,493,356,92,441,95,13,21,35,147,22,5,16,362 }, + { 156,271,354,586,360,132,591,195,121,18,340,1,5,13,21,48,668,446,23,463,296,658,60,55,407,698,146,70,626,51,163,24 }, + { 13,23,51,4,0,12,457,15,11,453,2,515,5,1,99,10,115,165,700,475,401,403,3,961,40,14,37,753,719,32,64,569 }, + { 48,125,21,165,13,221,23,763,423,508,197,5,98,92,193,16,441,386,64,314,293,457,391,140,49,60,102,693,683,51,35,867 }, + { 202,77,120,450,5,318,1,494,0,195,18,132,523,403,326,604,354,260,121,576,203,167,234,817,682,49,35,615,21,20,13,102 }, + { 39,9,166,30,0,101,158,68,404,190,333,274,252,310,88,100,49,28,344,35,21,22,419,131,438,1,16,65,530,694,124,10 }, + { 15,515,700,753,110,4,1,11,165,180,93,13,82,5,2,197,33,120,0,3,10,23,21,115,901,217,341,77,317,51,32,117 }, + { 2,29,1,14,6,52,5,46,50,26,70,19,103,58,38,67,96,262,516,309,218,133,108,27,75,17,112,114,24,487,331,83 }, + { 120,77,15,13,1,141,260,23,515,217,110,51,137,700,317,202,165,291,180,21,753,128,0,177,326,93,450,82,64,269,197,5 }, + { 255,59,554,297,183,56,33,444,108,358,123,196,269,122,77,153,57,177,117,730,19,467,605,130,128,50,275,4,291,475,134,133 }, + { 13,23,51,12,153,14,117,120,165,134,99,401,38,453,15,128,197,719,64,515,475,403,37,33,196,700,40,125,5,0,54,2 }, + { 64,33,174,348,95,108,467,554,56,0,25,306,233,6,63,511,343,120,13,85,29,561,543,707,319,180,899,355,77,49,256,18 }, + { 120,260,51,23,77,15,202,1,93,82,141,450,13,326,515,137,21,5,64,33,110,700,128,165,318,203,269,102,351,753,197,125 }, + { 15,515,700,753,4,13,11,1,5,21,23,2,33,64,3,180,32,141,22,102,77,0,10,93,82,352,117,40,341,31,165,6 }, + { 15,515,700,753,341,13,23,141,33,1,0,217,4,77,180,10,82,351,51,137,5,64,9,317,21,11,102,40,260,202,854,115 }, + { 105,272,131,22,327,286,28,239,320,9,109,578,219,49,98,224,95,159,538,371,616,127,187,64,713,55,0,170,168,258,716,623 }, + { 16,18,68,35,24,60,71,118,92,126,0,9,101,191,7,55,154,175,212,14,167,150,302,28,375,1,107,124,346,273,21,108 }, + { 20,147,43,470,376,142,904,178,427,798,0,595,198,325,858,319,61,202,173,97,5,422,14,22,107,259,32,49,887,77,414,392 }, + { 13,23,51,12,33,15,99,64,128,515,453,202,117,153,37,102,700,40,134,196,120,0,2,753,141,14,38,3,82,403,77,21 }, + { 383,17,62,136,84,119,56,440,3,504,240,80,378,129,123,548,106,128,4,11,14,555,162,32,184,361,59,64,205,5,469,57 }, + { 70,1,48,652,5,638,846,888,21,349,269,260,340,562,767,761,163,883,774,141,125,518,591,0,23,9,87,13,371,303,622,31 }, + { 66,135,6,97,74,278,69,7,14,324,267,172,2,140,462,1,357,38,808,550,92,841,189,29,16,25,298,87,75,204,24,335 }, + { 51,23,33,13,102,40,12,128,64,77,10,202,0,196,117,4,14,99,134,453,65,153,11,475,139,403,22,141,86,2,21,15 }, + { 88,100,264,166,274,435,772,1,382,921,96,478,30,438,639,909,897,521,190,466,960,410,9,144,530,418,31,329,265,691,778,93 }, + { 62,440,136,56,84,3,504,548,555,383,4,17,129,128,507,361,123,59,119,162,14,57,152,328,161,11,202,495,184,27,80,215 }, + { 911,617,332,959,206,141,253,244,282,384,110,120,10,260,352,143,951,811,269,373,160,417,93,531,728,203,434,940,137,55,36,717 }, + { 120,15,260,141,77,1,515,82,700,351,33,23,450,13,110,326,64,217,269,753,203,137,102,5,165,21,51,291,93,177,373,128 }, + { 15,515,700,753,0,1,2,23,13,51,5,9,82,901,180,8,3,4,120,6,7,141,93,12,197,341,10,33,115,730,64,125 }, + { 7,104,97,107,356,232,66,560,298,289,14,707,38,568,359,64,20,0,65,324,22,214,92,32,192,5,387,43,712,90,172,95 }, + { 6,1,2,66,67,14,74,24,108,29,69,83,458,7,25,38,135,103,36,150,451,114,52,594,75,65,380,18,267,602,19,278 }, + { 13,23,51,12,115,21,202,5,457,15,4,1,64,719,0,403,2,3,453,165,99,141,401,128,32,515,10,37,523,197,120,700 }, + { 57,59,4,11,412,381,77,53,421,291,250,368,99,14,27,369,803,283,23,108,403,19,339,210,0,401,12,444,236,40,361,736 }, + { 15,515,700,1,0,753,2,13,23,5,51,180,3,115,6,7,457,4,9,8,12,82,197,165,141,901,120,719,33,64,21,22 }, + { 64,95,180,247,929,146,90,126,197,32,237,60,288,165,316,92,5,13,77,7,217,955,522,22,16,314,132,4,317,10,312,86 }, + { 15,1,120,13,23,515,0,51,700,180,141,2,5,202,21,260,753,165,137,33,77,110,197,128,326,7,450,4,102,9,269,12 }, + { 14,2,16,46,1,7,24,69,75,35,38,50,29,220,52,140,267,67,18,54,70,309,5,60,92,189,171,87,71,163,58,0 }, + { 31,98,127,44,9,299,0,276,293,284,116,49,935,599,105,22,456,201,28,1,39,125,242,137,371,144,131,492,159,272,51,395 }, + { 6,27,151,53,573,445,297,113,26,73,436,19,491,250,396,315,45,112,145,58,614,881,25,34,611,200,17,80,70,5,138,631 }, + { 32,693,81,788,90,804,403,56,494,21,84,397,202,65,18,77,64,681,214,725,523,784,526,33,102,825,240,0,115,241,817,91 }, + { 24,7,14,2,18,16,65,0,108,149,28,69,1,71,154,36,124,35,67,140,189,429,92,68,66,22,55,118,302,150,9,6 }, + { 0,68,9,35,65,101,189,212,114,67,124,69,1,154,149,39,230,64,252,16,88,702,103,100,18,336,28,329,520,83,30,755 }, + { 5,2,186,29,61,45,17,1,52,48,58,171,155,227,80,209,311,21,14,46,50,106,243,513,334,502,496,38,3,6,32,592 }, + { 15,515,700,753,13,1,2,0,3,4,5,23,341,11,10,33,6,51,165,117,153,7,180,12,365,901,77,569,197,115,64,9 }, + { 13,15,23,515,0,51,1,700,4,2,753,10,3,5,12,77,33,961,165,457,197,11,115,9,22,102,40,403,202,21,14,59 }, + { 15,515,700,753,13,0,1,23,2,33,102,5,4,10,9,3,51,115,77,7,6,341,12,11,217,40,457,196,180,165,8,523 }, + { 166,39,30,274,190,100,333,438,530,310,88,252,0,9,539,265,1,656,404,101,625,131,778,254,31,455,676,329,724,158,21,23 }, + { 734,148,94,308,431,115,37,89,111,413,79,468,197,629,341,474,569,12,13,873,179,401,11,4,180,23,205,72,59,365,134,51 }, + { 539,228,224,219,816,190,30,258,871,840,669,93,406,530,957,187,160,531,748,137,131,88,863,36,728,839,44,213,352,116,202,466 }, + { 393,791,125,801,730,551,386,23,31,175,93,98,51,13,144,788,126,203,21,345,116,22,949,110,575,165,326,44,0,4,60,221 }, + { 13,23,77,141,0,4,51,2,33,115,64,1,10,3,6,15,11,102,7,217,180,40,515,22,128,177,202,9,700,269,165,5 }, + { 2,29,7,70,52,14,1,58,112,46,75,5,171,163,87,220,307,151,186,334,38,66,155,16,69,135,278,45,262,97,6,21 }, + { 88,321,213,100,230,435,689,466,1,382,30,352,217,699,410,96,795,36,921,752,190,141,144,180,44,831,317,83,443,31,840,251 }, + { 363,411,101,520,354,9,195,668,132,156,447,1,905,364,18,23,765,664,146,5,360,13,121,96,98,31,252,39,100,759,264,551 }, + { 13,23,51,730,12,719,453,457,401,475,5,21,403,2,0,1,15,4,3,899,99,32,165,11,515,308,197,115,6,961,700,523 }, + { 72,76,89,12,37,4,308,179,38,528,90,431,54,205,148,184,401,57,152,474,23,59,51,245,428,11,32,99,405,316,257,21 }, + { 376,20,43,147,470,173,97,595,107,319,414,142,819,5,729,178,858,7,427,32,426,104,14,0,392,362,259,61,230,77,560,246 }, + { 202,141,269,494,318,137,51,128,403,4,217,96,77,5,64,177,291,180,15,352,102,10,33,349,2,317,0,341,120,515,21,453 }, + { 77,202,33,128,102,318,494,269,13,0,117,23,342,291,403,15,134,51,153,141,177,515,82,137,196,700,203,64,22,351,753,4 }, + { 253,110,951,352,499,811,10,854,180,638,244,559,642,752,564,8,141,143,417,341,901,260,206,197,922,661,93,15,498,373,165,911 }, + { 141,13,23,180,4,217,5,1,269,317,21,0,2,202,115,51,352,77,3,197,64,341,318,15,291,9,137,93,32,165,515,33 }, + { 9,0,18,252,16,101,68,39,24,118,35,109,158,329,28,167,60,364,333,265,49,100,22,419,553,55,1,677,71,7,212,159 }, + { 28,109,9,39,0,158,49,22,168,35,55,175,1,65,67,185,194,159,289,95,272,114,30,105,86,584,36,169,254,2,83,24 }, + { 15,515,13,700,1,753,2,23,0,3,4,5,33,341,11,51,6,10,197,115,901,180,77,40,102,12,365,165,141,217,7,317 }, + { 173,693,104,422,5,18,61,32,102,0,20,13,784,560,33,66,397,526,49,207,29,25,510,707,65,6,11,344,21,263,81,77 }, + { 23,13,386,51,308,801,719,221,401,949,21,730,165,421,102,115,125,33,341,670,468,117,770,1,120,6,197,14,403,97,67,958 }, + { 0,49,105,16,28,24,159,9,158,320,1,68,35,239,170,18,109,7,55,65,2,95,301,124,347,14,21,154,22,127,286,31 }, + { 2,5,1,207,45,29,32,58,76,61,6,263,292,655,72,14,17,476,7,119,52,306,70,64,21,90,186,214,106,38,3,790 }, + { 21,6,125,49,13,64,715,66,115,95,197,33,22,32,204,165,56,278,0,408,241,120,4,808,681,350,263,85,81,571,135,509 }, + { 612,427,325,107,202,5,376,49,64,392,403,470,21,147,31,788,494,14,362,465,858,98,20,804,518,43,845,318,125,97,725,534 }, + { 32,21,76,72,2,1,14,5,241,449,89,38,350,221,155,48,50,292,37,46,45,90,270,54,17,179,214,12,148,430,476,413 }, + { 24,0,28,16,7,124,35,154,14,149,65,18,9,68,55,108,175,71,2,1,22,109,92,67,484,336,118,69,302,398,570,420 }, + { 1,5,14,2,48,50,38,67,46,21,0,54,45,270,281,12,24,32,155,96,513,103,290,83,61,58,36,17,37,72,69,181 }, + { 13,961,569,197,37,15,23,474,515,94,148,111,12,165,629,341,700,79,901,401,51,405,753,10,134,4,115,734,873,11,89,117 }, + { 33,23,102,51,13,40,77,128,64,202,141,15,4,12,0,1,2,117,22,11,10,403,153,515,99,318,137,269,139,196,700,134 }, + { 0,1,24,67,9,16,18,35,28,69,103,50,5,2,65,12,83,68,7,96,14,22,21,149,75,114,13,133,23,71,218,54 }, + { 384,617,940,332,855,911,206,959,434,282,141,10,93,253,244,110,144,268,120,36,352,137,417,203,116,31,44,269,160,201,143,951 }, + { 30,93,473,137,31,704,450,652,190,203,800,254,166,274,326,144,269,160,127,303,120,625,88,848,110,435,77,521,349,131,340,744 }, + { 53,27,73,26,19,250,297,200,25,630,17,6,611,122,34,42,714,235,472,65,436,14,80,684,690,106,45,113,680,108,64,4 }, + { 15,515,1,2,700,0,753,3,5,141,180,4,13,77,33,10,217,6,7,134,11,352,197,64,165,341,317,23,12,115,102,40 }, + { 254,530,39,613,688,221,30,31,438,190,228,960,1,44,141,21,180,406,23,166,9,202,13,96,137,48,131,829,317,269,393,51 }, + { 9,39,28,35,30,166,158,36,0,175,101,346,364,67,49,68,168,420,88,1,194,131,100,352,55,83,190,64,137,570,86,65 }, + { 62,56,3,548,555,507,440,161,34,4,215,136,162,514,361,527,17,14,211,130,328,11,383,123,84,183,38,57,184,152,205,494 }, + { 92,126,107,7,356,493,97,279,359,298,16,246,35,60,14,441,362,121,43,423,5,132,392,20,508,230,199,146,232,173,150,414 }, + { 15,82,141,515,291,922,349,700,217,260,372,120,351,93,77,753,318,352,373,854,1,326,269,21,13,102,144,202,64,23,203,137 }, + { 141,217,352,115,180,13,269,317,752,77,23,21,341,197,5,372,244,291,9,64,51,102,4,1,365,2,165,33,3,48,237,351 }, + { 78,47,390,19,130,453,108,27,711,813,730,444,412,283,196,690,123,14,128,26,250,389,650,236,200,65,51,4,34,183,297,73 }, + { 34,250,297,80,472,64,495,17,311,3,148,45,667,61,176,53,243,27,90,161,469,141,483,151,62,128,29,4,58,56,5,231 }, + { 51,23,33,13,551,77,102,326,421,21,523,120,5,899,453,692,202,153,308,615,115,958,450,401,791,68,221,93,475,18,403,4 }, + { 98,223,393,363,411,1,478,834,664,156,284,691,447,791,914,293,354,724,697,9,807,541,759,51,18,421,48,264,948,586,195,848 }, + { 7,14,107,232,16,92,2,60,46,5,359,121,24,526,220,620,135,1,172,21,126,314,132,77,18,75,32,278,12,23,52,38 }, + { 32,76,2,1,21,72,241,14,5,48,292,89,476,45,720,270,179,90,17,214,148,38,50,29,129,155,350,46,290,227,123,464 }, + { 15,515,700,753,13,23,33,77,51,4,102,0,32,202,1,11,128,82,117,141,40,5,110,8,3,90,137,21,10,318,403,165 }, + { 66,6,69,2,1,74,14,135,278,267,380,24,29,97,67,38,103,75,7,388,324,25,52,150,87,83,189,357,335,108,204,172 }, + { 152,4,339,59,79,471,188,11,77,94,128,33,529,377,12,111,102,202,452,402,216,99,13,542,51,40,474,37,64,291,23,961 }, + { 15,515,700,753,1,0,196,13,33,2,77,5,23,102,3,10,9,7,217,4,6,153,117,177,14,457,115,12,40,730,11,134 }, + { 17,209,45,106,207,5,255,119,62,2,61,3,263,742,306,655,425,378,32,56,29,136,84,80,311,58,186,240,243,383,14,21 }, + { 120,260,450,15,1,23,817,13,515,523,326,5,700,51,82,31,202,64,21,753,318,93,32,269,98,33,351,77,102,125,457,165 }, + { 116,492,268,93,23,206,203,0,551,918,13,51,8,22,417,940,120,10,499,31,949,791,125,523,165,473,341,730,421,959,401,391 }, + { 15,515,700,753,165,13,0,1,197,23,4,82,120,2,180,12,260,719,8,3,386,117,5,523,901,11,341,51,10,9,141,351 }, + { 14,24,69,7,2,66,108,1,67,6,36,398,18,267,150,97,29,38,83,149,65,74,28,0,189,71,388,16,273,124,46,22 }, + { 330,96,523,335,367,662,141,839,1,922,372,615,244,717,269,443,418,352,403,692,217,854,752,180,36,64,498,576,349,201,98,284 }, + { 184,90,257,205,245,229,57,152,769,17,524,5,32,497,45,432,619,2,452,266,4,106,1,21,179,59,76,3,460,292,381,128 }, + { 7,14,16,2,46,5,70,107,87,13,58,307,92,32,38,23,202,0,172,24,18,21,60,128,77,35,20,10,9,4,171,112 }, + { 7,66,140,16,14,92,97,69,267,172,189,24,380,2,35,60,298,451,230,135,314,74,150,71,38,357,6,330,67,423,21,443 }, + { 121,167,354,132,18,446,147,101,212,146,407,16,55,35,647,191,20,271,199,68,60,259,463,107,9,126,363,7,195,43,14,411 }, + { 76,90,179,32,205,21,184,460,257,288,45,245,316,5,57,152,241,2,358,1,229,72,524,148,48,769,17,4,12,38,14,720 }, + { 147,259,178,878,427,465,581,198,786,798,142,534,325,929,20,362,35,132,107,376,43,5,279,77,49,146,70,202,590,771,33,14 }, + { 473,93,450,778,141,30,855,466,144,203,330,530,88,523,459,372,201,617,839,704,254,321,934,326,39,36,82,717,332,213,559,403 }, + { 523,475,51,899,730,453,23,719,403,33,457,13,421,386,4,120,117,196,102,153,15,801,450,817,515,260,202,11,700,99,165,125 }, + { 15,1,13,515,0,2,700,5,23,753,4,3,341,317,10,115,180,11,33,64,217,77,117,165,197,7,6,365,9,141,102,134 }, + { 19,4,119,40,33,202,27,84,102,56,77,73,504,485,26,494,757,63,862,59,23,300,25,12,128,11,5,13,342,880,469,6 }, + { 32,20,2,13,5,21,23,6,12,38,43,29,64,7,95,51,61,207,48,147,90,178,17,182,49,0,115,202,52,362,37,22 }, + { 339,188,11,79,4,94,377,12,99,111,542,102,37,33,474,51,471,40,453,152,77,13,59,403,342,23,117,57,475,134,128,38 }, + { 34,128,283,176,495,231,318,432,503,275,529,527,161,53,3,202,56,291,585,469,73,17,14,412,57,27,80,245,250,381,402,51 }, + { 15,515,13,700,1,217,141,120,23,180,753,115,365,51,317,341,77,260,0,291,110,137,202,5,21,269,64,36,349,2,4,10 }, + { 13,15,961,515,700,753,4,12,2,457,3,11,197,51,37,569,115,23,5,0,99,10,1,134,6,111,165,33,72,40,38,79 }, + { 15,515,700,753,13,1,0,2,23,33,5,3,10,4,9,115,7,102,6,51,12,217,77,11,40,457,569,341,117,317,14,719 }, + { 5,76,2,32,292,214,45,1,129,519,123,179,90,710,17,29,460,72,14,207,21,249,58,205,464,263,618,48,6,245,3,257 }, + { 72,76,32,4,21,12,38,23,99,54,89,3,14,17,51,57,11,90,13,488,179,2,59,148,45,37,5,115,401,1,10,421 }, + { 98,223,393,1,834,264,284,791,724,293,478,772,697,909,363,682,905,447,541,821,411,51,421,9,807,48,765,31,730,96,386,410 }, + { 341,13,509,8,23,638,165,901,762,10,569,242,391,197,873,642,506,499,629,961,15,180,116,456,206,546,417,1,338,457,515,867 }, + { 1,2,5,50,14,38,46,114,0,36,29,22,218,65,86,96,137,21,133,285,12,10,323,181,17,58,51,23,67,7,28,6 }, + { 481,878,202,13,5,23,182,32,269,21,1,318,77,142,557,494,141,33,640,137,70,291,2,51,260,415,929,403,120,58,4,259 }, + { 15,515,700,753,1,4,13,0,2,5,341,3,11,180,134,12,10,317,197,365,33,21,23,165,117,6,77,7,217,37,32,498 }, + { 25,119,19,6,26,42,27,17,4,790,45,814,2,469,483,84,122,1,0,33,32,128,76,80,611,113,73,56,5,240,202,77 }, + { 14,2,7,1,24,0,65,6,16,69,67,22,124,28,108,5,18,36,86,10,38,46,66,398,289,168,12,83,21,23,610,13 }, + { 51,23,128,13,15,202,12,120,33,64,141,82,10,515,0,403,700,3,1,99,117,269,153,165,753,5,318,197,102,260,2,137 }, + { 16,35,24,0,9,18,7,1,68,69,50,71,103,65,67,189,133,23,28,13,60,537,149,335,75,21,64,5,114,2,12,14 }, + { 754,803,133,576,880,543,2,1,657,50,14,38,46,5,29,67,218,36,58,171,52,96,24,103,775,0,114,83,181,54,65,45 }, + { 21,32,5,3,2,17,14,72,76,1,12,23,38,51,4,54,10,0,89,13,99,137,45,36,421,115,543,11,22,128,221,48 }, + { 434,384,268,144,855,940,617,206,332,116,93,911,959,282,203,137,141,489,44,120,10,110,244,36,98,31,269,253,367,417,160,9 }, + { 15,2,1,0,13,515,5,700,3,23,180,217,141,10,753,4,117,6,77,33,64,7,11,197,352,317,341,134,165,115,12,9 }, + { 2,113,6,25,1,0,29,4,7,833,5,45,32,61,128,19,77,151,74,145,64,42,14,210,655,106,59,177,27,17,21,738 }, + { 116,268,918,203,551,31,8,692,206,791,403,499,417,93,940,421,0,23,22,120,13,523,44,51,299,473,959,1,10,475,202,125 }, + { 107,126,132,612,362,279,20,146,259,493,199,121,590,43,660,147,35,376,939,60,941,534,683,5,0,953,16,7,49,649,595,470 }, + { 15,515,700,753,13,1,0,23,2,33,77,4,3,51,5,102,115,10,9,341,6,7,11,342,217,12,120,180,40,317,141,8 }, + { 53,27,17,161,469,378,73,527,19,136,383,250,495,56,862,26,62,84,80,106,200,4,34,14,440,297,3,128,585,5,129,123 }, + { 17,45,209,106,5,207,243,454,119,255,2,263,186,290,29,3,21,62,425,61,84,32,58,56,48,408,655,136,306,14,742,227 }, + { 4,152,59,452,128,79,216,11,339,471,529,188,94,77,202,12,291,33,318,377,99,51,23,5,402,349,32,474,102,13,205,111 }, + { 15,515,700,753,1,0,2,13,3,5,23,4,180,51,115,9,6,12,7,8,197,33,10,961,901,77,141,752,110,22,120,341 }, + { 951,752,638,811,351,642,180,253,10,341,197,901,110,873,8,244,15,352,165,898,143,515,564,762,499,55,365,700,82,753,141,854 }, + { 6,262,197,350,74,26,115,509,841,583,165,38,21,13,47,50,235,19,33,324,453,4,308,196,138,99,64,903,675,1,223,130 }, + { 125,165,391,23,386,221,21,13,558,457,51,867,197,115,401,758,77,97,308,791,7,180,48,120,963,451,743,89,603,134,403,450 }, + { 1,14,2,5,16,46,7,38,58,24,50,0,69,48,35,67,54,18,12,75,21,45,513,155,430,37,270,9,61,163,223,32 }, + { 23,13,51,0,12,15,4,1,115,2,515,453,10,457,5,3,202,21,165,700,403,11,37,64,77,401,9,197,753,59,475,99 }, + { 129,84,17,56,27,495,19,548,80,123,162,378,3,504,161,469,618,73,40,53,4,26,205,184,106,183,62,6,257,128,862,12 }, + { 28,9,22,49,109,1,67,0,39,55,168,158,83,36,35,86,420,194,185,159,95,105,69,208,272,103,50,114,2,254,169,30 }, + { 242,391,8,456,116,13,23,492,341,165,867,51,499,457,479,638,338,509,719,10,1,642,417,762,401,93,206,268,901,569,22,197 }, + { 211,162,248,130,57,4,41,556,507,266,183,152,305,361,11,129,62,229,38,471,514,313,157,300,377,3,440,128,123,328,339,59 }, + { 7,92,97,16,298,140,60,126,14,35,279,314,232,246,43,230,508,173,71,107,423,24,150,779,20,189,66,18,607,21,0,653 }, + { 15,515,700,753,1,0,2,13,23,5,3,180,51,901,6,4,7,12,9,115,8,457,165,82,120,197,10,64,141,341,22,117 }, + { 0,18,403,25,523,74,6,24,42,91,22,102,13,51,49,193,475,681,95,85,730,64,899,397,273,750,247,673,32,805,757,288 }, + { 56,0,18,65,33,554,84,343,64,6,90,561,22,19,899,108,27,63,289,475,240,467,370,32,233,214,24,123,95,287,28,194 }, + { 31,98,127,9,0,44,293,105,395,299,49,242,28,22,599,116,1,284,276,125,456,685,763,159,272,623,23,935,393,144,201,137 }, + { 1,5,2,14,38,46,50,48,21,7,58,45,270,61,155,171,0,290,69,32,29,54,67,16,24,666,663,17,37,75,502,52 }, + { 23,51,13,453,457,12,719,4,15,99,401,2,961,3,11,730,475,515,0,1,165,115,629,700,14,17,403,40,5,33,37,64 }, + { 968,967,966,965,964,963,962,961,960,959,958,957,956,955,954,953,952,951,950,949,948,947,946,945,944,943,942,941,940,939,938,937 }, + { 2,1,14,29,67,103,6,46,52,75,24,133,38,218,83,309,36,108,70,114,96,5,238,74,25,26,220,236,65,50,69,87 }, + { 7,71,16,92,24,60,14,97,150,140,35,189,149,298,18,230,43,508,2,423,69,0,38,314,66,279,399,517,251,20,232,273 }, + { 23,1,120,51,13,202,77,141,260,21,15,5,128,82,2,450,269,165,102,318,48,32,137,515,125,64,12,115,351,180,33,7 }, + { 77,13,33,23,64,51,4,102,141,128,40,1,2,202,0,6,177,115,137,15,59,10,11,7,269,22,515,180,318,3,700,95 }, + { 101,9,18,363,264,520,411,604,676,682,905,271,16,821,167,0,621,364,39,100,121,118,166,781,647,252,1,848,447,265,404,60 }, + { 144,203,326,382,166,418,93,88,96,822,1,141,859,77,744,438,110,269,921,367,521,274,100,39,494,120,403,473,217,576,13,291 }, + { 13,21,180,125,5,23,191,32,18,16,146,199,115,24,165,118,0,225,22,1,60,197,64,901,375,241,48,12,408,71,522,818 }, + { 15,515,700,753,13,0,23,8,1,51,82,102,2,33,4,9,180,165,5,77,10,110,12,197,120,260,18,326,351,403,22,457 }, + { 33,77,102,64,13,23,128,51,141,202,1,40,0,2,117,10,15,4,6,318,269,134,22,515,180,115,177,153,137,196,3,700 }, + { 174,544,104,525,74,0,151,25,6,624,29,66,2,636,81,45,204,177,64,416,7,644,5,138,222,319,355,77,22,122,789,216 }, + { 141,304,372,352,291,947,177,269,128,954,77,349,217,202,64,318,498,437,102,864,86,13,115,180,137,5,210,197,32,950,678,7 }, + { 161,200,53,17,714,27,34,73,472,62,585,56,440,383,136,78,527,19,4,3,106,361,14,250,80,514,377,84,322,390,862,548 }, + { 32,76,72,21,38,14,89,54,12,37,2,241,5,428,17,1,181,221,350,45,3,4,449,90,148,179,99,292,794,770,477,46 }, + { 33,23,128,64,141,13,77,51,102,202,2,15,1,3,40,10,5,153,269,515,165,0,117,196,180,318,6,700,137,134,120,22 }, + { 96,137,30,0,9,39,840,202,669,406,141,530,613,1,180,88,22,160,679,576,28,403,31,219,49,228,829,100,36,15,10,856 }, + { 180,141,352,1,15,752,115,0,217,365,2,515,13,901,341,317,23,4,197,700,269,5,3,31,753,244,21,165,253,202,51,44 }, + { 1,2,67,0,28,50,83,65,14,46,103,114,24,38,36,9,69,5,18,7,22,133,55,218,16,124,29,54,96,160,12,480 }, + { 180,115,352,317,365,217,752,901,141,15,341,1,515,253,700,0,753,873,2,197,31,137,165,244,4,120,160,44,98,5,202,3 }, + { 5,32,347,49,13,21,95,713,23,1,77,33,60,64,107,4,126,928,296,850,0,241,197,102,652,195,180,534,165,153,379,10 }, + { 341,180,365,901,317,115,15,752,515,700,217,873,753,82,0,110,197,141,951,165,1,564,13,351,253,12,10,3,2,4,308,244 }, + { 17,45,21,3,106,5,155,38,227,32,2,209,62,54,12,243,14,181,552,587,46,540,207,794,37,48,430,119,255,221,770,29 }, + { 16,24,35,18,7,0,50,1,9,14,75,69,2,5,12,21,60,13,67,71,23,48,10,108,223,181,189,103,46,64,92,51 }, + { 127,13,98,165,308,23,286,293,258,51,219,395,197,115,301,401,31,391,22,105,457,170,239,276,55,338,629,116,180,479,509,569 }, + { 539,213,748,840,957,669,30,466,88,217,144,251,863,190,137,93,230,228,679,352,317,203,617,321,258,530,160,219,96,831,816,689 }, + { 5,48,1,21,2,14,0,36,12,38,32,54,430,181,50,270,72,99,281,45,17,10,46,22,37,218,67,3,290,76,23,51 }, + { 13,23,0,4,33,51,2,115,141,1,77,217,180,10,9,317,3,102,11,5,15,197,7,202,22,165,40,64,515,6,341,31 }, + { 13,15,117,515,23,12,37,134,165,700,38,54,457,753,51,64,153,197,14,10,33,82,961,0,99,89,115,719,141,3,4,1 }, + { 5,21,2,3,1,32,14,12,48,17,0,10,51,23,38,22,4,72,13,54,36,45,137,76,99,114,86,37,11,64,540,430 }, + { 202,128,77,318,291,33,269,102,275,141,494,342,40,678,0,177,20,210,402,7,4,5,137,6,13,450,403,32,49,120,23,22 }, + { 1,2,24,14,67,46,69,50,38,103,16,18,75,35,83,29,52,96,5,108,0,7,54,71,149,394,236,309,70,133,220,58 }, + { 15,515,1,700,0,2,753,13,23,5,180,3,51,4,165,457,12,197,115,6,7,21,9,141,8,901,33,82,120,77,10,110 }, + { 0,28,65,14,67,2,124,24,1,9,7,69,55,154,36,16,46,114,175,35,83,22,429,18,109,149,68,189,108,336,251,133 }, + { 56,162,403,3,129,775,99,161,17,40,527,33,880,4,14,128,475,12,548,23,102,202,361,117,34,184,383,200,183,196,64,53 }, + { 151,2,29,58,112,45,186,113,5,70,52,1,311,6,315,66,61,7,74,27,631,17,80,87,287,243,209,227,14,491,19,869 }, + { 6,1,74,2,75,29,25,66,26,70,52,138,67,324,357,42,19,220,14,85,87,108,38,451,309,103,24,69,380,135,114,65 }, + { 15,515,700,13,23,0,1,120,753,51,180,2,260,202,5,141,77,102,9,450,115,21,197,165,7,137,110,33,12,269,901,4 }, + { 5,45,17,2,14,46,48,38,181,50,155,3,186,54,61,29,21,227,281,80,540,106,12,400,52,1,58,32,328,171,209,487 }, + { 16,18,265,121,158,35,60,9,39,7,329,105,252,68,24,1,132,167,159,22,0,49,286,101,21,146,23,327,120,709,5,14 }, + { 108,467,283,56,389,650,123,412,33,177,899,475,216,453,269,349,619,65,51,730,403,670,23,196,523,128,84,13,401,789,503,543 }, + { 514,3,11,377,328,4,361,507,57,403,14,880,130,485,176,215,236,38,152,102,211,56,62,757,54,585,300,556,34,555,40,229 }, + { 3,555,62,266,130,99,507,139,514,12,152,229,215,305,57,40,440,33,403,471,38,56,475,14,361,313,775,328,196,548,123,23 }, + { 120,202,318,15,77,13,1,450,33,269,515,260,5,128,494,51,23,700,102,141,40,753,326,403,817,137,523,21,177,922,342,7 }, + { 15,1,515,23,0,13,700,2,51,753,180,5,165,21,197,12,3,120,115,4,141,6,9,7,457,33,386,202,82,8,31,341 }, + { 15,180,515,82,351,700,10,317,753,115,217,365,141,898,33,901,13,23,110,854,752,77,1,197,4,341,143,36,64,352,102,9 }, + { 104,289,66,707,214,90,712,64,97,173,20,0,414,194,874,43,32,7,568,560,65,38,426,312,715,192,376,74,835,5,324,147 }, + { 84,56,0,554,63,65,453,249,123,643,18,26,847,475,511,403,416,561,524,289,370,73,9,19,45,42,719,194,27,467,33,730 }, + { 21,346,13,350,308,826,197,101,352,68,570,0,165,23,9,841,115,100,509,694,221,230,35,217,569,88,124,749,1,777,212,154 }, + { 16,92,7,24,60,18,35,140,126,14,50,71,46,330,2,75,246,5,121,267,571,1,230,309,220,0,9,64,146,236,54,108 }, + { 82,15,515,898,365,700,180,33,341,753,77,901,10,115,55,351,21,5,1,4,13,102,36,217,2,165,752,120,197,117,11,317 }, + { 16,24,35,18,69,71,140,1,103,7,189,68,0,50,9,108,2,133,60,267,230,46,149,67,167,118,92,14,75,21,191,38 }, + { 60,71,16,18,7,20,43,118,35,68,375,28,608,0,175,566,154,92,14,149,628,33,22,13,2,10,279,23,107,356,55,117 }, + { 187,258,871,295,201,434,219,224,489,384,268,110,261,839,44,699,93,116,36,131,141,228,144,160,940,567,244,406,137,574,98,253 }, + { 66,7,97,172,192,712,232,324,204,74,43,448,387,426,568,20,526,107,104,135,356,729,173,0,22,5,32,95,2,64,500,560 }, + { 15,515,700,753,1,4,0,341,13,3,134,2,5,33,11,77,12,10,23,197,365,901,7,40,217,32,21,6,51,180,961,37 }, + { 0,28,24,9,35,65,16,124,68,55,109,154,7,39,22,149,158,14,175,1,49,252,18,71,2,168,289,419,108,420,67,101 }, + { 7,16,14,92,2,46,140,24,220,35,38,60,75,1,50,18,87,54,5,126,29,52,278,262,314,107,71,21,172,135,330,394 }, + { 7,92,16,14,172,126,2,60,140,35,135,314,278,46,24,38,232,107,330,66,5,18,150,246,230,97,52,1,121,563,279,21 }, + { 6,26,235,53,297,436,27,19,25,73,113,445,90,214,65,42,64,289,250,611,624,32,45,648,614,17,85,491,34,122,200,416 }, + { 352,141,1,217,854,752,351,180,244,36,110,661,82,258,816,160,295,219,567,224,230,269,922,144,260,268,93,201,137,116,489,202 }, + { 16,60,35,18,126,107,68,191,92,121,7,14,598,20,493,279,167,446,118,0,28,43,463,55,24,212,375,566,9,150,575,21 }, + { 15,1,515,2,4,13,0,700,3,5,23,753,341,77,51,115,33,11,180,10,197,141,6,165,7,901,102,40,9,202,217,12 }, + { 23,51,13,202,21,5,1,120,15,137,128,125,32,2,12,141,33,165,64,515,403,318,700,48,180,7,6,450,115,523,475,260 }, + { 131,716,224,371,219,187,737,616,385,254,9,98,105,924,31,258,836,39,127,578,49,916,44,761,272,137,944,159,0,242,442,22 }, + { 15,515,700,1,753,2,5,0,4,13,3,180,11,141,197,10,341,217,33,134,165,6,77,7,317,12,352,64,365,32,102,40 }, + { 66,74,7,173,174,29,192,2,222,20,226,43,353,52,712,6,0,138,500,204,97,145,64,104,426,673,355,90,25,5,65,87 }, + { 5,259,786,534,590,493,279,49,13,581,465,21,929,35,941,132,147,32,23,612,362,626,107,121,178,0,146,61,48,939,10,18 }, + { 2,14,16,7,278,69,135,140,46,24,267,35,92,38,1,189,29,52,309,60,66,75,71,172,74,357,18,87,67,6,230,5 }, + { 165,13,308,197,391,23,401,15,51,457,180,509,115,569,3,629,961,719,34,758,317,734,14,29,46,2,17,901,38,453,5,217 }, + { 1,22,2,14,0,28,7,168,67,49,65,24,36,95,5,105,55,35,12,46,69,16,114,159,194,50,10,9,158,83,164,109 }, + { 34,453,3,196,130,14,322,11,47,51,377,236,361,4,730,153,514,711,57,440,62,17,161,108,176,59,485,56,162,412,202,117 }, + { 18,16,21,23,48,13,24,35,121,5,156,60,51,1,7,132,141,221,163,115,0,271,447,340,363,202,125,71,2,781,22,698 }, + { 165,13,457,23,197,961,629,569,341,41,12,38,401,901,54,51,115,17,15,509,421,37,62,45,719,57,32,328,117,758,157,99 }, + { 2,1,77,141,33,64,3,102,0,23,13,5,128,10,6,15,180,202,269,40,51,515,7,165,137,117,318,4,700,153,197,352 }, + { 68,212,0,124,101,9,154,16,562,191,21,149,65,24,35,1,118,167,818,350,520,100,722,841,264,71,13,302,478,23,375,346 }, + { 98,23,48,598,13,293,541,21,125,121,51,807,0,31,35,259,126,7,386,1,223,783,10,107,199,20,221,144,342,963,49,64 }, + { 21,13,5,586,1,23,167,48,33,781,647,49,165,18,51,271,77,32,761,118,0,82,391,22,146,141,459,31,197,156,115,4 }, + { 2,1,5,61,29,7,58,45,14,6,425,32,70,52,290,738,207,21,72,112,66,76,655,17,186,46,64,263,38,0,128,87 }, + { 39,265,9,100,1,333,363,101,18,411,447,254,166,310,31,98,264,30,639,404,156,286,16,93,593,203,272,682,0,905,44,821 }, + { 6,2,1,19,29,51,26,108,25,74,5,23,14,114,13,386,133,103,42,66,453,70,309,138,719,324,65,38,64,96,52,75 }, + { 20,43,356,107,49,858,595,7,414,359,0,5,392,319,97,612,422,819,14,376,173,246,22,470,147,427,230,92,197,33,683,95 }, + { 0,9,68,35,65,67,114,101,28,1,124,175,336,69,154,103,83,24,189,133,39,16,50,7,2,149,55,251,18,345,230,36 }, + { 23,13,51,15,0,1,515,115,165,2,5,12,700,202,4,21,141,457,753,197,10,3,180,120,32,9,318,11,453,64,6,269 }, + { 121,195,60,16,126,107,98,271,146,407,132,35,1,167,199,223,493,191,279,20,18,5,43,7,21,92,48,393,0,362,212,467 }, + { 31,44,299,116,393,144,492,456,268,22,105,0,367,918,384,434,127,489,98,9,963,125,242,948,1,28,206,49,36,51,93,293 }, + { 23,13,457,51,165,401,719,758,197,453,961,629,308,14,15,12,730,3,386,569,391,29,739,515,34,828,832,901,115,514,670,341 }, + { 105,36,131,22,180,115,341,127,169,1,9,31,64,98,44,365,317,141,272,143,160,55,219,86,197,776,239,187,0,535,13,752 }, + { 1,6,2,14,66,25,29,5,108,67,65,114,19,38,26,52,74,7,24,18,69,86,36,388,64,51,17,83,23,46,42,75 }, + { 51,386,23,453,719,13,730,6,457,670,758,19,401,165,2,475,47,26,899,14,108,17,1,5,197,29,894,754,236,74,27,285 }, + { 252,18,9,101,121,16,132,0,419,167,364,60,604,35,265,363,146,271,39,158,68,109,28,329,848,24,647,907,682,159,212,55 }, + { 283,503,128,432,26,193,63,269,789,529,102,122,389,275,678,6,25,318,445,4,342,27,573,605,177,862,643,291,216,57,235,59 }, + { 2,1,29,75,69,52,14,6,46,74,87,7,220,226,278,38,135,66,267,70,16,262,25,24,380,324,357,140,67,394,97,222 }, + { 97,298,69,7,66,140,189,24,16,267,172,423,60,150,14,314,92,71,81,501,43,35,74,6,517,232,149,607,83,330,18,2 }, + { 475,421,403,899,51,805,523,958,453,817,23,615,401,801,120,326,202,670,494,730,450,386,115,629,260,576,77,365,569,0,165,13 }, + { 7,20,14,128,77,97,112,202,2,177,16,415,269,318,275,66,107,43,141,414,135,38,307,10,58,0,6,291,32,5,4,40 }, + { 24,14,7,0,2,1,22,28,16,65,168,124,35,67,108,109,18,49,10,149,69,158,5,95,289,12,55,6,36,71,46,21 }, + { 26,80,27,73,122,25,19,17,6,42,684,209,445,573,667,106,45,690,4,611,255,680,297,495,65,59,128,119,483,113,64,53 }, + { 107,259,362,376,465,20,470,147,595,534,612,683,660,43,5,49,581,0,858,35,427,246,97,786,178,356,14,21,142,878,7,279 }, + { 131,30,228,190,856,406,224,88,219,530,863,613,778,274,944,816,187,39,100,160,258,31,44,93,1,321,539,36,871,137,435,531 }, + { 113,6,311,25,45,491,80,611,27,26,209,667,17,73,122,42,684,396,19,85,106,5,614,4,2,255,151,29,1,64,648,61 }, + { 15,515,700,753,0,1,23,51,120,2,13,82,5,260,9,4,341,77,180,115,141,10,7,12,450,8,202,901,197,351,165,93 }, + { 219,127,98,258,395,421,924,293,242,201,697,105,276,51,308,23,453,272,401,944,512,137,13,31,284,567,386,365,116,131,964,125 }, + { 15,180,352,141,515,752,217,82,1,317,854,700,351,753,115,341,110,13,260,120,21,36,33,898,23,10,5,365,4,160,901,137 }, + { 129,123,17,257,162,184,205,249,183,769,5,80,3,4,229,130,119,45,90,99,618,106,57,497,12,128,2,84,59,152,27,40 }, + { 33,102,23,77,64,128,51,13,0,202,10,141,40,15,1,22,117,137,2,86,4,403,269,153,515,196,65,11,700,115,99,5 }, + { 7,14,2,16,172,107,46,92,5,135,35,202,294,87,38,232,29,97,20,21,24,1,60,220,66,43,12,0,126,52,54,70 }, + { 403,576,615,523,475,326,805,817,494,421,51,202,120,450,137,453,23,859,260,401,402,77,33,670,0,958,15,197,386,515,165,480 }, + { 141,352,217,137,0,180,202,349,9,269,23,51,115,291,77,372,13,317,120,752,365,351,93,22,2,341,64,10,82,854,28,18 }, + { 1,23,13,51,202,141,5,165,21,15,120,180,64,2,197,125,33,102,12,7,137,515,48,128,269,318,93,700,0,403,9,4 }, + { 25,151,6,145,122,29,174,45,113,74,4,665,42,138,2,614,416,287,19,348,746,0,66,26,1,7,64,243,311,396,81,624 }, + { 30,190,254,166,100,382,731,829,88,131,264,795,9,93,625,274,438,1,578,613,716,31,44,39,530,36,616,921,265,203,160,77 }, + { 132,5,21,13,1,23,32,195,379,687,156,121,626,296,48,70,850,146,51,82,883,771,35,49,652,407,60,4,260,0,845,33 }, + { 9,254,0,49,272,131,39,159,688,101,105,578,518,158,286,28,327,333,68,224,252,219,344,16,22,1,716,31,30,228,24,890 }, + { 16,7,35,60,18,20,14,68,9,0,28,118,43,92,126,55,107,2,101,154,24,71,5,202,121,109,22,252,21,97,1,621 }, + { 15,515,700,753,13,1,341,2,0,4,3,5,11,23,10,33,117,12,901,197,6,134,77,8,165,317,21,365,217,7,17,40 }, + { 78,19,444,47,26,390,27,453,130,813,108,730,711,65,412,122,51,680,113,235,690,196,630,283,128,236,14,64,73,53,200,445 }, + { 2,7,29,5,61,6,45,1,66,113,112,14,52,315,738,128,32,151,74,16,20,64,70,21,592,0,25,4,425,43,491,222 }, + { 145,112,74,66,6,29,26,70,19,396,25,87,2,287,135,151,138,222,5,226,42,122,7,307,1,644,45,58,113,651,635,632 }, + { 92,16,7,60,126,24,140,35,14,232,18,121,246,71,46,267,172,150,107,314,132,146,230,2,278,108,330,199,236,5,38,572 }, + { 13,115,197,538,569,341,98,55,165,127,365,762,219,286,844,23,170,206,734,638,535,901,169,253,629,0,873,509,180,10,332,258 }, + { 58,151,74,53,287,27,29,396,6,70,2,73,5,52,112,26,651,1,297,113,17,75,19,45,334,445,145,34,315,549,436,331 }, + { 214,289,90,874,104,751,64,65,312,835,204,249,750,194,74,81,875,32,519,288,348,0,174,247,636,715,138,192,784,6,524,280 }, + { 9,39,28,35,30,0,166,49,1,175,439,158,64,346,36,101,67,364,86,88,274,100,168,55,23,10,420,22,190,141,505,180 }, + { 341,901,15,515,700,753,1,365,10,0,569,180,2,197,115,31,165,3,5,4,44,22,317,13,9,951,23,253,116,143,762,93 }, + { 120,202,77,450,260,15,128,318,102,515,494,13,817,700,269,5,403,51,1,33,23,753,82,326,141,342,291,137,21,523,351,32 }, + { 13,115,241,64,180,32,125,197,165,4,118,22,21,23,16,247,237,28,225,191,95,141,167,5,0,341,288,35,459,18,177,24 }, + { 16,24,35,14,1,2,7,69,18,46,60,50,267,140,71,189,108,38,75,92,0,5,9,230,67,21,309,335,54,236,394,220 }, + { 15,515,700,753,898,180,901,341,197,638,10,165,33,1,115,4,77,365,317,13,102,217,117,0,5,2,253,3,82,569,21,752 }, + { 193,523,18,84,56,730,233,65,4,817,90,33,643,403,91,511,453,240,59,11,214,51,719,196,153,475,32,123,64,847,102,561 }, + { 112,29,151,2,74,6,66,7,222,145,287,45,5,624,52,25,113,416,58,122,19,70,186,204,4,87,644,549,337,884,32,0 }, + { 13,0,23,2,1,15,33,3,77,515,141,5,4,217,10,51,64,180,700,115,6,117,11,7,753,40,102,165,197,22,317,153 }, + { 28,0,1,67,65,9,2,114,83,69,103,50,36,22,55,24,46,14,124,109,35,7,16,38,133,160,389,323,18,12,154,5 }, + { 121,132,18,167,271,146,101,363,621,9,411,647,16,354,520,60,212,932,1,806,55,0,195,446,68,35,31,364,777,252,407,118 }, + { 26,6,85,396,122,624,25,19,42,445,64,648,573,416,174,680,665,214,45,348,90,65,194,145,113,881,138,289,112,436,297,544 }, + { 16,146,18,92,24,199,60,71,121,126,35,108,156,953,271,674,132,7,32,640,360,246,649,118,21,95,5,517,14,9,1,314 }, + { 51,13,23,453,475,730,719,15,457,403,64,115,33,95,4,523,3,12,21,6,899,102,5,128,401,202,11,141,308,515,22,125 }, + { 151,396,6,53,27,113,58,26,73,112,74,287,45,29,297,19,145,70,138,445,315,436,34,2,17,573,5,61,549,491,1,80 }, + { 223,1,888,774,260,98,269,385,349,202,96,141,421,622,730,863,318,697,87,453,393,418,922,834,751,5,163,335,120,291,352,30 }, + { 16,60,92,35,126,121,7,150,246,18,107,1,598,24,167,195,14,97,71,279,98,441,191,199,517,146,356,223,298,271,230,0 }, + { 22,1,105,28,239,170,0,55,95,31,36,301,2,320,98,127,9,49,44,64,35,67,10,86,5,12,109,23,168,13,21,312 }, + { 2,6,5,207,292,76,1,119,45,32,17,29,61,306,790,58,240,106,14,64,214,151,476,710,7,72,84,128,4,179,70,25 }, + { 51,23,221,254,115,13,438,530,125,48,21,39,541,960,386,49,1,613,15,840,228,308,627,131,688,401,5,326,421,158,165,83 }, + { 1,5,2,0,12,22,21,36,10,14,48,86,23,13,32,54,3,4,28,65,51,50,137,37,208,114,9,38,17,7,281,202 }, + { 363,23,447,182,296,340,1,93,698,478,379,156,284,144,18,269,21,98,141,70,668,411,664,658,110,914,67,937,180,691,335,291 }, + { 17,32,45,498,41,115,180,197,106,62,54,38,546,165,13,155,468,509,341,243,241,217,542,15,57,536,428,51,117,721,292,129 }, + { 32,95,64,246,22,92,180,13,5,652,125,241,638,237,7,49,4,126,21,115,197,296,888,316,0,165,774,23,16,392,1,534 }, + { 15,515,700,753,33,341,13,217,4,141,77,23,180,317,1,10,102,351,82,115,40,5,854,21,137,11,352,901,365,117,197,0 }, + { 15,120,1,82,93,217,515,260,77,141,13,110,700,351,352,23,180,753,21,854,202,317,64,349,269,51,165,137,5,128,291,36 }, + { 13,23,51,141,77,0,33,4,115,64,2,10,102,202,217,128,1,177,269,11,7,22,6,21,32,9,180,40,15,3,165,318 }, + { 478,264,1,520,98,724,9,682,223,664,21,759,13,772,604,100,23,363,411,48,821,5,0,905,909,447,31,265,88,101,166,39 }, + { 20,29,7,2,77,416,6,128,33,5,0,113,104,32,43,13,491,66,23,21,102,51,74,210,202,525,64,318,10,81,174,14 }, + { 2,1,5,14,7,58,61,29,45,290,46,38,52,21,32,270,6,592,425,0,75,155,16,48,17,50,72,70,207,24,263,663 }, + { 80,6,17,209,106,26,483,113,19,469,255,25,378,27,495,833,45,64,161,2,61,667,76,742,32,90,445,5,814,65,887,119 }, + { 98,223,393,1,354,834,195,791,447,697,284,293,360,541,781,156,51,807,18,664,421,411,163,668,48,31,591,765,883,386,948,23 }, + { 679,141,816,36,93,406,876,144,228,137,1,180,669,21,332,251,5,269,116,187,96,351,202,752,317,64,203,831,574,466,855,345 }, + { 15,515,700,13,1,753,2,0,23,341,3,5,4,10,51,11,33,165,6,7,115,197,12,64,180,153,217,77,9,569,901,317 }, + { 13,23,202,51,5,21,403,15,120,64,1,450,128,141,12,523,33,165,494,125,2,515,269,7,48,102,318,95,260,180,453,197 }, + { 16,18,24,60,71,92,146,246,199,35,140,7,9,118,121,108,167,230,126,132,0,640,156,14,68,133,267,360,649,271,64,55 }, + { 269,141,678,177,202,77,128,318,33,947,40,120,291,349,102,137,64,352,210,864,461,498,13,342,196,23,275,450,954,0,205,111 }, + { 16,24,92,18,71,60,35,7,108,191,167,246,140,14,126,21,1,68,150,118,149,388,399,9,273,0,121,796,230,48,212,517 }, + { 2,14,1,29,46,75,52,70,69,171,38,7,58,163,16,5,24,220,67,112,223,54,50,409,155,35,267,186,151,334,394,140 }, + { 9,252,100,265,166,39,88,404,329,0,1,520,382,812,101,593,264,274,604,676,30,118,68,553,18,664,363,23,639,865,21,411 }, + { 16,18,35,24,0,60,158,7,22,68,14,49,109,159,55,9,28,71,2,10,5,105,1,118,329,13,344,23,92,20,21,126 }, + { 15,13,515,700,23,0,753,1,51,2,4,10,77,5,3,197,115,165,961,202,9,457,180,12,141,22,33,120,6,11,318,31 }, + { 160,93,251,137,317,1,180,36,120,217,345,752,617,352,332,10,96,531,498,318,365,202,141,269,816,341,901,679,143,35,83,968 }, + { 6,25,42,128,19,59,122,4,85,26,611,27,269,233,45,0,343,91,318,80,11,177,283,73,33,614,2,77,64,138,445,216 }, + { 95,64,74,7,32,81,51,204,0,20,237,65,56,38,91,23,207,180,347,343,29,6,511,52,49,10,25,18,554,370,14,312 }, + { 202,120,326,260,450,817,494,318,137,403,128,77,523,553,859,5,704,1,15,23,13,576,7,16,615,51,682,291,515,0,21,234 }, + { 20,43,107,356,362,126,595,92,359,7,422,319,493,16,858,5,392,246,414,683,60,0,35,945,441,21,259,819,49,97,279,173 }, + { 25,42,6,77,33,102,0,122,4,690,29,483,210,27,21,19,2,300,18,648,680,119,117,59,1,10,342,12,26,153,91,684 }, + { 31,44,299,116,125,242,456,599,22,393,0,144,492,28,268,1,9,963,301,105,367,36,127,170,384,434,206,98,918,10,13,93 }, + { 410,521,686,367,662,88,335,321,201,96,98,772,144,1,934,921,443,435,284,274,264,551,120,897,44,100,33,225,744,418,909,960 }, + { 142,178,878,234,132,786,195,202,77,416,147,929,146,522,167,259,687,639,450,271,626,481,590,5,198,212,771,49,0,465,315,427 }, + { 254,39,131,9,272,0,578,716,310,224,30,49,105,827,518,829,166,333,616,228,613,846,101,219,1,31,890,98,159,938,252,100 }, + { 230,699,854,473,450,351,831,137,855,217,352,704,800,202,251,498,160,144,206,203,317,201,253,752,418,141,1,332,82,180,443,36 }, + { 403,202,475,453,494,23,51,77,318,402,13,33,128,102,137,141,120,342,269,0,450,4,899,576,40,421,275,117,217,177,196,64 }, + { 23,44,98,182,291,144,116,39,110,141,96,82,905,70,367,264,125,93,77,411,120,1,658,202,100,415,107,363,197,30,447,105 }, + { 15,515,1,13,700,23,77,120,0,753,51,180,202,141,260,5,21,115,2,137,128,9,450,197,365,269,12,326,110,102,318,7 }, + { 0,32,18,95,207,577,193,29,61,104,64,784,715,102,693,887,81,91,583,671,403,5,52,474,397,180,138,49,37,344,38,263 }, + { 0,101,9,68,252,16,100,39,166,364,124,24,154,265,212,88,18,35,329,419,28,118,71,30,65,158,191,55,1,694,21,676 }, + { 16,24,191,18,35,71,167,118,149,68,212,9,0,1,21,108,101,92,60,375,302,7,589,755,124,674,350,48,562,246,13,363 }, + { 2,14,69,24,1,67,46,16,38,103,29,267,7,35,189,135,278,71,108,18,83,309,52,6,149,388,75,236,60,0,150,66 }, + { 13,1,23,0,4,2,51,15,180,33,3,115,5,515,141,10,77,700,11,9,197,341,202,165,217,102,22,7,753,317,365,6 }, + { 447,1,698,411,31,363,98,5,919,4,156,125,759,691,13,64,459,354,44,21,48,293,30,914,478,225,82,120,2,922,848,839 }, + { 854,82,351,217,141,180,352,15,515,752,1,700,317,898,753,244,10,21,922,115,77,36,4,260,64,110,372,13,5,365,120,11 }, + { 0,1,4,13,5,2,82,33,3,120,10,23,9,11,77,260,21,102,8,31,40,6,351,51,64,450,22,117,93,110,7,457 }, + { 51,13,403,23,12,475,1,2,21,5,453,523,115,202,817,7,0,99,3,6,450,120,494,64,22,95,49,899,10,37,32,141 }, + { 180,752,352,141,498,864,317,217,9,0,115,237,230,39,30,197,83,1,930,64,35,365,372,13,579,88,702,36,101,901,482,21 }, + { 16,24,0,7,22,18,28,35,14,158,71,2,109,60,1,168,49,154,124,68,10,55,92,118,159,9,5,747,95,105,65,6 }, + { 15,515,700,753,0,23,1,13,341,51,120,77,141,4,137,33,260,82,202,9,180,5,351,2,291,10,11,901,21,115,40,128 }, + { 24,68,35,149,18,16,0,7,9,14,189,108,69,65,67,1,71,2,118,28,140,101,114,336,230,124,175,133,46,55,251,154 }, + { 13,308,197,115,125,9,165,237,391,23,509,569,546,28,49,629,22,338,317,254,749,180,468,159,903,386,217,352,558,39,36,734 }, + { 64,90,32,217,77,4,141,216,172,312,128,13,86,33,597,147,352,95,5,115,875,22,59,11,102,14,182,437,97,177,874,707 }, + { 1,22,36,0,105,28,2,67,95,49,55,5,239,12,86,9,83,170,312,64,31,21,23,10,164,50,114,159,208,13,7,320 }, + { 9,18,16,0,159,105,101,252,49,310,24,68,35,39,265,272,7,1,60,28,455,890,329,557,118,286,55,137,327,167,5,13 }, + { 129,123,214,249,618,17,5,257,205,184,460,76,2,162,769,245,90,106,128,45,119,1,183,4,3,12,179,64,6,229,99,209 }, + { 51,453,719,457,23,13,730,899,475,386,4,15,11,12,670,196,515,523,961,401,153,3,700,99,753,117,403,32,120,165,57,0 }, + { 173,66,192,204,20,74,104,636,7,43,289,426,825,712,560,214,81,750,65,97,707,0,90,414,64,348,32,500,22,861,95,6 }, + { 13,23,1,51,5,21,141,120,202,15,165,2,515,180,12,125,0,64,82,700,197,269,32,48,260,128,115,93,9,137,33,753 }, + { 200,34,322,78,472,390,27,714,19,14,136,161,453,176,236,444,59,3,62,128,108,57,283,862,73,53,47,17,412,813,4,56 }, + { 33,347,66,204,426,498,56,172,97,95,5,681,546,22,10,0,135,180,4,241,19,174,6,353,263,21,7,370,42,197,27,808 }, + { 131,224,219,187,385,371,258,442,254,737,31,98,836,127,924,944,44,871,908,716,39,827,201,574,116,137,36,1,276,242,578,616 }, + { 1,15,2,180,4,141,13,515,0,5,3,115,700,901,341,23,217,352,753,51,197,77,317,33,365,752,165,21,6,7,269,93 }, + { 370,91,718,74,81,510,397,66,636,240,355,84,138,511,18,278,6,681,701,289,90,5,214,582,64,104,0,643,192,65,750,32 }, + { 15,515,700,753,13,120,1,0,165,2,197,23,260,180,4,82,51,386,8,5,12,10,3,141,351,341,326,9,450,7,64,6 }, + { 32,2,76,5,1,292,72,45,476,214,21,241,29,14,17,48,129,90,179,460,464,123,290,148,519,205,3,263,249,38,710,89 }, + { 13,165,115,17,197,569,23,509,457,45,32,41,106,180,62,38,659,734,155,536,341,629,961,873,587,54,431,37,391,99,405,428 }, + { 68,24,35,16,0,101,9,124,154,71,149,65,18,175,28,118,7,55,302,108,92,14,22,346,1,39,429,252,375,364,10,67 }, + { 0,9,1,68,230,65,35,69,83,23,101,13,141,67,217,352,21,39,16,88,28,124,212,100,115,154,51,64,30,36,10,317 }, + { 100,265,88,909,410,382,812,593,1,213,321,30,252,230,352,264,9,166,689,39,676,98,21,466,724,639,478,217,13,48,553,101 }, + { 113,61,198,904,43,0,5,37,899,325,20,59,33,523,204,725,817,389,470,329,222,40,174,58,22,453,690,848,122,104,788,105 }, + { 16,24,141,18,7,0,71,140,35,269,75,352,12,9,108,217,5,330,60,64,199,70,22,13,486,246,318,133,65,50,23,498 }, + { 271,167,121,60,18,191,146,199,16,1,446,132,575,212,463,354,126,35,598,566,727,98,107,21,608,955,640,407,5,24,223,68 }, + { 15,515,115,217,700,13,317,753,141,180,33,23,110,120,4,341,82,10,1,260,365,36,64,854,351,21,51,352,137,77,40,0 }, + { 173,7,97,356,43,107,20,387,729,104,426,232,560,595,359,392,414,707,885,81,5,0,66,858,612,49,861,14,22,32,819,230 }, + { 15,515,700,753,13,23,51,82,0,33,165,120,196,4,1,2,197,453,260,351,180,12,40,8,386,110,5,326,9,141,217,457 }, + { 9,100,120,30,77,795,137,82,202,39,264,827,578,127,0,166,373,318,18,326,141,260,1,450,731,31,33,395,217,291,341,254 }, + { 14,2,67,1,24,69,0,28,65,7,46,18,114,108,36,83,38,398,9,16,124,133,103,154,50,55,22,267,29,160,35,547 }, + { 14,7,69,24,66,16,2,267,189,67,71,150,140,97,18,60,172,35,6,1,38,149,388,92,83,135,108,74,462,380,29,36 }, + { 15,515,700,753,1,13,2,0,4,341,5,3,23,365,11,117,180,10,12,33,134,115,77,197,217,165,6,7,317,102,21,9 }, + { 1,22,0,12,5,2,36,28,21,10,86,13,23,49,128,9,95,51,55,96,208,141,48,202,4,137,37,64,105,3,50,7 }, + { 605,630,63,123,736,650,65,108,444,368,561,389,19,25,42,619,122,194,183,27,53,33,84,26,297,813,114,73,256,235,249,216 }, + { 127,39,9,0,31,371,98,254,1,385,395,44,30,836,187,131,100,116,284,578,299,166,28,21,737,16,276,272,23,49,137,935 }, + { 2,61,6,29,45,151,1,655,7,207,32,5,112,425,17,76,833,4,14,64,58,106,119,25,113,128,72,52,70,21,292,790 }, + { 2,5,17,14,3,29,23,27,13,401,46,6,51,58,1,453,45,53,34,52,133,19,236,26,181,114,99,366,151,108,218,38 }, + { 31,22,170,1,301,44,127,98,36,28,55,105,239,0,338,116,512,299,293,125,86,10,242,395,2,13,9,64,841,23,95,685 }, + { 1,21,2,14,5,32,48,50,38,270,46,76,290,72,45,54,17,0,155,221,263,207,37,281,430,3,89,12,181,408,36,67 }, + { 17,106,119,378,84,240,62,80,383,136,306,3,56,790,742,5,207,504,64,440,32,128,45,2,123,209,14,4,61,57,297,667 }, + { 13,15,1,515,23,2,0,700,4,115,3,51,5,10,753,180,33,341,217,11,165,317,365,197,6,77,40,64,22,9,7,117 }, + { 772,335,96,744,1,367,662,686,652,897,303,264,521,31,225,410,141,520,260,116,64,44,321,98,144,88,919,966,340,269,349,284 }, + { 1,0,5,28,36,2,12,22,83,67,65,50,24,14,9,96,21,218,18,114,48,281,54,10,7,160,181,103,37,23,133,99 }, + { 25,6,145,42,138,81,174,348,525,544,26,74,85,280,287,648,746,91,66,0,29,396,204,64,636,90,122,194,355,104,65,233 }, + { 16,24,0,18,28,158,7,35,49,22,68,159,55,1,14,109,105,2,9,71,65,154,124,95,424,344,60,239,118,577,21,10 }, + { 352,854,699,230,93,689,137,144,217,160,251,36,669,202,351,120,617,855,752,203,332,82,450,180,141,748,831,30,258,201,1,816 }, + { 15,13,515,700,1,2,0,753,23,5,4,3,51,33,10,115,11,317,217,77,180,341,117,165,6,134,197,153,64,9,102,7 }, + { 104,20,43,173,66,319,0,77,202,7,198,5,97,580,355,74,2,204,174,52,712,234,426,155,102,192,32,4,500,337,226,904 }, + { 13,23,15,51,1,515,0,2,5,700,141,4,753,165,115,12,3,21,457,10,180,269,32,6,197,202,9,7,120,11,77,33 }, + { 15,515,700,753,0,1,13,2,23,115,4,317,8,3,5,51,9,341,10,217,22,365,33,457,6,180,77,901,197,120,18,7 }, + { 15,515,700,753,1,0,2,3,4,13,5,141,23,16,82,217,457,10,365,180,9,317,51,21,269,898,64,202,11,12,318,341 }, + { 2,5,1,14,50,38,29,17,114,46,133,3,45,21,58,171,181,36,218,12,6,52,0,48,137,65,361,23,155,4,285,51 }, + { 0,68,9,65,101,124,35,212,16,149,154,100,24,1,114,336,67,589,252,39,71,189,69,562,18,13,30,398,118,88,265,264 }, + { 1,2,14,22,0,7,67,65,28,36,24,46,168,5,86,69,38,16,49,12,289,10,194,50,83,114,95,6,18,23,55,158 }, + { 13,23,15,51,515,0,700,4,1,753,2,10,115,961,457,12,33,11,3,5,197,9,165,77,102,403,453,40,64,22,37,59 }, + { 15,515,700,753,0,1,2,13,23,5,51,901,8,9,180,3,7,82,4,120,12,10,719,341,6,31,141,457,197,22,115,93 }, + { 100,252,88,101,0,265,9,724,48,1,21,352,213,676,410,382,321,230,30,329,593,909,39,812,553,217,23,689,520,264,166,419 }, + { 2,5,1,58,171,14,46,50,29,52,45,38,186,155,67,54,151,281,334,61,48,96,17,181,103,400,502,227,21,223,12,69 }, + { 23,120,13,1,202,141,51,21,165,128,260,15,5,269,137,64,33,180,82,318,93,197,77,326,515,125,110,700,450,2,32,48 }, + { 341,197,10,901,13,15,8,638,569,515,479,23,180,873,700,165,143,642,0,961,753,951,1,115,509,499,116,12,498,242,82,206 }, + { 15,1,23,13,515,21,120,51,2,141,202,700,5,180,165,0,753,197,12,7,33,260,352,137,269,4,82,128,48,9,110,6 }, + { 2,29,50,58,1,6,5,52,14,262,17,46,27,53,151,34,171,74,324,26,38,309,45,113,19,96,287,396,223,67,73,583 }, + { 13,23,141,51,4,202,0,115,77,2,33,217,5,317,180,64,10,269,3,9,15,21,1,128,102,137,318,11,352,515,22,31 }, + { 1,67,0,24,50,5,14,18,16,69,2,9,103,35,83,12,96,28,54,7,58,223,21,46,281,48,65,181,22,38,36,108 }, + { 13,23,141,51,77,64,202,115,33,102,128,4,0,269,10,21,217,32,180,318,9,137,2,11,22,291,7,177,16,31,165,197 }, + { 317,115,180,365,873,498,217,341,13,752,482,197,569,352,1,901,36,23,457,468,165,346,546,143,509,134,579,876,868,2,332,21 }, + { 184,257,205,229,152,17,57,497,266,432,452,524,5,619,381,32,4,90,2,12,313,128,45,59,245,106,3,471,129,769,339,214 }, + { 13,23,1,0,15,2,4,515,51,3,10,33,5,700,115,180,753,77,11,365,341,217,9,6,197,7,102,165,317,40,22,64 }, + { 626,70,771,687,379,846,767,761,518,878,82,481,31,786,49,591,178,163,407,44,87,13,845,125,590,371,195,120,98,557,937,351 }, + { 264,1,410,909,772,897,686,521,335,478,98,96,691,639,100,44,284,382,31,321,744,88,914,724,662,765,223,9,682,363,0,367 }, + { 13,23,1,2,0,15,51,515,5,10,4,33,115,77,180,700,3,141,217,40,6,753,317,197,64,165,7,11,102,9,341,22 }, + { 141,77,13,64,269,23,115,21,318,217,5,202,102,33,137,2,15,291,177,51,48,180,32,4,515,352,128,7,0,10,96,11 }, + { 13,15,23,515,51,0,700,753,1,2,4,10,33,11,961,453,115,40,457,14,12,3,9,5,165,401,197,77,22,21,64,102 }, + { 1,22,0,36,2,31,5,12,13,105,28,9,49,86,141,21,23,95,128,55,44,115,170,10,164,98,180,4,137,239,83,51 }, + { 100,101,88,0,252,9,265,30,21,39,759,724,213,329,321,13,419,68,562,382,676,352,694,35,553,410,1,166,909,593,230,23 }, + { 539,88,30,190,321,530,840,144,669,435,957,748,778,100,96,418,203,213,1,131,410,228,466,274,36,382,219,863,613,83,822,352 }, + { 7,97,92,173,298,107,43,314,232,140,16,356,20,387,729,362,126,359,246,14,230,501,426,441,0,5,560,66,104,779,35,60 }, + { 2,14,7,1,58,5,46,16,38,70,75,45,24,155,29,0,21,52,61,163,220,50,69,270,35,48,32,171,18,6,64,54 }, + { 447,411,363,664,647,98,621,1,354,271,223,478,18,777,781,936,360,759,167,132,121,48,21,156,9,195,118,293,23,691,13,264 }, + { 2,1,14,65,36,67,0,7,46,22,69,5,38,24,28,6,83,29,86,114,168,50,124,208,12,18,108,10,194,484,103,16 }, + { 421,386,51,791,730,958,165,801,23,453,697,403,615,13,221,523,24,899,401,326,551,670,576,102,18,33,125,77,566,115,203,197 }, + { 104,319,422,945,0,81,20,43,715,32,784,693,879,7,397,74,306,207,52,681,671,2,61,173,6,636,904,95,887,5,18,192 }, + { 2,29,1,46,14,52,70,262,6,26,50,67,75,96,309,38,103,112,58,19,5,163,145,83,74,220,223,357,24,69,331,25 }, + { 786,929,590,771,687,626,941,178,465,259,70,5,13,21,35,534,107,518,132,49,878,48,146,121,379,279,31,767,147,195,108,125 }, + { 5,2,186,45,17,29,48,50,14,61,46,155,400,1,227,171,52,58,38,54,430,209,80,281,3,106,536,311,181,243,21,502 }, + { 0,32,64,95,817,494,342,403,207,202,194,389,453,365,312,180,316,5,690,237,848,577,450,61,102,523,475,289,49,241,65,482 }, + { 23,13,51,15,202,515,1,0,2,12,115,4,700,5,165,753,77,457,21,141,128,10,3,64,403,32,197,318,9,11,33,117 }, + { 119,2,6,76,5,17,45,292,306,240,32,1,19,84,64,61,4,209,710,80,26,0,106,27,214,25,128,129,29,179,3,113 }, + { 15,515,700,1,753,0,13,23,180,120,51,2,5,33,165,197,9,450,7,260,115,523,4,12,202,141,82,77,21,102,8,6 }, + { 6,138,74,280,222,85,66,226,25,42,87,204,64,337,29,135,95,174,235,26,145,65,19,32,792,294,112,52,256,2,5,22 }, + { 39,9,0,101,333,158,49,252,310,254,272,68,16,18,159,286,344,455,30,109,627,327,24,105,419,100,364,22,35,1,329,709 }, + { 21,5,32,14,2,1,38,72,76,54,17,3,48,221,270,0,45,46,12,181,37,89,36,50,540,290,430,10,4,741,99,23 }, + { 120,137,202,269,141,260,318,450,922,494,77,291,82,15,5,351,128,1,515,326,64,854,700,352,342,21,753,678,349,32,523,90 }, + { 16,24,68,35,71,18,149,118,191,167,9,0,212,124,65,246,7,67,140,189,399,101,133,60,1,108,267,114,69,92,695,154 }, + { 28,0,9,67,1,22,109,36,55,65,194,114,39,83,49,69,2,35,103,50,158,208,86,420,168,289,505,24,7,185,5,323 }, + { 147,325,198,427,142,178,202,798,5,376,20,318,259,43,120,450,77,234,534,904,470,465,878,725,329,14,315,0,260,858,70,61 }, + { 28,0,65,9,109,1,55,67,35,22,24,39,289,7,175,14,114,2,158,124,420,194,68,16,336,36,49,69,168,570,154,505 }, + { 141,180,13,115,1,23,4,269,2,202,0,317,217,51,15,5,21,352,77,318,3,752,197,10,165,365,137,341,9,515,33,64 }, + { 15,515,700,0,753,1,2,13,23,9,51,5,4,901,33,7,8,3,12,93,180,120,197,6,82,341,10,141,22,260,457,115 }, + { 6,74,66,1,25,75,324,380,278,26,138,85,135,500,87,42,220,841,97,350,29,19,70,226,38,21,52,606,235,889,2,14 }, + { 13,23,51,12,4,15,453,0,457,1,403,165,115,3,11,2,64,5,401,10,515,37,202,33,40,32,99,475,197,700,308,17 }, + { 788,180,5,83,693,319,314,4,32,21,17,11,817,3,510,498,33,12,24,104,814,120,64,117,306,804,523,450,288,160,102,43 }, + { 15,1,515,13,2,700,23,0,4,753,3,341,5,51,33,11,10,6,77,7,115,102,180,165,141,9,197,217,901,40,12,64 }, + { 101,18,9,167,520,16,0,118,60,212,604,364,694,24,55,252,68,917,264,35,1,121,146,363,39,100,806,5,21,166,191,28 }, + { 13,23,0,33,51,141,77,4,64,2,115,217,9,102,7,202,21,10,180,3,15,128,5,269,6,32,11,16,165,352,22,317 }, + { 66,135,97,74,172,6,278,7,204,324,138,174,29,85,2,87,25,140,92,192,52,38,802,69,448,500,808,620,22,1,280,232 }, + { 2,24,69,6,97,7,1,0,14,298,423,66,67,29,150,25,189,267,124,74,607,18,36,81,172,33,83,38,52,273,71,809 }, + { 0,9,158,39,68,49,109,16,24,333,35,344,101,22,159,254,272,30,124,65,28,18,793,154,310,252,327,105,627,419,286,55 }, + { 15,515,700,10,753,33,77,180,4,341,1,197,13,115,365,23,901,317,5,102,11,217,165,117,141,40,2,3,253,21,134,55 }, + { 100,166,382,478,265,264,88,39,98,1,404,274,9,593,724,921,639,438,363,682,411,31,30,812,96,447,821,905,252,0,223,435 }, + { 19,283,436,53,297,26,813,432,27,128,42,25,390,503,122,736,73,123,605,63,389,529,630,250,690,65,381,444,6,269,108,216 }, + { 33,202,13,128,494,0,51,141,269,1,4,2,102,180,15,137,65,95,6,450,77,40,117,59,457,36,196,817,134,86,49,515 }, + { 18,16,60,68,101,167,191,118,35,121,9,212,55,0,126,1,24,647,199,146,520,107,628,621,363,71,21,28,346,92,806,727 }, + { 352,230,217,531,160,93,36,669,748,854,689,258,137,871,728,699,752,251,574,202,373,351,228,120,717,260,144,219,268,82,816,1 }, + { 15,515,700,753,13,23,0,51,8,1,4,82,165,77,110,33,10,180,5,202,11,22,120,12,9,197,115,93,403,141,40,351 }, + { 0,9,101,217,35,88,352,100,39,175,30,68,562,752,13,317,252,115,180,197,64,1,83,141,65,213,165,230,194,36,28,265 }, + { 32,64,5,470,288,90,21,147,0,95,356,22,20,519,835,312,819,18,247,182,11,97,13,4,387,49,43,298,316,48,107,7 }, + { 16,14,24,1,7,2,35,0,5,50,18,69,46,12,58,75,9,67,70,163,21,54,38,48,223,502,281,37,140,60,28,10 }, + { 18,265,9,252,39,195,354,411,1,16,132,101,121,682,167,203,5,363,146,593,35,333,21,271,60,13,100,0,156,327,7,520 }, + { 4,13,1,115,141,23,2,180,5,0,51,3,217,202,77,15,33,269,341,318,317,21,165,515,11,10,197,365,9,137,64,352 }, + { 7,24,16,14,71,35,18,92,140,189,108,149,68,60,69,150,2,230,97,66,0,458,67,1,65,251,38,314,388,267,36,46 }, + { 1,22,31,36,0,2,44,5,141,105,180,170,12,64,13,98,86,55,23,21,28,164,115,127,10,125,128,4,9,239,352,197 }, + { 66,7,97,2,192,20,52,43,135,74,560,107,104,0,750,147,414,29,580,173,324,376,226,194,77,174,204,38,356,64,16,470 }, + { 0,101,9,68,35,124,24,65,39,16,252,100,154,166,28,364,149,694,30,88,55,346,1,419,71,439,265,289,22,21,175,158 }, + { 39,9,100,30,127,0,737,856,31,836,827,254,98,931,166,88,93,1,44,190,131,228,120,395,625,385,863,264,219,373,110,28 }, + { 5,17,2,3,21,45,14,155,48,32,38,1,328,181,186,46,23,51,12,61,227,29,106,54,99,133,62,832,13,37,514,543 }, + { 131,613,30,224,228,716,274,100,827,406,219,856,39,190,31,88,1,166,9,44,829,863,931,93,0,187,625,924,127,98,137,254 }, + { 352,217,64,141,752,269,180,864,437,372,954,115,498,177,77,349,317,318,579,291,947,197,247,0,23,717,237,304,128,457,776,678 }, + { 141,217,180,317,352,115,15,341,1,23,13,365,515,752,2,64,0,5,498,700,372,165,51,237,753,77,244,197,137,4,21,253 }, + { 5,2,17,14,1,45,3,38,21,29,181,58,46,48,50,133,114,171,61,155,32,6,186,281,361,12,36,54,4,13,52,514 }, + { 6,2,119,25,790,4,45,483,655,113,1,29,76,26,32,19,887,17,128,0,292,833,59,61,106,64,77,814,14,151,84,42 }, + { 13,23,2,0,51,4,1,115,141,3,5,180,33,217,77,9,202,11,7,15,10,6,317,64,21,197,515,165,102,128,22,269 }, + { 13,23,51,202,21,5,1,15,141,165,120,2,115,12,32,0,515,128,318,64,125,700,4,403,197,453,180,457,3,7,10,6 }, + { 9,39,31,30,0,127,1,44,100,131,98,187,385,276,88,442,219,908,254,116,49,166,935,28,201,36,141,827,137,299,284,21 }, + { 22,49,28,109,9,185,105,95,1,131,159,272,36,67,86,254,39,55,35,0,505,31,83,169,208,327,286,98,168,535,312,708 }, + { 5,1,2,21,0,12,48,22,10,14,36,3,32,17,23,54,86,38,4,51,13,37,137,50,65,281,114,45,28,99,58,202 }, + { 141,269,352,82,217,351,180,854,372,922,752,1,15,260,317,318,515,202,64,700,120,349,954,753,77,35,67,717,898,137,365,115 }, + { 144,203,613,418,326,406,96,669,137,679,1,228,494,822,840,317,36,83,855,160,817,859,856,816,217,831,345,93,876,77,44,251 }, + { 15,13,515,23,700,753,51,1,33,0,202,21,2,5,180,141,120,165,217,82,12,117,4,352,269,197,115,32,3,9,134,260 }, + { 13,23,115,1,0,51,4,77,2,33,15,141,10,5,341,180,515,3,217,202,9,365,317,64,700,102,11,165,197,22,753,7 }, + { 531,943,373,160,728,93,206,260,261,559,964,269,717,535,332,384,365,295,110,533,141,10,180,352,244,137,120,55,959,564,36,253 }, + { 1,31,36,170,22,55,44,10,86,64,127,0,2,98,301,164,740,338,237,143,5,125,116,13,242,141,299,180,23,169,105,12 }, + { 13,23,141,77,51,4,64,32,33,202,115,269,102,128,21,0,177,180,318,90,40,10,7,5,137,15,217,352,9,291,59,22 }, + { 202,120,260,318,77,15,450,269,1,82,33,23,141,13,51,515,351,128,700,5,64,326,137,21,102,110,753,494,93,523,817,165 }, + { 523,899,102,33,730,15,23,403,719,117,153,13,515,51,475,4,700,5,453,817,196,753,494,40,202,120,1,2,450,457,17,421 }, + { 202,403,494,450,120,817,523,475,318,453,33,402,128,77,13,51,260,576,342,102,15,23,515,4,700,5,82,753,326,210,137,615 }, + { 2,29,112,66,7,52,70,151,58,87,135,5,74,226,307,6,14,186,1,45,549,172,644,25,113,287,46,155,334,64,294,97 }, + { 1,77,349,291,260,120,652,102,5,39,64,269,9,33,340,342,13,98,888,698,23,296,100,318,51,202,87,137,638,128,50,850 }, + { 1,13,15,2,0,4,23,515,5,141,180,3,700,341,115,51,753,269,77,901,197,352,217,33,21,11,365,6,165,202,7,317 }, + { 7,14,16,2,46,5,70,58,1,38,24,35,92,163,0,75,21,18,50,54,140,12,87,220,155,69,171,23,60,9,13,307 }, + { 2,29,66,226,135,7,87,74,52,278,6,75,222,220,294,70,97,1,145,25,172,262,324,38,69,112,331,92,5,14,140,26 }, + { 15,515,700,753,33,77,117,4,1,102,134,40,153,11,13,196,217,21,5,51,23,115,32,3,2,202,141,137,128,291,48,177 }, + { 15,217,82,515,351,141,317,1,13,700,260,77,110,120,115,854,23,753,180,51,21,36,137,922,5,64,365,352,291,202,93,341 }, + { 31,190,30,373,120,110,863,88,44,127,908,856,260,318,82,98,93,187,836,717,935,39,442,131,141,254,228,219,1,968,77,116 }, + { 23,13,308,9,165,115,51,21,401,125,49,39,197,391,159,254,217,743,28,438,773,629,558,386,341,95,32,317,876,679,109,166 }, + { 49,5,43,165,7,0,21,104,125,22,173,422,64,13,623,102,20,18,314,95,91,141,23,31,193,51,391,900,779,558,92,232 }, + { 1,4,13,2,15,0,23,515,77,3,341,33,5,700,115,51,202,753,141,180,11,10,102,217,6,901,40,7,197,318,317,365 }, + { 93,843,295,120,36,160,206,261,10,137,567,110,384,141,943,268,201,332,258,55,1,180,64,116,44,144,699,203,282,31,260,373 }, + { 81,7,192,426,43,173,172,104,879,91,5,712,715,526,6,97,568,95,448,66,33,861,560,32,49,20,0,636,232,825,2,22 }, + { 475,403,51,453,33,102,13,23,494,202,0,196,15,77,153,18,4,117,515,450,318,22,730,128,700,421,65,753,269,402,134,817 }, + { 141,269,260,318,202,120,352,349,82,351,1,5,854,137,64,291,15,922,180,851,32,77,515,372,21,700,7,217,13,947,33,753 }, + { 15,515,700,753,1,13,0,2,4,23,3,5,180,115,197,12,51,165,217,10,961,9,6,141,352,21,8,7,33,77,457,120 }, + { 39,166,9,30,0,101,274,404,252,333,190,100,158,438,310,88,68,265,656,21,1,530,329,344,49,539,625,254,13,131,48,419 }, + { 0,1,28,9,22,12,65,83,67,36,5,2,50,55,96,109,16,13,24,23,21,238,49,18,285,160,128,39,69,114,7,323 }, + { 15,515,700,1,0,753,23,2,13,51,5,180,115,6,3,9,197,12,457,120,7,165,901,82,4,21,8,141,31,33,719,341 }, + { 9,39,30,0,28,166,22,49,180,1,352,35,317,158,88,141,498,131,115,345,752,128,228,217,100,83,219,930,13,251,365,36 }, + { 5,61,45,2,80,29,311,209,6,17,58,1,151,106,454,667,243,70,52,496,287,592,255,738,64,74,483,14,27,32,112,19 }, + { 31,125,22,44,299,456,685,242,599,116,170,28,0,1,492,393,506,144,558,10,268,301,239,23,13,36,963,367,55,206,105,95 }, + { 187,258,926,574,839,93,228,860,406,219,871,160,137,531,224,116,120,902,669,201,36,131,44,144,843,533,318,384,442,1,434,268 }, + { 7,107,75,16,87,9,64,177,24,18,291,77,349,141,60,232,23,0,51,269,132,14,5,21,70,32,678,112,126,121,71,947 }, + { 15,515,700,753,1,0,2,13,5,3,23,180,4,115,901,51,6,8,961,9,7,10,12,82,197,22,141,341,33,120,365,457 }, + { 13,23,51,1,5,202,2,12,15,21,165,141,0,115,3,4,32,515,197,10,180,318,128,120,64,700,6,7,403,269,457,137 }, + { 1,2,0,77,64,3,141,13,33,15,23,10,6,102,5,515,180,4,117,7,700,165,11,217,269,40,753,115,128,17,197,134 }, + { 345,531,332,269,260,317,717,752,373,351,180,352,728,82,10,365,160,533,217,143,498,251,244,93,341,901,36,1,141,898,55,864 }, + { 16,7,33,189,92,77,388,60,140,35,102,24,14,1,230,21,150,117,733,314,18,915,71,13,108,134,5,64,69,2,98,22 }, + { 142,202,234,178,5,786,77,49,70,0,416,450,639,878,1,48,21,929,147,259,315,455,198,120,12,481,163,113,846,329,318,22 }, + { 81,715,192,0,173,712,681,104,636,91,74,20,750,370,7,718,95,879,22,43,825,560,422,64,207,49,172,18,397,10,426,319 }, + { 13,23,15,51,515,0,700,753,4,1,961,2,10,115,457,11,33,453,3,5,9,40,12,197,165,77,401,475,64,102,22,569 }, + { 64,297,5,445,95,61,250,311,80,34,17,312,45,2,86,472,58,14,180,53,22,151,869,738,247,237,29,1,128,165,21,288 }, + { 16,24,18,71,7,35,118,92,14,154,60,68,0,149,28,302,124,150,55,175,2,9,97,1,429,20,108,273,22,65,43,126 }, + { 195,360,156,771,132,163,626,687,591,371,883,146,121,846,70,586,379,13,293,98,407,48,761,296,354,18,31,1,55,49,21,105 }, + { 202,13,77,23,318,33,51,0,4,141,5,21,217,32,291,102,64,128,15,10,9,494,269,137,515,403,1,31,117,700,120,317 }, + { 7,192,97,81,172,66,426,173,43,715,712,232,861,879,104,330,568,298,74,893,885,526,387,825,92,140,91,14,636,6,5,448 }, + { 2,1,14,6,67,7,65,69,24,36,66,124,108,83,38,29,22,86,0,18,484,5,28,46,12,10,25,302,150,16,650,74 }, + { 33,77,13,202,102,4,0,23,128,51,141,64,318,22,403,269,137,10,15,40,494,117,32,59,11,153,1,21,177,196,515,115 }, + { 269,141,318,77,349,291,217,202,33,15,372,304,515,22,102,177,351,700,352,120,5,137,10,317,260,753,64,851,854,403,49,21 }, + { 6,74,66,85,138,25,87,42,135,26,226,222,280,29,75,500,220,278,792,70,19,2,1,294,204,64,32,145,853,112,52,174 }, + { 9,0,105,39,16,18,1,101,272,31,127,98,24,518,333,252,310,28,68,737,846,371,158,916,938,49,30,7,286,35,301,455 }, + { 2,1,14,67,24,46,83,108,69,29,38,103,114,36,6,133,18,0,28,7,65,52,236,75,50,398,5,309,135,16,278,160 }, + { 22,1,28,105,49,95,0,2,67,55,36,239,168,159,65,35,14,170,320,164,9,7,10,5,114,12,83,64,194,109,24,301 }, + { 7,66,172,97,92,140,232,568,298,14,192,314,16,380,135,324,2,330,74,38,357,448,126,69,35,5,107,6,387,60,204,572 }, + { 2,29,1,14,5,6,46,133,114,50,52,26,218,108,19,13,366,236,27,45,70,17,58,23,86,51,137,65,112,38,25,12 }, + { 6,1,74,25,2,26,29,66,42,19,75,14,388,67,108,70,52,85,103,65,38,138,357,133,114,594,324,516,603,96,309,69 }, + { 22,9,28,1,36,49,109,105,86,95,131,31,169,39,0,141,272,159,44,55,98,180,13,30,185,115,83,128,352,137,64,208 }, + { 203,822,326,23,77,859,403,494,576,39,473,182,33,1,691,100,18,217,13,817,411,447,363,102,93,966,96,478,291,704,310,120 }, + { 15,515,700,753,33,77,117,4,102,134,115,153,13,1,40,217,11,196,341,2,5,3,23,317,365,0,21,291,32,51,12,569 }, + { 15,515,700,753,13,0,23,1,8,82,51,165,197,120,180,2,9,33,4,110,5,12,10,260,351,386,141,7,457,475,93,901 }, + { 1,23,13,15,51,0,21,2,515,5,141,180,120,165,700,202,197,4,753,12,33,9,7,82,115,93,3,352,260,6,110,48 }, + { 15,515,700,753,0,1,2,5,3,4,8,13,180,341,10,23,7,6,9,51,77,197,961,115,165,82,120,31,22,202,457,217 }, + { 559,661,922,564,141,533,10,317,373,110,143,269,244,260,332,261,93,642,752,295,351,876,531,843,180,206,728,384,352,1,434,120 }, + { 15,515,1,0,700,2,13,23,753,5,51,180,3,165,12,6,197,115,4,9,7,21,719,8,457,82,141,120,33,22,901,10 }, + { 198,234,0,325,5,77,202,416,20,147,32,43,639,315,49,61,450,455,142,21,113,230,22,318,725,342,207,13,95,904,494,10 }, + { 447,264,363,9,411,676,682,1,156,664,821,478,166,354,812,39,100,905,382,897,98,18,759,404,31,101,724,5,265,223,88,13 }, + { 24,14,69,16,35,18,2,7,108,189,71,67,267,149,1,46,68,83,38,140,0,236,251,9,388,60,133,103,65,28,29,50 }, + { 16,7,35,20,14,18,109,2,43,120,107,60,1,121,326,907,553,77,13,147,23,82,68,260,0,403,5,24,202,126,265,199 }, + { 30,131,187,276,31,44,613,442,39,9,190,228,1,839,116,935,908,219,127,88,244,224,110,137,93,201,98,141,36,567,0,856 }, + { 98,223,1,393,812,265,100,421,593,834,697,48,51,410,791,382,21,88,31,284,9,125,96,293,230,23,213,217,656,689,541,5 }, + { 98,51,127,219,616,258,105,293,395,421,924,512,31,308,23,201,116,44,301,272,763,276,125,13,453,170,401,295,261,944,115,567 }, + { 253,110,951,352,811,206,332,180,141,244,282,10,854,417,642,638,559,752,143,911,260,55,93,533,499,498,661,120,351,959,564,341 }, + { 49,9,159,254,272,158,0,131,28,39,627,105,327,286,22,518,688,578,68,347,374,101,224,424,95,35,219,24,16,364,65,344 }, + { 105,22,131,272,98,286,327,109,374,239,28,95,320,219,9,224,55,127,187,36,578,169,64,185,538,1,159,10,371,634,49,616 }, + { 691,478,340,1,658,914,724,363,744,698,156,772,411,296,682,447,9,284,335,98,264,303,909,21,354,410,225,13,664,686,88,919 }, + { 16,24,35,18,71,7,140,108,189,267,92,60,14,230,68,69,9,1,149,46,246,191,388,167,2,0,118,236,133,21,674,5 }, + { 9,0,127,31,98,371,395,39,737,49,1,44,385,272,512,28,293,242,836,761,254,299,101,16,187,22,116,158,159,131,18,21 }, + { 16,18,68,0,60,35,9,101,252,28,118,24,419,55,7,109,604,71,39,121,22,364,14,158,191,167,925,126,329,21,92,49 }, + { 116,268,203,93,206,692,551,31,417,940,499,8,473,44,202,523,959,0,120,137,559,22,450,403,576,10,728,299,13,326,51,1 }, + { 225,459,744,1,919,914,691,330,622,21,141,223,5,284,934,335,88,538,340,82,385,839,363,120,478,98,48,30,64,32,686,166 }, + { 5,1,2,0,14,36,21,281,12,48,50,67,22,28,54,83,24,218,38,10,181,9,32,18,65,58,45,114,430,17,99,37 }, + { 137,450,202,704,120,260,326,318,968,269,851,403,291,77,23,141,182,310,494,373,351,457,82,890,349,110,60,128,817,678,105,96 }, + { 15,515,700,753,4,33,13,23,77,5,40,11,102,93,1,21,110,51,82,117,141,2,10,8,32,64,120,31,202,3,217,115 }, + { 15,13,1,23,515,0,51,2,700,5,753,21,180,141,165,3,12,115,197,4,7,6,457,9,352,202,33,8,719,120,77,341 }, + { 219,127,258,98,276,201,131,395,944,293,116,284,567,31,242,105,137,935,295,44,403,860,51,224,576,456,9,371,578,475,202,512 }, + { 16,7,18,35,60,0,14,20,118,28,68,22,2,24,1,92,158,107,5,49,154,126,109,12,43,10,55,6,677,71,21,168 }, + { 93,728,531,160,559,373,574,120,295,860,533,269,717,260,926,902,258,318,36,201,261,434,851,137,617,141,187,352,843,384,332,251 }, + { 28,0,1,9,22,109,83,39,49,12,36,67,55,5,96,2,128,30,158,69,21,23,160,208,35,13,65,323,50,141,194,238 }, + { 23,13,51,1,5,15,141,21,0,2,165,515,202,700,12,197,180,120,32,115,4,753,64,9,7,269,6,3,125,386,48,453 }, + { 5,21,13,49,14,20,7,23,43,32,1,0,652,48,713,22,38,2,16,132,955,107,12,279,24,888,197,640,70,303,18,638 }, + { 9,0,28,39,1,30,35,101,22,67,83,141,49,175,36,68,55,88,13,251,10,69,23,158,180,115,64,100,217,65,345,166 }, + { 260,120,82,269,5,450,351,1,202,141,854,13,77,922,32,33,137,4,23,125,291,21,15,515,165,349,177,700,318,326,180,753 }, + { 121,16,18,35,363,101,60,20,107,14,68,259,621,55,604,43,7,252,9,364,126,0,167,191,5,407,132,28,199,419,146,10 }, + { 13,23,51,1,15,0,2,141,5,515,12,21,700,115,165,180,4,753,3,197,202,32,9,120,7,8,6,11,37,10,457,269 }, + { 201,144,206,443,418,203,435,96,335,459,187,1,88,332,330,321,269,934,30,372,822,521,268,326,44,523,382,141,410,264,494,473 }, + { 31,44,276,201,116,131,284,662,567,144,9,489,98,295,268,434,0,30,137,39,93,1,187,22,219,918,110,299,141,36,224,384 }, + { 520,478,664,1,264,604,9,167,777,759,411,0,806,724,48,21,101,68,647,936,363,223,118,682,410,18,100,16,252,98,265,13 }, + { 23,70,21,87,60,75,120,182,163,379,92,18,7,937,71,121,446,132,24,98,931,126,107,77,795,195,115,44,411,146,51,850 }, + { 39,9,0,737,127,31,846,98,1,827,105,310,371,30,254,100,44,18,395,242,272,101,385,916,836,16,265,131,938,93,166,557 }, + { 279,20,43,126,107,7,92,16,356,362,60,595,246,359,598,35,0,683,939,653,121,97,125,441,399,392,150,199,48,230,14,649 }, + { 206,417,93,959,499,728,8,559,120,473,137,141,10,564,31,260,44,450,203,341,253,244,373,116,143,638,268,180,352,110,318,940 }, + { 259,465,147,132,590,687,534,199,581,146,941,427,107,640,279,178,121,5,195,150,522,955,198,35,786,929,798,142,1,21,325,626 }, + { 523,15,120,450,202,515,403,51,817,700,13,753,23,457,33,899,128,64,730,102,494,342,115,719,453,196,49,99,318,421,308,5 }, + { 141,559,10,244,365,564,661,180,253,143,752,110,55,317,533,341,901,93,373,206,535,160,82,922,260,36,531,964,352,332,261,197 }, + { 219,258,98,127,276,964,943,137,843,535,201,935,131,860,261,295,284,567,206,44,116,31,253,492,203,332,160,615,36,93,55,692 }, + { 0,319,422,207,945,693,577,887,32,804,95,344,104,904,61,20,5,43,7,725,113,510,306,102,49,263,153,426,33,83,22,9 }, + { 1,22,0,5,12,2,36,21,28,86,49,105,9,10,23,13,141,95,31,55,128,37,51,4,83,202,3,64,96,7,32,44 }, + { 15,515,13,700,1,0,753,2,23,3,4,5,51,10,115,197,6,33,12,9,165,7,8,77,11,961,180,269,141,22,120,457 }, + { 15,1,23,120,77,13,515,51,141,202,700,180,110,137,260,753,326,5,128,102,0,21,2,165,269,33,197,450,318,217,93,115 }, + { 15,515,1,700,0,753,13,2,23,180,51,5,120,4,9,115,197,12,7,165,21,33,6,82,3,8,523,901,31,141,457,260 }, + { 16,18,24,7,92,35,60,75,9,13,71,14,0,108,50,21,126,121,1,140,23,5,132,146,2,12,128,10,64,141,70,87 }, + { 180,341,901,15,515,1,365,700,0,2,197,753,115,4,10,13,752,5,3,8,165,317,141,23,143,873,44,31,569,55,93,6 }, + { 9,0,175,35,101,28,39,67,68,1,65,83,30,69,364,336,22,114,55,124,194,158,100,289,252,166,64,345,103,36,50,88 }, + { 64,165,180,197,115,247,217,237,21,13,32,316,22,141,352,72,288,304,95,225,76,391,386,16,468,90,49,35,365,640,372,23 }, + { 15,515,700,13,753,1,0,2,23,4,5,3,115,51,141,197,12,10,180,961,7,9,21,33,217,6,8,165,457,11,77,341 }, + { 132,121,199,146,60,279,493,640,407,598,126,195,534,581,955,590,107,5,150,35,522,49,259,16,18,360,156,0,147,362,21,167 }, + { 0,1,28,9,22,5,36,12,65,24,67,96,2,83,18,50,114,55,21,16,7,10,23,14,13,160,137,51,48,218,103,69 }, + { 93,120,957,77,30,968,459,110,137,160,613,102,202,352,373,141,31,372,217,330,190,318,269,260,203,44,28,473,228,177,863,704 }, + { 15,515,700,0,753,1,13,23,2,51,5,9,120,82,4,7,901,197,10,8,260,180,341,12,33,6,3,523,165,102,115,141 }, + { 206,417,8,141,499,44,244,93,31,10,137,253,559,116,728,144,120,564,269,638,203,352,143,260,341,752,268,717,951,180,160,110 }, + { 530,254,228,1,96,21,406,39,827,31,669,840,613,829,137,679,166,98,23,51,960,438,131,93,48,224,219,317,310,36,876,190 }, + { 15,515,700,753,13,457,0,197,719,1,165,82,23,8,120,730,2,10,12,180,134,5,9,141,260,4,351,51,115,3,341,899 }, + { 0,16,68,9,24,28,18,35,252,109,39,419,124,158,154,55,101,71,22,118,60,7,49,65,333,14,1,10,329,364,677,346 }, + { 1,15,13,23,515,51,120,0,700,180,2,165,5,753,141,197,21,33,202,102,260,4,9,12,7,326,137,450,115,6,82,110 }, + { 535,253,352,564,110,365,82,180,341,10,854,533,55,898,244,901,873,141,752,143,642,559,498,317,36,951,115,964,638,282,661,197 }, + { 31,44,125,338,116,64,242,36,1,10,55,22,456,237,180,13,299,164,506,86,23,165,558,143,0,762,492,479,844,546,93,8 }, + { 13,23,4,1,202,2,0,51,115,77,141,180,5,15,217,3,33,11,515,317,9,10,102,21,700,341,365,318,269,64,32,128 }, + { 9,39,0,166,68,101,28,364,30,158,562,35,175,65,333,154,49,404,706,124,21,252,274,168,190,289,100,570,16,1,310,346 }, + { 15,515,700,753,341,13,0,23,1,33,141,4,260,82,77,51,351,180,9,5,115,137,10,217,11,120,102,40,349,269,202,854 } +#else + #include "rgbcx_table4.h" +#endif + }; + + static uint8_t g_best_total_orderings3[NUM_UNIQUE_TOTAL_ORDERINGS3][32] = + { + { 12,1,3,5,27,2,4,38,8,7,16,18,6,10,41,79,40,23,46,9,20,88,22,37,14,19,24,126,99,119,35,11 }, + { 7,64,116,14,94,30,8,42,1,108,47,55,137,10,134,95,96,115,69,32,63,29,90,113,11,148,16,103,19,9,34,25 }, + { 12,1,0,5,3,7,4,27,8,6,38,40,41,16,18,46,9,10,20,23,79,62,14,22,88,99,37,126,92,19,120,11 }, + { 16,88,27,18,46,48,126,107,79,19,59,38,37,65,23,66,0,2,3,43,12,151,28,25,5,87,72,40,1,20,52,92 }, + { 79,48,88,16,27,65,18,38,46,19,37,4,72,33,126,41,52,0,12,92,5,1,2,107,3,77,23,91,43,51,22,74 }, + { 1,8,41,122,10,22,2,0,87,24,37,120,38,7,39,4,5,3,9,92,62,59,23,16,104,11,27,79,19,26,25,32 }, + { 2,76,99,28,40,86,93,21,138,60,6,0,17,128,145,119,98,144,141,82,147,54,67,75,5,12,27,132,146,1,38,14 }, + { 47,7,64,90,1,118,116,85,57,14,30,94,50,45,137,134,8,42,69,139,55,68,58,108,95,29,10,115,0,32,2,11 }, + { 49,8,10,30,124,11,32,113,130,58,125,9,100,53,104,115,131,103,24,7,1,39,45,36,139,0,137,22,90,44,114,105 }, + { 9,38,72,125,49,41,84,11,13,5,27,0,16,92,8,2,65,105,10,18,48,29,127,131,36,14,1,46,111,79,130,12 }, + { 130,8,10,100,104,131,49,32,53,39,30,36,113,24,11,22,124,44,83,58,7,103,1,4,9,125,5,0,91,33,115,74 }, + { 114,11,58,8,120,49,9,124,142,111,41,30,10,0,97,130,62,84,38,5,72,125,92,127,100,27,139,113,13,132,32,1 }, + { 60,46,28,27,40,20,0,17,18,2,126,16,6,38,86,23,79,54,1,93,5,88,41,14,21,111,7,48,3,84,72,62 }, + { 72,92,38,65,84,48,41,79,27,16,29,111,88,5,18,46,1,0,152,14,37,19,77,42,132,7,22,13,119,56,12,2 }, + { 7,55,1,95,29,56,64,116,143,8,14,30,47,94,152,90,65,67,10,133,42,72,146,84,16,48,6,0,25,108,77,21 }, + { 27,23,20,5,0,79,38,2,3,1,59,46,4,41,33,86,37,87,88,92,7,126,43,8,22,152,151,150,149,148,147,146 }, + { 12,0,1,2,7,6,3,5,28,4,8,14,60,40,17,19,21,86,126,93,10,18,9,29,48,99,65,25,84,119,72,41 }, + { 60,40,99,2,54,12,0,1,19,28,98,93,6,138,21,5,27,17,151,14,76,46,16,18,38,29,86,144,107,7,25,41 }, + { 12,0,1,2,3,5,6,7,4,28,8,60,14,40,16,17,21,10,19,9,86,38,126,41,93,27,29,48,62,84,79,99 }, + { 0,1,2,10,5,8,3,25,4,29,32,34,63,7,77,26,16,48,65,56,14,22,129,103,72,24,18,152,140,53,96,42 }, + { 46,126,18,54,12,16,1,0,5,2,27,98,20,23,6,3,88,48,28,7,19,8,4,60,151,38,37,21,79,14,65,40 }, + { 76,6,141,86,119,2,138,67,28,145,0,93,17,1,40,60,146,99,147,14,21,144,132,7,5,29,55,27,16,75,19,12 }, + { 71,5,51,39,22,80,0,43,10,122,8,62,41,24,104,87,35,37,2,91,33,120,36,38,1,131,9,100,130,66,3,4 }, + { 126,18,46,27,20,16,88,23,12,79,54,59,48,0,73,1,37,151,5,19,28,38,2,66,60,3,65,98,14,26,6,43 }, + { 22,10,8,5,0,71,35,80,104,39,24,51,100,1,62,32,2,130,11,41,7,9,53,43,49,83,122,120,30,44,37,38 }, + { 1,34,14,129,53,63,42,26,121,148,7,44,96,10,0,24,100,32,64,116,140,22,5,19,29,103,135,108,8,61,39,83 }, + { 1,7,34,63,44,25,135,14,24,108,22,0,83,94,5,129,35,101,47,121,2,19,42,53,6,110,103,8,148,10,16,123 }, + { 12,28,16,60,18,1,6,21,14,0,86,19,2,48,93,17,38,29,7,5,65,126,46,72,41,79,84,119,40,56,54,88 }, + { 0,2,12,27,5,46,38,40,41,79,88,99,3,23,1,62,20,4,22,37,92,35,18,8,16,24,10,60,7,120,98,54 }, + { 1,7,14,56,8,0,84,67,10,2,133,72,42,111,5,30,21,4,9,3,25,94,16,116,47,11,65,18,132,90,55,64 }, + { 30,8,124,139,45,11,58,90,113,137,7,115,10,32,1,49,94,85,9,47,108,103,0,97,63,14,50,114,53,106,100,25 }, + { 65,38,48,27,16,79,72,18,88,19,46,77,84,92,37,41,0,29,1,14,12,111,2,5,31,36,87,74,105,40,28,51 }, + { 10,8,30,113,130,100,53,32,115,103,104,7,1,121,39,49,131,44,24,36,63,137,34,45,22,90,108,83,26,11,94,139 }, + { 51,52,43,33,5,74,16,37,71,91,38,3,36,87,48,22,4,0,122,41,39,18,66,27,79,24,65,88,59,23,62,92 }, + { 1,7,63,53,108,121,94,44,103,100,14,10,129,47,32,26,24,25,148,42,135,22,0,61,83,8,39,104,5,64,115,34 }, + { 1,8,10,7,5,0,80,32,62,2,24,44,53,83,9,41,30,22,100,11,14,25,120,4,26,6,3,16,122,34,19,35 }, + { 74,4,36,48,33,91,39,79,22,16,65,5,131,38,24,71,27,52,0,105,51,18,88,104,3,31,10,37,72,19,41,130 }, + { 59,43,38,79,23,27,92,51,0,16,46,5,18,88,41,37,66,3,87,20,48,2,122,4,22,12,1,126,19,65,33,24 }, + { 12,28,1,27,0,16,2,46,65,60,21,3,5,18,6,19,48,14,4,7,79,88,86,29,22,72,93,40,23,8,17,41 }, + { 22,91,39,33,24,71,5,131,36,10,51,0,130,8,104,2,35,125,9,43,52,49,83,80,100,41,122,3,37,38,4,16 }, + { 12,0,1,2,5,3,4,8,7,27,18,38,10,6,16,46,9,20,41,23,126,79,22,14,19,99,88,54,37,48,62,35 }, + { 12,27,1,2,3,0,46,4,38,16,8,28,7,79,18,5,84,6,88,10,14,21,23,20,40,22,60,19,9,29,72,65 }, + { 1,14,7,55,95,29,8,94,30,56,10,108,77,116,152,64,32,48,63,42,143,148,16,25,137,65,11,0,115,9,19,72 }, + { 37,79,66,38,16,52,48,59,43,27,87,33,41,4,23,51,3,5,88,18,92,46,73,122,22,71,20,0,65,19,2,120 }, + { 24,32,83,22,53,1,8,10,7,30,35,5,103,0,100,101,121,113,34,123,63,2,44,25,71,115,80,14,26,108,51,39 }, + { 97,45,111,58,85,139,0,90,47,7,120,106,142,30,50,132,41,62,84,1,119,114,14,56,117,8,38,29,2,64,116,5 }, + { 12,28,16,18,1,60,6,14,2,21,0,86,126,19,48,93,7,27,17,29,5,65,54,38,72,79,84,88,119,145,8,111 }, + { 118,47,64,116,57,85,7,14,50,1,42,0,45,68,86,69,2,111,134,28,90,55,16,29,56,48,84,144,60,30,112,41 }, + { 12,1,2,0,7,6,28,5,3,4,8,14,60,21,18,40,17,86,10,9,16,29,19,93,126,79,38,84,72,27,111,119 }, + { 11,8,49,130,10,125,9,124,100,114,131,30,58,104,32,39,24,113,36,105,0,41,22,120,5,53,111,38,142,44,83,35 }, + { 50,70,47,118,85,57,106,0,45,7,64,90,81,14,2,134,28,62,86,55,69,1,78,119,68,56,18,67,16,60,29,21 }, + { 43,37,33,87,51,41,66,5,122,38,22,59,92,0,23,91,27,16,71,79,18,52,120,4,3,24,46,20,73,39,62,36 }, + { 79,48,4,16,27,88,43,33,18,38,65,37,46,3,19,51,52,22,66,87,74,5,41,91,23,59,0,71,122,72,20,92 }, + { 32,100,10,8,30,104,24,44,39,113,83,103,1,7,22,53,115,63,135,121,26,35,34,5,0,108,137,90,91,45,2,130 }, + { 0,1,2,5,16,12,6,7,14,3,19,18,29,20,4,21,40,8,17,35,23,48,126,22,25,56,26,10,98,27,38,65 }, + { 143,67,56,146,1,7,133,55,64,141,134,69,6,47,14,29,84,21,111,147,57,16,95,72,118,132,50,0,2,18,119,42 }, + { 1,7,67,14,133,111,8,84,0,21,2,47,64,132,55,10,95,147,119,42,16,5,72,56,4,3,6,29,9,25,18,30 }, + { 68,57,69,112,144,86,102,2,134,55,0,70,118,64,75,47,14,28,93,143,67,7,50,149,1,21,29,56,119,95,60,78 }, + { 58,97,114,30,124,45,11,139,8,90,0,142,7,10,41,113,84,62,49,111,85,1,9,5,137,120,32,14,2,117,47,38 }, + { 23,66,18,79,38,20,43,27,16,88,46,59,126,37,87,12,73,92,3,5,48,0,19,54,2,51,28,1,41,65,122,22 }, + { 0,12,2,27,5,40,46,38,1,41,3,79,88,23,99,4,20,62,22,54,92,18,8,37,16,35,10,7,19,120,144,24 }, + { 1,14,25,26,0,7,44,34,129,42,24,5,135,22,19,148,6,96,83,2,29,16,63,35,101,64,140,136,116,110,3,10 }, + { 12,1,2,27,3,4,38,5,7,8,18,16,46,6,0,40,41,10,79,23,88,9,20,22,14,19,37,92,48,126,28,21 }, + { 7,1,10,32,108,103,94,47,8,53,25,14,34,115,100,129,121,130,148,42,64,116,63,26,44,0,24,30,113,4,104,22 }, + { 47,134,7,14,55,69,64,95,1,29,85,118,56,116,45,57,102,143,50,90,42,30,16,94,0,8,67,75,133,2,18,48 }, + { 12,1,2,0,7,6,28,8,14,5,3,4,40,21,17,18,60,86,16,93,126,10,9,29,99,38,119,25,19,54,27,84 }, + { 59,16,27,18,23,88,79,37,46,66,38,20,73,126,3,43,48,87,92,51,41,12,19,5,52,107,65,0,151,122,54,2 }, + { 1,21,147,7,119,14,76,132,55,0,86,145,2,6,69,67,16,143,111,138,17,28,29,60,18,93,8,19,40,56,84,5 }, + { 144,86,112,2,68,102,69,0,149,93,75,28,57,55,145,60,21,67,99,134,143,40,146,119,82,110,62,6,29,26,78,14 }, + { 102,57,55,69,143,75,146,67,56,68,134,2,29,141,0,21,6,14,133,118,64,1,7,95,47,84,111,28,147,82,72,119 }, + { 0,70,57,119,50,145,2,86,28,118,69,78,149,47,60,68,67,55,93,81,134,21,14,62,64,7,5,1,132,85,41,16 }, + { 51,5,43,71,122,87,41,37,91,39,0,22,33,36,38,24,66,120,62,2,80,16,92,10,59,4,27,23,35,79,8,3 }, + { 12,1,2,0,7,6,28,5,8,14,3,21,40,4,60,17,86,18,16,93,10,9,126,119,99,29,19,41,38,27,25,92 }, + { 27,18,46,126,23,16,88,79,20,151,59,73,48,38,0,54,12,2,37,1,19,5,28,60,66,41,3,109,86,65,40,6 }, + { 48,79,4,33,16,74,65,38,88,27,91,52,18,36,22,19,46,0,37,3,51,5,71,39,72,43,24,41,92,87,2,10 }, + { 86,2,144,93,28,112,141,6,102,21,99,60,75,0,68,82,69,146,67,149,55,40,145,76,111,147,56,119,110,143,26,132 }, + { 6,138,2,99,86,17,40,93,28,21,145,141,0,60,119,147,128,76,67,54,1,12,5,27,144,14,38,98,146,41,29,19 }, + { 1,8,0,10,2,29,7,5,3,56,4,25,14,152,63,32,65,72,96,42,34,108,48,9,26,16,84,103,67,148,22,129 }, + { 149,145,0,86,2,28,93,144,62,60,119,101,21,41,5,35,78,99,26,40,12,68,57,67,110,120,69,18,55,76,132,70 }, + { 12,28,16,1,48,19,6,60,2,14,18,21,0,27,46,65,86,29,5,7,72,93,40,3,17,84,56,88,126,4,38,8 }, + { 1,8,5,10,7,24,2,62,0,41,22,122,120,9,4,3,32,87,11,37,38,83,100,44,25,104,16,26,39,80,14,6 }, + { 0,119,62,86,145,149,28,132,93,2,120,67,60,41,35,5,144,21,123,38,111,81,84,56,12,44,24,50,92,55,40,22 }, + { 2,93,99,28,40,144,60,0,86,150,76,21,149,98,6,25,1,61,82,26,12,5,54,141,7,18,145,16,27,138,110,38 }, + { 24,8,10,22,32,35,100,5,1,53,0,7,71,80,30,123,83,104,51,11,2,39,44,113,9,62,25,103,34,101,43,41 }, + { 12,1,2,0,7,6,28,5,40,60,8,16,3,18,14,4,86,21,17,93,41,10,9,99,27,119,38,19,126,22,48,145 }, + { 45,47,50,7,85,90,97,1,64,139,116,118,30,58,14,106,70,111,0,57,94,42,137,142,29,120,8,56,18,134,84,41 }, + { 12,0,2,5,27,38,1,46,41,40,79,144,3,22,88,23,28,60,99,62,6,24,26,7,4,16,10,35,37,18,14,20 }, + { 37,38,59,92,0,5,23,51,79,41,27,22,2,3,87,16,46,4,1,43,20,33,18,88,24,71,8,10,48,19,126,122 }, + { 12,28,16,60,1,18,6,21,19,14,48,0,2,86,93,5,46,29,17,27,65,7,3,72,38,126,119,40,84,37,56,4 }, + { 0,2,5,1,16,6,27,28,18,38,60,7,14,21,46,40,86,41,19,48,93,8,3,79,22,4,10,37,62,23,24,111 }, + { 85,7,90,30,47,139,45,50,94,58,137,1,8,64,14,116,118,115,113,11,124,108,0,10,97,57,32,70,42,106,29,114 }, + { 33,36,22,71,51,5,91,39,0,52,43,24,131,74,16,37,38,122,41,3,87,48,4,104,35,80,10,2,105,62,27,18 }, + { 12,1,27,2,0,16,3,28,46,18,4,6,5,72,21,79,38,7,14,60,88,8,65,19,48,29,23,40,22,20,86,126 }, + { 0,12,2,27,5,38,46,41,1,40,79,3,88,23,22,99,20,37,62,4,18,6,16,35,60,28,24,7,92,8,14,10 }, + { 7,47,1,30,137,8,116,94,90,64,14,115,108,118,57,10,148,113,42,85,32,11,63,50,103,45,124,134,55,9,69,34 }, + { 55,7,1,29,56,143,64,47,67,133,14,146,95,72,84,8,116,111,6,134,141,21,65,0,69,30,16,45,85,42,50,10 }, + { 14,1,42,8,10,29,108,63,55,148,95,32,7,19,25,115,103,34,56,129,77,0,16,152,94,30,113,26,2,5,48,4 }, + { 111,120,142,97,58,0,41,45,62,132,114,84,139,30,5,8,38,2,7,85,119,90,117,1,124,11,56,47,28,27,35,72 }, + { 1,0,14,2,6,5,16,19,7,29,42,18,3,25,12,35,21,8,26,17,40,4,20,48,109,99,22,96,55,101,10,61 }, + { 12,0,1,5,3,2,4,7,27,8,38,6,40,18,16,10,20,46,9,41,23,22,79,14,62,19,37,126,88,11,92,48 }, + { 10,8,104,39,24,32,22,83,44,100,30,130,53,91,113,5,11,1,35,33,7,49,0,2,103,71,36,124,9,80,131,34 }, + { 1,7,0,14,8,34,5,25,35,26,6,63,10,123,2,16,103,19,44,32,135,121,108,80,62,30,115,94,149,144,53,18 }, + { 75,68,146,141,102,67,2,21,6,57,69,143,0,55,82,86,28,144,147,29,93,112,56,119,133,14,76,60,84,134,111,145 }, + { 10,32,115,7,8,53,1,108,30,113,94,137,100,63,90,34,130,103,121,47,44,25,104,39,24,26,85,14,49,36,22,131 }, + { 39,24,10,22,8,130,91,104,83,49,5,33,100,11,0,35,32,131,71,36,9,44,53,2,80,51,30,1,41,7,43,62 }, + { 38,36,65,105,27,72,31,79,41,131,5,48,125,39,0,16,92,46,22,13,18,84,24,37,88,2,33,74,91,71,130,49 }, + { 0,106,62,50,45,119,85,81,132,28,2,86,41,47,38,60,35,117,5,29,7,30,145,90,55,70,14,111,18,67,93,56 }, + { 0,2,5,1,3,25,19,26,4,34,29,10,22,16,8,7,24,14,48,65,53,18,6,77,44,56,72,61,121,21,136,40 }, + { 7,1,94,8,47,115,10,32,113,103,30,108,137,63,14,64,116,148,129,42,90,25,34,118,53,57,11,49,85,9,96,50 }, + { 14,0,1,26,19,5,42,2,25,24,29,22,6,44,61,16,7,96,136,3,140,34,35,55,135,18,48,77,83,4,8,10 }, + { 1,7,14,0,25,6,34,5,26,16,63,2,19,8,35,101,108,29,94,10,18,42,123,144,129,47,61,21,3,62,149,4 }, + { 12,0,2,1,28,5,6,120,7,60,40,16,18,86,27,14,21,93,8,62,41,38,3,17,4,119,99,48,19,126,10,9 }, + { 86,144,93,2,28,149,0,60,99,112,110,145,40,21,102,26,75,62,69,1,12,101,119,25,76,67,7,68,55,5,6,14 }, + { 8,30,10,32,113,49,115,137,124,103,45,90,7,139,11,1,58,53,130,94,108,100,9,63,85,125,34,47,0,24,44,104 }, + { 120,142,111,41,58,114,97,0,11,62,84,124,5,30,8,38,132,127,27,139,92,10,72,45,49,9,28,2,29,56,16,1 }, + { 8,113,30,137,7,32,10,90,94,115,1,103,108,63,47,85,49,53,11,45,34,50,14,25,9,124,100,130,139,121,42,26 }, + { 64,7,14,47,134,55,1,42,95,69,116,90,94,30,8,29,56,137,45,108,85,10,57,16,102,143,118,19,63,32,11,50 }, + { 62,132,0,119,120,41,111,86,35,28,5,84,56,38,2,93,145,60,67,12,92,27,29,72,55,117,21,24,133,149,22,45 }, + { 57,68,69,118,134,64,50,47,55,14,7,2,102,144,0,112,70,86,85,1,95,29,116,143,42,75,16,56,28,45,21,48 }, + { 0,12,2,1,5,28,6,40,60,27,7,38,16,14,86,18,93,41,62,46,99,35,8,23,3,17,22,21,10,19,79,20 }, + { 12,1,2,27,16,3,38,111,4,0,18,5,7,46,40,8,79,6,14,28,88,10,48,41,19,84,21,9,22,23,20,72 }, + { 53,103,32,7,1,100,22,63,71,44,10,115,108,24,92,104,26,30,122,94,8,39,83,34,137,135,90,91,121,5,87,47 }, + { 87,37,41,0,22,38,2,92,1,24,4,8,3,59,10,5,39,23,71,79,122,27,16,46,33,7,91,20,18,51,9,120 }, + { 1,7,8,10,0,5,35,32,53,44,14,30,2,80,25,34,6,62,26,103,16,19,63,9,149,24,121,41,22,11,113,83 }, + { 11,58,8,30,124,49,10,113,9,114,139,45,97,32,7,137,90,1,0,130,115,125,100,24,5,94,53,41,14,13,35,38 }, + { 125,105,9,36,131,49,8,130,39,11,10,5,22,38,41,104,0,31,13,24,27,16,2,72,65,91,48,32,84,18,100,74 }, + { 12,1,0,2,6,3,7,5,4,8,14,28,16,60,18,10,21,17,19,9,40,27,86,93,29,38,54,11,25,48,46,41 }, + { 84,41,38,72,92,29,111,5,65,120,79,0,27,56,48,14,132,16,119,22,86,88,46,28,62,12,1,2,93,18,24,127 }, + { 99,28,40,60,2,93,138,0,98,17,86,54,76,12,27,1,21,144,128,38,5,14,46,18,25,16,109,6,41,145,7,29 }, + { 1,63,10,32,148,14,103,34,42,7,8,108,116,53,64,96,25,121,26,94,140,0,29,19,55,24,100,136,5,4,44,115 }, + { 131,100,130,49,10,8,36,104,39,0,48,41,11,38,4,24,27,22,16,44,79,5,33,2,53,9,125,74,91,120,32,83 }, + { 36,39,131,74,4,91,22,33,125,104,130,48,10,24,16,5,49,8,100,105,79,0,9,65,71,2,18,83,31,11,19,44 }, + { 0,12,2,1,6,5,7,28,40,60,16,14,18,62,86,27,93,8,17,38,21,41,35,99,3,19,10,23,22,4,9,48 }, + { 1,7,67,14,21,147,111,55,132,119,0,8,2,76,64,16,47,84,6,18,86,95,145,10,42,29,133,5,56,134,17,72 }, + { 69,55,47,134,102,143,7,57,118,95,14,64,29,56,1,50,75,67,146,2,0,133,68,16,21,6,141,85,116,18,72,65 }, + { 1,44,7,24,83,63,34,103,22,121,53,32,25,35,0,115,108,5,14,8,10,101,94,30,2,123,110,26,137,47,90,19 }, + { 14,1,25,42,34,0,26,96,19,29,140,5,53,10,2,121,3,24,44,22,55,77,129,7,63,16,8,4,6,61,100,48 }, + { 30,90,7,8,137,94,85,1,47,113,115,108,45,139,124,11,10,32,50,58,103,14,63,64,9,116,49,42,25,148,0,53 }, + { 40,99,2,60,28,17,0,54,93,98,86,138,6,12,21,76,1,5,27,144,128,38,19,46,14,41,145,7,16,67,3,109 }, + { 45,58,30,139,90,7,85,137,97,8,124,47,1,11,106,114,50,94,0,113,10,115,14,32,9,64,108,41,49,29,62,116 }, + { 14,42,10,1,63,96,32,25,34,8,129,29,0,103,55,19,26,53,77,5,95,2,4,7,3,16,148,56,18,24,121,108 }, + { 21,2,75,86,6,76,144,28,119,99,93,147,141,67,102,145,60,132,146,128,0,82,40,138,55,111,143,17,133,112,69,14 }, + { 111,120,41,62,84,132,0,5,38,119,56,92,72,142,27,28,29,35,58,80,2,86,65,79,12,14,1,24,145,16,21,48 }, + { 146,67,141,69,133,21,6,143,57,55,111,147,56,1,14,132,7,2,134,102,0,119,29,84,76,64,86,72,28,68,47,75 }, + { 12,1,0,5,27,3,7,4,38,8,6,41,16,40,46,10,18,79,2,9,23,86,20,22,62,14,37,88,92,19,24,11 }, + { 0,12,2,1,27,5,38,28,60,6,40,7,16,46,18,14,41,99,93,62,3,79,86,23,149,8,22,35,88,17,19,10 }, + { 141,6,21,67,147,102,146,2,76,119,132,69,55,111,86,75,28,133,143,0,1,145,14,128,56,99,17,60,29,93,84,68 }, + { 21,76,1,119,86,145,2,0,14,7,6,138,146,55,17,28,132,93,67,40,60,143,29,147,111,16,69,141,5,56,19,133 }, + { 1,8,108,14,7,116,64,42,10,63,94,32,115,103,113,96,30,34,55,47,95,148,29,140,129,25,134,53,69,26,19,11 }, + { 12,1,3,5,4,2,0,7,8,38,27,16,18,6,10,20,41,40,79,46,9,23,22,88,92,37,14,24,62,19,48,99 }, + { 1,14,7,0,6,25,5,16,19,2,42,26,29,35,61,8,18,129,101,21,3,110,34,148,96,10,17,4,22,40,12,20 }, + { 0,2,5,1,3,19,22,26,16,24,29,7,14,6,4,25,18,44,8,48,12,61,20,21,10,35,65,56,23,40,17,107 }, + { 1,7,8,29,56,0,10,14,2,42,72,5,4,65,3,30,84,94,67,9,25,133,111,11,32,108,16,63,21,96,26,48 } + }; + + static inline uint32_t iabs(int32_t i) { return (i < 0) ? static_cast(-i) : static_cast(i); } + static inline uint64_t iabs(int64_t i) { return (i < 0) ? static_cast(-i) : static_cast(i); } + + static inline uint8_t to_5(uint32_t v) { v = v * 31 + 128; return (uint8_t)((v + (v >> 8)) >> 8); } + static inline uint8_t to_6(uint32_t v) { v = v * 63 + 128; return (uint8_t)((v + (v >> 8)) >> 8); } + + template inline S maximum(S a, S b) { return (a > b) ? a : b; } + template inline S maximum(S a, S b, S c) { return maximum(maximum(a, b), c); } + template inline S maximum(S a, S b, S c, S d) { return maximum(maximum(maximum(a, b), c), d); } + + template inline S minimum(S a, S b) { return (a < b) ? a : b; } + template inline S minimum(S a, S b, S c) { return minimum(minimum(a, b), c); } + template inline S minimum(S a, S b, S c, S d) { return minimum(minimum(minimum(a, b), c), d); } + + template inline T square(T a) { return a * a; } + + static inline float clampf(float value, float low, float high) { if (value < low) value = low; else if (value > high) value = high; return value; } + static inline uint8_t clamp255(int32_t i) { return (uint8_t)((i & 0xFFFFFF00U) ? (~(i >> 31)) : i); } + + template inline S clamp(S value, S low, S high) { return (value < low) ? low : ((value > high) ? high : value); } + static inline int32_t clampi(int32_t value, int32_t low, int32_t high) { if (value < low) value = low; else if (value > high) value = high; return value; } + + static inline int squarei(int a) { return a * a; } + static inline int absi(int a) { return (a < 0) ? -a : a; } + + template inline F lerp(F a, F b, F s) { return a + (b - a) * s; } + + enum class eNoClamp { cNoClamp }; + + struct color32 + { + union + { + struct + { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + }; + + uint8_t c[4]; + + uint32_t m; + }; + + color32() { } + + color32(uint32_t vr, uint32_t vg, uint32_t vb, uint32_t va) { set(vr, vg, vb, va); } + color32(eNoClamp unused, uint32_t vr, uint32_t vg, uint32_t vb, uint32_t va) { (void)unused; set_noclamp_rgba(vr, vg, vb, va); } + + void set(uint32_t vr, uint32_t vg, uint32_t vb, uint32_t va) { c[0] = static_cast(vr); c[1] = static_cast(vg); c[2] = static_cast(vb); c[3] = static_cast(va); } + + void set_noclamp_rgb(uint32_t vr, uint32_t vg, uint32_t vb) { c[0] = static_cast(vr); c[1] = static_cast(vg); c[2] = static_cast(vb); } + void set_noclamp_rgba(uint32_t vr, uint32_t vg, uint32_t vb, uint32_t va) { set(vr, vg, vb, va); } + + void set_clamped(int vr, int vg, int vb, int va) { c[0] = clamp255(vr); c[1] = clamp255(vg); c[2] = clamp255(vb); c[3] = clamp255(va); } + + uint8_t operator[] (uint32_t idx) const { assert(idx < 4); return c[idx]; } + uint8_t &operator[] (uint32_t idx) { assert(idx < 4); return c[idx]; } + + bool operator== (const color32&rhs) const { return m == rhs.m; } + + void set_rgb(const color32& other) { c[0] = static_cast(other.c[0]); c[1] = static_cast(other.c[1]); c[2] = static_cast(other.c[2]); } + + static color32 comp_min(const color32& a, const color32& b) { return color32(eNoClamp::cNoClamp, std::min(a[0], b[0]), std::min(a[1], b[1]), std::min(a[2], b[2]), std::min(a[3], b[3])); } + static color32 comp_max(const color32& a, const color32& b) { return color32(eNoClamp::cNoClamp, std::max(a[0], b[0]), std::max(a[1], b[1]), std::max(a[2], b[2]), std::max(a[3], b[3])); } + }; + + enum dxt_constants + { + cDXT1SelectorBits = 2U, cDXT1SelectorValues = 1U << cDXT1SelectorBits, cDXT1SelectorMask = cDXT1SelectorValues - 1U, + cDXT5SelectorBits = 3U, cDXT5SelectorValues = 1U << cDXT5SelectorBits, cDXT5SelectorMask = cDXT5SelectorValues - 1U, + }; + + struct bc1_block + { + enum { cTotalEndpointBytes = 2, cTotalSelectorBytes = 4 }; + + uint8_t m_low_color[cTotalEndpointBytes]; + uint8_t m_high_color[cTotalEndpointBytes]; + uint8_t m_selectors[cTotalSelectorBytes]; + + inline uint32_t get_low_color() const { return m_low_color[0] | (m_low_color[1] << 8U); } + inline uint32_t get_high_color() const { return m_high_color[0] | (m_high_color[1] << 8U); } + inline bool is_3color() const { return get_low_color() <= get_high_color(); } + inline void set_low_color(uint16_t c) { m_low_color[0] = static_cast(c & 0xFF); m_low_color[1] = static_cast((c >> 8) & 0xFF); } + inline void set_high_color(uint16_t c) { m_high_color[0] = static_cast(c & 0xFF); m_high_color[1] = static_cast((c >> 8) & 0xFF); } + inline uint32_t get_selector(uint32_t x, uint32_t y) const { assert((x < 4U) && (y < 4U)); return (m_selectors[y] >> (x * cDXT1SelectorBits)) & cDXT1SelectorMask; } + inline void set_selector(uint32_t x, uint32_t y, uint32_t val) { assert((x < 4U) && (y < 4U) && (val < 4U)); m_selectors[y] &= (~(cDXT1SelectorMask << (x * cDXT1SelectorBits))); m_selectors[y] |= (val << (x * cDXT1SelectorBits)); } + + static inline uint16_t pack_color(const color32& color, bool scaled, uint32_t bias = 127U) + { + uint32_t r = color.r, g = color.g, b = color.b; + if (scaled) + { + r = (r * 31U + bias) / 255U; + g = (g * 63U + bias) / 255U; + b = (b * 31U + bias) / 255U; + } + return static_cast(minimum(b, 31U) | (minimum(g, 63U) << 5U) | (minimum(r, 31U) << 11U)); + } + + static inline uint16_t pack_unscaled_color(uint32_t r, uint32_t g, uint32_t b) { return static_cast(b | (g << 5U) | (r << 11U)); } + + static inline void unpack_color(uint32_t c, uint32_t& r, uint32_t& g, uint32_t& b) + { + r = (c >> 11) & 31; + g = (c >> 5) & 63; + b = c & 31; + + r = (r << 3) | (r >> 2); + g = (g << 2) | (g >> 4); + b = (b << 3) | (b >> 2); + } + + static inline void unpack_color_unscaled(uint32_t c, uint32_t& r, uint32_t& g, uint32_t& b) + { + r = (c >> 11) & 31; + g = (c >> 5) & 63; + b = c & 31; + } + }; + + static const uint32_t TOTAL_ORDER_4_0_16 = 15; + static const uint32_t TOTAL_ORDER_4_1_16 = 700; + static const uint32_t TOTAL_ORDER_4_2_16 = 753; + static const uint32_t TOTAL_ORDER_4_3_16 = 515; + static uint16_t g_total_ordering4_hash[4096]; + static float g_selector_factors4[NUM_UNIQUE_TOTAL_ORDERINGS4][3]; + + static const uint32_t TOTAL_ORDER_3_0_16 = 12; + static const uint32_t TOTAL_ORDER_3_1_16 = 15; + static const uint32_t TOTAL_ORDER_3_2_16 = 89; + static uint16_t g_total_ordering3_hash[256]; + static float g_selector_factors3[NUM_UNIQUE_TOTAL_ORDERINGS3][3]; + + struct hist4 + { + uint8_t m_hist[4]; + + hist4() + { + memset(m_hist, 0, sizeof(m_hist)); + } + + hist4(uint32_t i, uint32_t j, uint32_t k, uint32_t l) + { + m_hist[0] = (uint8_t)i; + m_hist[1] = (uint8_t)j; + m_hist[2] = (uint8_t)k; + m_hist[3] = (uint8_t)l; + } + + inline bool operator== (const hist4 &h) const + { + if (m_hist[0] != h.m_hist[0]) return false; + if (m_hist[1] != h.m_hist[1]) return false; + if (m_hist[2] != h.m_hist[2]) return false; + if (m_hist[3] != h.m_hist[3]) return false; + return true; + } + + inline bool any_16() const + { + return (m_hist[0] == 16) || (m_hist[1] == 16) || (m_hist[2] == 16) || (m_hist[3] == 16); + } + + inline uint32_t lookup_total_ordering_index() const + { + if (m_hist[0] == 16) + return TOTAL_ORDER_4_0_16; + else if (m_hist[1] == 16) + return TOTAL_ORDER_4_1_16; + else if (m_hist[2] == 16) + return TOTAL_ORDER_4_2_16; + else if (m_hist[3] == 16) + return TOTAL_ORDER_4_3_16; + + // Must sum to 16, so m_hist[3] isn't needed. + return g_total_ordering4_hash[m_hist[0] | (m_hist[1] << 4) | (m_hist[2] << 8)]; + } + }; + + struct hist3 + { + uint8_t m_hist[3]; + + hist3() + { + memset(m_hist, 0, sizeof(m_hist)); + } + + hist3(uint32_t i, uint32_t j, uint32_t k) + { + m_hist[0] = (uint8_t)i; + m_hist[1] = (uint8_t)j; + m_hist[2] = (uint8_t)k; + } + + inline bool operator== (const hist3 &h) const + { + if (m_hist[0] != h.m_hist[0]) return false; + if (m_hist[1] != h.m_hist[1]) return false; + if (m_hist[2] != h.m_hist[2]) return false; + return true; + } + + inline bool any_16() const + { + return (m_hist[0] == 16) || (m_hist[1] == 16) || (m_hist[2] == 16); + } + + inline uint32_t lookup_total_ordering_index() const + { + if (m_hist[0] == 16) + return TOTAL_ORDER_3_0_16; + else if (m_hist[1] == 16) + return TOTAL_ORDER_3_1_16; + else if (m_hist[2] == 16) + return TOTAL_ORDER_3_2_16; + + // Must sum to 16, so m_hist[2] isn't needed. + return g_total_ordering3_hash[m_hist[0] | (m_hist[1] << 4)]; + } + }; + + struct bc1_match_entry + { + uint8_t m_hi; + uint8_t m_lo; + uint8_t m_e; + }; + + static bc1_approx_mode g_bc1_approx_mode; + static bc1_match_entry g_bc1_match5_equals_1[256], g_bc1_match6_equals_1[256]; + static bc1_match_entry g_bc1_match5_half[256], g_bc1_match6_half[256]; + + static inline int scale_5_to_8(int v) { return (v << 3) | (v >> 2); } + static inline int scale_6_to_8(int v) { return (v << 2) | (v >> 4); } + + // v0, v1 = unexpanded DXT1 endpoint values (5/6-bits) + // c0, c1 = expanded DXT1 endpoint values (8-bits) + static inline int interp_5_6_ideal(int c0, int c1) { assert(c0 < 256 && c1 < 256); return (c0 * 2 + c1) / 3; } + static inline int interp_5_6_ideal_round(int c0, int c1) { assert(c0 < 256 && c1 < 256); return (c0 * 2 + c1 + 1) / 3; } + static inline int interp_half_5_6_ideal(int c0, int c1) { assert(c0 < 256 && c1 < 256); return (c0 + c1) / 2; } + + static inline int interp_5_nv(int v0, int v1) { assert(v0 < 32 && v1 < 32); return ((2 * v0 + v1) * 22) / 8; } + static inline int interp_6_nv(int c0, int c1) { assert(c0 < 256 && c1 < 256); const int gdiff = c1 - c0; return (256 * c0 + (gdiff / 4) + 128 + gdiff * 80) / 256; } + + static inline int interp_half_5_nv(int v0, int v1) { assert(v0 < 32 && v1 < 32); return ((v0 + v1) * 33) / 8; } + static inline int interp_half_6_nv(int c0, int c1) { assert(c0 < 256 && c1 < 256); const int gdiff = c1 - c0; return (256 * c0 + gdiff / 4 + 128 + gdiff * 128) / 256; } + + static inline int interp_5_6_amd(int c0, int c1) { assert(c0 < 256 && c1 < 256); return (c0 * 43 + c1 * 21 + 32) >> 6; } + static inline int interp_half_5_6_amd(int c0, int c1) { assert(c0 < 256 && c1 < 256); return (c0 + c1 + 1) >> 1; } + + static inline int interp_5(int v0, int v1, int c0, int c1, bc1_approx_mode mode) + { + assert(scale_5_to_8(v0) == c0 && scale_5_to_8(v1) == c1); + switch (mode) + { + case bc1_approx_mode::cBC1NVidia: return interp_5_nv(v0, v1); + case bc1_approx_mode::cBC1AMD: return interp_5_6_amd(c0, c1); + default: + case bc1_approx_mode::cBC1Ideal: return interp_5_6_ideal(c0, c1); + case bc1_approx_mode::cBC1IdealRound4: return interp_5_6_ideal_round(c0, c1); + } + } + + static inline int interp_6(int v0, int v1, int c0, int c1, bc1_approx_mode mode) + { + (void)v0; (void)v1; + assert(scale_6_to_8(v0) == c0 && scale_6_to_8(v1) == c1); + switch (mode) + { + case bc1_approx_mode::cBC1NVidia: return interp_6_nv(c0, c1); + case bc1_approx_mode::cBC1AMD: return interp_5_6_amd(c0, c1); + default: + case bc1_approx_mode::cBC1Ideal: return interp_5_6_ideal(c0, c1); + case bc1_approx_mode::cBC1IdealRound4: return interp_5_6_ideal_round(c0, c1); + } + } + + static inline int interp_half_5(int v0, int v1, int c0, int c1, bc1_approx_mode mode) + { + assert(scale_5_to_8(v0) == c0 && scale_5_to_8(v1) == c1); + switch (mode) + { + case bc1_approx_mode::cBC1NVidia: return interp_half_5_nv(v0, v1); + case bc1_approx_mode::cBC1AMD: return interp_half_5_6_amd(c0, c1); + case bc1_approx_mode::cBC1Ideal: + case bc1_approx_mode::cBC1IdealRound4: + default: + return interp_half_5_6_ideal(c0, c1); + } + } + + static inline int interp_half_6(int v0, int v1, int c0, int c1, bc1_approx_mode mode) + { + (void)v0; (void)v1; + assert(scale_6_to_8(v0) == c0 && scale_6_to_8(v1) == c1); + switch (mode) + { + case bc1_approx_mode::cBC1NVidia: return interp_half_6_nv(c0, c1); + case bc1_approx_mode::cBC1AMD: return interp_half_5_6_amd(c0, c1); + case bc1_approx_mode::cBC1Ideal: + case bc1_approx_mode::cBC1IdealRound4: + default: + return interp_half_5_6_ideal(c0, c1); + } + } + + static void prepare_bc1_single_color_table_half(bc1_match_entry* pTable, const uint8_t* pExpand, int size, bc1_approx_mode mode) + { + for (int i = 0; i < 256; i++) + { + int lowest_e = 256; + for (int lo = 0; lo < size; lo++) + { + const int lo_e = pExpand[lo]; + + for (int hi = 0; hi < size; hi++) + { + const int hi_e = pExpand[hi]; + + const int v = (size == 32) ? interp_half_5(hi, lo, hi_e, lo_e, mode) : interp_half_6(hi, lo, hi_e, lo_e, mode); + + int e = iabs(v - i); + + // We only need to factor in 3% error in BC1 ideal mode. + if ((mode == bc1_approx_mode::cBC1Ideal) || (mode == bc1_approx_mode::cBC1IdealRound4)) + e += (iabs(hi_e - lo_e) * 3) / 100; + + // Favor equal endpoints, for lower error on actual GPU's which approximate the interpolation. + if ((e < lowest_e) || ((e == lowest_e) && (lo == hi))) + { + pTable[i].m_hi = static_cast(hi); + pTable[i].m_lo = static_cast(lo); + + assert(e <= UINT8_MAX); + pTable[i].m_e = static_cast(e); + + lowest_e = e; + } + + } // hi + } // lo + } + } + + static void prepare_bc1_single_color_table(bc1_match_entry* pTable, const uint8_t* pExpand, int size, bc1_approx_mode mode) + { + for (int i = 0; i < 256; i++) + { + int lowest_e = 256; + for (int lo = 0; lo < size; lo++) + { + const int lo_e = pExpand[lo]; + + for (int hi = 0; hi < size; hi++) + { + const int hi_e = pExpand[hi]; + + const int v = (size == 32) ? interp_5(hi, lo, hi_e, lo_e, mode) : interp_6(hi, lo, hi_e, lo_e, mode); + + int e = iabs(v - i); + + if ((mode == bc1_approx_mode::cBC1Ideal) || (mode == bc1_approx_mode::cBC1IdealRound4)) + e += (iabs(hi_e - lo_e) * 3) / 100; + + // Favor equal endpoints, for lower error on actual GPU's which approximate the interpolation. + if ((e < lowest_e) || ((e == lowest_e) && (lo == hi))) + { + pTable[i].m_hi = static_cast(hi); + pTable[i].m_lo = static_cast(lo); + + assert(e <= UINT8_MAX); + pTable[i].m_e = static_cast(e); + + lowest_e = e; + } + + } // hi + } // lo + } + } + + // This table is: 9 * (w * w), 9 * ((1.0f - w) * w), 9 * ((1.0f - w) * (1.0f - w)) + // where w is [0,1/3,2/3,1]. 9 is the perfect multiplier. + static const uint32_t g_weight_vals4[4] = { 0x000009, 0x010204, 0x040201, 0x090000 }; + + // multiplier is 4 for 3-color + static const uint32_t g_weight_vals3[3] = { 0x000004, 0x040000, 0x010101 }; + + static inline void compute_selector_factors4(const hist4 &h, float &iz00, float &iz10, float &iz11) + { + uint32_t weight_accum = 0; + for (uint32_t sel = 0; sel < 4; sel++) + weight_accum += g_weight_vals4[sel] * h.m_hist[sel]; + + float z00 = (float)((weight_accum >> 16) & 0xFF); + float z10 = (float)((weight_accum >> 8) & 0xFF); + float z11 = (float)(weight_accum & 0xFF); + float z01 = z10; + + float det = z00 * z11 - z01 * z10; + if (fabs(det) < 1e-8f) + det = 0.0f; + else + det = (3.0f / 255.0f) / det; + + iz00 = z11 * det; + iz10 = -z10 * det; + iz11 = z00 * det; + } + + static inline void compute_selector_factors3(const hist3 &h, float &iz00, float &iz10, float &iz11) + { + uint32_t weight_accum = 0; + for (uint32_t sel = 0; sel < 3; sel++) + weight_accum += g_weight_vals3[sel] * h.m_hist[sel]; + + float z00 = (float)((weight_accum >> 16) & 0xFF); + float z10 = (float)((weight_accum >> 8) & 0xFF); + float z11 = (float)(weight_accum & 0xFF); + float z01 = z10; + + float det = z00 * z11 - z01 * z10; + if (fabs(det) < 1e-8f) + det = 0.0f; + else + det = (2.0f / 255.0f) / det; + + iz00 = z11 * det; + iz10 = -z10 * det; + iz11 = z00 * det; + } + + static bool g_initialized; + + void init(bc1_approx_mode mode) + { + g_bc1_approx_mode = mode; + + uint8_t bc1_expand5[32]; + for (int i = 0; i < 32; i++) + bc1_expand5[i] = static_cast((i << 3) | (i >> 2)); + prepare_bc1_single_color_table(g_bc1_match5_equals_1, bc1_expand5, 32, mode); + prepare_bc1_single_color_table_half(g_bc1_match5_half, bc1_expand5, 32, mode); + + uint8_t bc1_expand6[64]; + for (int i = 0; i < 64; i++) + bc1_expand6[i] = static_cast((i << 2) | (i >> 4)); + prepare_bc1_single_color_table(g_bc1_match6_equals_1, bc1_expand6, 64, mode); + prepare_bc1_single_color_table_half(g_bc1_match6_half, bc1_expand6, 64, mode); + + for (uint32_t i = 0; i < NUM_UNIQUE_TOTAL_ORDERINGS4; i++) + { + hist4 h; + h.m_hist[0] = (uint8_t)g_unique_total_orders4[i][0]; + h.m_hist[1] = (uint8_t)g_unique_total_orders4[i][1]; + h.m_hist[2] = (uint8_t)g_unique_total_orders4[i][2]; + h.m_hist[3] = (uint8_t)g_unique_total_orders4[i][3]; + + if (!h.any_16()) + { + const uint32_t index = h.m_hist[0] | (h.m_hist[1] << 4) | (h.m_hist[2] << 8); + assert(index < 4096); + g_total_ordering4_hash[index] = (uint16_t)i; + } + + compute_selector_factors4(h, g_selector_factors4[i][0], g_selector_factors4[i][1], g_selector_factors4[i][2]); + } + + for (uint32_t i = 0; i < NUM_UNIQUE_TOTAL_ORDERINGS3; i++) + { + hist3 h; + h.m_hist[0] = (uint8_t)g_unique_total_orders3[i][0]; + h.m_hist[1] = (uint8_t)g_unique_total_orders3[i][1]; + h.m_hist[2] = (uint8_t)g_unique_total_orders3[i][2]; + + if (!h.any_16()) + { + const uint32_t index = h.m_hist[0] | (h.m_hist[1] << 4); + assert(index < 256); + g_total_ordering3_hash[index] = (uint16_t)i; + } + + compute_selector_factors3(h, g_selector_factors3[i][0], g_selector_factors3[i][1], g_selector_factors3[i][2]); + } + + g_initialized = true; + } + + void encode_bc1_solid_block(void* pDst, uint32_t fr, uint32_t fg, uint32_t fb, bool allow_3color) + { + bc1_block* pDst_block = static_cast(pDst); + + uint32_t mask = 0xAA; + int max16 = -1, min16 = 0; + + if (allow_3color) + { + const uint32_t err4 = g_bc1_match5_equals_1[fr].m_e + g_bc1_match6_equals_1[fg].m_e + g_bc1_match5_equals_1[fb].m_e; + const uint32_t err3 = g_bc1_match5_half[fr].m_e + g_bc1_match6_half[fg].m_e + g_bc1_match5_half[fb].m_e; + + if (err3 < err4) + { + max16 = (g_bc1_match5_half[fr].m_hi << 11) | (g_bc1_match6_half[fg].m_hi << 5) | g_bc1_match5_half[fb].m_hi; + min16 = (g_bc1_match5_half[fr].m_lo << 11) | (g_bc1_match6_half[fg].m_lo << 5) | g_bc1_match5_half[fb].m_lo; + + if (max16 > min16) + std::swap(max16, min16); + } + } + + if (max16 == -1) + { + max16 = (g_bc1_match5_equals_1[fr].m_hi << 11) | (g_bc1_match6_equals_1[fg].m_hi << 5) | g_bc1_match5_equals_1[fb].m_hi; + min16 = (g_bc1_match5_equals_1[fr].m_lo << 11) | (g_bc1_match6_equals_1[fg].m_lo << 5) | g_bc1_match5_equals_1[fb].m_lo; + + if (min16 == max16) + { + // Always forbid 3 color blocks + // This is to guarantee that BC3 blocks never use punchthrough alpha (3 color) mode, which isn't supported on some (all?) GPU's. + mask = 0; + + // Make l > h + if (min16 > 0) + min16--; + else + { + // l = h = 0 + assert(min16 == max16 && max16 == 0); + + max16 = 1; + min16 = 0; + mask = 0x55; + } + + assert(max16 > min16); + } + + if (max16 < min16) + { + std::swap(max16, min16); + mask ^= 0x55; + } + } + + pDst_block->set_low_color(static_cast(max16)); + pDst_block->set_high_color(static_cast(min16)); + pDst_block->m_selectors[0] = static_cast(mask); + pDst_block->m_selectors[1] = static_cast(mask); + pDst_block->m_selectors[2] = static_cast(mask); + pDst_block->m_selectors[3] = static_cast(mask); + } + + static const float g_midpoint5[32] = { .015686f, .047059f, .078431f, .111765f, .145098f, .176471f, .207843f, .241176f, .274510f, .305882f, .337255f, .370588f, .403922f, .435294f, .466667f, .5f, .533333f, .564706f, .596078f, .629412f, .662745f, .694118f, .725490f, .758824f, .792157f, .823529f, .854902f, .888235f, .921569f, .952941f, .984314f, 1e+37f }; + static const float g_midpoint6[64] = { .007843f, .023529f, .039216f, .054902f, .070588f, .086275f, .101961f, .117647f, .133333f, .149020f, .164706f, .180392f, .196078f, .211765f, .227451f, .245098f, .262745f, .278431f, .294118f, .309804f, .325490f, .341176f, .356863f, .372549f, .388235f, .403922f, .419608f, .435294f, .450980f, .466667f, .482353f, .500000f, .517647f, .533333f, .549020f, .564706f, .580392f, .596078f, .611765f, .627451f, .643137f, .658824f, .674510f, .690196f, .705882f, .721569f, .737255f, .754902f, .772549f, .788235f, .803922f, .819608f, .835294f, .850980f, .866667f, .882353f, .898039f, .913725f, .929412f, .945098f, .960784f, .976471f, .992157f, 1e+37f }; + + struct vec3F { float c[3]; }; + + static inline void compute_least_squares_endpoints4_rgb( + vec3F* pXl, vec3F* pXh, + int total_r, int total_g, int total_b, + float iz00, float iz10, float iz11, + uint32_t s, const uint32_t r_sum[17], const uint32_t g_sum[17], const uint32_t b_sum[17]) + { + const float iz01 = iz10; + + const uint32_t f1 = g_unique_total_orders4[s][0]; + const uint32_t f2 = g_unique_total_orders4[s][0] + g_unique_total_orders4[s][1]; + const uint32_t f3 = g_unique_total_orders4[s][0] + g_unique_total_orders4[s][1] + g_unique_total_orders4[s][2]; + uint32_t uq00_r = (r_sum[f2] - r_sum[f1]) + (r_sum[f3] - r_sum[f2]) * 2 + (r_sum[16] - r_sum[f3]) * 3; + uint32_t uq00_g = (g_sum[f2] - g_sum[f1]) + (g_sum[f3] - g_sum[f2]) * 2 + (g_sum[16] - g_sum[f3]) * 3; + uint32_t uq00_b = (b_sum[f2] - b_sum[f1]) + (b_sum[f3] - b_sum[f2]) * 2 + (b_sum[16] - b_sum[f3]) * 3; + + float q10_r = (float)(total_r * 3 - uq00_r); + float q10_g = (float)(total_g * 3 - uq00_g); + float q10_b = (float)(total_b * 3 - uq00_b); + + pXl->c[0] = iz00 * (float)uq00_r + iz01 * q10_r; + pXh->c[0] = iz10 * (float)uq00_r + iz11 * q10_r; + + pXl->c[1] = iz00 * (float)uq00_g + iz01 * q10_g; + pXh->c[1] = iz10 * (float)uq00_g + iz11 * q10_g; + + pXl->c[2] = iz00 * (float)uq00_b + iz01 * q10_b; + pXh->c[2] = iz10 * (float)uq00_b + iz11 * q10_b; + } + + static inline bool compute_least_squares_endpoints4_rgb(const color32* pColors, const uint8_t* pSelectors, vec3F* pXl, vec3F* pXh, int total_r, int total_g, int total_b) + { + uint32_t uq00_r = 0, uq00_g = 0, uq00_b = 0; + uint32_t weight_accum = 0; + for (uint32_t i = 0; i < 16; i++) + { + const uint8_t r = pColors[i].c[0], g = pColors[i].c[1], b = pColors[i].c[2]; + const uint8_t sel = pSelectors[i]; + + weight_accum += g_weight_vals4[sel]; + uq00_r += sel * r; + uq00_g += sel * g; + uq00_b += sel * b; + } + + int q10_r = total_r * 3 - uq00_r; + int q10_g = total_g * 3 - uq00_g; + int q10_b = total_b * 3 - uq00_b; + + float z00 = (float)((weight_accum >> 16) & 0xFF); + float z10 = (float)((weight_accum >> 8) & 0xFF); + float z11 = (float)(weight_accum & 0xFF); + float z01 = z10; + + float det = z00 * z11 - z01 * z10; + if (fabs(det) < 1e-8f) + return false; + + det = (3.0f / 255.0f) / det; + + float iz00, iz01, iz10, iz11; + iz00 = z11 * det; + iz01 = -z01 * det; + iz10 = -z10 * det; + iz11 = z00 * det; + + pXl->c[0] = iz00 * (float)uq00_r + iz01 * q10_r; + pXh->c[0] = iz10 * (float)uq00_r + iz11 * q10_r; + + pXl->c[1] = iz00 * (float)uq00_g + iz01 * q10_g; + pXh->c[1] = iz10 * (float)uq00_g + iz11 * q10_g; + + pXl->c[2] = iz00 * (float)uq00_b + iz01 * q10_b; + pXh->c[2] = iz10 * (float)uq00_b + iz11 * q10_b; + + return true; + } + + static inline void compute_least_squares_endpoints3_rgb( + vec3F* pXl, vec3F* pXh, + int total_r, int total_g, int total_b, + float iz00, float iz10, float iz11, + uint32_t s, const uint32_t r_sum[17], const uint32_t g_sum[17], const uint32_t b_sum[17]) + { + const float iz01 = iz10; + + // Compensates for BC1 3-color ordering, which is selector 0, 2, 1 + const uint32_t f1 = g_unique_total_orders3[s][0]; + const uint32_t f2 = g_unique_total_orders3[s][0] + g_unique_total_orders3[s][2]; + uint32_t uq00_r = (r_sum[16] - r_sum[f2]) * 2 + (r_sum[f2] - r_sum[f1]); + uint32_t uq00_g = (g_sum[16] - g_sum[f2]) * 2 + (g_sum[f2] - g_sum[f1]); + uint32_t uq00_b = (b_sum[16] - b_sum[f2]) * 2 + (b_sum[f2] - b_sum[f1]); + + float q10_r = (float)(total_r * 2 - uq00_r); + float q10_g = (float)(total_g * 2 - uq00_g); + float q10_b = (float)(total_b * 2 - uq00_b); + + pXl->c[0] = iz00 * (float)uq00_r + iz01 * q10_r; + pXh->c[0] = iz10 * (float)uq00_r + iz11 * q10_r; + + pXl->c[1] = iz00 * (float)uq00_g + iz01 * q10_g; + pXh->c[1] = iz10 * (float)uq00_g + iz11 * q10_g; + + pXl->c[2] = iz00 * (float)uq00_b + iz01 * q10_b; + pXh->c[2] = iz10 * (float)uq00_b + iz11 * q10_b; + } + + static inline bool compute_least_squares_endpoints3_rgb(bool use_black, const color32* pColors, const uint8_t* pSelectors, vec3F* pXl, vec3F* pXh) + { + int uq00_r = 0, uq00_g = 0, uq00_b = 0; + uint32_t weight_accum = 0; + int total_r = 0, total_g = 0, total_b = 0; + for (uint32_t i = 0; i < 16; i++) + { + const uint8_t r = pColors[i].c[0], g = pColors[i].c[1], b = pColors[i].c[2]; + if (use_black) + { + if ((r | g | b) < 4) + continue; + } + + const uint8_t sel = pSelectors[i]; + assert(sel <= 3); + if (sel == 3) + continue; + + weight_accum += g_weight_vals3[sel]; + + static const uint8_t s_tran[3] = { 0, 2, 1 }; + const uint8_t tsel = s_tran[sel]; + uq00_r += tsel * r; + uq00_g += tsel * g; + uq00_b += tsel * b; + + total_r += r; + total_g += g; + total_b += b; + } + + int q10_r = total_r * 2 - uq00_r; + int q10_g = total_g * 2 - uq00_g; + int q10_b = total_b * 2 - uq00_b; + + float z00 = (float)((weight_accum >> 16) & 0xFF); + float z10 = (float)((weight_accum >> 8) & 0xFF); + float z11 = (float)(weight_accum & 0xFF); + float z01 = z10; + + float det = z00 * z11 - z01 * z10; + if (fabs(det) < 1e-8f) + return false; + + det = (2.0f / 255.0f) / det; + + float iz00, iz01, iz10, iz11; + iz00 = z11 * det; + iz01 = -z01 * det; + iz10 = -z10 * det; + iz11 = z00 * det; + + pXl->c[0] = iz00 * (float)uq00_r + iz01 * q10_r; + pXh->c[0] = iz10 * (float)uq00_r + iz11 * q10_r; + + pXl->c[1] = iz00 * (float)uq00_g + iz01 * q10_g; + pXh->c[1] = iz10 * (float)uq00_g + iz11 * q10_g; + + pXl->c[2] = iz00 * (float)uq00_b + iz01 * q10_b; + pXh->c[2] = iz10 * (float)uq00_b + iz11 * q10_b; + + return true; + } + + static inline void bc1_get_block_colors4(uint32_t block_r[4], uint32_t block_g[4], uint32_t block_b[4], uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb) + { + block_r[0] = (lr << 3) | (lr >> 2); block_g[0] = (lg << 2) | (lg >> 4); block_b[0] = (lb << 3) | (lb >> 2); + block_r[3] = (hr << 3) | (hr >> 2); block_g[3] = (hg << 2) | (hg >> 4); block_b[3] = (hb << 3) | (hb >> 2); + + if (g_bc1_approx_mode == bc1_approx_mode::cBC1Ideal) + { + block_r[1] = (block_r[0] * 2 + block_r[3]) / 3; block_g[1] = (block_g[0] * 2 + block_g[3]) / 3; block_b[1] = (block_b[0] * 2 + block_b[3]) / 3; + block_r[2] = (block_r[3] * 2 + block_r[0]) / 3; block_g[2] = (block_g[3] * 2 + block_g[0]) / 3; block_b[2] = (block_b[3] * 2 + block_b[0]) / 3; + } + else if (g_bc1_approx_mode == bc1_approx_mode::cBC1IdealRound4) + { + block_r[1] = (block_r[0] * 2 + block_r[3] + 1) / 3; block_g[1] = (block_g[0] * 2 + block_g[3] + 1) / 3; block_b[1] = (block_b[0] * 2 + block_b[3] + 1) / 3; + block_r[2] = (block_r[3] * 2 + block_r[0] + 1) / 3; block_g[2] = (block_g[3] * 2 + block_g[0] + 1) / 3; block_b[2] = (block_b[3] * 2 + block_b[0] + 1) / 3; + } + else if (g_bc1_approx_mode == bc1_approx_mode::cBC1AMD) + { + block_r[1] = interp_5_6_amd(block_r[0], block_r[3]); block_g[1] = interp_5_6_amd(block_g[0], block_g[3]); block_b[1] = interp_5_6_amd(block_b[0], block_b[3]); + block_r[2] = interp_5_6_amd(block_r[3], block_r[0]); block_g[2] = interp_5_6_amd(block_g[3], block_g[0]); block_b[2] = interp_5_6_amd(block_b[3], block_b[0]); + } + else + { + block_r[1] = interp_5_nv(lr, hr); block_g[1] = interp_6_nv(block_g[0], block_g[3]); block_b[1] = interp_5_nv(lb, hb); + block_r[2] = interp_5_nv(hr, lr); block_g[2] = interp_6_nv(block_g[3], block_g[0]); block_b[2] = interp_5_nv(hb, lb); + } + } + + static inline void bc1_get_block_colors3(uint32_t block_r[3], uint32_t block_g[3], uint32_t block_b[3], uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb) + { + block_r[0] = (lr << 3) | (lr >> 2); block_g[0] = (lg << 2) | (lg >> 4); block_b[0] = (lb << 3) | (lb >> 2); + block_r[1] = (hr << 3) | (hr >> 2); block_g[1] = (hg << 2) | (hg >> 4); block_b[1] = (hb << 3) | (hb >> 2); + + if ((g_bc1_approx_mode == bc1_approx_mode::cBC1Ideal) || (g_bc1_approx_mode == bc1_approx_mode::cBC1IdealRound4)) + { + block_r[2] = (block_r[0] + block_r[1]) / 2; block_g[2] = (block_g[0] + block_g[1]) / 2; block_b[2] = (block_b[0] + block_b[1]) / 2; + } + else if (g_bc1_approx_mode == bc1_approx_mode::cBC1AMD) + { + block_r[2] = interp_half_5_6_amd(block_r[0], block_r[1]); block_g[2] = interp_half_5_6_amd(block_g[0], block_g[1]); block_b[2] = interp_half_5_6_amd(block_b[0], block_b[1]); + } + else + { + block_r[2] = interp_half_5_nv(lr, hr); block_g[2] = interp_half_6_nv(block_g[0], block_g[1]); block_b[2] = interp_half_5_nv(lb, hb); + } + } + + static inline void bc1_find_sels4_noerr(const color32* pSrc_pixels, uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb, uint8_t sels[16]) + { + uint32_t block_r[4], block_g[4], block_b[4]; + bc1_get_block_colors4(block_r, block_g, block_b, lr, lg, lb, hr, hg, hb); + + int ar = block_r[3] - block_r[0], ag = block_g[3] - block_g[0], ab = block_b[3] - block_b[0]; + + int dots[4]; + for (uint32_t i = 0; i < 4; i++) + dots[i] = (int)block_r[i] * ar + (int)block_g[i] * ag + (int)block_b[i] * ab; + + int t0 = dots[0] + dots[1], t1 = dots[1] + dots[2], t2 = dots[2] + dots[3]; + + ar *= 2; ag *= 2; ab *= 2; + + static const uint8_t s_sels[4] = { 3, 2, 1, 0 }; + + for (uint32_t i = 0; i < 16; i += 4) + { + const int d0 = pSrc_pixels[i + 0].r * ar + pSrc_pixels[i + 0].g * ag + pSrc_pixels[i + 0].b * ab; + const int d1 = pSrc_pixels[i + 1].r * ar + pSrc_pixels[i + 1].g * ag + pSrc_pixels[i + 1].b * ab; + const int d2 = pSrc_pixels[i + 2].r * ar + pSrc_pixels[i + 2].g * ag + pSrc_pixels[i + 2].b * ab; + const int d3 = pSrc_pixels[i + 3].r * ar + pSrc_pixels[i + 3].g * ag + pSrc_pixels[i + 3].b * ab; + + sels[i + 0] = s_sels[(d0 <= t0) + (d0 < t1) + (d0 < t2)]; + sels[i + 1] = s_sels[(d1 <= t0) + (d1 < t1) + (d1 < t2)]; + sels[i + 2] = s_sels[(d2 <= t0) + (d2 < t1) + (d2 < t2)]; + sels[i + 3] = s_sels[(d3 <= t0) + (d3 < t1) + (d3 < t2)]; + } + } + + static inline uint32_t bc1_find_sels4_fasterr(const color32* pSrc_pixels, uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb, uint8_t sels[16], uint32_t cur_err) + { + uint32_t block_r[4], block_g[4], block_b[4]; + bc1_get_block_colors4(block_r, block_g, block_b, lr, lg, lb, hr, hg, hb); + + int ar = block_r[3] - block_r[0], ag = block_g[3] - block_g[0], ab = block_b[3] - block_b[0]; + + int dots[4]; + for (uint32_t i = 0; i < 4; i++) + dots[i] = (int)block_r[i] * ar + (int)block_g[i] * ag + (int)block_b[i] * ab; + + int t0 = dots[0] + dots[1], t1 = dots[1] + dots[2], t2 = dots[2] + dots[3]; + + ar *= 2; ag *= 2; ab *= 2; + + static const uint8_t s_sels[4] = { 3, 2, 1, 0 }; + + uint32_t total_err = 0; + + for (uint32_t i = 0; i < 16; i += 4) + { + const int d0 = pSrc_pixels[i + 0].r * ar + pSrc_pixels[i + 0].g * ag + pSrc_pixels[i + 0].b * ab; + const int d1 = pSrc_pixels[i + 1].r * ar + pSrc_pixels[i + 1].g * ag + pSrc_pixels[i + 1].b * ab; + const int d2 = pSrc_pixels[i + 2].r * ar + pSrc_pixels[i + 2].g * ag + pSrc_pixels[i + 2].b * ab; + const int d3 = pSrc_pixels[i + 3].r * ar + pSrc_pixels[i + 3].g * ag + pSrc_pixels[i + 3].b * ab; + + uint8_t sel0 = s_sels[(d0 <= t0) + (d0 < t1) + (d0 < t2)]; + uint8_t sel1 = s_sels[(d1 <= t0) + (d1 < t1) + (d1 < t2)]; + uint8_t sel2 = s_sels[(d2 <= t0) + (d2 < t1) + (d2 < t2)]; + uint8_t sel3 = s_sels[(d3 <= t0) + (d3 < t1) + (d3 < t2)]; + + sels[i + 0] = sel0; + sels[i + 1] = sel1; + sels[i + 2] = sel2; + sels[i + 3] = sel3; + + total_err += squarei(pSrc_pixels[i + 0].r - block_r[sel0]) + squarei(pSrc_pixels[i + 0].g - block_g[sel0]) + squarei(pSrc_pixels[i + 0].b - block_b[sel0]); + total_err += squarei(pSrc_pixels[i + 1].r - block_r[sel1]) + squarei(pSrc_pixels[i + 1].g - block_g[sel1]) + squarei(pSrc_pixels[i + 1].b - block_b[sel1]); + total_err += squarei(pSrc_pixels[i + 2].r - block_r[sel2]) + squarei(pSrc_pixels[i + 2].g - block_g[sel2]) + squarei(pSrc_pixels[i + 2].b - block_b[sel2]); + total_err += squarei(pSrc_pixels[i + 3].r - block_r[sel3]) + squarei(pSrc_pixels[i + 3].g - block_g[sel3]) + squarei(pSrc_pixels[i + 3].b - block_b[sel3]); + + if (total_err >= cur_err) + break; + } + + return total_err; + } + + static inline uint32_t bc1_find_sels4_check2_err(const color32* pSrc_pixels, uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb, uint8_t sels[16], uint32_t cur_err) + { + uint32_t block_r[4], block_g[4], block_b[4]; + bc1_get_block_colors4(block_r, block_g, block_b, lr, lg, lb, hr, hg, hb); + + int dr = block_r[3] - block_r[0], dg = block_g[3] - block_g[0], db = block_b[3] - block_b[0]; + + const float f = 4.0f / (float)(squarei(dr) + squarei(dg) + squarei(db) + .00000125f); + + uint32_t total_err = 0; + + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r; + const int g = pSrc_pixels[i].g; + const int b = pSrc_pixels[i].b; + + int sel = (int)((float)((r - (int)block_r[0]) * dr + (g - (int)block_g[0]) * dg + (b - (int)block_b[0]) * db) * f + .5f); + sel = clampi(sel, 1, 3); + + uint32_t err0 = squarei((int)block_r[sel - 1] - (int)r) + squarei((int)block_g[sel - 1] - (int)g) + squarei((int)block_b[sel - 1] - (int)b); + uint32_t err1 = squarei((int)block_r[sel] - (int)r) + squarei((int)block_g[sel] - (int)g) + squarei((int)block_b[sel] - (int)b); + + int best_sel = sel; + uint32_t best_err = err1; + if (err0 == err1) + { + // Prefer non-interpolation + if ((best_sel - 1) == 0) + best_sel = 0; + } + else if (err0 < best_err) + { + best_sel = sel - 1; + best_err = err0; + } + + total_err += best_err; + + if (total_err >= cur_err) + break; + + sels[i] = (uint8_t)best_sel; + } + return total_err; + } + + static inline uint32_t bc1_find_sels4_fullerr(const color32* pSrc_pixels, uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb, uint8_t sels[16], uint32_t cur_err) + { + uint32_t block_r[4], block_g[4], block_b[4]; + bc1_get_block_colors4(block_r, block_g, block_b, lr, lg, lb, hr, hg, hb); + + uint32_t total_err = 0; + + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r; + const int g = pSrc_pixels[i].g; + const int b = pSrc_pixels[i].b; + + uint32_t best_err = squarei((int)block_r[0] - (int)r) + squarei((int)block_g[0] - (int)g) + squarei((int)block_b[0] - (int)b); + uint8_t best_sel = 0; + + for (uint32_t j = 1; (j < 4) && best_err; j++) + { + uint32_t err = squarei((int)block_r[j] - (int)r) + squarei((int)block_g[j] - (int)g) + squarei((int)block_b[j] - (int)b); + if ((err < best_err) || ((err == best_err) && (j == 3))) + { + best_err = err; + best_sel = (uint8_t)j; + } + } + + total_err += best_err; + + if (total_err >= cur_err) + break; + + sels[i] = (uint8_t)best_sel; + } + return total_err; + } + + static inline uint32_t bc1_find_sels4(uint32_t flags, const color32* pSrc_pixels, uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb, uint8_t sels[16], uint32_t cur_err) + { + uint32_t err; + + if (flags & cEncodeBC1UseFasterMSEEval) + err = bc1_find_sels4_fasterr(pSrc_pixels, lr, lg, lb, hr, hg, hb, sels, cur_err); + else if (flags & cEncodeBC1UseFullMSEEval) + err = bc1_find_sels4_fullerr(pSrc_pixels, lr, lg, lb, hr, hg, hb, sels, cur_err); + else + err = bc1_find_sels4_check2_err(pSrc_pixels, lr, lg, lb, hr, hg, hb, sels, cur_err); + + return err; + } + + static inline uint32_t bc1_find_sels3_fullerr(bool use_black, const color32* pSrc_pixels, uint32_t lr, uint32_t lg, uint32_t lb, uint32_t hr, uint32_t hg, uint32_t hb, uint8_t sels[16], uint32_t cur_err) + { + uint32_t block_r[3], block_g[3], block_b[3]; + bc1_get_block_colors3(block_r, block_g, block_b, lr, lg, lb, hr, hg, hb); + + uint32_t total_err = 0; + + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r; + const int g = pSrc_pixels[i].g; + const int b = pSrc_pixels[i].b; + + uint32_t best_err = squarei((int)block_r[0] - (int)r) + squarei((int)block_g[0] - (int)g) + squarei((int)block_b[0] - (int)b); + uint32_t best_sel = 0; + + uint32_t err1 = squarei((int)block_r[1] - (int)r) + squarei((int)block_g[1] - (int)g) + squarei((int)block_b[1] - (int)b); + if (err1 < best_err) + { + best_err = err1; + best_sel = 1; + } + + uint32_t err2 = squarei((int)block_r[2] - (int)r) + squarei((int)block_g[2] - (int)g) + squarei((int)block_b[2] - (int)b); + if (err2 < best_err) + { + best_err = err2; + best_sel = 2; + } + + if (use_black) + { + uint32_t err3 = squarei(r) + squarei(g) + squarei(b); + if (err3 < best_err) + { + best_err = err3; + best_sel = 3; + } + } + + total_err += best_err; + if (total_err >= cur_err) + return total_err; + + sels[i] = (uint8_t)best_sel; + } + + return total_err; + } + + static inline void precise_round_565(const vec3F &xl, const vec3F &xh, + int &trial_lr, int &trial_lg, int &trial_lb, + int &trial_hr, int &trial_hg, int &trial_hb) + { + trial_lr = (int)(xl.c[0] * 31.0f); + trial_lg = (int)(xl.c[1] * 63.0f); + trial_lb = (int)(xl.c[2] * 31.0f); + + trial_hr = (int)(xh.c[0] * 31.0f); + trial_hg = (int)(xh.c[1] * 63.0f); + trial_hb = (int)(xh.c[2] * 31.0f); + + if ((uint32_t)(trial_lr | trial_lb | trial_hr | trial_hb) > 31U) + { + trial_lr = ((uint32_t)trial_lr > 31U) ? (~trial_lr >> 31) & 31 : trial_lr; + trial_hr = ((uint32_t)trial_hr > 31U) ? (~trial_hr >> 31) & 31 : trial_hr; + + trial_lb = ((uint32_t)trial_lb > 31U) ? (~trial_lb >> 31) & 31 : trial_lb; + trial_hb = ((uint32_t)trial_hb > 31U) ? (~trial_hb >> 31) & 31 : trial_hb; + } + + if ((uint32_t)(trial_lg | trial_hg) > 63U) + { + trial_lg = ((uint32_t)trial_lg > 63U) ? (~trial_lg >> 31) & 63 : trial_lg; + trial_hg = ((uint32_t)trial_hg > 63U) ? (~trial_hg >> 31) & 63 : trial_hg; + } + + trial_lr = (trial_lr + (xl.c[0] > g_midpoint5[trial_lr])) & 31; + trial_lg = (trial_lg + (xl.c[1] > g_midpoint6[trial_lg])) & 63; + trial_lb = (trial_lb + (xl.c[2] > g_midpoint5[trial_lb])) & 31; + + trial_hr = (trial_hr + (xh.c[0] > g_midpoint5[trial_hr])) & 31; + trial_hg = (trial_hg + (xh.c[1] > g_midpoint6[trial_hg])) & 63; + trial_hb = (trial_hb + (xh.c[2] > g_midpoint5[trial_hb])) & 31; + } + + static inline void precise_round_565_noscale(vec3F xl, vec3F xh, + int &trial_lr, int &trial_lg, int &trial_lb, + int &trial_hr, int &trial_hg, int &trial_hb) + { + xl.c[0] *= 1.0f / 255.0f; + xl.c[1] *= 1.0f / 255.0f; + xl.c[2] *= 1.0f / 255.0f; + + xh.c[0] *= 1.0f / 255.0f; + xh.c[1] *= 1.0f / 255.0f; + xh.c[2] *= 1.0f / 255.0f; + + precise_round_565(xl, xh, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb); + } + + static inline void bc1_encode4(bc1_block *pDst_block, int lr, int lg, int lb, int hr, int hg, int hb, const uint8_t sels[16]) + { + uint32_t lc16 = bc1_block::pack_unscaled_color(lr, lg, lb); + uint32_t hc16 = bc1_block::pack_unscaled_color(hr, hg, hb); + + // Always forbid 3 color blocks + if (lc16 == hc16) + { + uint8_t mask = 0; + + // Make l > h + if (hc16 > 0) + hc16--; + else + { + // lc16 = hc16 = 0 + assert(lc16 == hc16 && hc16 == 0); + + hc16 = 0; + lc16 = 1; + mask = 0x55; // select hc16 + } + + assert(lc16 > hc16); + pDst_block->set_low_color(static_cast(lc16)); + pDst_block->set_high_color(static_cast(hc16)); + + pDst_block->m_selectors[0] = mask; + pDst_block->m_selectors[1] = mask; + pDst_block->m_selectors[2] = mask; + pDst_block->m_selectors[3] = mask; + } + else + { + uint8_t invert_mask = 0; + if (lc16 < hc16) + { + std::swap(lc16, hc16); + invert_mask = 0x55; + } + + assert(lc16 > hc16); + pDst_block->set_low_color((uint16_t)lc16); + pDst_block->set_high_color((uint16_t)hc16); + + uint32_t packed_sels = 0; + static const uint8_t s_sel_trans[4] = { 0, 2, 3, 1 }; + for (uint32_t i = 0; i < 16; i++) + packed_sels |= ((uint32_t)s_sel_trans[sels[i]] << (i * 2)); + + pDst_block->m_selectors[0] = (uint8_t)packed_sels ^ invert_mask; + pDst_block->m_selectors[1] = (uint8_t)(packed_sels >> 8) ^ invert_mask; + pDst_block->m_selectors[2] = (uint8_t)(packed_sels >> 16) ^ invert_mask; + pDst_block->m_selectors[3] = (uint8_t)(packed_sels >> 24) ^ invert_mask; + } + } + + static inline void bc1_encode3(bc1_block *pDst_block, int lr, int lg, int lb, int hr, int hg, int hb, const uint8_t sels[16]) + { + uint32_t lc16 = bc1_block::pack_unscaled_color(lr, lg, lb); + uint32_t hc16 = bc1_block::pack_unscaled_color(hr, hg, hb); + + bool invert_flag = false; + if (lc16 > hc16) + { + std::swap(lc16, hc16); + invert_flag = true; + } + + assert(lc16 <= hc16); + + pDst_block->set_low_color((uint16_t)lc16); + pDst_block->set_high_color((uint16_t)hc16); + + uint32_t packed_sels = 0; + + if (invert_flag) + { + static const uint8_t s_sel_trans_inv[4] = { 1, 0, 2, 3 }; + + for (uint32_t i = 0; i < 16; i++) + packed_sels |= ((uint32_t)s_sel_trans_inv[sels[i]] << (i * 2)); + } + else + { + for (uint32_t i = 0; i < 16; i++) + packed_sels |= ((uint32_t)sels[i] << (i * 2)); + } + + pDst_block->m_selectors[0] = (uint8_t)packed_sels; + pDst_block->m_selectors[1] = (uint8_t)(packed_sels >> 8); + pDst_block->m_selectors[2] = (uint8_t)(packed_sels >> 16); + pDst_block->m_selectors[3] = (uint8_t)(packed_sels >> 24); + } + + struct bc1_encode_results + { + int lr, lg, lb; + int hr, hg, hb; + uint8_t sels[16]; + bool m_3color; + }; + + static bool try_3color_block_useblack(const color32* pSrc_pixels, uint32_t flags, uint32_t &cur_err, bc1_encode_results &results) + { + int total_r = 0, total_g = 0, total_b = 0; + int max_r = 0, max_g = 0, max_b = 0; + int min_r = 255, min_g = 255, min_b = 255; + int total_pixels = 0; + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r, g = pSrc_pixels[i].g, b = pSrc_pixels[i].b; + if ((r | g | b) < 4) + continue; + + max_r = std::max(max_r, r); max_g = std::max(max_g, g); max_b = std::max(max_b, b); + min_r = std::min(min_r, r); min_g = std::min(min_g, g); min_b = std::min(min_b, b); + total_r += r; total_g += g; total_b += b; + + total_pixels++; + } + + if (!total_pixels) + return false; + + int half_total_pixels = total_pixels >> 1; + int avg_r = (total_r + half_total_pixels) / total_pixels; + int avg_g = (total_g + half_total_pixels) / total_pixels; + int avg_b = (total_b + half_total_pixels) / total_pixels; + + uint32_t low_c = 0, high_c = 0; + + int icov[6] = { 0, 0, 0, 0, 0, 0 }; + for (uint32_t i = 0; i < 16; i++) + { + int r = (int)pSrc_pixels[i].r; + int g = (int)pSrc_pixels[i].g; + int b = (int)pSrc_pixels[i].b; + + if ((r | g | b) < 4) + continue; + + r -= avg_r; + g -= avg_g; + b -= avg_b; + + icov[0] += r * r; + icov[1] += r * g; + icov[2] += r * b; + icov[3] += g * g; + icov[4] += g * b; + icov[5] += b * b; + } + + float cov[6]; + for (uint32_t i = 0; i < 6; i++) + cov[i] = (float)(icov[i]) * (1.0f / 255.0f); + + float xr = (float)(max_r - min_r); + float xg = (float)(max_g - min_g); + float xb = (float)(max_b - min_b); + + if (icov[2] < 0) + xr = -xr; + + if (icov[4] < 0) + xg = -xg; + + for (uint32_t power_iter = 0; power_iter < 4; power_iter++) + { + float r = xr * cov[0] + xg * cov[1] + xb * cov[2]; + float g = xr * cov[1] + xg * cov[3] + xb * cov[4]; + float b = xr * cov[2] + xg * cov[4] + xb * cov[5]; + xr = r; xg = g; xb = b; + } + + float k = maximum(fabsf(xr), fabsf(xg), fabsf(xb)); + int saxis_r = 306, saxis_g = 601, saxis_b = 117; + if (k >= 2) + { + float m = 1024.0f / k; + saxis_r = (int)(xr * m); + saxis_g = (int)(xg * m); + saxis_b = (int)(xb * m); + } + + int low_dot = INT_MAX, high_dot = INT_MIN; + for (uint32_t i = 0; i < 16; i++) + { + int r = (int)pSrc_pixels[i].r, g = (int)pSrc_pixels[i].g, b = (int)pSrc_pixels[i].b; + + if ((r | g | b) < 4) + continue; + + int dot = r * saxis_r + g * saxis_g + b * saxis_b; + if (dot < low_dot) + { + low_dot = dot; + low_c = i; + } + if (dot > high_dot) + { + high_dot = dot; + high_c = i; + } + } + + int lr = to_5(pSrc_pixels[low_c].r); + int lg = to_6(pSrc_pixels[low_c].g); + int lb = to_5(pSrc_pixels[low_c].b); + + int hr = to_5(pSrc_pixels[high_c].r); + int hg = to_6(pSrc_pixels[high_c].g); + int hb = to_5(pSrc_pixels[high_c].b); + + uint8_t trial_sels[16]; + uint32_t trial_err = bc1_find_sels3_fullerr(true, pSrc_pixels, lr, lg, lb, hr, hg, hb, trial_sels, UINT32_MAX); + + if (trial_err) + { + const uint32_t total_ls_passes = flags & cEncodeBC1TwoLeastSquaresPasses ? 2 : 1; + for (uint32_t trials = 0; trials < total_ls_passes; trials++) + { + vec3F xl, xh; + int lr2, lg2, lb2, hr2, hg2, hb2; + if (!compute_least_squares_endpoints3_rgb(true, pSrc_pixels, trial_sels, &xl, &xh)) + { + lr2 = g_bc1_match5_half[avg_r].m_hi; + lg2 = g_bc1_match6_half[avg_g].m_hi; + lb2 = g_bc1_match5_half[avg_b].m_hi; + + hr2 = g_bc1_match5_half[avg_r].m_lo; + hg2 = g_bc1_match6_half[avg_g].m_lo; + hb2 = g_bc1_match5_half[avg_b].m_lo; + } + else + { + precise_round_565(xl, xh, hr2, hg2, hb2, lr2, lg2, lb2); + } + + if ((lr == lr2) && (lg == lg2) && (lb == lb2) && (hr == hr2) && (hg == hg2) && (hb == hb2)) + break; + + uint8_t trial_sels2[16]; + uint32_t trial_err2 = bc1_find_sels3_fullerr(true, pSrc_pixels, lr2, lg2, lb2, hr2, hg2, hb2, trial_sels2, trial_err); + + if (trial_err2 < trial_err) + { + trial_err = trial_err2; + lr = lr2; lg = lg2; lb = lb2; + hr = hr2; hg = hg2; hb = hb2; + memcpy(trial_sels, trial_sels2, sizeof(trial_sels)); + } + else + break; + } + } + + if (trial_err < cur_err) + { + results.m_3color = true; + results.lr = lr; + results.lg = lg; + results.lb = lb; + results.hr = hr; + results.hg = hg; + results.hb = hb; + memcpy(results.sels, trial_sels, 16); + + cur_err = trial_err; + + return true; + } + + return false; + } + + static bool try_3color_block(const color32* pSrc_pixels, uint32_t flags, uint32_t &cur_err, + int avg_r, int avg_g, int avg_b, int lr, int lg, int lb, int hr, int hg, int hb, int total_r, int total_g, int total_b, uint32_t total_orderings_to_try, + bc1_encode_results &results) + { + uint8_t trial_sels[16]; + uint32_t trial_err = bc1_find_sels3_fullerr(false, pSrc_pixels, lr, lg, lb, hr, hg, hb, trial_sels, UINT32_MAX); + + if (trial_err) + { + const uint32_t total_ls_passes = flags & cEncodeBC1TwoLeastSquaresPasses ? 2 : 1; + for (uint32_t trials = 0; trials < total_ls_passes; trials++) + { + vec3F xl, xh; + int lr2, lg2, lb2, hr2, hg2, hb2; + if (!compute_least_squares_endpoints3_rgb(false, pSrc_pixels, trial_sels, &xl, &xh)) + { + lr2 = g_bc1_match5_half[avg_r].m_hi; + lg2 = g_bc1_match6_half[avg_g].m_hi; + lb2 = g_bc1_match5_half[avg_b].m_hi; + + hr2 = g_bc1_match5_half[avg_r].m_lo; + hg2 = g_bc1_match6_half[avg_g].m_lo; + hb2 = g_bc1_match5_half[avg_b].m_lo; + } + else + { + precise_round_565(xl, xh, hr2, hg2, hb2, lr2, lg2, lb2); + } + + if ((lr == lr2) && (lg == lg2) && (lb == lb2) && (hr == hr2) && (hg == hg2) && (hb == hb2)) + break; + + uint8_t trial_sels2[16]; + uint32_t trial_err2 = bc1_find_sels3_fullerr(false, pSrc_pixels, lr2, lg2, lb2, hr2, hg2, hb2, trial_sels2, trial_err); + + if (trial_err2 < trial_err) + { + trial_err = trial_err2; + lr = lr2; lg = lg2; lb = lb2; + hr = hr2; hg = hg2; hb = hb2; + memcpy(trial_sels, trial_sels2, sizeof(trial_sels)); + } + else + break; + } + } + + if ((trial_err) && (flags & cEncodeBC1UseLikelyTotalOrderings) && (total_orderings_to_try)) + { + hist3 h; + for (uint32_t i = 0; i < 16; i++) + { + assert(trial_sels[i] < 3); + h.m_hist[trial_sels[i]]++; + } + + const uint32_t orig_total_order_index = h.lookup_total_ordering_index(); + + int r0, g0, b0, r3, g3, b3; + r0 = (lr << 3) | (lr >> 2); g0 = (lg << 2) | (lg >> 4); b0 = (lb << 3) | (lb >> 2); + r3 = (hr << 3) | (hr >> 2); g3 = (hg << 2) | (hg >> 4); b3 = (hb << 3) | (hb >> 2); + + int ar = r3 - r0, ag = g3 - g0, ab = b3 - b0; + + int dots[16]; + for (uint32_t i = 0; i < 16; i++) + { + int r = pSrc_pixels[i].r; + int g = pSrc_pixels[i].g; + int b = pSrc_pixels[i].b; + int d = 0x1000000 + (r * ar + g * ag + b * ab); + assert(d >= 0); + dots[i] = (d << 4) + i; + } + + std::sort(dots, dots + 16); + + uint32_t r_sum[17], g_sum[17], b_sum[17]; + uint32_t r = 0, g = 0, b = 0; + for (uint32_t i = 0; i < 16; i++) + { + const uint32_t p = dots[i] & 15; + + r_sum[i] = r; + g_sum[i] = g; + b_sum[i] = b; + + r += pSrc_pixels[p].r; + g += pSrc_pixels[p].g; + b += pSrc_pixels[p].b; + } + + r_sum[16] = total_r; + g_sum[16] = total_g; + b_sum[16] = total_b; + + const uint32_t q_total = (flags & cEncodeBC1Exhaustive) ? NUM_UNIQUE_TOTAL_ORDERINGS3 : std::min(total_orderings_to_try, MAX_TOTAL_ORDERINGS3); + for (uint32_t q = 0; q < q_total; q++) + { + const uint32_t s = (flags & cEncodeBC1Exhaustive) ? q : g_best_total_orderings3[orig_total_order_index][q]; + + int trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb; + + vec3F xl, xh; + + if ((s == TOTAL_ORDER_3_0_16) || (s == TOTAL_ORDER_3_1_16) || (s == TOTAL_ORDER_3_2_16)) + { + trial_lr = g_bc1_match5_half[avg_r].m_hi; + trial_lg = g_bc1_match6_half[avg_g].m_hi; + trial_lb = g_bc1_match5_half[avg_b].m_hi; + + trial_hr = g_bc1_match5_half[avg_r].m_lo; + trial_hg = g_bc1_match6_half[avg_g].m_lo; + trial_hb = g_bc1_match5_half[avg_b].m_lo; + } + else + { + compute_least_squares_endpoints3_rgb(&xl, &xh, total_r, total_g, total_b, + g_selector_factors3[s][0], g_selector_factors3[s][1], g_selector_factors3[s][2], s, r_sum, g_sum, b_sum); + + precise_round_565(xl, xh, trial_hr, trial_hg, trial_hb, trial_lr, trial_lg, trial_lb); + } + + uint8_t trial_sels2[16]; + uint32_t trial_err2 = bc1_find_sels3_fullerr(false, pSrc_pixels, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb, trial_sels2, UINT32_MAX); + + if (trial_err2 < trial_err) + { + trial_err = trial_err2; + + lr = trial_lr; + lg = trial_lg; + lb = trial_lb; + + hr = trial_hr; + hg = trial_hg; + hb = trial_hb; + + memcpy(trial_sels, trial_sels2, sizeof(trial_sels)); + } + + } // s + } + + if (trial_err < cur_err) + { + results.m_3color = true; + results.lr = lr; + results.lg = lg; + results.lb = lb; + results.hr = hr; + results.hg = hg; + results.hb = hb; + memcpy(results.sels, trial_sels, 16); + + cur_err = trial_err; + + return true; + } + + return false; + } + + void encode_bc1(uint32_t level, void* pDst, const uint8_t* pPixels, bool allow_3color, bool allow_transparent_texels_for_black) + { + uint32_t flags = 0, total_orderings4 = 1, total_orderings3 = 1; + + static_assert(MAX_TOTAL_ORDERINGS3 >= 32, "MAX_TOTAL_ORDERINGS3 >= 32"); + static_assert(MAX_TOTAL_ORDERINGS4 >= 32, "MAX_TOTAL_ORDERINGS4 >= 32"); + + switch (level) + { + case 0: + // Faster/higher quality than stb_dxt default. + flags = cEncodeBC1BoundingBoxInt; + break; + case 1: + // Faster/higher quality than stb_dxt default. A bit higher average quality vs. mode 0. + flags = cEncodeBC1Use2DLS; + break; + case 2: + // On average mode 2 is a little weaker than modes 0/1, but it's stronger on outliers (very tough textures). + // Slightly stronger than stb_dxt. + flags = 0; + break; + case 3: + // Slightly stronger than stb_dxt HIGHQUAL. + flags = cEncodeBC1TwoLeastSquaresPasses; + break; + case 4: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1Use6PowerIters; + break; + default: + case 5: + // stb_dxt HIGHQUAL + permit 3 color (if it's enabled). + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFasterMSEEval; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + break; + case 6: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFasterMSEEval | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + break; + case 7: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFasterMSEEval | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 4; + break; + case 8: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFasterMSEEval | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 8; + break; + case 9: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 11; + total_orderings3 = 3; + break; + case 10: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 20; + total_orderings3 = 8; + break; + case 11: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 28; + total_orderings3 = 16; + break; + case 12: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseLikelyTotalOrderings; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 32; + total_orderings3 = 32; + break; + case 13: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | (20 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 32; + total_orderings3 = 32; + break; + case 14: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | (32 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 32; + total_orderings3 = 32; + break; + case 15: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | (32 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = ((((32 + MAX_TOTAL_ORDERINGS4) / 2) + 32) / 2); + total_orderings3 = 32; + break; + case 16: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | (256 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = (32 + MAX_TOTAL_ORDERINGS4) / 2; + total_orderings3 = 32; + break; + case 17: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | (256 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = MAX_TOTAL_ORDERINGS4; + total_orderings3 = 32; + break; + case 18: + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | cEncodeBC1Iterative | (256 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = MAX_TOTAL_ORDERINGS4; + total_orderings3 = 32; + break; + case 19: + // This hidden mode is *extremely* slow and abuses the encoder. It's just for testing/training. + flags = cEncodeBC1TwoLeastSquaresPasses | cEncodeBC1UseFullMSEEval | cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use6PowerIters | cEncodeBC1Exhaustive | cEncodeBC1Iterative | (256 << cEncodeBC1EndpointSearchRoundsShift) | cEncodeBC1TryAllInitialEndponts; + flags |= (allow_3color ? cEncodeBC1Use3ColorBlocks : 0) | (allow_transparent_texels_for_black ? cEncodeBC1Use3ColorBlocksForBlackPixels : 0); + total_orderings4 = 32; + total_orderings3 = 32; + break; + } + + encode_bc1(pDst, pPixels, flags, total_orderings4, total_orderings3); + } + + static inline void encode_bc1_pick_initial(const color32 *pSrc_pixels, uint32_t flags, bool grayscale_flag, + int min_r, int min_g, int min_b, int max_r, int max_g, int max_b, + int avg_r, int avg_g, int avg_b, int total_r, int total_g, int total_b, + int &lr, int &lg, int &lb, int &hr, int &hg, int &hb) + { + if (grayscale_flag) + { + const int fr = pSrc_pixels[0].r; + + // Grayscale blocks are a common enough case to specialize. + if ((max_r - min_r) < 2) + { + lr = lb = hr = hb = to_5(fr); + lg = hg = to_6(fr); + } + else + { + lr = lb = to_5(min_r); + lg = to_6(min_r); + + hr = hb = to_5(max_r); + hg = to_6(max_r); + } + } + else if (flags & cEncodeBC1Use2DLS) + { + // 2D Least Squares approach from Humus's example, with added inset and optimal rounding. + int big_chan = 0, min_chan_val = min_r, max_chan_val = max_r; + if ((max_g - min_g) > (max_chan_val - min_chan_val)) + big_chan = 1, min_chan_val = min_g, max_chan_val = max_g; + + if ((max_b - min_b) > (max_chan_val - min_chan_val)) + big_chan = 2, min_chan_val = min_b, max_chan_val = max_b; + + int sum_xy_r = 0, sum_xy_g = 0, sum_xy_b = 0; + vec3F l, h; + if (big_chan == 0) + { + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r, g = pSrc_pixels[i].g, b = pSrc_pixels[i].b; + sum_xy_r += r * r, sum_xy_g += r * g, sum_xy_b += r * b; + } + + int sum_x = total_r; + int sum_x2 = sum_xy_r; + + float div = (float)(16 * sum_x2 - sum_x * sum_x); + float b_y = 0.0f, b_z = 0.0f; + if (fabs(div) > 1e-8f) + { + div = 1.0f / div; + b_y = (16 * sum_xy_g - sum_x * total_g) * div; + b_z = (16 * sum_xy_b - sum_x * total_b) * div; + } + + float a_y = (total_g - b_y * sum_x) / 16.0f; + float a_z = (total_b - b_z * sum_x) / 16.0f; + + l.c[1] = a_y + b_y * min_chan_val; + l.c[2] = a_z + b_z * min_chan_val; + + h.c[1] = a_y + b_y * max_chan_val; + h.c[2] = a_z + b_z * max_chan_val; + + float dg = (h.c[1] - l.c[1]); + float db = (h.c[2] - l.c[2]); + + h.c[1] = l.c[1] + dg * (15.0f / 16.0f); + h.c[2] = l.c[2] + db * (15.0f / 16.0f); + + l.c[1] = l.c[1] + dg * (1.0f / 16.0f); + l.c[2] = l.c[2] + db * (1.0f / 16.0f); + + float d = (float)(max_chan_val - min_chan_val); + float fmin_chan_val = min_chan_val + d * (1.0f / 16.0f); + float fmax_chan_val = min_chan_val + d * (15.0f / 16.0f); + + l.c[0] = fmin_chan_val; + h.c[0] = fmax_chan_val; + } + else if (big_chan == 1) + { + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r, g = pSrc_pixels[i].g, b = pSrc_pixels[i].b; + sum_xy_r += g * r, sum_xy_g += g * g, sum_xy_b += g * b; + } + + int sum_x = total_g; + int sum_x2 = sum_xy_g; + + float div = (float)(16 * sum_x2 - sum_x * sum_x); + float b_x = 0.0f, b_z = 0.0f; + if (fabs(div) > 1e-8f) + { + div = 1.0f / div; + b_x = (16 * sum_xy_r - sum_x * total_r) * div; + b_z = (16 * sum_xy_b - sum_x * total_b) * div; + } + + float a_x = (total_r - b_x * sum_x) / 16.0f; + float a_z = (total_b - b_z * sum_x) / 16.0f; + + l.c[0] = a_x + b_x * min_chan_val; + l.c[2] = a_z + b_z * min_chan_val; + + h.c[0] = a_x + b_x * max_chan_val; + h.c[2] = a_z + b_z * max_chan_val; + + float dr = (h.c[0] - l.c[0]); + float db = (h.c[2] - l.c[2]); + + h.c[0] = l.c[0] + dr * (15.0f / 16.0f); + h.c[2] = l.c[2] + db * (15.0f / 16.0f); + + l.c[0] = l.c[0] + dr * (1.0f / 16.0f); + l.c[2] = l.c[2] + db * (1.0f / 16.0f); + + float d = (float)(max_chan_val - min_chan_val); + float fmin_chan_val = min_chan_val + d * (1.0f / 16.0f); + float fmax_chan_val = min_chan_val + d * (15.0f / 16.0f); + + l.c[1] = fmin_chan_val; + h.c[1] = fmax_chan_val; + } + else + { + for (uint32_t i = 0; i < 16; i++) + { + const int r = pSrc_pixels[i].r, g = pSrc_pixels[i].g, b = pSrc_pixels[i].b; + sum_xy_r += b * r, sum_xy_g += b * g, sum_xy_b += b * b; + } + + int sum_x = total_b; + int sum_x2 = sum_xy_b; + + float div = (float)(16 * sum_x2 - sum_x * sum_x); + float b_x = 0.0f, b_y = 0.0f; + if (fabs(div) > 1e-8f) + { + div = 1.0f / div; + b_x = (16 * sum_xy_r - sum_x * total_r) * div; + b_y = (16 * sum_xy_g - sum_x * total_g) * div; + } + + float a_x = (total_r - b_x * sum_x) / 16.0f; + float a_y = (total_g - b_y * sum_x) / 16.0f; + + l.c[0] = a_x + b_x * min_chan_val; + l.c[1] = a_y + b_y * min_chan_val; + + h.c[0] = a_x + b_x * max_chan_val; + h.c[1] = a_y + b_y * max_chan_val; + + float dr = (h.c[0] - l.c[0]); + float dg = (h.c[1] - l.c[1]); + + h.c[0] = l.c[0] + dr * (15.0f / 16.0f); + h.c[1] = l.c[1] + dg * (15.0f / 16.0f); + + l.c[0] = l.c[0] + dr * (1.0f / 16.0f); + l.c[1] = l.c[1] + dg * (1.0f / 16.0f); + + float d = (float)(max_chan_val - min_chan_val); + float fmin_chan_val = min_chan_val + d * (1.0f / 16.0f); + float fmax_chan_val = min_chan_val + d * (15.0f / 16.0f); + + l.c[2] = fmin_chan_val; + h.c[2] = fmax_chan_val; + } + + precise_round_565_noscale(l, h, lr, lg, lb, hr, hg, hb); + } + else if (flags & cEncodeBC1BoundingBox) + { + // Algorithm from icbc.h compress_dxt1_fast() + vec3F l, h; + l.c[0] = min_r * (1.0f / 255.0f); + l.c[1] = min_g * (1.0f / 255.0f); + l.c[2] = min_b * (1.0f / 255.0f); + + h.c[0] = max_r * (1.0f / 255.0f); + h.c[1] = max_g * (1.0f / 255.0f); + h.c[2] = max_b * (1.0f / 255.0f); + + const float bias = 8.0f / 255.0f; + float inset_r = (h.c[0] - l.c[0] - bias) * (1.0f / 16.0f); + float inset_g = (h.c[1] - l.c[1] - bias) * (1.0f / 16.0f); + float inset_b = (h.c[2] - l.c[2] - bias) * (1.0f / 16.0f); + + l.c[0] = clampf(l.c[0] + inset_r, 0.0f, 1.0f); + l.c[1] = clampf(l.c[1] + inset_g, 0.0f, 1.0f); + l.c[2] = clampf(l.c[2] + inset_b, 0.0f, 1.0f); + + h.c[0] = clampf(h.c[0] - inset_r, 0.0f, 1.0f); + h.c[1] = clampf(h.c[1] - inset_g, 0.0f, 1.0f); + h.c[2] = clampf(h.c[2] - inset_b, 0.0f, 1.0f); + + int icov_xz = 0, icov_yz = 0; + for (uint32_t i = 0; i < 16; i++) + { + int r = (int)pSrc_pixels[i].r - avg_r; + int g = (int)pSrc_pixels[i].g - avg_g; + int b = (int)pSrc_pixels[i].b - avg_b; + icov_xz += r * b; + icov_yz += g * b; + } + + if (icov_xz < 0) + std::swap(l.c[0], h.c[0]); + + if (icov_yz < 0) + std::swap(l.c[1], h.c[1]); + + precise_round_565(l, h, lr, lg, lb, hr, hg, hb); + } + else if (flags & cEncodeBC1BoundingBoxInt) + { + // Algorithm from icbc.h compress_dxt1_fast(), but converted to integer. + int inset_r = (max_r - min_r - 8) >> 4; + int inset_g = (max_g - min_g - 8) >> 4; + int inset_b = (max_b - min_b - 8) >> 4; + + min_r += inset_r; + min_g += inset_g; + min_b += inset_b; + if ((uint32_t)(min_r | min_g | min_b) > 255U) + { + min_r = clampi(min_r, 0, 255); + min_g = clampi(min_g, 0, 255); + min_b = clampi(min_b, 0, 255); + } + + max_r -= inset_r; + max_g -= inset_g; + max_b -= inset_b; + if ((uint32_t)(max_r | max_g | max_b) > 255U) + { + max_r = clampi(max_r, 0, 255); + max_g = clampi(max_g, 0, 255); + max_b = clampi(max_b, 0, 255); + } + + int icov_xz = 0, icov_yz = 0; + for (uint32_t i = 0; i < 16; i++) + { + int r = (int)pSrc_pixels[i].r - avg_r; + int g = (int)pSrc_pixels[i].g - avg_g; + int b = (int)pSrc_pixels[i].b - avg_b; + icov_xz += r * b; + icov_yz += g * b; + } + + int x0 = min_r; + int y0 = min_g; + int x1 = max_r; + int y1 = max_g; + + if (icov_xz < 0) + std::swap(x0, x1); + + if (icov_yz < 0) + std::swap(y0, y1); + + lr = to_5(x0); + lg = to_6(y0); + lb = to_5(min_b); + + hr = to_5(x1); + hg = to_6(y1); + hb = to_5(max_b); + } + else + { + // Select 2 colors along the principle axis. (There must be a faster/simpler way.) + uint32_t low_c = 0, high_c = 0; + + int icov[6] = { 0, 0, 0, 0, 0, 0 }; + for (uint32_t i = 0; i < 16; i++) + { + int r = (int)pSrc_pixels[i].r - avg_r; + int g = (int)pSrc_pixels[i].g - avg_g; + int b = (int)pSrc_pixels[i].b - avg_b; + icov[0] += r * r; + icov[1] += r * g; + icov[2] += r * b; + icov[3] += g * g; + icov[4] += g * b; + icov[5] += b * b; + } + + int saxis_r = 306, saxis_g = 601, saxis_b = 117; + + float xr = (float)(max_r - min_r); + float xg = (float)(max_g - min_g); + float xb = (float)(max_b - min_b); + + if (icov[2] < 0) + xr = -xr; + + if (icov[4] < 0) + xg = -xg; + + float cov[6]; + for (uint32_t i = 0; i < 6; i++) + cov[i] = (float)(icov[i]) * (1.0f / 255.0f); + + const uint32_t total_power_iters = (flags & cEncodeBC1Use6PowerIters) ? 6 : 4; + for (uint32_t power_iter = 0; power_iter < total_power_iters; power_iter++) + { + float r = xr * cov[0] + xg * cov[1] + xb * cov[2]; + float g = xr * cov[1] + xg * cov[3] + xb * cov[4]; + float b = xr * cov[2] + xg * cov[4] + xb * cov[5]; + xr = r; xg = g; xb = b; + } + + float k = maximum(fabsf(xr), fabsf(xg), fabsf(xb)); + if (k >= 2) + { + float m = 2048.0f / k; + saxis_r = (int)(xr * m); + saxis_g = (int)(xg * m); + saxis_b = (int)(xb * m); + } + + int low_dot = INT_MAX, high_dot = INT_MIN; + + saxis_r = (int)((uint32_t)saxis_r << 4U); + saxis_g = (int)((uint32_t)saxis_g << 4U); + saxis_b = (int)((uint32_t)saxis_b << 4U); + + for (uint32_t i = 0; i < 16; i += 4) + { + int dot0 = ((pSrc_pixels[i].r * saxis_r + pSrc_pixels[i].g * saxis_g + pSrc_pixels[i].b * saxis_b) & ~0xF) + i; + int dot1 = ((pSrc_pixels[i + 1].r * saxis_r + pSrc_pixels[i + 1].g * saxis_g + pSrc_pixels[i + 1].b * saxis_b) & ~0xF) + i + 1; + int dot2 = ((pSrc_pixels[i + 2].r * saxis_r + pSrc_pixels[i + 2].g * saxis_g + pSrc_pixels[i + 2].b * saxis_b) & ~0xF) + i + 2; + int dot3 = ((pSrc_pixels[i + 3].r * saxis_r + pSrc_pixels[i + 3].g * saxis_g + pSrc_pixels[i + 3].b * saxis_b) & ~0xF) + i + 3; + + int min_d01 = std::min(dot0, dot1); + int max_d01 = std::max(dot0, dot1); + + int min_d23 = std::min(dot2, dot3); + int max_d23 = std::max(dot2, dot3); + + int min_d = std::min(min_d01, min_d23); + int max_d = std::max(max_d01, max_d23); + + low_dot = std::min(low_dot, min_d); + high_dot = std::max(high_dot, max_d); + } + low_c = low_dot & 15; + high_c = high_dot & 15; + + lr = to_5(pSrc_pixels[low_c].r); + lg = to_6(pSrc_pixels[low_c].g); + lb = to_5(pSrc_pixels[low_c].b); + + hr = to_5(pSrc_pixels[high_c].r); + hg = to_6(pSrc_pixels[high_c].g); + hb = to_5(pSrc_pixels[high_c].b); + } + } + + static const int8_t s_adjacent_voxels[16][4] = + { + { 1,0,0, 3 }, // 0 + { 0,1,0, 4 }, // 1 + { 0,0,1, 5 }, // 2 + { -1,0,0, 0 }, // 3 + { 0,-1,0, 1 }, // 4 + { 0,0,-1, 2 }, // 5 + { 1,1,0, 9 }, // 6 + { 1,0,1, 10 }, // 7 + { 0,1,1, 11 }, // 8 + { -1,-1,0, 6 }, // 9 + { -1,0,-1, 7 }, // 10 + { 0,-1,-1, 8 }, // 11 + { -1,1,0, 13 }, // 12 + { 1,-1,0, 12 }, // 13 + { 0,-1,1, 15 }, // 14 + { 0,1,-1, 14 }, // 15 + }; + + // From icbc's high quality mode. + static inline void encode_bc1_endpoint_search(const color32 *pSrc_pixels, bool any_black_pixels, + uint32_t flags, bc1_encode_results &results, uint32_t cur_err) + { + int &lr = results.lr, &lg = results.lg, &lb = results.lb, &hr = results.hr, &hg = results.hg, &hb = results.hb; + uint8_t *sels = results.sels; + + int prev_improvement_index = 0, forbidden_direction = -1; + + const int endpoint_search_rounds = (flags & cEncodeBC1EndpointSearchRoundsMask) >> cEncodeBC1EndpointSearchRoundsShift; + for (int i = 0; i < endpoint_search_rounds; i++) + { + assert(s_adjacent_voxels[s_adjacent_voxels[i & 15][3]][3] == (i & 15)); + + if (forbidden_direction == (i & 31)) + continue; + + const int8_t delta[3] = { s_adjacent_voxels[i & 15][0], s_adjacent_voxels[i & 15][1], s_adjacent_voxels[i & 15][2] }; + + int trial_lr = lr, trial_lg = lg, trial_lb = lb, trial_hr = hr, trial_hg = hg, trial_hb = hb; + + if ((i >> 4) & 1) + { + trial_lr = clampi(trial_lr + delta[0], 0, 31); + trial_lg = clampi(trial_lg + delta[1], 0, 63); + trial_lb = clampi(trial_lb + delta[2], 0, 31); + } + else + { + trial_hr = clampi(trial_hr + delta[0], 0, 31); + trial_hg = clampi(trial_hg + delta[1], 0, 63); + trial_hb = clampi(trial_hb + delta[2], 0, 31); + } + + uint8_t trial_sels[16]; + + uint32_t trial_err; + if (results.m_3color) + { + trial_err = bc1_find_sels3_fullerr( + ((any_black_pixels) && ((flags & cEncodeBC1Use3ColorBlocksForBlackPixels) != 0)), + pSrc_pixels, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb, trial_sels, cur_err); + } + else + { + trial_err = bc1_find_sels4(flags, pSrc_pixels, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb, trial_sels, cur_err); + } + + if (trial_err < cur_err) + { + cur_err = trial_err; + + forbidden_direction = s_adjacent_voxels[i & 15][3] | (i & 16); + + lr = trial_lr, lg = trial_lg, lb = trial_lb, hr = trial_hr, hg = trial_hg, hb = trial_hb; + + memcpy(sels, trial_sels, 16); + + prev_improvement_index = i; + } + + if (i - prev_improvement_index > 32) + break; + } + } + + void encode_bc1(void* pDst, const uint8_t* pPixels, uint32_t flags, uint32_t total_orderings_to_try, uint32_t total_orderings_to_try3) + { + assert(g_initialized); + + const color32* pSrc_pixels = (const color32*)pPixels; + bc1_block* pDst_block = static_cast(pDst); + + int avg_r, avg_g, avg_b, min_r, min_g, min_b, max_r, max_g, max_b; + + const uint32_t fr = pSrc_pixels[0].r, fg = pSrc_pixels[0].g, fb = pSrc_pixels[0].b; + + uint32_t j; + for (j = 15; j >= 1; --j) + if ((pSrc_pixels[j].r != fr) || (pSrc_pixels[j].g != fg) || (pSrc_pixels[j].b != fb)) + break; + + if (j == 0) + { + encode_bc1_solid_block(pDst, fr, fg, fb, (flags & (cEncodeBC1Use3ColorBlocks | cEncodeBC1Use3ColorBlocksForBlackPixels)) != 0); + return; + } + + int total_r = fr, total_g = fg, total_b = fb; + + max_r = fr, max_g = fg, max_b = fb; + min_r = fr, min_g = fg, min_b = fb; + + uint32_t grayscale_flag = (fr == fg) && (fr == fb); + uint32_t any_black_pixels = (fr | fg | fb) < 4; + + for (uint32_t i = 1; i < 16; i++) + { + const int r = pSrc_pixels[i].r, g = pSrc_pixels[i].g, b = pSrc_pixels[i].b; + + grayscale_flag &= ((r == g) && (r == b)); + any_black_pixels |= ((r | g | b) < 4); + + max_r = std::max(max_r, r); max_g = std::max(max_g, g); max_b = std::max(max_b, b); + min_r = std::min(min_r, r); min_g = std::min(min_g, g); min_b = std::min(min_b, b); + total_r += r; total_g += g; total_b += b; + } + + avg_r = (total_r + 8) >> 4, avg_g = (total_g + 8) >> 4, avg_b = (total_b + 8) >> 4; + + bc1_encode_results results; + results.m_3color = false; + + uint8_t *sels = results.sels; + int &lr = results.lr, &lg = results.lg, &lb = results.lb, &hr = results.hr, &hg = results.hg, &hb = results.hb; + int orig_lr = 0, orig_lg = 0, orig_lb = 0, orig_hr = 0, orig_hg = 0, orig_hb = 0; + + lr = 0, lg = 0, lb = 0, hr = 0, hg = 0, hb = 0; + + const bool needs_block_error = ((flags & (cEncodeBC1UseLikelyTotalOrderings | cEncodeBC1Use3ColorBlocks | cEncodeBC1UseFullMSEEval | cEncodeBC1EndpointSearchRoundsMask)) != 0) || + (any_black_pixels && ((flags & cEncodeBC1Use3ColorBlocksForBlackPixels) != 0)); + + uint32_t cur_err = UINT32_MAX; + + if (!needs_block_error) + { + assert((flags & cEncodeBC1TryAllInitialEndponts) == 0); + + encode_bc1_pick_initial(pSrc_pixels, flags, grayscale_flag != 0, + min_r, min_g, min_b, max_r, max_g, max_b, + avg_r, avg_g, avg_b, total_r, total_g, total_b, + lr, lg, lb, hr, hg, hb); + + orig_lr = lr, orig_lg = lg, orig_lb = lb, orig_hr = hr, orig_hg = hg, orig_hb = hb; + + bc1_find_sels4_noerr(pSrc_pixels, lr, lg, lb, hr, hg, hb, sels); + + const uint32_t total_ls_passes = flags & cEncodeBC1TwoLeastSquaresPasses ? 2 : 1; + for (uint32_t ls_pass = 0; ls_pass < total_ls_passes; ls_pass++) + { + int trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb; + + vec3F xl, xh; + if (!compute_least_squares_endpoints4_rgb(pSrc_pixels, sels, &xl, &xh, total_r, total_g, total_b)) + { + // All selectors equal - treat it as a solid block which should always be equal or better. + trial_lr = g_bc1_match5_equals_1[avg_r].m_hi; + trial_lg = g_bc1_match6_equals_1[avg_g].m_hi; + trial_lb = g_bc1_match5_equals_1[avg_b].m_hi; + + trial_hr = g_bc1_match5_equals_1[avg_r].m_lo; + trial_hg = g_bc1_match6_equals_1[avg_g].m_lo; + trial_hb = g_bc1_match5_equals_1[avg_b].m_lo; + + // In high/higher quality mode, let it try again in case the optimal tables have caused the sels to diverge. + } + else + { + precise_round_565(xl, xh, trial_hr, trial_hg, trial_hb, trial_lr, trial_lg, trial_lb); + } + + if ((lr == trial_lr) && (lg == trial_lg) && (lb == trial_lb) && (hr == trial_hr) && (hg == trial_hg) && (hb == trial_hb)) + break; + + bc1_find_sels4_noerr(pSrc_pixels, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb, sels); + + lr = trial_lr; + lg = trial_lg; + lb = trial_lb; + hr = trial_hr; + hg = trial_hg; + hb = trial_hb; + + } // ls_pass + } + else + { + const uint32_t total_rounds = (flags & cEncodeBC1TryAllInitialEndponts) ? 2 : 1; + for (uint32_t round = 0; round < total_rounds; round++) + { + uint32_t modified_flags = flags; + if (round == 1) + { + modified_flags &= ~(cEncodeBC1Use2DLS | cEncodeBC1BoundingBox); + modified_flags |= cEncodeBC1BoundingBox; + } + + int round_lr, round_lg, round_lb, round_hr, round_hg, round_hb; + uint8_t round_sels[16]; + + encode_bc1_pick_initial(pSrc_pixels, modified_flags, grayscale_flag != 0, + min_r, min_g, min_b, max_r, max_g, max_b, + avg_r, avg_g, avg_b, total_r, total_g, total_b, + round_lr, round_lg, round_lb, round_hr, round_hg, round_hb); + + int orig_round_lr = round_lr, orig_round_lg = round_lg, orig_round_lb = round_lb, orig_round_hr = round_hr, orig_round_hg = round_hg, orig_round_hb = round_hb; + + uint32_t round_err = bc1_find_sels4(flags, pSrc_pixels, round_lr, round_lg, round_lb, round_hr, round_hg, round_hb, round_sels, UINT32_MAX); + + const uint32_t total_ls_passes = flags & cEncodeBC1TwoLeastSquaresPasses ? 2 : 1; + for (uint32_t ls_pass = 0; ls_pass < total_ls_passes; ls_pass++) + { + int trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb; + + vec3F xl, xh; + if (!compute_least_squares_endpoints4_rgb(pSrc_pixels, round_sels, &xl, &xh, total_r, total_g, total_b)) + { + // All selectors equal - treat it as a solid block which should always be equal or better. + trial_lr = g_bc1_match5_equals_1[avg_r].m_hi; + trial_lg = g_bc1_match6_equals_1[avg_g].m_hi; + trial_lb = g_bc1_match5_equals_1[avg_b].m_hi; + + trial_hr = g_bc1_match5_equals_1[avg_r].m_lo; + trial_hg = g_bc1_match6_equals_1[avg_g].m_lo; + trial_hb = g_bc1_match5_equals_1[avg_b].m_lo; + + // In high/higher quality mode, let it try again in case the optimal tables have caused the sels to diverge. + } + else + { + precise_round_565(xl, xh, trial_hr, trial_hg, trial_hb, trial_lr, trial_lg, trial_lb); + } + + if ((round_lr == trial_lr) && (round_lg == trial_lg) && (round_lb == trial_lb) && (round_hr == trial_hr) && (round_hg == trial_hg) && (round_hb == trial_hb)) + break; + + uint8_t trial_sels[16]; + uint32_t trial_err = bc1_find_sels4(flags, pSrc_pixels, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb, trial_sels, round_err); + + if (trial_err < round_err) + { + round_lr = trial_lr; + round_lg = trial_lg; + round_lb = trial_lb; + + round_hr = trial_hr; + round_hg = trial_hg; + round_hb = trial_hb; + + round_err = trial_err; + memcpy(round_sels, trial_sels, 16); + } + else + break; + + } // ls_pass + + if (round_err <= cur_err) + { + cur_err = round_err; + + lr = round_lr; + lg = round_lg; + lb = round_lb; + hr = round_hr; + hg = round_hg; + hb = round_hb; + + orig_lr = orig_round_lr; + orig_lg = orig_round_lg; + orig_lb = orig_round_lb; + orig_hr = orig_round_hr; + orig_hg = orig_round_hg; + orig_hb = orig_round_hb; + + memcpy(sels, round_sels, 16); + } + + } // round + } + + if ((cur_err) && (flags & cEncodeBC1UseLikelyTotalOrderings)) + { + assert(needs_block_error); + + const uint32_t total_iters = (flags & cEncodeBC1Iterative) ? 2 : 1; + for (uint32_t iter_index = 0; iter_index < total_iters; iter_index++) + { + const uint32_t orig_err = cur_err; + + hist4 h; + for (uint32_t i = 0; i < 16; i++) + { + assert(sels[i] < 4); + h.m_hist[sels[i]]++; + } + + const uint32_t orig_total_order_index = h.lookup_total_ordering_index(); + + int r0, g0, b0, r3, g3, b3; + r0 = (lr << 3) | (lr >> 2); g0 = (lg << 2) | (lg >> 4); b0 = (lb << 3) | (lb >> 2); + r3 = (hr << 3) | (hr >> 2); g3 = (hg << 2) | (hg >> 4); b3 = (hb << 3) | (hb >> 2); + + int ar = r3 - r0, ag = g3 - g0, ab = b3 - b0; + + int dots[16]; + for (uint32_t i = 0; i < 16; i++) + { + int r = pSrc_pixels[i].r; + int g = pSrc_pixels[i].g; + int b = pSrc_pixels[i].b; + int d = 0x1000000 + (r * ar + g * ag + b * ab); + assert(d >= 0); + dots[i] = (d << 4) + i; + } + + std::sort(dots, dots + 16); + + uint32_t r_sum[17], g_sum[17], b_sum[17]; + uint32_t r = 0, g = 0, b = 0; + for (uint32_t i = 0; i < 16; i++) + { + const uint32_t p = dots[i] & 15; + + r_sum[i] = r; + g_sum[i] = g; + b_sum[i] = b; + + r += pSrc_pixels[p].r; + g += pSrc_pixels[p].g; + b += pSrc_pixels[p].b; + } + + r_sum[16] = total_r; + g_sum[16] = total_g; + b_sum[16] = total_b; + + const uint32_t q_total = (flags & cEncodeBC1Exhaustive) ? NUM_UNIQUE_TOTAL_ORDERINGS4 : clampi(total_orderings_to_try, MIN_TOTAL_ORDERINGS, MAX_TOTAL_ORDERINGS4); + for (uint32_t q = 0; q < q_total; q++) + { + const uint32_t s = (flags & cEncodeBC1Exhaustive) ? q : g_best_total_orderings4[orig_total_order_index][q]; + + int trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb; + + vec3F xl, xh; + + if ((s == TOTAL_ORDER_4_0_16) || (s == TOTAL_ORDER_4_1_16) || (s == TOTAL_ORDER_4_2_16) || (s == TOTAL_ORDER_4_3_16)) + { + trial_lr = g_bc1_match5_equals_1[avg_r].m_hi; + trial_lg = g_bc1_match6_equals_1[avg_g].m_hi; + trial_lb = g_bc1_match5_equals_1[avg_b].m_hi; + + trial_hr = g_bc1_match5_equals_1[avg_r].m_lo; + trial_hg = g_bc1_match6_equals_1[avg_g].m_lo; + trial_hb = g_bc1_match5_equals_1[avg_b].m_lo; + } + else + { + compute_least_squares_endpoints4_rgb(&xl, &xh, total_r, total_g, total_b, + g_selector_factors4[s][0], g_selector_factors4[s][1], g_selector_factors4[s][2], s, r_sum, g_sum, b_sum); + + precise_round_565(xl, xh, trial_hr, trial_hg, trial_hb, trial_lr, trial_lg, trial_lb); + } + + uint8_t trial_sels[16]; + + uint32_t trial_err = bc1_find_sels4(flags, pSrc_pixels, trial_lr, trial_lg, trial_lb, trial_hr, trial_hg, trial_hb, trial_sels, cur_err); + + if (trial_err < cur_err) + { + cur_err = trial_err; + + lr = trial_lr; + lg = trial_lg; + lb = trial_lb; + + hr = trial_hr; + hg = trial_hg; + hb = trial_hb; + + memcpy(sels, trial_sels, 16); + } + + } // s + + if ((!cur_err) || (cur_err == orig_err)) + break; + + } // iter_index + } + + if (((flags & (cEncodeBC1Use3ColorBlocks | cEncodeBC1Use3ColorBlocksForBlackPixels)) != 0) && (cur_err)) + { + if (flags & cEncodeBC1Use3ColorBlocks) + { + assert(needs_block_error); + try_3color_block(pSrc_pixels, flags, cur_err, avg_r, avg_g, avg_b, orig_lr, orig_lg, orig_lb, orig_hr, orig_hg, orig_hb, total_r, total_g, total_b, total_orderings_to_try3, results); + } + + if ((any_black_pixels) && ((flags & cEncodeBC1Use3ColorBlocksForBlackPixels) != 0)) + { + assert(needs_block_error); + try_3color_block_useblack(pSrc_pixels, flags, cur_err, results); + } + } + + if ((flags & cEncodeBC1EndpointSearchRoundsMask) && (cur_err)) + { + assert(needs_block_error); + + encode_bc1_endpoint_search(pSrc_pixels, any_black_pixels != 0, flags, results, cur_err); + } + + if (results.m_3color) + bc1_encode3(pDst_block, results.lr, results.lg, results.lb, results.hr, results.hg, results.hb, results.sels); + else + bc1_encode4(pDst_block, results.lr, results.lg, results.lb, results.hr, results.hg, results.hb, results.sels); + } + + // BC3-5 + + struct bc4_block + { + enum { cBC4SelectorBits = 3, cTotalSelectorBytes = 6, cMaxSelectorValues = 8 }; + uint8_t m_endpoints[2]; + + uint8_t m_selectors[cTotalSelectorBytes]; + + inline uint32_t get_low_alpha() const { return m_endpoints[0]; } + inline uint32_t get_high_alpha() const { return m_endpoints[1]; } + inline bool is_alpha6_block() const { return get_low_alpha() <= get_high_alpha(); } + + inline uint64_t get_selector_bits() const + { + return ((uint64_t)((uint32_t)m_selectors[0] | ((uint32_t)m_selectors[1] << 8U) | ((uint32_t)m_selectors[2] << 16U) | ((uint32_t)m_selectors[3] << 24U))) | + (((uint64_t)m_selectors[4]) << 32U) | + (((uint64_t)m_selectors[5]) << 40U); + } + + inline uint32_t get_selector(uint32_t x, uint32_t y, uint64_t selector_bits) const + { + assert((x < 4U) && (y < 4U)); + return (selector_bits >> (((y * 4) + x) * cBC4SelectorBits))& (cMaxSelectorValues - 1); + } + + static inline uint32_t get_block_values6(uint8_t* pDst, uint32_t l, uint32_t h) + { + pDst[0] = static_cast(l); + pDst[1] = static_cast(h); + pDst[2] = static_cast((l * 4 + h) / 5); + pDst[3] = static_cast((l * 3 + h * 2) / 5); + pDst[4] = static_cast((l * 2 + h * 3) / 5); + pDst[5] = static_cast((l + h * 4) / 5); + pDst[6] = 0; + pDst[7] = 255; + return 6; + } + + static inline uint32_t get_block_values8(uint8_t* pDst, uint32_t l, uint32_t h) + { + pDst[0] = static_cast(l); + pDst[1] = static_cast(h); + pDst[2] = static_cast((l * 6 + h) / 7); + pDst[3] = static_cast((l * 5 + h * 2) / 7); + pDst[4] = static_cast((l * 4 + h * 3) / 7); + pDst[5] = static_cast((l * 3 + h * 4) / 7); + pDst[6] = static_cast((l * 2 + h * 5) / 7); + pDst[7] = static_cast((l + h * 6) / 7); + return 8; + } + + static inline uint32_t get_block_values(uint8_t* pDst, uint32_t l, uint32_t h) + { + if (l > h) + return get_block_values8(pDst, l, h); + else + return get_block_values6(pDst, l, h); + } + }; + + void encode_bc4(void* pDst, const uint8_t* pPixels, uint32_t stride) + { + assert(g_initialized); + + uint32_t min0_v, max0_v, min1_v, max1_v, min2_v, max2_v, min3_v, max3_v; + + { + min0_v = max0_v = pPixels[0 * stride]; + min1_v = max1_v = pPixels[1 * stride]; + min2_v = max2_v = pPixels[2 * stride]; + min3_v = max3_v = pPixels[3 * stride]; + } + + { + uint32_t v0 = pPixels[4 * stride]; min0_v = std::min(min0_v, v0); max0_v = std::max(max0_v, v0); + uint32_t v1 = pPixels[5 * stride]; min1_v = std::min(min1_v, v1); max1_v = std::max(max1_v, v1); + uint32_t v2 = pPixels[6 * stride]; min2_v = std::min(min2_v, v2); max2_v = std::max(max2_v, v2); + uint32_t v3 = pPixels[7 * stride]; min3_v = std::min(min3_v, v3); max3_v = std::max(max3_v, v3); + } + + { + uint32_t v0 = pPixels[8 * stride]; min0_v = std::min(min0_v, v0); max0_v = std::max(max0_v, v0); + uint32_t v1 = pPixels[9 * stride]; min1_v = std::min(min1_v, v1); max1_v = std::max(max1_v, v1); + uint32_t v2 = pPixels[10 * stride]; min2_v = std::min(min2_v, v2); max2_v = std::max(max2_v, v2); + uint32_t v3 = pPixels[11 * stride]; min3_v = std::min(min3_v, v3); max3_v = std::max(max3_v, v3); + } + + { + uint32_t v0 = pPixels[12 * stride]; min0_v = std::min(min0_v, v0); max0_v = std::max(max0_v, v0); + uint32_t v1 = pPixels[13 * stride]; min1_v = std::min(min1_v, v1); max1_v = std::max(max1_v, v1); + uint32_t v2 = pPixels[14 * stride]; min2_v = std::min(min2_v, v2); max2_v = std::max(max2_v, v2); + uint32_t v3 = pPixels[15 * stride]; min3_v = std::min(min3_v, v3); max3_v = std::max(max3_v, v3); + } + + const uint32_t min_v = minimum(min0_v, min1_v, min2_v, min3_v); + const uint32_t max_v = maximum(max0_v, max1_v, max2_v, max3_v); + + uint8_t* pDst_bytes = static_cast(pDst); + pDst_bytes[0] = (uint8_t)max_v; + pDst_bytes[1] = (uint8_t)min_v; + + if (max_v == min_v) + { + memset(pDst_bytes + 2, 0, 6); + return; + } + + const uint32_t delta = max_v - min_v; + + // min_v is now 0. Compute thresholds between values by scaling max_v. It's x14 because we're adding two x7 scale factors. + const int t0 = delta * 13; + const int t1 = delta * 11; + const int t2 = delta * 9; + const int t3 = delta * 7; + const int t4 = delta * 5; + const int t5 = delta * 3; + const int t6 = delta * 1; + + // BC4 floors in its divisions, which we compensate for with the 4 bias. + // This function is optimal for all possible inputs (i.e. it outputs the same results as checking all 8 values and choosing the closest one). + const int bias = 4 - min_v * 14; + + static const uint32_t s_tran0[8] = { 1U , 7U , 6U , 5U , 4U , 3U , 2U , 0U }; + static const uint32_t s_tran1[8] = { 1U << 3U, 7U << 3U, 6U << 3U, 5U << 3U, 4U << 3U, 3U << 3U, 2U << 3U, 0U << 3U }; + static const uint32_t s_tran2[8] = { 1U << 6U, 7U << 6U, 6U << 6U, 5U << 6U, 4U << 6U, 3U << 6U, 2U << 6U, 0U << 6U }; + static const uint32_t s_tran3[8] = { 1U << 9U, 7U << 9U, 6U << 9U, 5U << 9U, 4U << 9U, 3U << 9U, 2U << 9U, 0U << 9U }; + + uint64_t a0, a1, a2, a3; + { + const int v0 = pPixels[0 * stride] * 14 + bias; + const int v1 = pPixels[1 * stride] * 14 + bias; + const int v2 = pPixels[2 * stride] * 14 + bias; + const int v3 = pPixels[3 * stride] * 14 + bias; + a0 = s_tran0[(v0 >= t0) + (v0 >= t1) + (v0 >= t2) + (v0 >= t3) + (v0 >= t4) + (v0 >= t5) + (v0 >= t6)]; + a1 = s_tran1[(v1 >= t0) + (v1 >= t1) + (v1 >= t2) + (v1 >= t3) + (v1 >= t4) + (v1 >= t5) + (v1 >= t6)]; + a2 = s_tran2[(v2 >= t0) + (v2 >= t1) + (v2 >= t2) + (v2 >= t3) + (v2 >= t4) + (v2 >= t5) + (v2 >= t6)]; + a3 = s_tran3[(v3 >= t0) + (v3 >= t1) + (v3 >= t2) + (v3 >= t3) + (v3 >= t4) + (v3 >= t5) + (v3 >= t6)]; + } + + { + const int v0 = pPixels[4 * stride] * 14 + bias; + const int v1 = pPixels[5 * stride] * 14 + bias; + const int v2 = pPixels[6 * stride] * 14 + bias; + const int v3 = pPixels[7 * stride] * 14 + bias; + a0 |= (uint64_t)(s_tran0[(v0 >= t0) + (v0 >= t1) + (v0 >= t2) + (v0 >= t3) + (v0 >= t4) + (v0 >= t5) + (v0 >= t6)] << 12U); + a1 |= (uint64_t)(s_tran1[(v1 >= t0) + (v1 >= t1) + (v1 >= t2) + (v1 >= t3) + (v1 >= t4) + (v1 >= t5) + (v1 >= t6)] << 12U); + a2 |= (uint64_t)(s_tran2[(v2 >= t0) + (v2 >= t1) + (v2 >= t2) + (v2 >= t3) + (v2 >= t4) + (v2 >= t5) + (v2 >= t6)] << 12U); + a3 |= (uint64_t)(s_tran3[(v3 >= t0) + (v3 >= t1) + (v3 >= t2) + (v3 >= t3) + (v3 >= t4) + (v3 >= t5) + (v3 >= t6)] << 12U); + } + + { + const int v0 = pPixels[8 * stride] * 14 + bias; + const int v1 = pPixels[9 * stride] * 14 + bias; + const int v2 = pPixels[10 * stride] * 14 + bias; + const int v3 = pPixels[11 * stride] * 14 + bias; + a0 |= (((uint64_t)s_tran0[(v0 >= t0) + (v0 >= t1) + (v0 >= t2) + (v0 >= t3) + (v0 >= t4) + (v0 >= t5) + (v0 >= t6)]) << 24U); + a1 |= (((uint64_t)s_tran1[(v1 >= t0) + (v1 >= t1) + (v1 >= t2) + (v1 >= t3) + (v1 >= t4) + (v1 >= t5) + (v1 >= t6)]) << 24U); + a2 |= (((uint64_t)s_tran2[(v2 >= t0) + (v2 >= t1) + (v2 >= t2) + (v2 >= t3) + (v2 >= t4) + (v2 >= t5) + (v2 >= t6)]) << 24U); + a3 |= (((uint64_t)s_tran3[(v3 >= t0) + (v3 >= t1) + (v3 >= t2) + (v3 >= t3) + (v3 >= t4) + (v3 >= t5) + (v3 >= t6)]) << 24U); + } + + { + const int v0 = pPixels[12 * stride] * 14 + bias; + const int v1 = pPixels[13 * stride] * 14 + bias; + const int v2 = pPixels[14 * stride] * 14 + bias; + const int v3 = pPixels[15 * stride] * 14 + bias; + a0 |= (((uint64_t)s_tran0[(v0 >= t0) + (v0 >= t1) + (v0 >= t2) + (v0 >= t3) + (v0 >= t4) + (v0 >= t5) + (v0 >= t6)]) << 36U); + a1 |= (((uint64_t)s_tran1[(v1 >= t0) + (v1 >= t1) + (v1 >= t2) + (v1 >= t3) + (v1 >= t4) + (v1 >= t5) + (v1 >= t6)]) << 36U); + a2 |= (((uint64_t)s_tran2[(v2 >= t0) + (v2 >= t1) + (v2 >= t2) + (v2 >= t3) + (v2 >= t4) + (v2 >= t5) + (v2 >= t6)]) << 36U); + a3 |= (((uint64_t)s_tran3[(v3 >= t0) + (v3 >= t1) + (v3 >= t2) + (v3 >= t3) + (v3 >= t4) + (v3 >= t5) + (v3 >= t6)]) << 36U); + } + + const uint64_t f = a0 | a1 | a2 | a3; + + pDst_bytes[2] = (uint8_t)f; + pDst_bytes[3] = (uint8_t)(f >> 8U); + pDst_bytes[4] = (uint8_t)(f >> 16U); + pDst_bytes[5] = (uint8_t)(f >> 24U); + pDst_bytes[6] = (uint8_t)(f >> 32U); + pDst_bytes[7] = (uint8_t)(f >> 40U); + } + + void encode_bc3(void* pDst, const uint8_t* pPixels, uint32_t flags, uint32_t total_orderings_to_try) + { + assert(g_initialized); + + // 3-color blocks are not allowed with BC3 (on most GPU's). + flags &= ~(cEncodeBC1Use3ColorBlocksForBlackPixels | cEncodeBC1Use3ColorBlocks); + + encode_bc4(pDst, pPixels + 3, 4); + encode_bc1(static_cast(pDst) + 8, pPixels, flags, total_orderings_to_try); + } + + void encode_bc3(uint32_t level, void* pDst, const uint8_t* pPixels) + { + assert(g_initialized); + + encode_bc4(pDst, pPixels + 3, 4); + encode_bc1(level, static_cast(pDst) + 8, pPixels, false, false); + } + + void encode_bc5(void* pDst, const uint8_t* pPixels, uint32_t chan0, uint32_t chan1, uint32_t stride) + { + assert(g_initialized); + + encode_bc4(pDst, pPixels + chan0, stride); + encode_bc4(static_cast(pDst) + 8, pPixels + chan1, stride); + } + + // Returns true if the block uses 3 color punchthrough alpha mode. + bool unpack_bc1(const void* pBlock_bits, void* pPixels, bool set_alpha, bc1_approx_mode mode) + { + color32* pDst_pixels = static_cast(pPixels); + + static_assert(sizeof(bc1_block) == 8, "sizeof(bc1_block) == 8"); + static_assert(sizeof(bc4_block) == 8, "sizeof(bc4_block) == 8"); + + const bc1_block* pBlock = static_cast(pBlock_bits); + + const uint32_t l = pBlock->get_low_color(); + const uint32_t h = pBlock->get_high_color(); + + color32 c[4]; + + const int cr0 = (l >> 11) & 31; + const int cg0 = (l >> 5) & 63; + const int cb0 = l & 31; + const int r0 = (cr0 << 3) | (cr0 >> 2); + const int g0 = (cg0 << 2) | (cg0 >> 4); + const int b0 = (cb0 << 3) | (cb0 >> 2); + + const int cr1 = (h >> 11) & 31; + const int cg1 = (h >> 5) & 63; + const int cb1 = h & 31; + const int r1 = (cr1 << 3) | (cr1 >> 2); + const int g1 = (cg1 << 2) | (cg1 >> 4); + const int b1 = (cb1 << 3) | (cb1 >> 2); + + bool used_punchthrough = false; + + if (l > h) + { + c[0].set_noclamp_rgba(r0, g0, b0, 255); + c[1].set_noclamp_rgba(r1, g1, b1, 255); + switch (mode) + { + case bc1_approx_mode::cBC1Ideal: + c[2].set_noclamp_rgba((r0 * 2 + r1) / 3, (g0 * 2 + g1) / 3, (b0 * 2 + b1) / 3, 255); + c[3].set_noclamp_rgba((r1 * 2 + r0) / 3, (g1 * 2 + g0) / 3, (b1 * 2 + b0) / 3, 255); + break; + case bc1_approx_mode::cBC1IdealRound4: + c[2].set_noclamp_rgba((r0 * 2 + r1 + 1) / 3, (g0 * 2 + g1 + 1) / 3, (b0 * 2 + b1 + 1) / 3, 255); + c[3].set_noclamp_rgba((r1 * 2 + r0 + 1) / 3, (g1 * 2 + g0 + 1) / 3, (b1 * 2 + b0 + 1) / 3, 255); + break; + case bc1_approx_mode::cBC1NVidia: + c[2].set_noclamp_rgba(interp_5_nv(cr0, cr1), interp_6_nv(g0, g1), interp_5_nv(cb0, cb1), 255); + c[3].set_noclamp_rgba(interp_5_nv(cr1, cr0), interp_6_nv(g1, g0), interp_5_nv(cb1, cb0), 255); + break; + case bc1_approx_mode::cBC1AMD: + c[2].set_noclamp_rgba(interp_5_6_amd(r0, r1), interp_5_6_amd(g0, g1), interp_5_6_amd(b0, b1), 255); + c[3].set_noclamp_rgba(interp_5_6_amd(r1, r0), interp_5_6_amd(g1, g0), interp_5_6_amd(b1, b0), 255); + break; + } + } + else + { + c[0].set_noclamp_rgba(r0, g0, b0, 255); + c[1].set_noclamp_rgba(r1, g1, b1, 255); + switch (mode) + { + case bc1_approx_mode::cBC1Ideal: + case bc1_approx_mode::cBC1IdealRound4: + c[2].set_noclamp_rgba((r0 + r1) / 2, (g0 + g1) / 2, (b0 + b1) / 2, 255); + break; + case bc1_approx_mode::cBC1NVidia: + c[2].set_noclamp_rgba(interp_half_5_nv(cr0, cr1), interp_half_6_nv(g0, g1), interp_half_5_nv(cb0, cb1), 255); + break; + case bc1_approx_mode::cBC1AMD: + c[2].set_noclamp_rgba(interp_half_5_6_amd(r0, r1), interp_half_5_6_amd(g0, g1), interp_half_5_6_amd(b0, b1), 255); + break; + } + + c[3].set_noclamp_rgba(0, 0, 0, 0); + used_punchthrough = true; + } + + if (set_alpha) + { + for (uint32_t y = 0; y < 4; y++, pDst_pixels += 4) + { + pDst_pixels[0] = c[pBlock->get_selector(0, y)]; + pDst_pixels[1] = c[pBlock->get_selector(1, y)]; + pDst_pixels[2] = c[pBlock->get_selector(2, y)]; + pDst_pixels[3] = c[pBlock->get_selector(3, y)]; + } + } + else + { + for (uint32_t y = 0; y < 4; y++, pDst_pixels += 4) + { + pDst_pixels[0].set_rgb(c[pBlock->get_selector(0, y)]); + pDst_pixels[1].set_rgb(c[pBlock->get_selector(1, y)]); + pDst_pixels[2].set_rgb(c[pBlock->get_selector(2, y)]); + pDst_pixels[3].set_rgb(c[pBlock->get_selector(3, y)]); + } + } + + return used_punchthrough; + } + + void unpack_bc4(const void* pBlock_bits, uint8_t* pPixels, uint32_t stride) + { + static_assert(sizeof(bc4_block) == 8, "sizeof(bc4_block) == 8"); + + const bc4_block* pBlock = static_cast(pBlock_bits); + + uint8_t sel_values[8]; + bc4_block::get_block_values(sel_values, pBlock->get_low_alpha(), pBlock->get_high_alpha()); + + const uint64_t selector_bits = pBlock->get_selector_bits(); + + for (uint32_t y = 0; y < 4; y++, pPixels += (stride * 4U)) + { + pPixels[0] = sel_values[pBlock->get_selector(0, y, selector_bits)]; + pPixels[stride * 1] = sel_values[pBlock->get_selector(1, y, selector_bits)]; + pPixels[stride * 2] = sel_values[pBlock->get_selector(2, y, selector_bits)]; + pPixels[stride * 3] = sel_values[pBlock->get_selector(3, y, selector_bits)]; + } + } + + // Returns false if the block uses 3-color punchthrough alpha mode, which isn't supported on some GPU's for BC3. + bool unpack_bc3(const void* pBlock_bits, void* pPixels, bc1_approx_mode mode) + { + color32* pDst_pixels = static_cast(pPixels); + + bool success = true; + + if (unpack_bc1((const uint8_t*)pBlock_bits + sizeof(bc4_block), pDst_pixels, true, mode)) + success = false; + + unpack_bc4(pBlock_bits, &pDst_pixels[0].a, sizeof(color32)); + + return success; + } + + // writes RG + void unpack_bc5(const void* pBlock_bits, void* pPixels, uint32_t chan0, uint32_t chan1, uint32_t stride) + { + unpack_bc4(pBlock_bits, (uint8_t *)pPixels + chan0, stride); + unpack_bc4((const uint8_t*)pBlock_bits + sizeof(bc4_block), (uint8_t *)pPixels + chan1, stride); + } + +} // namespace rgbcx + +#endif //#ifdef RGBCX_IMPLEMENTATION + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright(c) 2020 Richard Geldreich, Jr. +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files(the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions : +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain(www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non - commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain.We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors.We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/extern/rg/rgbcx_table4.h b/extern/rg/rgbcx_table4.h new file mode 100644 index 00000000..cda3f0a1 --- /dev/null +++ b/extern/rg/rgbcx_table4.h @@ -0,0 +1,969 @@ +{ 202,403,51,450,318,23,120,13,494,5,523,260,77,21,15,128,48,141,33,817,137,269,12,102,1,475,4,326,7,32,453,64,196,115,730,49,165,2,82,342,6,401,180,31,899,59,402,351,197,17,125,457,14,386,40,3,61,58,37,221,95,16,99,719,98,20,10,854,117,153,27,576,134,341,308,216,11,194,30,24,922,285,9,50,86,65,19,615,391,44,75,237,177,90,352,93,56,22,18,116,70,96,247,291,45,110,105,60,57,54,43,36,0,217,421,203,46,629,569,365,210,92,69,66,38,28,144,551 }, +{ 13,115,51,23,141,217,269,137,318,202,77,21,317,5,64,4,291,2,352,7,32,33,6,372,0,48,365,3,102,349,12,341,177,180,10,237,9,221,403,165,752,22,11,244,28,308,15,128,247,197,49,16,494,125,98,40,120,498,31,90,304,143,95,93,437,196,144,86,44,864,153,18,678,342,901,39,24,30,203,160,117,105,475,14,482,253,457,873,59,35,579,36,569,450,206,72,99,17,717,401,241,453,110,546,201,83,421,61,37,326,260,509,284,275,96,8,109,57,391,386,468,134,82,961,822,576,89,68 }, +{ 29,58,262,74,287,52,151,331,171,500,396,334,75,27,635,220,53,1,26,409,6,324,5,70,145,223,163,112,73,50,45,549,445,113,297,19,675,651,46,61,502,307,14,17,34,573,186,80,394,436,583,315,138,38,21,767,250,491,820,350,64,2,32,357,42,852,25,764,309,67,802,96,631,48,606,780,243,881,103,241,115,807,13,4,155,181,11,106,611,614,278,153,23,108,69,845,841,308,400,72,853,200,66,196,226,237,587,632,24,281,785,133,128,125,117,380,95,474,294,83,197,90,161,134,366,236,760,311 }, +{ 40,51,62,33,453,14,23,56,730,196,475,99,12,34,139,775,153,403,585,440,102,38,130,47,162,17,108,880,117,11,202,57,361,84,123,27,184,236,4,128,19,2,670,136,54,26,111,134,13,161,277,719,152,6,377,183,5,59,211,53,412,485,46,328,77,711,78,21,556,452,65,283,421,129,37,514,507,402,176,29,25,229,401,488,757,45,76,205,899,322,32,177,494,527,383,497,457,249,300,114,215,555,386,119,133,0,349,115,3,862,1,165,73,41,523,72,200,64,291,217,80,305,22,318,194,308,18,714 }, +{ 33,51,102,202,23,128,196,13,64,153,40,12,141,99,403,15,10,269,77,139,475,453,5,318,117,2,14,134,1,86,165,120,401,3,0,22,137,6,197,277,17,402,180,21,421,494,37,115,31,82,38,9,95,342,93,7,110,351,125,457,65,36,361,49,54,19,260,111,44,291,237,28,8,11,194,961,719,352,217,18,485,523,308,730,386,326,210,450,328,300,98,899,27,32,341,48,25,670,34,50,629,26,24,503,498,285,317,67,817,143,365,177,509,41,164,116,757,55,46,203,569,898,373,114,144,16,349,775 }, +{ 13,23,51,115,77,177,202,4,141,32,40,33,217,64,128,90,269,102,59,318,11,291,0,137,403,22,21,7,165,197,15,210,247,180,16,117,153,352,14,2,125,494,10,49,237,18,95,453,6,9,1,24,28,349,475,216,12,342,317,304,3,196,86,98,275,134,31,17,35,25,365,308,19,341,44,36,372,30,93,20,401,76,241,402,139,752,57,244,105,386,37,26,260,110,288,120,116,48,326,421,221,285,901,38,99,82,498,39,468,55,523,143,111,482,65,300,214,450,203,457,351,43,29,27,8,576,678,569 }, +{ 235,26,19,648,624,630,78,47,122,444,145,27,665,112,85,42,390,416,813,113,130,65,680,64,711,25,453,108,644,6,53,73,138,256,95,412,22,730,29,289,90,194,34,525,74,690,32,297,128,45,196,250,287,133,445,86,283,214,236,237,137,222,884,200,746,59,52,312,77,280,632,0,17,114,835,51,123,14,288,881,28,307,180,57,381,141,183,70,4,472,10,33,76,337,3,389,247,315,2,18,368,849,874,573,23,58,544,153,151,436,102,322,99,352,36,1,177,714,719,125,597,63,165,519,285,49,13,396 }, +{ 64,352,751,141,217,247,237,304,269,954,437,372,177,947,312,86,318,349,180,875,95,864,291,597,498,128,678,77,232,92,115,317,752,32,202,588,59,197,579,90,638,392,652,76,210,546,260,1,448,126,340,164,18,303,13,165,275,14,582,120,633,205,179,69,156,296,35,230,391,888,267,572,28,16,379,851,660,96,717,314,0,23,863,49,195,39,223,5,386,137,75,509,107,571,563,46,194,526,309,21,450,342,288,140,83,24,330,87,70,50,12,9,514,365,246,199,100,65,36,385,55,125,658,244,326,264,696,453 }, +{ 642,898,638,180,901,341,82,197,951,10,762,253,165,15,752,811,479,244,143,365,569,873,242,110,506,351,31,8,116,55,137,115,317,499,141,352,44,338,206,373,386,854,164,22,758,93,37,217,36,1,417,77,629,661,21,717,33,9,564,160,401,456,30,4,203,559,5,509,86,28,326,102,282,268,535,0,13,308,170,269,11,498,391,51,120,2,457,64,704,965,40,32,23,299,421,482,148,615,39,318,533,3,169,961,801,202,260,851,576,117,247,221,349,372,670,968,403,468,291,285,128,824,134,719,237,734,177,342 }, +{ 51,221,23,254,308,438,21,125,166,39,530,656,159,401,49,13,158,115,386,421,688,613,629,228,743,48,518,190,627,453,0,829,333,30,105,912,341,9,670,424,827,165,406,217,404,840,669,391,137,274,197,301,286,272,170,468,457,95,89,22,770,242,33,310,109,569,938,393,960,1,101,36,88,773,538,364,890,131,616,100,28,219,456,344,64,479,679,734,327,846,365,261,55,317,32,5,4,492,180,68,67,482,237,475,793,385,2,367,16,7,347,293,371,224,86,35,719,762,578,332,202,102,442,865,12,949,351,98 }, +{ 1,143,31,197,44,116,242,2,180,125,23,55,206,13,93,498,5,8,115,341,36,752,638,338,141,268,64,901,165,456,0,203,951,546,479,365,873,253,417,4,569,137,15,762,506,237,12,352,965,120,3,299,244,170,164,7,22,282,51,144,6,86,864,21,269,384,558,128,37,9,457,326,844,492,160,961,391,499,202,509,599,870,260,317,685,434,127,217,824,393,373,489,629,77,98,903,308,33,559,332,811,473,301,318,401,102,963,28,386,564,918,367,110,105,911,285,959,523,134,482,740,678,169,617,14,96,758,450 }, +{ 12,23,51,37,13,99,14,38,15,196,328,54,21,134,153,64,453,401,117,128,2,33,139,120,308,5,82,141,361,0,277,29,403,351,719,165,10,115,629,457,46,475,89,450,22,32,110,260,1,31,269,93,9,137,8,386,202,125,86,18,40,111,52,180,17,49,48,4,102,72,477,523,474,326,318,45,898,3,44,402,197,77,730,203,28,24,6,19,421,854,961,352,237,194,114,65,155,373,116,50,36,498,242,236,221,98,55,16,25,7,217,391,569,880,615,41,546,144,509,59,316,79,57,514,494,317,899,488 }, +{ 13,23,15,961,457,115,569,51,165,38,197,2,4,1,474,5,719,99,629,77,0,14,37,401,3,33,7,94,6,128,11,40,10,453,59,64,153,79,509,482,54,17,21,328,111,89,139,277,12,102,498,188,9,152,141,734,76,157,873,386,196,402,32,475,177,117,72,391,36,8,730,758,237,45,304,57,403,134,579,148,202,775,22,523,341,29,431,318,317,308,120,546,62,313,468,437,86,405,217,180,361,50,269,46,342,90,31,143,16,48,44,339,184,19,49,27,18,749,41,450,880,542,205,901,300,216,164,52 }, +{ 15,10,12,0,1,23,961,197,5,82,2,4,3,120,134,457,7,165,260,33,51,9,6,11,351,31,22,21,14,64,8,180,40,450,110,141,386,898,719,523,37,17,153,102,77,117,44,341,217,32,326,93,36,854,269,317,115,18,730,352,49,922,196,365,202,901,28,38,99,59,291,817,125,318,16,569,453,403,55,498,475,111,48,30,94,372,349,342,752,41,391,139,72,474,128,19,899,373,210,203,57,873,661,177,494,98,79,86,143,95,509,27,76,401,89,864,615,304,116,431,144,482,758,137,35,45,29,277 }, +{ 23,51,13,961,719,457,730,401,453,386,758,165,99,899,328,0,10,9,2,1,308,15,134,33,7,6,5,117,54,12,153,11,523,4,391,403,197,629,40,139,14,22,361,28,202,509,128,402,236,231,888,488,369,111,87,57,196,514,79,115,880,317,65,35,817,377,3,291,46,176,77,49,44,38,31,8,450,64,585,477,244,180,141,498,120,507,412,283,102,59,775,475,114,108,62,52,546,237,188,160,157,152,137,94,452,383,260,95,56,440,215,830,774,757,622,569,494,485,472,342,330,300,275,210,203,201,187,144 }, +{ 134,898,82,117,13,23,33,102,153,77,351,341,196,197,110,260,961,180,901,10,120,165,115,111,457,8,450,854,177,40,569,51,94,365,37,11,922,523,277,4,326,291,0,79,55,342,1,9,93,642,12,217,59,352,817,202,5,730,317,21,873,719,141,31,661,811,629,349,16,98,509,373,386,453,372,44,64,18,54,32,3,139,203,116,615,275,22,125,269,210,899,38,318,128,2,144,752,57,479,49,704,17,28,90,30,6,564,638,95,7,403,475,137,304,494,758,474,300,48,36,391,237,498,482,105,499,14,39 }, +{ 60,126,167,191,18,71,35,121,199,16,271,24,212,92,146,150,118,575,107,68,727,566,446,132,21,273,463,108,246,7,279,467,48,653,695,608,517,589,1,101,9,598,5,354,14,649,55,562,345,522,97,98,441,375,140,0,195,22,407,640,149,28,32,223,10,156,49,298,125,13,423,755,508,953,363,221,23,411,314,46,50,781,346,447,154,37,12,818,356,95,647,302,31,230,43,69,674,2,388,20,783,809,232,621,359,189,267,362,124,175,67,293,105,51,109,65,360,493,520,236,163,607,535,75,165,103,39,33 }, +{ 136,62,129,123,128,41,162,789,211,618,249,214,183,678,248,507,38,216,710,119,152,177,269,130,64,17,57,141,245,597,318,205,184,4,179,90,503,77,59,402,305,106,3,313,229,157,266,54,210,139,102,257,275,556,209,45,117,40,13,11,292,99,328,76,457,33,339,23,452,378,217,86,291,80,194,471,369,947,349,383,188,524,497,304,542,381,255,153,519,751,494,240,361,84,803,588,202,32,440,372,115,403,742,164,56,529,12,137,37,790,21,5,504,432,207,196,10,14,285,215,134,342,36,15,587,0,358,165 }, +{ 523,494,475,403,51,899,817,453,202,23,450,730,421,13,805,120,128,757,102,5,4,719,33,21,342,318,958,326,196,153,260,402,7,1,386,12,48,133,65,20,32,457,141,9,8,615,16,114,108,14,10,77,19,0,361,137,17,300,84,82,59,351,123,3,194,576,11,700,221,401,269,95,64,49,177,541,27,40,57,26,115,125,117,22,474,308,99,37,862,701,304,193,56,503,91,697,551,134,105,283,50,129,86,24,249,240,2,942,814,673,671,579,569,519,490,468,437,397,389,365,352,349,306,291,281,247,218,208 }, +{ 59,4,84,62,77,40,3,102,76,119,27,33,56,177,32,12,161,73,21,196,136,123,17,210,11,193,216,80,90,18,64,57,128,51,6,25,13,611,300,63,202,65,48,415,42,605,106,23,152,0,99,275,22,217,803,26,49,205,122,503,291,53,5,2,37,29,349,87,667,453,402,318,209,361,19,690,283,403,718,445,342,129,14,61,194,79,436,245,370,397,297,141,86,862,485,269,240,52,91,85,494,304,510,153,95,573,115,1,45,416,249,184,139,757,475,255,133,81,529,292,41,469,111,680,250,813,113,31 }, +{ 43,414,422,319,20,819,945,7,0,376,61,904,97,470,325,173,707,5,804,693,22,104,14,49,560,426,330,95,595,32,392,17,107,147,207,887,577,246,46,21,324,356,77,74,344,725,58,52,1,198,113,784,347,28,27,18,66,38,76,427,135,105,329,31,858,25,12,158,526,291,263,112,9,523,357,239,232,120,115,362,81,230,359,118,19,10,715,450,119,241,64,44,259,424,315,24,260,140,13,942,292,350,165,102,56,45,37,36,861,125,879,817,719,600,86,33,30,2,814,204,500,476,205,98,26,16,180,179 }, +{ 13,23,51,217,115,77,141,2,33,10,4,0,64,7,180,6,102,40,11,22,317,9,14,269,352,3,1,5,202,197,15,177,341,165,59,237,291,125,365,16,12,128,28,18,247,318,308,31,153,196,349,95,372,117,36,17,24,137,49,498,98,752,32,403,304,134,90,475,342,457,453,210,143,401,93,391,19,86,44,120,30,901,275,386,8,57,105,216,244,164,569,39,65,494,509,20,29,110,25,421,864,961,139,116,873,38,55,27,719,37,35,82,50,221,482,46,260,56,26,546,450,316,468,351,326,45,899,523 }, +{ 28,49,24,105,35,65,159,0,55,109,1,16,239,320,14,7,347,95,424,158,168,170,124,9,2,185,67,68,301,18,169,654,286,149,12,289,175,36,5,127,154,21,10,71,69,114,98,64,740,83,512,39,108,13,272,48,164,327,31,23,623,420,374,395,46,50,713,125,371,518,51,194,338,577,312,6,37,143,916,22,346,344,429,570,32,86,835,103,336,761,101,928,44,638,242,890,737,60,133,202,237,293,115,538,30,762,128,141,137,38,302,398,747,484,479,165,439,189,96,844,610,92,221,299,892,308,54,131 }, +{ 15,10,0,12,1,457,13,165,5,2,82,9,4,117,120,7,961,3,134,6,64,22,197,14,11,260,351,37,33,32,51,21,31,719,77,141,180,38,341,17,8,365,450,317,102,217,153,28,523,269,110,115,44,93,898,372,854,202,386,18,196,40,291,326,99,901,49,730,349,453,352,16,128,125,922,36,237,72,111,318,509,177,76,59,342,403,48,475,817,401,98,391,29,30,89,752,90,474,373,569,27,137,45,704,24,275,19,95,328,55,494,54,498,86,899,143,437,139,210,304,629,758,57,25,402,116,546,873 }, +{ 7,97,71,14,92,150,140,60,149,189,18,16,517,69,336,398,298,154,124,66,302,35,43,68,175,467,273,38,230,118,251,508,314,429,24,2,28,399,172,232,20,0,882,36,279,55,423,173,267,6,46,1,107,126,67,375,83,566,108,22,74,65,547,29,607,104,192,5,426,246,135,847,52,81,531,420,109,596,501,10,809,9,13,952,387,533,505,608,484,169,21,458,330,674,628,49,823,86,25,345,158,51,191,705,48,101,637,12,386,723,439,570,324,653,462,185,168,697,779,535,783,796,346,114,722,861,799,95 }, +{ 102,4,77,59,33,210,11,342,40,32,12,64,128,139,624,5,503,196,202,90,494,21,300,91,51,233,318,403,23,17,291,177,416,269,275,678,141,817,450,13,529,0,25,10,3,485,277,153,151,49,37,42,789,216,496,457,115,57,197,680,214,22,18,788,523,249,205,27,389,194,86,72,453,122,145,480,81,26,961,280,148,138,134,111,104,74,65,6,899,730,204,165,120,89,209,804,475,348,123,95,19,636,396,174,693,651,287,125,869,750,629,306,257,76,48,386,349,221,61,45,803,784,544,402,397,240,58,31 }, +{ 25,42,256,235,19,122,85,436,813,6,297,680,53,26,573,416,233,445,390,63,605,73,250,343,80,27,65,630,389,283,106,255,194,444,45,17,138,544,396,690,525,503,648,269,141,64,119,33,145,123,611,113,128,102,174,112,84,91,29,789,70,624,4,412,77,0,736,483,209,358,205,597,179,56,117,249,243,280,287,108,153,650,196,619,114,32,136,78,678,18,746,348,5,129,2,495,200,57,14,378,76,240,40,511,86,137,161,90,216,10,684,881,23,665,222,22,432,12,289,51,177,1,21,214,370,245,134,11 }, +{ 102,300,402,128,202,403,33,23,342,77,40,99,21,757,84,12,115,196,483,318,19,119,117,210,494,139,90,32,25,4,569,153,469,277,26,475,91,134,63,59,80,523,73,14,275,51,485,453,44,36,31,10,6,48,576,37,49,22,352,193,56,165,18,790,152,415,53,42,880,125,370,291,177,74,13,1,197,180,81,64,62,3,814,611,343,161,136,106,391,386,138,129,66,54,45,38,34,27,17,2,678,11,378,770,697,543,511,504,120,65,82,226,961,899,862,730,718,690,643,317,256,235,89,87,72,61,47,605 }, +{ 158,109,9,39,49,0,35,65,168,68,24,124,159,344,185,154,22,55,333,577,272,175,254,289,810,169,16,327,101,346,95,105,570,149,747,627,286,374,71,310,703,67,439,793,30,28,252,429,131,419,1,455,912,114,610,671,347,18,424,364,7,36,835,100,194,14,21,420,239,336,86,688,10,634,69,108,83,538,706,709,578,484,23,518,2,320,64,51,13,166,48,12,60,118,962,170,128,5,190,133,913,398,50,46,125,677,535,137,127,96,98,345,302,189,826,584,103,251,31,224,638,37,265,92,160,722,219,32 }, +{ 237,498,546,180,115,197,873,287,5,34,923,61,297,509,165,45,400,80,445,2,311,341,3,58,52,468,176,231,186,881,250,64,13,56,151,48,17,217,62,490,14,153,141,23,513,901,51,391,21,667,334,247,352,903,171,84,482,161,549,10,72,401,243,53,738,592,196,46,316,73,719,308,869,666,396,365,645,106,130,585,125,887,635,569,215,86,749,1,207,864,472,177,211,317,22,659,573,37,95,40,227,136,33,372,527,29,507,483,128,651,90,469,229,629,436,833,721,787,758,515,437,54,36,27,117,32,430,304 }, +{ 120,968,704,260,373,450,202,137,661,326,717,269,349,110,217,77,318,473,1,652,95,851,291,93,177,244,33,21,372,141,719,102,351,82,518,156,51,48,848,340,210,928,713,160,922,98,296,128,817,146,86,827,304,264,32,197,225,115,623,317,212,96,23,751,386,854,35,13,7,863,698,180,919,494,385,64,800,253,730,678,523,140,15,70,65,303,453,437,275,247,49,642,341,352,127,37,888,737,5,942,898,167,776,87,658,744,692,615,389,203,101,36,478,196,190,393,59,55,363,132,118,850,163,131,916,836,811,599 }, +{ 44,116,144,268,489,434,367,384,127,918,98,855,940,948,617,206,203,959,93,137,105,31,332,393,492,22,131,9,911,282,276,141,219,202,0,49,284,28,299,120,326,36,39,417,269,1,51,523,30,473,935,899,293,318,352,125,23,395,253,64,13,244,55,160,10,551,128,95,403,373,201,143,450,115,260,8,692,386,21,86,109,110,187,730,165,456,272,737,159,791,261,499,170,7,16,341,728,295,77,951,5,48,96,944,559,242,258,365,371,494,24,254,2,317,421,578,752,18,224,716,164,197,391,285,301,498,924,12 }, +{ 77,13,23,51,102,33,141,64,115,0,177,291,217,202,269,6,2,7,4,318,40,14,180,128,59,1,10,196,117,153,22,11,16,15,352,95,134,9,137,3,165,197,210,18,86,403,17,237,28,49,304,342,125,275,12,349,24,341,247,317,453,5,90,19,475,216,57,25,36,494,65,365,27,20,457,31,120,143,93,498,372,308,401,402,391,29,26,752,260,98,110,719,312,82,961,164,45,56,386,35,44,139,21,99,509,30,730,194,38,244,144,351,8,37,111,203,421,546,50,300,96,288,285,208,46,54,39,901 }, +{ 15,4,11,40,141,165,23,32,202,180,21,197,64,269,125,13,59,386,120,93,51,110,77,5,128,57,318,457,82,3,12,523,260,0,17,49,10,450,730,134,117,31,403,1,719,352,8,102,137,22,115,90,153,899,351,98,44,326,237,2,494,475,139,203,391,144,9,111,961,56,37,402,116,177,210,48,801,453,65,196,6,95,217,341,509,14,421,99,76,291,7,86,216,373,758,401,498,18,28,752,27,36,275,365,300,72,342,615,901,854,898,247,317,45,922,105,127,30,308,152,304,123,817,551,19,791,393,55 }, +{ 176,231,585,62,56,161,412,34,236,527,14,440,202,3,57,17,283,361,84,402,136,23,369,51,128,4,803,13,130,472,383,548,322,507,46,719,457,555,53,73,38,514,503,250,381,119,59,200,162,64,77,452,401,495,153,469,11,229,318,29,205,211,196,497,453,152,2,730,556,240,33,390,27,372,210,184,106,961,215,183,123,65,757,629,99,494,108,129,52,37,18,0,21,40,529,515,475,54,377,828,275,209,197,217,117,1,899,543,300,269,245,862,483,305,45,504,378,342,297,111,102,76,50,24,10,95,12,611 }, +{ 101,9,237,180,0,352,217,230,498,141,100,88,702,115,68,317,83,175,213,39,365,1,252,30,345,752,64,546,482,208,321,864,265,341,490,562,13,372,818,336,952,399,128,69,36,244,197,212,96,410,21,154,689,269,158,28,251,289,166,194,65,382,419,48,443,759,596,901,873,23,468,67,51,16,547,831,797,165,570,55,285,264,930,329,49,756,646,346,124,694,144,391,579,799,854,247,35,190,189,164,699,755,24,364,203,777,323,238,429,569,768,435,37,724,466,201,349,12,509,723,840,50,789,826,160,676,291,137 }, +{ 28,22,49,109,9,39,1,95,0,105,158,168,83,185,159,55,86,30,96,208,141,272,128,12,420,5,505,13,31,327,169,160,131,69,67,137,23,202,21,64,115,251,286,254,51,35,98,127,2,101,244,44,238,194,48,197,50,531,10,7,217,927,180,533,175,352,584,103,285,269,165,37,65,218,100,535,317,323,68,374,946,239,597,24,837,735,289,797,896,418,341,347,333,601,170,116,346,365,237,143,318,345,678,32,344,125,16,164,498,627,253,752,402,577,424,310,4,219,99,403,252,6,312,144,578,166,789,242 }, +{ 72,76,38,89,51,477,4,413,308,179,474,12,152,401,57,148,59,11,205,99,54,421,670,23,245,17,629,431,79,488,405,90,94,184,13,569,21,453,32,229,128,3,358,45,197,14,475,188,77,528,157,464,316,165,257,543,115,41,288,202,457,428,961,216,15,341,403,40,734,266,5,339,749,10,64,33,2,452,328,217,645,460,141,775,111,313,468,1,247,361,102,277,432,743,365,381,587,482,62,509,37,269,0,769,497,471,285,137,402,177,794,449,155,6,318,542,377,86,805,181,129,9,369,7,153,524,349,243 }, +{ 23,13,457,961,15,51,165,629,12,719,11,3,197,2,1,37,0,117,5,569,7,509,33,153,40,196,6,134,328,99,9,542,391,237,17,474,139,111,277,64,453,54,730,546,386,401,57,4,38,14,514,45,775,59,734,361,115,21,102,41,498,477,77,873,431,475,880,369,339,19,587,62,89,377,29,27,523,479,248,128,758,308,482,352,291,275,210,32,8,468,413,164,94,155,659,428,864,752,751,579,494,405,403,397,342,247,240,216,184,180,171,148,122,106,91,84,72,56,52,34,721,188,157,79,654,597,312,95 }, +{ 254,310,100,166,625,9,265,272,30,731,190,39,404,557,688,1,578,131,98,593,101,616,438,264,0,31,829,252,795,716,127,21,382,51,812,49,88,93,613,48,105,827,478,274,18,639,329,36,44,656,23,203,363,68,411,96,682,159,16,116,327,160,242,128,333,13,5,938,910,224,35,447,286,676,144,165,921,530,67,228,137,520,125,219,223,22,724,455,86,33,846,110,284,118,627,905,120,24,77,115,65,83,737,435,32,158,856,664,95,326,924,821,102,518,167,960,202,385,395,931,371,406,10,69,403,55,709,40 }, +{ 51,23,202,99,128,12,15,13,120,403,10,453,153,196,141,64,165,5,318,117,475,82,197,269,401,33,260,2,37,3,1,110,0,14,180,93,386,22,21,450,421,31,402,115,125,137,17,351,134,326,102,494,6,38,308,457,44,36,4,77,11,95,523,28,49,7,9,8,719,237,352,730,32,203,116,391,373,57,18,98,59,361,86,54,19,89,285,775,328,277,757,498,341,854,111,16,27,139,72,45,48,41,143,79,509,961,898,758,342,291,65,474,488,30,569,217,144,56,901,242,899,670,34,24,678,817,922,194 }, +{ 38,99,542,453,139,196,117,457,23,328,13,111,37,134,961,11,12,775,401,51,587,40,474,153,277,477,54,629,475,33,719,79,165,41,14,569,157,4,413,188,89,115,64,339,734,308,15,361,369,197,313,102,94,247,155,45,248,236,57,514,72,758,402,128,181,485,377,509,86,237,488,0,403,266,141,46,10,164,211,471,184,588,65,180,29,2,875,528,490,95,76,22,5,50,17,7,721,670,391,49,18,503,817,789,431,21,257,216,32,208,305,177,136,1,880,803,352,140,342,260,229,202,67,867,597,59,757,899 }, +{ 85,6,233,343,91,25,138,26,63,174,256,235,122,29,19,81,283,65,605,648,42,718,445,370,4,74,59,573,389,416,194,396,45,177,544,297,355,64,141,348,145,77,114,216,123,280,436,881,133,680,432,87,70,511,137,108,27,128,57,630,0,11,415,18,90,503,619,86,412,40,287,17,397,789,222,14,73,269,32,66,52,291,204,243,56,22,209,275,597,104,76,72,529,148,678,84,80,119,53,643,304,210,208,285,33,46,2,523,5,311,813,636,510,381,255,10,524,112,102,403,289,214,152,483,62,736,525,349 }, +{ 49,5,197,408,193,18,20,61,713,350,173,21,64,97,509,95,729,841,263,0,241,32,165,104,43,422,65,125,35,510,60,474,7,120,102,523,397,14,48,232,260,128,347,68,546,387,38,58,693,403,16,105,81,71,115,784,10,560,91,72,6,862,27,92,51,707,344,22,9,237,319,29,414,107,55,66,643,147,663,450,391,498,240,357,70,468,90,2,751,370,98,701,84,819,903,330,207,623,141,63,52,718,569,308,864,475,25,159,74,283,356,326,158,86,12,900,494,137,171,42,221,202,85,734,386,847,873,650 }, +{ 434,144,268,489,116,384,367,855,940,206,617,332,959,911,127,93,44,98,203,137,276,282,219,202,131,22,141,31,417,284,918,9,36,105,28,201,269,258,244,120,473,23,318,523,51,326,253,1,450,39,0,30,352,160,948,143,10,13,8,110,49,64,125,55,551,935,951,692,295,187,128,21,86,261,567,260,499,559,373,96,224,170,899,386,242,115,299,817,95,662,728,293,165,197,811,395,159,48,492,365,109,317,498,403,37,752,341,393,836,638,717,5,180,254,77,15,272,851,164,24,944,494,237,385,16,7,301,391 }, +{ 106,17,255,32,64,62,136,292,162,129,476,352,237,214,123,519,241,720,141,752,498,247,211,41,119,209,864,507,249,180,179,290,710,954,425,148,317,618,197,90,186,21,5,115,248,77,76,269,217,183,45,48,14,227,130,3,263,12,304,38,165,128,243,546,23,2,358,207,117,164,57,579,51,245,205,54,454,313,152,350,177,13,155,873,339,270,50,4,428,378,157,655,449,496,305,400,365,171,86,1,437,742,556,372,369,408,471,328,266,216,33,80,153,139,460,181,597,542,316,40,102,29,751,59,361,257,84,341 }, +{ 2,29,52,58,5,50,27,6,53,26,171,45,366,151,14,287,61,19,357,74,17,73,764,1,113,34,297,309,218,262,181,38,133,48,583,70,487,600,739,334,25,396,250,760,281,96,186,445,516,75,502,635,315,114,308,108,3,223,80,549,42,545,103,331,324,106,200,163,112,21,785,67,436,145,603,238,401,243,51,37,651,433,155,834,491,675,236,99,745,209,161,13,845,32,227,115,409,23,894,388,765,12,56,36,311,255,220,920,766,138,323,453,573,24,594,62,59,65,832,754,160,86,54,307,283,83,285,629 }, +{ 130,711,412,381,59,196,210,730,236,77,402,401,803,202,453,361,99,108,283,291,153,57,183,128,503,421,4,51,14,719,432,11,318,275,117,23,529,757,3,475,13,339,457,133,488,123,670,899,603,369,134,33,65,46,266,386,2,47,754,12,32,389,114,38,838,56,300,40,102,177,739,111,961,523,629,328,758,64,54,90,216,514,269,21,594,0,743,37,775,657,576,894,403,152,650,194,471,34,200,5,832,162,50,494,805,472,18,165,22,6,29,181,95,285,10,129,188,480,15,1,322,24,229,342,139,714,79,86 }, +{ 13,23,51,217,115,77,141,33,4,64,10,202,102,180,0,40,317,352,177,11,291,269,197,165,9,32,22,59,7,2,128,318,341,18,15,21,237,137,117,6,16,5,95,3,153,403,125,349,365,14,247,752,49,12,196,28,31,453,90,1,24,98,304,17,143,494,372,308,244,475,498,134,210,221,120,901,401,36,342,421,86,93,44,30,216,260,35,164,457,19,110,275,569,391,57,386,203,105,326,55,864,82,402,523,241,139,8,450,39,873,730,719,144,65,20,253,160,27,351,116,72,29,437,509,37,629,285,546 }, +{ 23,13,202,51,21,269,141,120,5,48,128,137,318,523,15,102,125,98,1,450,93,403,165,260,64,197,77,33,180,12,457,32,221,82,817,115,44,110,31,7,352,494,2,386,475,308,117,4,153,326,14,401,719,116,196,421,37,237,16,453,9,144,730,351,17,99,6,30,291,402,203,18,11,899,19,24,217,96,498,40,391,20,10,39,95,854,3,341,50,134,349,293,373,177,615,35,365,65,139,0,45,285,372,61,8,317,90,922,805,901,342,59,43,898,76,29,509,393,127,86,752,170,208,105,89,72,67,38 }, +{ 2,1,46,14,52,29,171,67,38,103,58,75,70,69,163,24,83,223,5,96,309,181,54,186,112,334,108,45,394,675,155,366,220,35,238,151,16,236,409,18,281,760,307,133,537,400,36,71,189,328,227,433,28,218,766,61,545,65,17,487,149,7,48,552,21,502,0,12,262,19,87,6,765,114,25,388,267,150,113,820,418,50,549,27,26,37,251,22,99,335,430,486,32,60,536,287,68,587,9,828,55,64,74,243,10,516,137,160,86,66,128,311,600,696,739,852,583,451,336,315,514,72,135,80,175,145,89,294 }, +{ 15,2,1,13,0,10,153,5,9,7,12,23,3,14,117,6,165,134,4,719,457,196,82,341,180,197,33,22,120,115,77,8,961,21,64,217,102,317,569,365,351,141,260,32,31,18,28,291,11,16,110,111,37,125,93,386,17,202,40,450,269,372,730,901,99,898,44,36,177,854,38,342,349,352,48,523,758,318,453,57,128,401,391,304,72,76,403,19,922,326,752,29,629,49,509,475,237,137,116,98,89,55,373,95,24,27,26,30,494,247,59,482,86,25,210,96,54,46,437,899,139,65,253,817,661,498,308,873 }, +{ 509,197,546,391,165,180,308,13,23,498,569,29,873,115,901,5,401,61,457,903,80,734,629,468,3,287,34,2,45,758,311,445,250,579,297,341,961,237,17,186,171,749,386,51,14,38,217,231,48,58,62,400,46,752,247,64,211,176,490,106,719,56,764,738,667,227,215,349,151,11,558,316,502,513,833,32,161,243,54,317,153,196,50,21,53,40,365,583,155,923,10,6,587,334,305,483,33,4,369,372,181,136,1,125,119,12,482,130,552,263,57,52,95,123,814,266,84,832,495,645,739,864,96,15,787,472,129,36 }, +{ 73,19,250,27,714,200,444,472,26,34,813,53,390,322,17,283,78,297,106,630,436,113,122,690,123,432,136,128,176,862,161,389,503,684,611,495,80,378,62,42,108,529,14,56,469,57,25,412,236,177,59,47,65,102,6,216,275,3,381,680,235,179,527,605,84,129,383,130,619,183,368,46,255,814,33,23,318,2,789,77,141,13,453,194,245,51,11,445,45,4,152,63,650,269,22,90,64,0,133,440,29,349,40,585,86,678,736,291,95,196,153,184,361,18,210,38,58,803,401,5,117,10,114,358,61,730,249,119 }, +{ 17,21,3,45,62,32,155,119,106,38,5,328,14,828,227,76,2,401,209,123,129,243,270,115,540,29,56,536,46,12,221,488,99,13,629,57,72,719,181,51,552,290,361,136,41,37,514,165,543,152,421,408,84,48,77,308,207,255,90,306,23,263,569,11,454,52,587,162,758,378,4,89,80,754,130,402,236,197,186,440,457,27,383,157,50,1,183,311,832,128,10,794,425,59,576,961,211,741,453,805,790,86,742,496,386,34,313,54,700,600,266,148,659,202,19,94,341,22,880,509,229,240,697,770,670,548,73,177 }, +{ 115,341,873,365,197,13,901,180,569,752,317,1,509,498,10,143,15,4,634,165,268,943,261,5,258,23,237,116,141,0,127,601,244,843,282,253,164,44,12,33,64,860,638,533,219,77,144,9,567,31,134,7,2,352,864,276,160,535,51,206,217,824,125,391,8,28,951,295,11,93,332,201,40,964,844,308,137,6,3,120,531,260,22,36,482,98,177,111,318,474,417,37,170,82,961,291,196,102,169,924,434,203,153,94,954,395,734,898,384,269,242,479,965,735,405,326,30,728,662,617,386,159,24,18,944,401,301,367 }, +{ 453,51,23,33,403,475,421,196,153,102,670,13,117,753,134,40,494,523,4,730,342,0,21,65,59,22,12,880,77,11,86,801,401,719,202,48,28,899,18,805,757,64,14,10,24,128,1,629,457,99,108,57,308,5,2,217,317,139,16,485,569,165,141,36,361,341,365,177,143,125,283,386,120,82,44,9,115,221,7,817,576,300,152,137,124,123,98,61,50,46,32,6,450,111,775,543,488,417,269,197,114,110,95,93,54,35,31,402,34,17,3,911,642,564,561,554,511,431,332,277,261,253,242,239,194,170,116,96 }, +{ 23,13,51,33,12,453,196,117,99,153,134,40,102,403,14,128,202,77,15,401,475,37,139,38,54,11,64,165,421,21,2,0,141,115,308,318,719,328,65,108,670,197,10,46,457,361,269,730,79,1,22,402,28,111,120,95,82,18,3,386,9,389,6,17,283,50,36,24,86,236,114,125,775,5,494,180,4,260,31,94,41,32,899,523,19,210,110,137,59,391,7,326,488,450,351,291,217,177,412,341,93,300,485,477,509,880,377,44,39,30,277,52,221,16,8,961,629,365,203,29,758,133,26,817,350,342,237,194 }, +{ 2,7,14,5,52,29,70,61,112,46,87,592,135,1,66,45,38,16,32,6,186,21,315,290,48,227,24,72,307,113,75,172,425,20,243,58,74,97,666,128,845,631,76,226,155,294,18,738,23,270,25,35,64,141,334,115,0,89,22,50,43,163,151,37,51,171,77,207,69,17,220,36,177,202,19,262,10,13,137,9,90,232,4,54,86,92,263,269,255,278,59,496,655,60,28,95,140,26,106,27,180,12,454,192,148,67,40,209,102,318,33,292,400,849,49,65,324,331,409,405,217,491,311,461,549,476,431,210 }, +{ 33,102,128,202,51,23,141,196,64,153,13,269,318,403,77,117,10,137,134,40,1,5,453,2,6,165,3,0,14,475,86,99,139,15,180,120,12,22,494,402,17,197,352,260,19,7,95,342,21,110,237,65,82,115,93,125,31,36,37,277,18,217,210,9,49,44,25,177,291,326,523,38,450,401,194,32,457,421,285,386,26,28,351,16,111,719,27,4,11,114,48,341,203,300,8,752,98,373,143,730,361,498,57,54,365,317,24,164,961,116,569,108,275,899,50,34,391,45,41,901,96,244,29,629,133,72,509,144 }, +{ 92,16,43,20,126,107,7,35,71,97,14,60,140,246,279,68,18,149,230,121,575,356,375,191,362,24,783,150,118,55,695,566,345,48,0,359,175,173,319,598,298,232,939,22,653,441,167,463,21,414,125,819,467,407,33,69,346,38,422,146,77,446,154,608,28,649,336,172,10,199,102,101,104,168,189,637,251,212,49,314,376,2,124,51,9,595,399,221,23,66,5,392,541,755,196,470,386,13,6,158,117,768,393,147,628,551,493,683,165,67,46,36,259,108,81,1,727,535,364,342,325,672,267,281,674,120,203,153 }, +{ 13,23,77,115,51,33,59,4,177,40,90,64,102,32,141,202,10,128,22,210,291,0,11,21,117,95,137,217,16,318,196,9,180,153,7,197,165,49,28,269,6,342,14,18,2,216,1,237,134,86,98,352,349,203,326,24,403,36,494,31,125,450,120,475,275,15,93,351,341,260,194,386,105,3,247,48,57,365,373,20,372,402,317,457,44,5,139,110,17,35,30,25,12,498,76,144,116,72,39,453,304,19,300,244,208,82,60,401,143,285,65,214,55,38,26,817,569,50,678,551,391,308,123,111,46,854,509,523 }, +{ 507,162,129,211,41,183,38,123,4,248,59,62,57,556,130,99,361,402,305,128,202,11,266,136,17,3,77,803,152,497,313,452,184,210,369,33,40,471,339,56,117,757,157,54,328,229,205,494,381,23,139,457,153,12,403,84,503,257,19,34,65,13,76,514,119,275,37,188,542,14,80,106,440,475,775,318,618,102,21,134,453,300,27,432,64,880,95,89,49,141,86,196,32,529,377,249,73,79,460,177,50,5,10,90,53,619,548,342,94,401,269,179,288,587,961,383,148,114,579,115,477,216,72,45,805,285,291,217 }, +{ 643,123,193,718,650,18,802,65,389,84,415,91,177,25,90,619,256,216,87,289,511,183,736,370,217,324,380,235,108,63,808,500,432,102,249,57,275,194,152,6,673,510,304,862,240,524,355,588,561,397,233,372,13,523,130,81,96,4,0,343,605,141,1,22,103,77,59,283,214,64,789,437,306,630,23,85,153,80,33,475,597,529,210,544,349,196,129,56,291,32,27,847,300,114,889,550,138,86,886,444,269,124,28,26,416,421,280,208,174,70,10,2,814,401,115,19,851,117,42,730,469,352,204,17,202,150,73,51 }, +{ 23,13,51,15,5,1,2,7,115,0,12,6,165,141,21,3,4,457,9,197,180,32,77,14,37,202,217,10,33,120,341,352,11,269,22,8,16,93,569,961,31,401,318,102,247,719,453,308,629,17,365,18,260,403,177,317,901,386,40,48,509,137,752,44,730,28,391,498,72,117,523,128,110,153,59,450,98,494,99,196,36,372,237,30,90,49,475,134,291,326,125,24,210,95,349,89,899,482,38,116,421,468,351,304,19,76,873,82,20,139,57,734,203,86,342,373,546,54,39,437,45,65,817,854,758,922,144,96 }, +{ 51,23,13,453,21,403,12,475,202,165,141,64,128,115,32,5,95,523,125,730,494,180,197,401,899,308,48,120,37,719,386,269,318,817,457,4,99,421,3,326,1,6,237,17,450,2,260,10,19,22,14,0,217,194,18,402,77,221,90,247,15,177,27,25,26,961,59,9,7,758,137,16,670,391,352,117,11,801,312,33,110,82,50,28,241,57,40,351,123,153,49,615,317,291,72,341,210,24,86,54,61,29,196,102,216,93,56,569,31,304,170,98,275,289,46,42,20,629,361,108,58,89,389,283,144,45,84,203 }, +{ 204,74,135,174,192,66,138,85,6,280,353,348,580,172,7,673,97,889,426,500,792,568,95,87,355,32,620,64,712,29,65,91,233,81,232,222,52,448,43,872,25,825,42,104,173,888,22,289,226,63,526,86,387,5,312,636,861,49,90,237,278,2,343,415,194,560,21,0,715,92,38,214,145,140,20,256,835,324,235,330,18,10,750,61,28,75,808,1,4,26,681,288,77,36,24,70,69,58,107,45,874,347,125,14,112,314,33,72,337,102,298,241,294,707,59,729,108,180,37,115,370,40,287,76,48,356,164,117 }, +{ 35,68,149,24,69,0,65,133,103,16,189,9,28,18,50,114,175,336,124,101,1,71,154,46,83,251,14,7,2,55,283,118,230,108,218,238,38,398,345,140,705,75,54,302,443,39,596,22,532,309,335,181,96,361,418,21,399,12,52,394,565,433,412,267,346,109,60,5,29,36,486,236,48,160,375,732,831,545,23,480,487,516,51,220,92,366,86,429,10,13,64,323,328,67,49,252,30,37,330,514,364,212,100,439,547,158,389,95,87,458,194,115,32,646,891,930,246,208,70,641,171,163,6,191,223,722,167,99 }, +{ 101,118,16,71,24,9,18,154,191,212,0,35,60,520,124,68,694,806,167,364,375,252,604,346,55,302,562,628,28,39,149,917,439,126,419,92,65,826,329,100,706,589,166,108,175,265,264,21,1,273,199,109,22,701,48,925,676,49,158,7,150,363,404,10,146,942,5,88,121,815,105,411,14,967,682,67,23,535,69,13,818,566,882,50,777,907,647,429,95,159,51,96,30,12,333,621,31,2,857,848,32,107,140,722,98,575,821,246,37,847,46,382,905,221,677,169,36,336,125,553,695,83,467,593,185,759,114,286 }, +{ 35,16,9,0,68,24,65,1,18,71,149,103,67,189,101,28,21,48,212,114,23,335,486,124,13,51,39,118,167,191,55,154,7,133,238,433,50,30,443,141,96,230,22,100,140,218,60,5,137,64,537,352,115,12,88,330,217,223,75,10,128,399,37,269,49,83,411,202,32,283,175,36,31,221,246,264,98,163,398,2,281,723,375,302,69,166,478,447,125,108,487,180,54,372,317,589,44,99,520,336,181,361,345,418,318,363,177,86,695,341,664,565,77,160,95,545,562,252,70,237,116,752,532,190,72,105,92,14 }, +{ 13,23,202,77,51,128,33,32,115,102,21,269,177,141,318,64,5,217,137,494,291,11,4,10,0,48,22,153,95,210,117,86,90,196,3,15,6,317,2,49,125,349,40,18,12,342,352,9,31,17,247,304,403,194,134,36,16,7,14,450,19,275,98,180,120,1,61,44,372,216,28,341,65,165,221,326,116,76,20,260,59,523,237,365,285,203,24,35,105,453,288,143,386,678,30,351,101,68,60,55,25,817,421,475,96,901,401,367,308,293,99,93,82,39,37,27,752,312,144,615,323,730,58,72,437,859,899,316 }, +{ 16,92,60,35,7,18,68,150,24,126,149,97,191,246,375,118,14,230,107,140,71,273,575,175,517,653,154,566,55,43,298,345,167,399,0,121,28,467,20,108,279,212,101,441,346,302,336,66,423,232,508,48,22,674,124,38,356,608,314,9,21,2,189,199,359,446,49,10,695,46,5,69,1,463,65,815,589,12,172,439,607,755,251,146,37,362,67,392,23,173,6,109,13,722,125,809,702,796,628,36,32,51,95,637,74,135,354,398,52,132,83,29,429,221,407,768,882,105,672,50,64,104,86,271,501,364,535,96 }, +{ 76,90,464,21,179,316,205,288,460,245,32,257,184,148,45,358,152,57,270,48,241,38,449,89,14,2,1,350,769,645,229,155,5,497,221,54,17,524,37,243,12,59,227,405,266,428,4,452,413,308,749,432,50,619,99,720,51,29,292,476,217,11,290,46,157,115,79,188,339,129,313,216,401,381,431,471,171,341,247,77,10,94,106,513,400,3,23,64,317,141,52,7,0,365,773,474,477,72,430,528,36,659,162,369,453,181,62,214,128,33,237,741,186,9,6,281,328,13,202,102,502,349,536,498,177,291,180,372 }, +{ 19,297,26,27,813,80,436,495,17,73,53,250,122,106,200,113,378,390,690,42,4,45,469,361,59,25,742,128,136,161,77,255,202,736,445,605,402,123,862,630,40,63,318,78,383,803,56,11,235,102,283,444,119,527,6,62,210,503,680,14,57,33,148,472,209,129,684,256,84,412,667,611,18,573,85,365,483,0,177,12,3,300,814,153,504,65,22,76,139,61,34,205,133,341,117,64,51,23,13,58,269,152,90,257,10,236,2,358,497,38,432,342,95,47,368,243,183,494,757,453,619,196,184,548,171,714,475,322 }, +{ 6,26,235,138,145,112,19,42,624,122,70,648,27,331,262,85,78,47,25,500,52,632,630,226,113,444,307,644,409,453,29,222,665,163,75,50,849,324,2,65,108,390,294,64,675,53,416,711,130,220,22,34,196,17,73,813,87,32,95,680,14,280,223,852,412,133,730,151,74,237,315,33,86,45,115,66,197,287,241,58,236,153,583,51,256,28,5,114,1,297,283,792,180,4,165,38,90,63,135,102,337,690,250,21,3,171,820,396,546,36,853,889,357,10,183,137,46,200,445,56,475,125,99,461,603,309,117,0 }, +{ 16,7,14,92,24,35,60,18,46,140,126,71,87,50,171,54,9,2,38,5,0,220,108,69,23,230,21,13,246,128,163,70,12,107,394,58,20,68,64,121,155,150,330,309,28,48,22,67,32,10,51,141,267,137,55,314,236,202,146,1,37,281,115,181,502,461,269,189,307,852,232,774,132,97,571,328,75,43,223,65,278,199,52,217,86,820,77,366,335,172,72,112,186,6,409,622,318,99,61,95,103,149,262,49,780,552,177,133,36,227,29,294,462,430,17,334,135,352,572,45,675,563,270,66,33,451,39,180 }, +{ 257,90,205,184,460,769,245,32,179,524,5,45,229,497,288,152,619,21,57,432,452,2,17,292,59,381,266,14,476,1,4,48,106,241,316,358,216,255,29,77,38,217,11,54,155,58,313,64,263,157,425,76,471,12,129,6,227,72,243,148,186,141,3,79,247,37,128,7,339,464,214,188,290,209,207,99,720,519,369,317,177,40,50,115,365,33,710,51,89,270,269,102,221,588,86,46,162,61,202,529,237,291,111,454,94,10,62,372,408,875,23,277,350,618,210,645,349,123,308,19,52,25,180,36,449,352,119,181 }, +{ 15,4,5,11,13,23,141,21,32,40,202,180,1,0,33,269,3,128,17,318,352,134,51,120,2,64,153,117,450,31,326,12,137,196,22,197,102,82,260,44,6,752,165,59,10,49,7,48,177,217,494,57,341,115,403,523,95,901,237,386,457,37,210,14,317,98,351,365,90,56,9,961,203,817,498,719,125,93,28,730,18,110,19,372,116,291,244,678,86,475,615,8,194,76,342,27,45,453,349,36,61,139,96,873,864,216,402,391,111,72,373,16,275,143,285,30,25,247,39,144,300,253,24,922,214,38,70,164 }, +{ 130,711,47,412,108,453,730,196,283,390,78,381,27,183,236,503,472,51,14,200,803,128,153,719,59,250,133,432,34,318,57,73,123,4,114,117,65,17,53,177,33,576,714,216,657,56,378,322,475,46,23,3,529,754,134,369,275,339,19,11,269,12,389,899,291,813,402,650,368,40,603,401,21,444,361,436,266,210,99,457,297,202,480,77,102,54,666,592,513,349,403,129,194,106,894,38,471,0,523,32,739,137,18,22,2,690,136,386,594,152,161,684,678,181,162,548,26,670,141,37,10,184,814,743,421,789,45,629 }, +{ 12,277,51,474,153,111,99,23,37,13,629,961,431,94,569,38,453,542,139,115,79,134,117,401,196,33,40,188,157,89,11,775,457,72,485,15,405,54,4,339,413,300,377,197,477,148,313,328,165,59,734,308,102,719,76,14,45,210,179,21,128,730,152,3,64,17,509,498,386,10,266,880,2,77,32,391,57,482,41,475,0,471,403,304,141,177,898,523,82,18,365,490,205,758,275,5,217,29,402,546,372,488,260,351,341,120,24,202,452,358,237,22,352,873,468,361,6,269,317,216,155,437,162,48,1,229,31,811 }, +{ 495,469,17,378,106,26,27,483,161,862,383,742,19,73,80,527,53,436,814,136,297,84,62,119,611,56,250,25,440,209,113,42,6,122,34,4,255,128,240,14,3,684,200,59,585,129,65,45,29,123,504,57,573,2,5,11,445,361,141,630,61,64,205,179,86,833,76,32,667,690,33,235,202,245,162,618,40,283,680,548,318,472,402,269,503,77,555,102,194,184,108,183,207,95,151,21,152,112,177,514,46,153,887,491,311,803,54,58,257,12,38,10,507,90,648,196,51,176,22,614,306,48,0,229,130,145,1,114 }, +{ 681,636,81,750,91,370,138,718,0,104,348,784,174,397,673,693,18,29,355,192,173,280,74,426,306,65,207,6,701,715,86,319,64,124,671,85,52,32,289,95,510,22,90,511,887,204,343,712,560,879,526,422,240,233,214,7,49,312,40,120,72,77,519,43,24,707,484,4,577,353,42,523,84,63,11,177,27,145,835,730,57,474,643,151,448,756,28,25,10,61,19,21,20,260,415,102,194,888,580,87,861,610,825,33,288,232,193,115,66,59,817,76,45,172,847,17,2,719,457,273,114,26,23,450,168,13,414,302 }, +{ 15,33,77,102,115,117,4,134,153,40,196,11,13,217,1,5,23,317,21,3,365,2,291,341,32,12,59,51,177,139,342,6,0,349,210,7,372,37,180,48,351,111,17,90,569,141,275,36,57,197,457,202,137,72,89,304,14,308,9,120,854,901,898,300,277,10,55,96,64,148,247,961,160,27,165,450,128,437,269,719,352,260,752,38,401,318,523,216,730,734,93,629,76,221,94,482,56,579,18,16,143,253,873,922,453,61,638,179,49,19,22,31,244,498,125,8,697,45,24,817,44,245,403,485,79,326,84,899 }, +{ 9,0,28,68,35,65,101,39,67,175,1,124,154,69,24,22,55,18,16,238,103,30,336,114,12,49,251,109,149,96,50,13,21,51,7,23,252,5,345,100,596,218,158,141,831,418,189,480,532,37,10,166,115,346,2,433,64,323,217,128,137,48,443,88,86,160,36,439,75,237,547,269,202,71,289,866,646,429,118,335,389,364,285,230,317,930,197,352,180,159,143,181,486,503,402,283,99,133,281,95,223,194,498,208,165,168,318,32,60,14,83,4,657,105,212,131,265,694,745,956,54,185,163,484,6,403,77,722 }, +{ 23,33,102,40,51,77,13,403,117,196,153,64,11,128,453,134,137,300,59,291,141,4,10,202,22,475,180,95,57,719,139,99,0,342,86,65,494,90,12,28,9,49,485,421,21,115,114,1,194,901,752,210,177,165,120,108,15,37,18,349,328,2,323,269,899,450,391,351,260,197,125,36,961,523,457,361,48,14,341,958,954,947,922,854,817,758,730,546,509,498,412,365,289,275,236,160,93,54,32,16,7,847,805,576,401,217,962,570,467,285,218,124,105,874,835,775,701,670,629,577,569,541,386,373,372,347,277,247 }, +{ 214,90,289,874,6,65,256,235,64,751,25,42,312,249,194,746,288,875,525,519,247,835,174,85,233,348,544,217,437,32,524,352,343,95,123,138,26,63,355,954,86,122,91,280,630,416,0,177,605,22,204,317,752,648,222,736,141,77,45,579,864,180,74,216,415,304,389,59,597,57,66,306,81,237,287,56,881,588,243,115,84,208,19,445,370,108,498,114,183,87,29,671,4,316,49,283,76,145,275,18,444,205,573,396,240,52,28,112,337,104,10,636,202,624,70,368,11,511,353,33,21,135,102,650,680,137,291,619 }, +{ 1,22,2,28,67,36,50,5,12,49,0,95,14,168,55,7,83,46,103,105,114,69,194,9,38,21,159,584,35,65,239,133,169,109,24,218,23,16,158,208,10,323,48,170,54,51,96,37,160,597,164,13,29,6,18,320,244,708,32,115,892,202,128,503,505,424,185,874,776,253,312,64,347,143,68,75,238,654,137,141,756,31,124,480,301,531,39,181,269,289,824,3,251,835,646,389,361,318,789,52,98,189,797,532,30,638,285,180,165,308,420,99,286,751,127,237,17,283,45,4,175,44,577,125,533,154,72,197 }, +{ 269,318,352,202,141,13,77,51,180,102,349,23,372,291,137,403,33,128,125,197,21,44,31,494,342,317,217,32,402,117,1,365,16,901,475,177,49,22,11,5,116,98,93,386,165,160,153,115,59,40,18,752,253,244,15,14,12,10,7,2,0,4,947,704,692,678,661,615,597,576,473,373,326,208,203,48,39,30,6,90,28,24,498,453,421,127,96,17,961,899,817,474,408,401,350,308,304,285,263,241,196,194,185,169,168,148,134,113,111,101,95,94,89,86,71,64,55,36,35,769,638,569,275,257,152,9,8,968 }, +{ 435,144,274,88,203,418,410,778,190,30,530,960,521,795,686,466,1,321,326,96,367,100,166,822,382,264,692,855,539,131,438,576,335,213,9,265,201,98,613,921,93,615,859,44,31,840,765,403,800,83,772,662,225,744,523,494,284,473,116,957,924,0,909,36,478,217,817,141,28,966,69,934,831,551,137,21,120,731,269,829,219,128,948,669,406,51,639,625,23,5,230,206,39,13,268,77,944,372,110,617,238,260,404,125,716,557,67,856,691,224,32,7,442,349,332,16,805,492,254,242,228,10,704,291,223,35,842,64 }, +{ 76,72,90,179,205,21,245,316,428,288,32,464,184,37,38,257,460,413,148,54,645,405,57,749,45,308,12,358,152,221,431,14,449,4,155,350,229,48,401,50,270,2,59,1,99,5,497,769,17,11,528,524,452,474,266,241,115,51,243,247,10,128,773,477,79,741,432,281,430,217,129,188,77,181,619,292,64,659,157,339,46,313,227,106,23,453,476,720,36,202,468,7,328,743,381,488,216,94,341,141,3,0,498,794,471,197,137,421,180,536,317,403,237,629,490,29,62,482,86,13,6,165,540,369,33,402,352,162 }, +{ 77,102,33,141,64,115,23,40,177,13,51,291,2,269,202,217,6,128,10,210,180,318,1,196,7,14,352,137,197,0,165,3,22,4,153,237,95,117,19,17,59,5,275,15,134,139,86,11,342,125,9,16,317,18,25,349,341,12,36,26,494,216,49,403,31,498,752,27,93,143,111,65,300,24,110,312,28,120,457,391,372,386,44,98,21,247,20,901,164,304,29,82,203,453,402,401,365,99,569,57,719,56,509,475,961,194,260,34,730,678,546,45,116,32,50,48,244,35,38,864,37,308,629,46,450,326,8,54 }, +{ 397,32,788,81,65,693,249,681,90,422,4,804,194,123,21,59,56,348,11,64,23,61,95,91,690,3,725,718,84,319,0,280,152,237,138,43,355,817,174,6,510,57,494,17,523,899,141,114,49,214,52,165,414,370,784,77,526,60,86,51,386,217,74,40,12,904,85,365,102,450,326,208,18,120,945,750,636,343,242,233,115,650,615,5,20,511,342,29,33,887,457,888,524,880,350,263,180,137,133,108,36,24,15,13,222,204,183,177,160,582,532,391,278,135,730,719,289,715,671,597,10,566,421,403,221,218,207,202 }, +{ 126,60,16,314,150,121,199,146,107,92,246,7,132,35,71,359,232,18,24,14,298,392,649,672,423,517,140,441,97,279,508,388,95,653,32,462,877,195,108,21,230,598,607,407,167,46,172,451,5,118,68,22,387,357,38,267,640,55,522,191,28,156,467,360,271,380,594,0,10,953,733,49,48,2,356,64,66,955,633,809,603,273,278,75,149,65,50,1,52,660,783,135,43,12,362,354,674,236,711,212,702,86,309,13,9,115,493,37,330,20,125,36,220,312,241,54,501,324,101,87,29,345,23,90,550,928,446,77 }, +{ 217,15,141,115,317,365,341,13,23,260,51,137,120,202,77,372,180,33,349,4,269,352,64,102,40,1,110,373,450,291,197,21,32,36,160,117,244,752,318,128,5,854,351,0,11,922,59,247,134,661,9,304,10,901,165,12,153,22,457,177,143,96,253,28,86,82,48,523,2,196,730,494,57,90,811,49,403,7,326,237,16,83,3,8,18,437,125,39,817,30,72,111,139,55,37,17,961,898,498,899,308,719,24,475,386,76,164,35,717,288,873,704,6,89,221,569,14,642,391,241,203,67,56,509,210,285,95,342 }, +{ 111,134,117,474,23,13,961,569,12,431,51,37,115,99,277,15,405,38,197,89,72,629,148,457,76,54,4,45,165,11,139,94,719,498,106,59,873,14,79,128,40,10,196,33,482,3,17,179,188,2,64,413,730,775,245,177,153,205,471,57,509,477,401,358,453,0,403,6,485,22,5,152,304,1,180,402,275,475,300,341,901,36,880,339,237,210,82,141,386,32,110,7,758,120,452,77,365,317,260,129,391,31,95,202,308,46,864,542,523,8,757,86,18,44,752,217,162,93,65,734,437,497,421,678,269,229,546,285 }, +{ 23,13,51,5,202,21,32,1,12,2,141,15,165,115,269,7,4,453,197,403,318,6,48,120,9,0,3,386,128,64,180,14,125,37,475,308,401,137,457,16,10,99,18,450,260,196,523,33,352,237,494,730,719,17,77,11,421,341,326,31,22,40,221,102,8,391,90,24,82,217,30,93,59,117,177,153,351,365,28,19,44,110,899,98,317,569,39,72,61,629,961,817,49,134,509,57,498,247,76,20,29,402,45,27,203,38,36,96,752,89,241,50,56,373,144,25,304,758,86,291,46,54,65,35,349,116,901,576 }, +{ 13,141,23,5,115,202,4,51,269,352,217,11,2,318,180,137,317,21,7,341,77,3,6,32,197,752,33,1,291,12,64,372,10,365,128,9,102,22,0,165,403,40,15,349,494,498,482,48,308,177,901,31,28,16,37,873,44,237,14,49,125,153,247,18,244,98,30,59,453,120,143,55,401,475,304,36,39,457,342,93,17,72,95,221,24,196,35,117,134,253,86,90,509,579,76,116,203,864,326,961,576,569,210,717,523,859,144,421,678,160,8,719,110,127,216,89,391,260,468,730,65,386,629,450,437,805,164,105 }, +{ 165,125,391,197,21,13,558,380,23,48,386,237,900,221,66,509,180,14,326,120,457,33,32,357,115,961,97,426,401,298,135,278,308,719,51,98,758,841,172,75,38,56,12,6,571,204,770,74,19,72,554,867,629,408,393,77,670,64,63,25,10,1,42,498,462,134,40,7,563,247,102,715,773,90,31,763,324,808,494,451,523,450,317,293,244,210,177,43,29,20,171,22,572,501,681,582,350,743,615,365,335,262,217,203,105,87,69,490,482,641,370,26,11,81,73,65,53,4,579,192,963,367,342,267,260,241,239,216 }, +{ 120,82,260,450,351,15,141,21,854,77,217,13,23,51,1,202,817,180,33,898,110,48,326,93,102,32,128,137,5,165,523,269,352,318,125,291,922,2,177,203,275,403,317,4,210,12,373,494,115,64,197,96,386,7,144,0,342,196,36,457,752,37,349,453,9,6,16,221,50,237,615,59,10,475,341,14,372,730,244,18,22,223,285,160,67,365,86,498,661,421,402,401,31,901,308,719,391,70,3,99,35,44,24,95,90,28,473,899,69,30,65,864,704,116,11,29,8,83,367,17,163,49,551,304,961,216,61,692 }, +{ 23,51,13,15,961,0,2,10,115,1,457,5,569,453,4,7,9,719,14,33,629,11,165,40,197,6,77,21,64,3,474,139,38,401,59,22,72,57,102,12,111,475,32,79,341,730,386,128,54,37,509,177,17,8,196,391,36,237,141,202,277,18,89,148,76,99,734,28,758,308,41,117,498,180,90,403,873,365,482,31,45,328,94,546,48,153,86,210,93,317,24,468,494,247,304,300,269,82,16,95,402,120,670,134,46,488,757,194,110,55,62,125,155,29,188,52,405,49,899,775,50,275,221,880,477,44,152,523 }, +{ 264,166,435,9,39,254,30,382,921,404,438,363,656,190,100,897,411,478,93,203,812,274,625,1,795,691,88,156,101,473,326,110,265,639,340,51,447,272,141,18,35,165,131,33,329,67,0,354,77,910,616,291,914,530,105,68,118,197,731,137,120,23,21,578,128,36,333,49,593,494,271,98,676,310,102,44,664,613,48,349,28,228,195,5,960,658,800,180,24,724,96,682,678,403,160,688,523,127,829,242,521,83,31,716,13,342,159,69,16,144,260,352,32,269,55,167,158,219,576,364,704,4,615,202,65,60,318,456 }, +{ 252,9,0,166,265,100,364,329,404,39,101,520,676,419,68,118,553,604,382,88,167,274,18,212,593,333,158,264,16,49,806,865,438,48,812,21,154,30,677,310,1,35,656,24,96,124,51,857,22,13,23,105,28,60,31,71,286,562,65,777,435,455,190,98,639,159,759,109,917,254,344,191,647,125,10,55,907,694,363,221,44,127,5,557,131,327,682,411,67,628,95,83,538,936,149,925,272,36,664,175,375,478,121,64,793,146,821,50,671,69,302,271,921,116,625,541,942,446,530,724,709,706,33,634,463,170,128,223 }, +{ 15,4,11,141,5,13,21,23,202,40,269,32,12,165,523,3,180,64,318,17,352,457,197,1,93,0,110,2,125,120,128,386,51,59,77,31,117,326,49,10,719,403,961,82,153,48,137,134,899,450,115,260,494,196,44,33,37,730,6,57,203,817,177,752,22,98,9,90,18,373,237,8,7,217,958,351,291,14,139,95,341,144,27,210,475,615,402,391,56,453,901,116,19,143,86,349,244,317,72,105,498,123,485,365,111,152,342,401,76,28,30,247,678,801,65,45,216,36,569,300,308,509,221,99,127,84,164,873 }, +{ 24,35,69,18,71,68,46,67,16,1,2,50,14,149,108,133,189,28,38,75,83,0,7,9,218,65,238,114,52,335,29,54,251,60,55,309,236,175,118,336,486,267,96,394,181,220,366,87,418,124,154,5,545,412,516,140,70,22,487,12,21,36,101,171,433,641,230,328,58,48,458,345,361,398,283,92,6,37,103,514,302,906,10,388,596,565,273,443,64,160,532,163,399,705,223,891,86,150,262,537,32,51,39,831,23,109,95,375,155,13,99,480,571,45,49,128,281,696,112,194,754,25,137,294,602,208,323,191 }, +{ 90,214,289,874,64,712,751,77,51,13,177,32,312,23,192,66,194,202,216,59,288,4,835,875,65,0,249,247,95,519,102,57,5,123,33,22,524,234,104,450,173,49,437,500,889,210,217,636,319,597,21,153,416,196,38,20,117,954,304,115,134,120,18,715,86,583,113,494,61,204,10,784,291,28,275,342,147,318,879,43,74,142,11,588,888,403,864,237,2,198,352,426,752,707,48,1,639,17,81,180,750,861,52,315,207,560,24,128,402,40,141,16,671,31,372,36,130,455,260,12,9,317,37,325,349,389,904,306 }, +{ 9,0,49,127,28,301,98,371,395,159,512,158,916,737,761,31,101,24,623,16,272,68,18,39,35,293,242,1,286,109,44,385,327,65,170,299,55,125,51,23,22,518,105,836,21,116,616,137,685,284,48,599,344,252,7,124,13,276,64,187,95,506,5,131,890,202,456,627,36,2,219,30,254,333,419,763,14,347,12,154,578,320,96,713,141,935,201,144,338,442,870,118,71,128,10,364,168,374,67,60,37,310,221,100,32,318,424,93,269,393,910,165,403,86,688,160,793,908,50,83,69,203,421,492,401,6,244,166 }, +{ 17,136,62,214,123,129,249,710,119,162,618,292,209,141,32,183,77,128,211,106,64,45,4,11,179,269,507,519,207,59,177,130,3,40,90,86,255,378,33,202,76,57,205,655,790,152,678,38,21,245,37,742,248,5,102,597,476,306,556,41,291,229,117,349,80,339,153,313,266,318,84,54,947,184,56,12,155,134,240,197,305,157,304,217,148,186,165,275,257,789,99,216,13,497,317,72,137,115,10,196,460,383,619,61,51,188,361,457,369,425,50,290,440,14,342,263,180,503,452,241,208,237,194,432,381,65,111,22 }, +{ 5,107,581,441,356,493,362,660,279,534,32,683,298,423,259,786,22,612,590,359,21,13,49,147,61,508,241,263,929,48,97,246,14,126,0,132,7,465,939,232,64,230,607,95,121,941,23,92,771,115,470,314,51,387,626,172,1,58,12,347,779,392,407,17,150,687,16,357,28,146,43,77,87,60,199,197,37,40,711,178,501,65,10,9,180,140,35,33,24,595,102,120,56,30,70,207,344,324,125,46,31,165,18,20,577,414,376,2,350,4,260,427,173,408,195,141,247,76,603,217,86,11,379,55,729,90,75,50 }, +{ 51,475,453,13,23,15,730,403,457,421,386,523,899,719,670,401,12,361,6,99,33,1,128,269,961,141,27,19,5,494,165,21,64,2,450,153,202,117,65,115,236,7,196,77,95,32,328,37,14,10,0,318,134,17,391,197,102,308,40,26,120,9,22,4,125,412,389,16,34,194,57,569,402,54,53,8,352,25,758,291,59,3,880,757,503,488,217,90,38,72,48,45,801,177,11,304,509,326,283,260,180,139,137,76,47,41,867,350,629,558,949,838,832,803,775,773,770,754,749,657,597,576,543,514,468,297,255,250 }, +{ 49,159,272,28,9,327,254,158,22,347,95,627,374,286,131,424,105,168,35,39,912,65,68,578,688,0,538,55,24,518,175,154,124,239,634,346,289,224,169,913,577,16,320,364,747,219,185,616,101,716,67,344,1,890,570,170,30,810,109,333,228,420,21,36,439,64,149,23,127,371,194,13,706,827,125,51,114,312,83,187,98,429,613,10,137,829,610,86,310,166,910,31,835,190,406,71,18,242,202,846,141,938,160,44,14,2,385,69,7,48,308,301,258,128,638,237,115,12,165,96,100,103,562,703,221,116,164,50 }, +{ 15,33,77,4,102,317,341,141,117,365,134,13,180,1,40,153,5,115,23,11,197,10,217,196,21,901,22,64,752,352,143,253,244,351,137,51,32,2,269,177,82,59,165,12,3,291,569,202,120,0,854,139,342,86,55,36,372,31,9,898,48,498,349,37,260,7,28,111,125,17,482,49,318,160,457,6,450,44,128,90,275,237,95,210,57,386,873,638,98,523,105,164,89,93,30,719,922,961,509,308,8,14,72,951,403,401,730,391,304,116,326,39,468,56,38,717,94,24,579,817,76,61,96,16,18,546,629,494 }, +{ 134,13,15,23,12,474,569,51,37,10,197,457,961,99,115,4,38,2,165,0,153,5,3,11,719,64,139,431,1,277,120,82,33,6,94,873,14,401,110,7,89,117,351,40,498,128,260,148,54,93,72,629,453,180,21,31,22,9,405,143,141,8,17,77,36,102,44,386,41,509,196,59,450,125,730,55,342,523,86,403,326,45,95,898,98,32,854,237,365,217,391,775,116,349,291,210,179,203,202,317,752,901,372,341,352,177,402,49,57,76,922,475,28,30,144,373,421,318,308,269,90,494,413,46,18,678,899,242 }, +{ 7,2,66,20,58,29,52,74,128,14,135,5,32,97,192,43,38,61,6,631,16,151,87,21,25,315,172,177,46,48,173,186,45,884,70,90,113,77,227,72,226,23,102,51,137,35,210,337,202,59,40,104,402,155,115,269,89,592,81,33,122,13,60,174,112,107,24,19,243,0,145,222,580,76,37,49,64,10,416,318,738,18,353,204,26,491,678,95,4,290,141,54,232,69,92,22,415,140,712,270,217,12,171,496,86,220,27,17,549,294,209,1,355,609,494,425,285,50,665,148,403,560,36,216,400,75,275,307 }, +{ 77,202,13,23,128,318,33,269,141,102,403,117,4,342,153,134,51,40,64,196,32,0,49,177,22,494,291,137,11,21,59,65,95,475,98,165,210,90,18,115,48,217,197,15,275,105,10,120,127,86,28,180,9,453,352,36,39,317,31,125,5,194,402,57,450,349,372,14,116,44,16,300,6,2,284,96,24,20,30,457,12,859,678,299,289,242,114,110,109,61,7,1,216,214,100,326,304,260,237,3,82,789,752,579,576,490,347,344,293,207,205,144,139,93,37,615,373,351,285,421,401,961,391,203,817,923,922,901 }, +{ 2,14,1,46,29,38,6,52,103,50,65,36,67,5,108,75,83,7,22,24,25,69,28,86,208,133,0,323,19,26,484,18,309,782,96,283,236,238,124,160,135,21,10,12,74,87,66,168,17,262,70,412,23,389,16,51,650,278,289,532,45,194,3,756,218,32,220,58,646,244,42,115,95,37,27,13,48,886,49,267,366,226,302,128,54,610,64,516,547,584,137,253,9,308,143,388,141,717,335,480,401,164,185,357,505,109,150,732,602,420,99,285,172,202,891,112,189,324,181,35,418,696,331,90,114,55,294,458 }, +{ 15,5,1,2,3,4,12,11,13,10,0,341,21,180,7,33,197,6,134,17,77,32,365,23,901,37,117,9,8,40,165,102,153,961,51,498,196,569,14,873,752,217,22,94,64,317,59,36,352,474,31,509,99,141,110,55,291,111,457,120,391,57,19,16,82,48,177,401,38,386,349,202,308,139,93,342,453,72,275,18,44,143,351,28,27,90,128,403,269,372,45,137,76,260,318,89,326,210,86,277,898,413,237,719,148,864,730,96,95,79,373,475,61,24,46,30,523,253,98,482,83,546,54,49,50,41,899,758 }, +{ 203,268,206,940,93,417,959,499,473,137,31,44,728,692,8,120,202,559,564,450,127,141,260,326,817,244,22,10,0,23,551,318,144,125,13,523,269,128,299,98,1,253,373,51,494,403,9,116,341,143,64,110,638,285,5,615,642,859,367,55,918,576,21,421,180,386,922,165,105,36,401,2,365,115,899,242,352,28,951,393,704,86,30,901,475,7,762,276,77,384,948,237,32,197,49,492,434,160,661,489,170,15,39,752,317,498,854,453,282,717,6,18,16,569,395,479,351,805,12,958,898,456,48,293,851,308,301,509 }, +{ 15,120,82,10,165,31,0,197,64,260,33,8,93,110,22,351,40,44,77,23,153,13,9,102,4,51,196,125,326,11,450,49,139,28,237,203,386,98,457,18,32,373,95,523,1,21,277,59,854,180,111,202,12,141,898,17,36,116,144,14,115,922,86,57,128,5,45,30,2,391,217,7,817,37,177,730,90,509,719,72,99,16,76,62,453,291,352,475,318,269,403,341,48,134,961,55,24,3,143,899,308,401,137,65,38,615,210,629,317,901,758,342,569,494,661,365,39,247,164,421,704,546,61,6,811,41,642,752 }, +{ 60,7,16,71,43,0,14,20,28,97,68,22,92,24,149,2,35,10,154,13,126,615,608,51,124,362,140,55,805,18,958,576,566,175,23,359,6,1,48,453,158,150,703,21,421,260,173,475,298,153,107,74,64,36,29,925,46,12,882,899,441,801,81,357,246,196,77,69,38,25,9,117,65,49,314,37,484,386,730,336,115,570,403,356,324,221,135,121,19,401,99,939,420,399,859,942,628,610,289,285,259,125,101,95,33,26,702,677,165,4,653,375,185,192,91,515,302,197,104,326,595,318,230,202,191,143,102,90 }, +{ 26,19,6,27,80,25,84,45,17,5,504,42,129,2,240,123,618,29,56,106,113,710,4,76,119,128,14,136,65,64,73,59,1,209,483,53,162,51,90,548,122,205,249,202,40,99,3,460,32,257,62,292,61,214,77,245,57,12,378,141,183,453,34,297,11,184,108,23,255,469,0,403,22,33,58,95,10,86,814,318,769,114,179,402,611,667,130,475,21,151,210,137,742,161,38,177,494,7,436,269,102,194,115,445,18,36,421,13,47,153,880,775,54,133,196,37,49,495,306,311,112,46,52,117,250,28,491,48 }, +{ 15,77,13,33,4,23,102,11,51,5,40,177,0,117,10,202,64,8,93,22,291,32,21,44,31,153,110,1,141,49,115,59,82,180,9,17,318,196,98,269,351,403,137,453,36,95,457,217,3,90,139,128,48,28,898,12,165,450,475,349,341,197,523,18,30,210,317,86,16,260,401,2,961,901,719,57,116,494,854,326,373,125,365,817,352,730,275,134,39,386,105,76,24,7,308,372,37,342,6,421,120,704,144,14,899,922,203,111,304,569,638,72,661,61,629,96,127,99,811,535,498,65,615,752,247,83,402,758 }, +{ 195,271,98,223,167,132,407,146,360,591,1,212,834,121,522,393,293,199,259,354,446,668,590,562,807,191,156,48,765,125,107,147,941,163,727,541,535,465,126,284,21,346,31,279,23,55,18,5,687,16,60,640,13,697,586,178,534,35,20,608,581,150,955,427,68,70,589,43,142,791,463,198,116,51,883,362,9,963,781,202,49,0,818,96,493,7,948,281,120,165,367,798,450,10,44,318,77,105,14,325,221,92,28,22,61,770,101,777,58,93,32,97,467,141,386,33,144,371,75,127,37,108,929,269,411,598,551,128 }, +{ 210,128,202,77,402,318,102,403,33,342,275,40,196,475,6,300,139,29,177,99,494,269,42,503,111,757,277,141,117,52,2,4,678,13,153,12,0,23,59,285,37,137,85,81,7,291,859,657,351,122,82,576,44,31,880,260,216,120,91,78,63,14,11,1,745,65,64,93,854,27,684,22,485,180,76,74,19,3,21,805,49,38,281,48,966,838,631,452,450,421,218,134,26,25,569,341,115,898,738,592,110,98,10,315,788,707,491,483,432,396,319,268,242,125,116,95,62,57,56,50,17,16,9,655,526,453,426,422 }, +{ 40,33,102,23,51,13,117,196,153,77,134,64,128,202,4,59,141,453,65,475,11,403,22,95,0,137,14,139,15,342,210,12,86,318,269,165,115,1,49,10,494,177,28,180,36,291,421,21,57,5,6,217,18,194,99,401,2,457,108,719,125,19,111,260,82,37,27,48,17,3,523,197,133,26,402,120,114,670,352,7,24,730,93,216,90,46,237,50,32,386,361,9,341,351,25,349,300,283,277,38,34,901,365,326,275,98,110,285,45,41,391,44,317,576,961,242,143,16,509,170,31,854,308,54,116,817,757,629 }, +{ 7,14,16,24,18,28,71,2,92,60,35,22,20,0,154,118,168,6,1,97,69,703,302,149,140,150,185,38,109,43,66,68,108,420,29,55,10,158,610,12,65,67,5,701,189,273,570,95,230,429,46,124,246,289,298,51,21,169,143,49,175,23,107,747,126,671,13,64,48,159,25,925,677,137,36,52,398,32,9,251,584,467,164,128,942,19,86,577,847,83,173,336,403,74,50,424,202,232,882,172,17,344,279,638,375,105,314,104,37,125,115,441,356,505,99,253,239,26,221,359,329,194,533,837,517,165,494,601 }, +{ 23,1,15,51,2,13,5,0,7,180,21,9,6,115,197,120,12,165,4,33,457,386,523,202,141,3,14,260,450,48,8,16,77,93,31,341,37,269,40,403,44,730,110,326,32,102,317,137,318,453,352,719,365,18,128,217,153,82,475,36,98,64,391,752,401,901,899,421,308,196,11,498,22,28,351,99,116,10,117,24,817,96,221,30,39,494,509,569,177,203,49,961,144,291,373,615,59,17,801,372,482,72,758,90,89,854,50,629,134,127,35,86,349,922,160,55,244,105,237,143,468,898,210,54,46,670,342,45 }, +{ 132,146,199,107,60,121,126,279,150,441,92,649,16,955,493,195,598,423,653,298,35,407,356,640,362,508,32,21,953,7,360,359,522,18,271,783,5,246,167,0,660,156,534,939,71,191,22,517,590,24,49,259,314,10,607,28,392,13,232,147,68,97,95,14,43,883,118,1,37,581,48,501,354,809,55,108,4,591,12,20,23,347,345,212,467,230,446,241,125,50,941,75,9,31,98,683,929,77,2,672,33,713,463,702,273,61,40,59,70,46,101,58,172,586,357,296,115,779,36,350,109,727,388,236,207,87,105,408 }, +{ 31,44,276,284,98,299,935,116,201,662,9,39,492,144,489,131,567,371,268,0,49,918,127,137,367,254,28,434,293,737,30,203,1,295,22,456,93,125,219,385,23,202,187,393,21,716,105,599,578,51,36,128,141,836,272,269,244,318,384,13,159,395,48,261,96,110,224,616,326,242,35,16,253,5,95,55,64,160,258,158,143,18,100,699,165,24,115,948,120,37,403,86,166,310,12,924,457,855,940,77,10,442,494,101,109,7,197,317,206,68,2,373,617,761,352,285,908,217,332,341,916,228,32,33,518,688,730,473 }, +{ 13,15,23,51,1,0,10,2,4,115,77,5,9,202,3,197,457,7,22,11,165,6,961,12,33,14,59,177,403,21,102,40,453,180,719,217,18,31,120,141,32,475,8,318,569,37,16,341,210,17,386,450,401,28,269,64,99,326,494,317,730,308,44,523,93,352,291,90,125,365,260,36,275,24,134,49,139,30,110,498,421,98,57,196,391,19,117,72,342,153,48,817,873,349,482,901,221,629,76,237,111,899,86,95,216,509,752,304,137,247,82,372,116,758,89,27,38,39,65,203,55,402,45,29,373,300,143,615 }, +{ 162,123,257,184,183,17,229,130,84,136,497,556,152,383,129,452,99,80,3,205,62,57,56,266,106,119,12,128,40,4,161,378,27,14,495,504,381,202,769,469,249,59,77,432,11,34,33,305,64,90,403,240,38,54,5,102,45,32,23,73,618,475,51,361,440,139,775,37,402,471,318,53,21,494,65,141,19,372,453,313,421,177,880,472,757,217,245,548,250,527,2,76,524,349,61,86,216,153,210,196,115,179,10,619,328,269,291,214,72,483,117,209,6,26,22,477,111,95,13,401,114,157,369,211,36,134,48,306 }, +{ 196,153,117,453,134,33,40,23,102,51,13,475,0,14,22,15,12,2,64,670,21,401,730,4,18,99,65,10,9,11,1,28,95,57,128,77,5,38,46,37,403,386,202,719,24,6,108,457,899,139,31,59,16,82,36,165,32,120,961,86,236,48,8,342,141,775,125,308,137,7,54,523,50,269,197,494,318,115,300,260,39,758,450,180,421,277,90,217,341,629,361,49,3,326,114,93,391,291,210,194,328,317,111,17,352,558,110,377,29,275,283,133,485,817,898,615,801,351,160,19,488,569,350,373,109,84,56,183 }, +{ 224,219,187,258,442,871,908,385,836,131,944,574,839,127,98,613,31,116,926,44,137,829,860,160,827,276,39,254,284,36,144,228,201,96,406,1,371,530,202,856,716,93,30,51,9,203,268,737,902,492,23,49,21,190,13,318,843,531,326,269,924,125,367,141,64,77,120,166,816,935,800,242,299,115,456,260,293,274,931,494,395,567,110,217,662,5,317,22,717,100,143,434,128,28,48,86,533,10,295,105,332,55,489,180,365,918,418,102,578,197,244,83,341,576,403,384,625,165,261,177,159,352,291,822,863,473,251,206 }, +{ 195,121,360,590,146,407,156,786,522,132,883,591,626,929,941,259,687,279,379,586,296,465,467,150,178,354,5,21,55,534,70,60,783,771,13,346,340,48,271,581,49,493,163,1,199,147,608,668,125,955,167,562,535,98,518,108,362,18,371,212,446,107,761,878,31,126,50,463,35,818,105,75,120,598,87,0,767,223,165,640,22,447,293,777,159,16,23,9,142,115,658,92,481,44,95,37,807,93,61,58,24,191,33,7,846,395,12,197,4,385,127,423,71,140,82,427,144,116,17,117,2,363,698,246,39,64,32,781 }, +{ 2,1,29,14,6,46,52,26,75,38,5,25,19,50,96,70,108,114,309,36,103,74,17,65,27,112,45,262,236,220,145,218,58,42,86,516,24,366,22,7,67,21,12,66,532,87,412,18,480,283,602,323,137,3,163,226,238,0,194,51,32,28,10,69,171,37,23,115,208,128,331,394,135,48,99,64,13,433,285,160,61,782,113,357,308,222,95,484,401,16,141,294,151,287,223,83,646,124,389,361,894,866,545,421,54,324,4,278,388,396,186,650,594,53,168,453,289,202,59,253,181,90,273,138,150,403,756,606 }, +{ 15,82,120,10,197,260,0,165,351,8,64,31,110,93,9,22,117,13,457,450,1,44,33,23,326,102,49,125,898,153,719,77,854,523,18,14,98,12,40,7,961,2,115,373,180,5,51,386,36,111,141,95,730,28,196,922,139,203,55,116,4,817,498,899,128,30,177,86,569,144,661,99,37,202,16,24,65,318,21,873,11,59,6,277,217,391,269,341,38,32,291,143,237,352,210,317,3,365,509,474,349,758,704,642,216,39,615,137,453,275,403,401,94,300,304,629,247,372,242,342,90,48,752,901,801,308,221,811 }, +{ 7,66,97,172,232,192,226,2,74,324,52,29,135,92,568,222,43,107,353,87,387,580,500,38,620,448,331,526,140,330,5,138,294,174,356,20,14,262,298,32,357,145,173,853,6,359,21,126,58,16,204,808,64,888,337,104,314,673,35,22,729,95,872,25,278,380,70,802,37,583,426,1,49,12,112,69,75,65,86,61,45,60,48,10,246,90,230,0,42,355,24,220,415,85,81,889,46,885,36,825,287,28,194,72,171,792,392,632,560,280,312,50,71,115,76,54,26,18,151,155,707,587,89,17,4,764,147,59 }, +{ 62,129,123,162,183,507,618,136,249,152,211,57,77,184,205,59,130,4,128,41,11,40,117,17,229,497,361,257,3,33,38,313,452,266,378,248,153,64,106,90,210,383,119,12,328,214,99,432,216,157,196,86,202,556,179,54,102,80,37,381,402,471,134,245,177,5,514,369,188,339,440,305,275,524,141,45,269,84,710,529,291,403,139,342,115,56,318,209,76,504,421,372,742,619,292,240,237,79,27,14,775,22,19,10,23,457,95,21,207,488,13,494,180,542,65,300,401,306,32,34,114,26,215,25,217,769,151,110 }, +{ 13,1,4,5,2,23,115,15,3,51,6,0,7,77,341,217,11,141,177,33,317,12,180,21,365,197,202,32,318,352,269,102,901,9,291,10,165,40,403,752,59,22,8,31,401,569,349,494,120,308,304,44,110,90,17,386,64,93,37,247,153,210,326,14,450,28,373,117,16,372,48,196,457,260,98,275,475,498,237,453,125,30,18,203,523,342,49,509,391,36,961,128,873,134,719,116,629,24,482,421,39,221,216,139,244,72,730,253,95,817,55,86,143,615,57,661,351,704,144,127,899,105,76,864,576,82,922,758 }, +{ 6,26,235,145,19,47,112,78,648,624,630,27,85,64,42,95,122,444,25,644,113,70,108,453,29,632,130,711,53,222,74,390,32,65,237,412,416,280,665,287,813,138,730,307,73,680,283,14,196,52,34,4,312,51,236,226,90,262,17,337,22,180,59,331,500,128,86,884,315,194,690,114,133,498,849,137,50,200,3,256,21,2,49,45,33,23,13,66,141,409,445,297,288,57,381,719,11,396,289,247,87,163,165,1,250,5,46,115,153,525,99,183,76,746,324,63,792,675,294,316,56,214,28,583,751,125,285,503 }, +{ 51,23,99,12,15,13,153,10,117,403,120,37,82,165,128,453,401,64,202,197,2,115,110,14,260,457,21,475,5,308,0,38,93,719,31,3,22,134,141,1,33,196,386,180,351,17,421,569,44,326,125,523,961,11,730,269,137,402,318,450,4,494,8,49,36,9,98,18,7,95,391,6,54,629,328,32,237,28,40,19,86,775,373,57,116,41,854,77,79,59,899,352,94,474,102,203,509,477,65,758,89,341,285,221,901,217,111,177,16,361,144,30,880,757,498,46,29,27,670,105,898,143,24,62,72,277,317,55 }, +{ 16,24,71,18,92,108,35,60,146,64,7,118,246,199,126,121,32,50,9,267,649,156,167,830,271,133,273,140,36,68,5,230,132,247,21,14,1,640,12,563,48,0,87,388,75,2,237,220,330,86,46,354,115,65,672,304,128,55,751,522,180,360,95,28,236,191,516,114,163,696,149,953,189,22,54,565,141,51,137,217,674,412,352,49,340,23,633,37,309,458,202,39,10,394,58,103,70,597,125,262,72,38,947,726,591,502,437,195,164,363,67,641,514,602,954,124,864,448,107,150,143,101,366,283,13,678,317,177 }, +{ 15,2,0,13,1,4,3,5,23,7,217,6,9,115,51,8,341,10,11,317,372,180,365,77,33,12,22,247,901,18,120,197,457,14,16,165,291,28,21,202,31,349,961,719,102,260,32,453,30,352,523,40,752,569,730,24,82,450,304,308,110,437,93,117,44,177,36,351,196,403,64,17,318,475,153,899,134,269,494,922,401,386,128,48,482,316,326,37,137,49,57,873,125,39,854,59,55,509,90,579,342,35,817,629,758,373,210,98,498,237,898,116,65,111,144,139,615,19,670,241,20,56,638,468,89,95,275,801 }, +{ 234,639,178,416,77,455,5,49,142,202,450,427,0,147,329,21,198,315,61,557,344,13,113,32,318,120,22,23,325,48,259,534,494,105,95,347,518,798,39,884,159,58,481,99,817,623,878,291,112,711,70,64,17,1,31,320,51,265,158,65,465,128,362,192,137,236,845,260,403,44,310,141,196,342,177,30,7,271,241,195,135,269,28,290,210,929,15,4,307,170,125,663,102,33,275,263,132,859,408,294,194,786,581,402,301,153,86,523,98,150,423,346,167,25,237,415,36,858,682,592,352,117,100,12,37,10,709,146 }, +{ 31,1,44,36,116,64,55,5,180,2,22,352,98,86,127,141,12,164,13,498,125,115,144,253,170,4,242,137,752,197,128,105,7,244,0,160,237,23,341,21,165,9,365,299,901,301,3,951,317,10,6,28,864,51,338,269,15,268,844,83,169,217,202,873,638,93,569,509,96,824,546,8,37,456,740,293,512,203,77,395,479,318,206,14,776,599,95,506,33,367,276,11,48,685,954,285,239,457,535,201,492,762,717,401,965,533,102,393,482,208,49,109,391,601,558,489,67,870,284,947,961,403,708,946,35,434,923,40 }, +{ 120,217,260,141,23,77,13,51,317,1,180,269,15,115,202,450,137,110,373,291,21,352,64,349,5,177,82,326,351,48,318,854,341,36,365,304,165,197,0,32,922,372,128,96,9,93,752,12,22,523,160,10,2,244,7,457,4,28,898,386,86,901,661,498,719,33,16,275,90,247,203,143,11,253,482,40,37,83,403,730,494,102,50,18,961,615,473,221,237,8,817,30,968,125,704,216,39,59,14,67,6,117,210,35,49,95,72,342,308,24,89,453,55,134,475,76,69,116,17,61,31,3,437,864,70,899,576,98 }, +{ 26,396,648,6,112,122,624,145,287,19,222,416,42,25,573,138,74,651,644,151,66,113,445,45,85,665,280,29,525,204,64,174,337,680,87,884,135,53,65,70,436,27,95,58,297,881,194,73,80,746,544,235,17,86,2,90,243,32,22,5,128,1,609,353,311,141,61,315,307,491,226,106,0,52,81,813,614,209,255,7,632,75,114,10,36,186,580,415,289,63,611,14,34,33,49,214,28,792,117,250,312,283,77,125,172,108,389,76,192,208,355,237,667,56,4,91,165,294,40,348,148,635,102,123,256,153,46,549 }, +{ 156,360,522,271,146,354,21,446,121,132,5,463,591,340,195,727,586,18,48,407,13,49,167,32,668,60,199,566,23,16,447,698,955,575,9,658,296,493,608,150,126,0,534,35,24,581,92,71,590,363,107,279,141,125,640,31,212,4,929,411,467,562,10,1,51,115,783,165,191,22,623,68,598,379,61,12,293,273,202,95,197,303,163,663,269,108,37,101,221,118,621,391,76,28,17,40,109,7,767,260,55,518,120,33,11,77,259,39,347,941,44,252,713,478,98,140,408,350,93,626,346,264,900,509,818,30,170,763 }, +{ 21,5,61,49,98,23,95,32,612,178,259,51,182,48,13,481,120,77,683,660,427,291,147,64,70,4,465,33,344,269,241,0,17,767,318,263,202,141,107,415,817,450,180,22,534,392,362,125,116,347,11,929,350,121,595,408,423,352,293,260,196,165,117,105,102,87,86,59,37,18,7,3,557,376,845,663,579,541,490,356,316,115,90,163,928,711,28,132,590,407,941,922,704,645,523,360,346,284,268,232,210,203,195,177,144,134,118,97,65,60,40,16,1,298,153,146,58,937,798,414,113,31,771,246,207,142,281,647 }, +{ 468,89,358,79,365,94,179,205,317,405,482,498,245,72,115,341,217,180,413,490,111,734,247,431,188,216,37,474,152,452,11,629,569,873,752,749,497,197,4,339,308,13,12,59,901,428,864,579,40,76,23,372,291,875,10,352,134,961,117,77,542,528,401,51,588,349,471,529,33,464,546,477,645,139,221,1,377,38,21,99,36,177,509,64,449,316,14,2,304,143,102,437,9,32,196,741,3,165,5,275,202,128,54,277,237,153,210,743,457,430,300,773,485,460,141,17,0,350,22,288,421,257,270,48,8,184,137,15 }, +{ 24,35,71,68,16,18,92,118,375,108,7,101,302,175,336,154,60,273,14,124,9,398,230,140,0,150,55,149,28,345,189,399,246,191,65,346,69,722,212,46,1,458,167,22,429,314,2,267,126,674,21,388,439,97,67,38,114,10,48,252,628,95,364,251,882,50,133,637,36,49,39,109,12,823,172,768,602,103,236,650,5,83,520,66,232,64,517,32,562,847,694,815,589,702,107,96,51,594,23,695,363,298,37,535,462,484,29,13,796,86,467,886,604,806,868,121,419,125,54,755,451,168,100,135,570,158,6,169 }, +{ 421,453,51,801,730,475,23,523,386,670,401,719,13,629,899,365,403,758,457,115,494,569,805,958,576,543,697,165,615,221,423,817,450,33,488,308,197,102,66,21,514,388,56,14,38,734,341,117,7,326,69,467,961,880,323,196,153,19,202,886,770,128,273,97,120,811,642,532,458,207,110,24,10,6,1,540,67,0,753,554,390,135,134,92,73,52,43,894,37,32,743,214,114,103,90,65,29,891,847,782,125,451,269,208,75,754,602,480,244,229,200,133,130,119,16,9,426,162,83,40,22,2,42,25,203,123,4,901 }, +{ 113,311,614,29,491,145,45,112,80,6,151,631,209,315,74,61,27,2,73,5,287,66,26,243,25,70,396,611,667,52,138,19,58,454,869,122,222,17,186,106,87,255,445,32,64,496,42,297,1,135,684,227,4,128,644,7,86,624,76,337,95,416,65,22,72,85,59,14,204,148,90,21,738,174,250,53,119,141,280,10,483,0,833,137,651,690,549,46,75,226,11,378,37,665,155,742,200,56,194,207,57,177,179,525,12,114,84,77,48,495,40,469,172,292,307,161,49,38,884,887,655,573,881,89,425,18,36,33 }, +{ 471,339,188,4,11,59,377,79,12,99,94,102,77,33,51,111,542,37,342,152,961,13,474,403,40,202,196,153,128,3,452,453,177,229,431,475,401,23,139,117,184,266,157,57,134,115,494,210,300,17,291,402,129,90,32,529,629,5,141,76,775,72,64,275,38,21,318,757,569,277,216,162,14,421,313,123,269,880,89,1,2,497,257,62,197,405,27,45,285,54,304,148,485,217,15,457,41,10,6,179,165,205,180,137,477,349,130,488,245,19,523,432,437,260,22,120,95,769,372,0,352,381,249,618,482,308,237,7 }, +{ 15,40,4,11,33,120,10,82,165,77,110,93,31,8,260,0,23,22,102,51,13,59,44,351,125,64,197,139,32,9,21,326,28,450,196,180,98,203,57,141,386,49,373,12,111,95,1,391,5,457,99,403,115,18,453,116,202,134,475,523,719,854,37,117,128,401,237,48,144,177,14,898,36,217,2,90,308,269,342,758,30,210,318,277,730,494,17,509,922,352,291,817,86,3,65,16,901,24,194,402,105,38,137,7,341,317,29,961,39,629,55,72,76,300,661,752,421,899,242,54,775,247,349,365,569,143,615,485 }, +{ 16,71,24,35,68,18,118,60,0,28,124,92,7,55,9,419,375,14,109,175,149,101,126,252,302,346,150,439,108,154,158,570,169,185,364,22,273,49,65,917,701,329,168,962,420,191,925,39,628,107,2,1,604,46,140,67,97,21,535,265,38,69,159,942,677,10,722,336,105,345,694,467,703,48,5,95,246,553,810,882,20,83,333,43,12,706,13,637,826,100,23,847,671,36,167,279,121,793,189,199,374,50,125,51,212,230,286,66,272,566,6,484,634,344,32,429,289,327,86,103,96,601,114,441,517,37,64,298 }, +{ 17,45,227,106,209,243,21,290,255,400,207,48,263,270,62,186,119,2,496,454,50,32,3,5,52,221,29,425,136,408,430,46,513,171,14,659,54,84,787,721,741,56,281,38,536,80,181,378,240,742,587,552,1,306,76,123,241,541,655,328,428,61,129,41,666,72,502,57,89,12,760,540,115,155,148,383,449,794,37,96,361,152,11,34,214,4,311,51,440,474,592,431,64,790,202,179,405,350,292,36,90,67,663,6,141,59,13,498,103,583,130,697,514,40,211,99,58,10,128,237,217,770,27,869,157,828,834,391 }, +{ 340,354,586,658,668,156,195,698,363,447,883,296,1,411,303,18,379,9,919,360,51,621,98,31,48,591,371,13,21,446,163,5,121,70,132,125,23,759,846,127,761,478,60,293,223,271,146,385,120,664,691,108,763,82,634,638,75,4,260,24,807,774,144,44,522,407,30,457,32,16,914,463,126,777,335,93,771,367,71,49,39,12,0,687,351,118,299,201,40,7,50,848,518,284,922,854,758,538,364,279,11,10,724,310,217,326,64,393,77,541,767,167,150,137,105,103,101,87,58,17,115,286,225,33,401,867,850,663 }, +{ 277,153,111,12,23,51,474,99,38,139,37,457,453,117,542,41,79,629,196,401,13,11,14,569,961,102,33,134,188,89,40,157,54,328,72,775,57,115,17,94,413,339,431,15,377,369,3,477,308,719,248,165,313,4,468,45,485,148,32,197,76,734,216,62,2,21,10,587,405,64,5,59,29,34,6,210,82,509,471,128,155,152,730,177,490,7,266,361,52,120,475,1,0,873,19,305,758,9,899,125,22,110,386,300,211,93,529,229,48,260,237,180,65,50,528,880,77,391,86,36,27,588,326,546,482,402,514,56 }, +{ 18,16,24,0,159,35,68,49,105,9,60,71,101,28,344,55,7,118,320,109,424,14,327,455,239,22,286,170,272,310,1,374,252,154,419,329,167,158,124,518,23,95,709,39,2,21,51,65,13,301,5,890,48,92,265,98,191,212,12,10,108,137,347,128,30,538,31,364,125,202,37,553,20,149,121,557,185,36,677,67,333,169,338,146,127,346,46,175,64,6,126,100,577,50,254,32,512,916,33,403,86,395,69,242,806,371,115,96,44,77,318,221,479,694,616,102,165,623,83,910,627,737,917,38,793,578,846,375 }, +{ 0,105,9,16,49,18,24,68,101,518,158,320,28,35,301,170,272,890,344,286,109,327,39,65,55,512,7,1,127,916,98,118,252,60,737,159,239,371,21,71,124,395,154,14,48,455,623,242,31,23,51,419,374,364,761,5,2,12,137,310,95,125,293,333,846,202,13,616,329,347,338,385,30,37,131,44,938,479,128,836,709,22,538,265,506,64,793,627,10,67,167,299,403,827,212,713,578,149,116,32,36,219,100,910,254,553,175,318,677,108,185,50,6,96,46,685,221,421,424,191,577,92,93,269,599,187,165,284 }, +{ 141,180,1,5,352,365,13,2,4,217,341,115,269,317,15,23,752,3,7,901,6,0,197,21,51,31,77,202,44,318,32,64,372,873,498,10,93,8,11,244,33,9,165,12,102,137,22,253,49,48,237,116,30,98,125,39,177,569,401,28,143,291,308,864,509,40,120,349,403,37,105,391,144,153,482,203,450,110,421,127,72,576,494,95,453,260,247,96,475,373,326,117,36,717,304,131,128,134,90,89,14,457,854,221,206,196,55,811,82,947,629,351,922,386,59,961,734,670,17,437,661,224,201,16,88,76,164,187 }, +{ 51,4,23,102,33,300,40,485,453,880,153,19,17,196,27,342,78,26,53,403,47,77,210,0,475,117,73,2,57,34,11,5,200,13,99,494,14,1,22,12,176,421,64,111,41,21,368,361,59,757,231,130,123,6,139,128,134,401,106,18,56,49,322,317,177,45,775,48,115,165,108,10,125,65,504,495,197,32,605,229,80,341,221,183,390,813,46,37,618,306,95,719,554,152,753,736,543,444,161,402,277,119,630,236,216,122,113,29,730,237,25,899,217,714,383,297,472,445,378,250,38,678,670,527,503,469,412,318 }, +{ 62,440,56,184,229,183,556,130,3,136,548,152,266,99,162,161,17,57,84,452,305,12,383,257,123,403,34,40,527,14,205,349,504,555,497,328,4,361,202,139,775,33,38,37,128,475,129,880,313,381,757,102,11,196,59,119,401,432,402,54,471,453,215,77,23,514,507,585,51,211,153,80,494,495,469,236,477,117,111,64,421,240,369,106,21,214,277,157,308,5,291,141,378,249,13,2,803,619,318,45,76,177,27,485,472,134,41,32,412,339,216,65,524,197,10,72,114,176,165,53,90,372,22,188,245,86,217,543 }, +{ 13,23,115,51,141,202,77,64,269,217,33,318,102,32,21,128,137,0,177,180,4,5,291,9,48,352,10,197,90,196,317,40,153,7,372,18,15,349,22,2,247,165,275,6,403,11,117,125,237,59,3,16,752,494,28,342,304,31,341,134,14,98,86,210,36,241,12,244,49,95,24,498,30,116,39,1,143,901,453,20,450,144,365,402,221,17,475,93,203,127,65,253,216,72,326,120,164,576,35,19,96,44,437,160,421,308,83,67,864,954,569,817,719,25,101,100,61,55,57,284,805,523,401,60,293,285,105,88 }, +{ 1,22,36,105,170,28,55,239,86,31,2,95,5,9,127,0,98,301,12,64,67,7,49,320,109,654,44,83,10,169,208,143,21,312,35,13,23,128,141,740,125,242,14,512,293,116,160,237,51,395,50,338,37,159,96,6,933,114,115,708,299,751,185,137,844,505,269,168,69,48,638,103,597,928,202,180,244,323,16,352,253,165,3,713,197,194,892,39,24,599,65,54,341,285,318,286,46,685,456,951,4,623,824,32,133,158,365,584,601,535,38,498,144,218,251,841,533,506,30,371,217,479,8,503,284,870,752,276 }, +{ 15,0,1,2,5,13,23,7,901,9,6,8,12,51,4,3,457,180,341,898,82,22,115,10,141,120,117,31,351,14,202,260,197,28,269,33,153,961,64,30,44,37,93,18,569,854,11,21,16,77,217,137,365,386,719,237,134,391,110,128,523,49,450,36,629,498,352,102,125,326,317,40,401,509,730,318,196,24,203,546,308,39,116,922,55,752,32,86,817,17,403,90,98,35,453,95,373,59,99,873,177,758,111,143,38,291,242,139,65,48,244,899,372,285,642,349,247,144,734,638,615,482,277,72,253,421,89,475 }, +{ 274,98,100,39,1,265,438,190,310,625,382,30,530,223,909,96,264,593,166,778,88,812,410,960,731,557,252,31,125,21,539,23,254,9,48,51,116,639,44,478,393,131,127,13,101,0,293,284,329,795,404,840,144,656,435,333,724,616,5,219,228,321,272,421,834,165,921,957,224,105,32,36,93,128,697,367,541,669,765,242,221,49,676,137,418,455,160,748,83,897,163,202,682,578,475,453,553,386,807,217,213,551,613,406,335,403,141,466,197,827,180,948,37,158,187,115,905,821,791,203,352,286,258,371,120,863,730,2 }, +{ 212,18,118,447,167,781,363,411,271,647,146,121,60,562,664,621,463,815,478,1,16,446,9,777,354,628,21,936,48,101,932,132,68,191,98,520,522,223,71,264,5,24,759,55,199,575,727,566,126,13,23,724,156,360,691,125,0,407,591,608,49,293,604,221,51,35,92,195,346,31,107,252,108,375,586,96,154,914,682,541,807,150,39,589,124,848,265,69,22,105,50,834,32,364,302,393,329,12,4,10,382,535,404,28,166,765,100,668,273,33,149,88,706,806,163,279,95,410,598,44,335,955,7,30,67,284,159,467 }, +{ 24,28,14,7,35,16,22,65,0,1,2,158,49,109,55,159,124,95,18,67,149,105,71,239,169,68,108,185,424,289,9,12,69,46,577,10,175,154,320,5,164,347,6,747,344,21,835,36,286,50,38,83,170,654,892,23,420,92,114,51,64,143,60,13,374,189,302,429,140,48,103,570,118,32,37,29,336,610,133,327,312,398,39,484,128,638,168,301,272,125,202,137,86,150,30,194,230,671,345,584,703,96,54,115,273,251,310,283,141,518,98,308,20,538,401,101,127,52,31,221,346,455,535,236,403,389,458,267 }, +{ 105,272,131,22,286,239,320,327,98,127,219,9,185,224,374,187,55,28,578,86,31,258,36,913,616,535,1,95,538,64,164,837,634,109,116,601,44,654,312,170,910,49,708,623,115,23,5,0,713,371,201,159,13,505,2,197,83,892,7,35,67,180,533,928,51,933,317,737,301,751,10,716,352,284,6,160,776,237,509,916,165,242,498,251,531,12,395,39,924,137,638,385,293,269,30,276,168,141,217,254,752,208,144,569,896,836,143,346,24,824,21,4,546,468,169,308,14,761,128,345,244,318,482,365,3,597,391,384 }, +{ 28,301,22,31,127,512,105,98,395,109,44,299,293,95,9,320,1,599,685,900,55,0,239,36,763,338,242,49,116,125,841,168,870,456,286,23,276,506,86,35,284,51,185,65,492,159,2,24,374,479,13,393,928,5,144,7,64,169,713,141,12,137,327,21,202,14,268,237,16,935,10,201,558,272,538,67,401,367,37,143,83,308,424,164,312,128,158,115,48,165,918,654,194,269,923,740,39,347,244,623,18,6,489,253,318,114,963,160,352,289,124,180,68,96,420,170,203,175,131,421,219,434,197,391,221,762,453,93 }, +{ 2,58,29,52,1,186,334,46,5,14,151,75,45,400,155,50,61,227,163,262,502,69,549,70,220,223,48,38,311,112,67,409,113,780,7,243,675,767,27,17,209,24,103,80,394,96,21,315,54,307,513,536,83,287,787,309,37,281,6,16,106,807,171,587,496,267,19,32,631,474,270,491,12,35,181,26,583,454,74,869,820,852,36,324,721,255,845,278,64,73,335,357,89,87,140,72,537,25,760,290,18,659,614,430,189,66,97,133,663,114,108,592,552,128,331,666,764,141,606,3,86,380,486,366,76,65,148,10 }, +{ 7,107,232,135,97,387,92,356,298,66,14,2,192,359,278,172,52,357,126,324,448,35,60,526,314,16,38,29,46,330,380,43,362,259,392,230,20,226,74,140,262,246,279,147,24,825,64,58,5,121,568,87,294,32,220,501,132,21,612,465,95,150,86,104,620,18,12,71,173,581,54,534,0,893,37,22,808,583,178,353,90,10,580,550,146,707,802,600,606,331,194,112,222,28,69,660,853,65,70,199,171,68,560,1,174,36,50,77,49,48,779,500,204,683,493,414,6,61,25,764,55,138,33,102,750,888,307,45 }, +{ 20,43,104,414,560,426,707,784,173,319,861,7,819,81,715,422,879,0,376,330,74,95,97,52,32,192,64,38,22,49,526,356,66,204,681,397,207,140,232,5,470,65,693,61,359,636,387,500,107,324,28,91,712,18,10,29,147,77,21,595,392,113,577,172,729,2,325,24,138,92,33,347,125,86,945,102,90,306,40,115,4,198,370,583,230,174,12,904,180,11,858,312,153,124,17,587,750,76,59,69,344,298,3,135,13,37,46,825,718,357,165,348,315,214,72,887,117,289,353,246,196,141,84,36,427,51,237,48 }, +{ 104,74,636,204,355,222,66,81,0,145,25,319,784,746,192,750,29,20,173,174,792,64,90,138,280,715,65,194,91,879,525,32,22,4,348,287,43,95,18,422,7,214,415,86,77,42,40,6,681,289,59,524,151,33,10,52,712,2,28,544,945,13,597,102,45,177,97,21,57,11,243,49,85,36,312,500,426,693,141,5,673,624,396,16,1,122,87,115,648,24,26,186,632,233,67,17,172,414,304,416,123,12,353,389,117,651,580,69,588,751,153,113,874,112,14,23,227,216,128,58,217,197,27,875,114,635,137,707 }, +{ 101,0,9,35,68,154,252,39,65,28,364,124,166,100,149,336,158,289,346,439,429,419,67,55,114,570,694,30,16,265,24,109,484,88,1,329,69,194,404,637,49,189,389,547,133,398,703,826,671,283,22,168,610,175,212,190,7,83,345,103,64,14,768,399,71,274,333,344,230,95,799,50,21,706,36,722,677,420,10,185,962,51,23,18,553,140,254,159,125,967,535,676,46,48,310,2,86,96,952,264,13,12,169,382,5,596,108,323,705,782,251,118,208,857,702,756,562,865,438,218,60,267,131,237,37,755,105,272 }, +{ 57,14,4,236,231,59,369,361,300,585,342,51,23,719,401,13,38,176,46,202,62,402,3,56,210,54,12,2,412,803,381,457,215,11,507,128,40,757,555,77,514,961,32,730,629,322,161,328,37,162,33,133,283,108,129,21,211,34,102,494,17,152,130,29,99,139,153,52,527,472,181,79,123,475,229,6,497,899,453,240,758,194,205,184,188,183,177,0,136,377,305,134,155,248,165,157,425,290,440,714,495,209,739,196,277,269,80,50,556,10,805,64,65,523,503,386,257,141,16,7,5,179,403,84,600,469,318,180 }, +{ 2,1,3,5,141,6,7,15,0,269,180,64,33,77,10,352,102,13,202,128,318,11,197,17,14,4,291,12,134,117,9,120,752,165,153,196,137,217,498,341,349,260,110,21,342,93,40,31,237,23,317,44,82,115,22,16,59,19,86,51,351,678,32,57,36,961,37,450,111,125,365,457,27,143,901,569,95,79,203,49,403,873,326,8,139,494,864,372,28,98,402,116,18,244,56,854,509,48,719,386,947,29,922,954,76,94,373,38,45,523,25,391,285,99,730,546,144,475,275,72,90,164,210,26,24,453,817,253 }, +{ 5,21,61,48,32,202,1,70,259,13,58,115,22,23,178,90,0,494,51,12,475,453,182,18,465,403,49,17,76,450,120,142,318,141,137,147,534,455,402,146,132,128,64,31,11,522,260,771,953,922,859,523,420,269,241,221,207,175,121,72,37,6,4,3,2,768,205,179,415,376,362,28,10,237,30,937,702,113,68,16,9,798,247,590,326,197,165,626,344,279,347,878,125,195,955,933,928,868,854,851,821,815,795,780,765,727,678,668,657,576,562,540,503,502,493,488,482,430,423,411,365,288,285,281,273,118,87,65 }, +{ 205,141,59,152,245,4,352,72,497,76,216,247,79,452,11,588,94,21,188,217,89,875,77,339,864,954,464,269,115,148,64,12,37,529,38,111,32,358,180,5,316,405,471,490,45,474,365,317,349,752,177,288,437,498,51,99,90,468,102,372,128,318,48,1,237,17,542,23,947,241,431,221,54,3,33,291,2,734,197,413,377,270,460,13,401,961,873,341,14,196,579,482,244,569,629,40,308,645,184,257,304,678,720,449,36,10,202,749,275,134,117,428,15,290,153,143,453,57,139,7,430,6,350,769,281,210,476,403 }, +{ 15,1,0,2,5,13,4,3,7,6,23,365,341,115,8,51,9,77,31,10,457,93,44,569,120,197,202,141,12,961,165,33,317,450,901,11,260,55,110,352,22,719,730,453,217,98,82,64,401,18,102,40,21,269,523,403,70,386,49,351,752,105,498,28,16,629,308,318,111,61,898,30,117,475,509,391,817,95,922,342,36,59,494,210,134,899,137,421,873,116,854,14,32,177,196,139,153,734,128,143,291,24,20,349,37,758,372,247,90,326,690,801,113,216,48,275,670,27,125,25,39,57,638,17,304,35,237,244 }, +{ 5,2,50,58,171,186,46,29,14,52,45,38,61,155,17,218,1,281,334,151,227,400,48,487,502,36,54,760,67,133,103,114,21,96,328,236,366,243,80,552,209,83,311,828,27,745,160,920,19,24,766,32,6,108,832,65,12,223,106,514,3,433,70,787,842,99,28,549,113,112,834,540,361,163,26,37,536,516,496,137,765,75,480,454,754,532,780,0,430,966,739,22,238,86,474,51,767,283,18,25,583,115,285,587,309,7,73,287,72,255,23,600,412,128,822,807,13,323,315,208,76,119,545,10,956,270,64,16 }, +{ 457,795,70,120,846,48,23,761,125,318,64,751,415,291,758,221,763,202,391,269,87,401,77,352,237,21,165,128,96,163,558,13,1,260,137,494,5,51,851,767,141,197,546,557,867,597,49,518,102,349,450,623,509,33,98,177,678,922,900,743,498,293,31,223,342,403,371,32,180,873,854,0,217,884,196,153,95,4,44,308,7,2,541,17,30,127,765,58,351,372,386,117,807,6,903,704,182,845,22,134,663,210,105,39,27,402,326,859,307,159,285,281,82,817,719,455,353,312,192,61,931,523,203,947,247,207,385,45 }, +{ 23,51,13,40,453,102,33,4,196,77,117,475,64,153,0,22,10,11,65,59,15,12,134,21,1,403,139,202,95,14,210,28,177,108,18,115,141,165,57,137,128,457,86,2,31,99,6,37,36,401,269,49,9,318,82,7,275,180,5,24,217,342,485,16,111,277,125,386,291,44,32,300,197,19,421,352,46,48,194,730,341,237,17,120,93,494,283,133,90,25,523,260,3,285,114,89,216,8,317,899,38,961,719,498,312,50,26,20,365,351,67,391,54,110,373,326,289,208,168,546,752,569,308,304,98,377,402,361 }, +{ 229,152,266,57,381,452,432,313,471,12,99,17,184,339,369,62,4,129,59,157,128,77,497,3,11,38,123,202,162,37,291,188,257,40,403,136,5,216,21,205,102,111,775,79,51,475,14,33,32,45,402,453,54,619,90,119,115,64,76,177,2,106,361,377,72,880,139,23,494,130,277,757,183,349,84,401,27,56,308,89,80,19,318,141,117,1,94,10,328,529,474,210,245,249,41,36,217,269,421,86,618,6,148,556,342,305,588,179,383,0,134,34,514,477,304,769,542,22,214,378,275,137,13,65,300,95,285,82 }, +{ 49,109,159,28,272,22,327,9,105,95,254,168,131,374,286,347,39,35,424,158,55,175,169,420,627,578,312,67,346,194,0,912,1,224,219,65,86,239,892,36,83,518,114,688,320,538,127,634,584,913,439,371,64,616,30,69,24,10,535,187,336,2,228,7,716,289,68,98,601,23,16,31,164,654,208,505,51,258,14,13,170,874,128,44,12,837,103,890,160,115,385,137,345,50,185,143,116,756,251,141,101,96,190,747,333,125,202,5,166,708,133,21,637,570,242,237,46,835,189,165,638,149,610,706,100,751,48,577 }, +{ 5,61,29,58,311,2,45,209,80,52,454,227,243,106,17,496,592,869,1,151,255,334,75,667,287,70,738,549,171,48,46,483,663,74,155,14,50,163,207,666,290,6,186,119,32,27,378,21,220,659,263,112,136,84,742,307,833,7,400,780,469,767,62,64,72,513,113,148,262,56,409,270,161,331,315,635,425,89,19,38,495,631,3,76,73,383,887,502,69,66,34,223,128,26,240,54,86,306,87,491,96,67,845,408,135,814,37,4,25,445,181,95,294,24,90,226,103,10,405,237,12,297,141,22,655,129,11,16 }, +{ 260,244,373,276,44,269,141,228,110,131,574,219,137,30,839,717,224,217,661,36,352,567,406,120,1,116,253,93,318,160,202,341,31,21,88,201,39,190,187,77,372,752,96,180,64,851,268,55,98,317,82,22,258,613,326,86,351,48,51,23,115,295,213,100,539,291,144,860,35,922,864,9,450,261,489,28,365,105,13,177,442,840,515,321,83,166,856,854,49,935,203,530,284,0,274,349,816,69,197,954,251,165,67,10,811,434,247,778,143,385,531,254,968,957,237,498,843,127,384,669,466,824,102,223,32,5,871,800 }, +{ 99,12,139,79,453,11,277,196,474,51,37,542,111,401,23,94,188,775,33,13,40,102,313,339,961,629,153,431,477,4,38,485,475,300,115,569,134,117,377,157,210,59,14,471,266,15,89,328,880,148,369,57,457,54,413,405,308,403,197,152,128,72,64,165,734,10,3,2,21,17,670,488,719,202,229,82,757,0,5,402,32,41,77,275,177,45,76,29,305,22,342,36,498,1,730,46,494,184,28,318,93,31,529,162,514,6,269,27,482,62,110,873,528,452,179,120,141,137,86,421,317,7,237,129,8,18,361,428 }, +{ 68,35,16,149,24,71,9,69,0,18,67,118,101,212,65,191,114,230,167,133,124,103,399,140,154,1,50,283,246,398,60,7,64,565,55,695,39,218,336,723,375,302,796,28,108,238,267,705,83,189,330,100,23,486,589,702,562,458,21,443,175,13,361,48,75,345,92,96,22,51,181,237,532,755,46,30,2,115,88,14,10,86,363,650,732,335,12,36,49,54,891,520,217,411,516,141,166,95,412,394,641,180,37,5,906,478,447,223,251,247,264,433,252,389,146,480,98,596,602,545,830,346,664,309,271,121,364,628 }, +{ 88,274,435,30,613,100,131,829,166,530,382,93,960,795,190,127,856,466,957,187,521,264,473,778,31,254,228,716,406,1,686,39,863,203,410,224,800,457,137,9,160,704,219,438,28,924,944,120,450,144,836,492,299,326,260,44,116,840,98,202,83,96,321,36,0,21,921,55,141,367,341,827,639,385,265,158,128,772,201,49,539,64,258,317,180,110,86,269,851,442,295,125,908,77,662,276,23,669,744,272,373,242,105,82,931,48,35,968,351,168,318,859,115,578,822,33,557,418,371,616,32,625,67,213,217,109,523,365 }, +{ 167,118,212,18,16,71,60,24,191,375,411,68,363,146,447,101,199,589,271,562,126,302,647,121,815,9,628,566,273,35,575,664,21,92,55,781,621,1,48,777,478,0,149,936,818,108,520,150,354,154,446,847,463,124,346,132,264,98,107,7,65,522,156,28,759,13,22,23,39,49,932,727,882,5,14,223,32,640,608,467,100,51,604,125,695,10,69,724,806,246,221,50,140,195,517,67,252,96,768,279,293,31,360,848,88,166,105,691,95,682,674,46,535,103,2,175,649,109,159,598,458,265,329,364,914,12,653,33 }, +{ 141,64,86,177,128,597,77,269,95,180,237,352,304,291,275,147,588,372,102,194,125,947,13,678,49,875,202,349,120,437,115,4,59,137,153,751,197,40,208,342,465,954,67,23,5,318,135,32,216,660,470,534,196,182,98,31,22,612,90,38,312,448,107,7,10,581,165,353,192,172,707,51,262,498,494,117,33,21,17,1,389,76,203,14,46,565,563,65,569,546,391,330,285,284,277,210,205,139,134,26,25,20,19,12,9,6,3,620,217,11,326,97,853,629,259,278,232,789,380,365,294,289,244,55,43,0,247,111 }, +{ 18,289,701,65,240,194,90,403,523,214,421,283,475,389,217,102,862,202,847,437,494,453,650,64,697,874,51,352,751,401,817,33,84,0,899,13,597,5,196,805,32,23,11,954,95,3,27,22,24,757,875,141,671,312,108,21,153,19,306,114,118,247,450,288,77,17,730,56,4,12,177,942,273,958,814,117,519,86,61,128,859,207,835,193,880,123,249,838,28,120,342,49,134,300,2,6,801,216,719,57,457,576,864,304,125,302,124,14,615,372,16,210,40,237,60,577,504,119,770,608,752,62,10,9,643,48,1,15 }, +{ 51,23,13,202,115,21,12,5,32,128,403,453,141,401,165,308,120,318,457,15,475,4,269,64,1,0,197,10,719,494,99,2,450,37,48,730,3,180,523,77,7,18,386,14,9,6,16,59,22,217,260,125,11,17,90,177,341,237,117,421,153,24,221,899,33,352,317,102,28,326,137,247,82,817,961,19,40,365,402,391,569,27,629,57,95,49,25,31,8,216,210,110,758,304,72,29,93,54,351,26,38,291,98,20,134,61,196,76,56,45,44,241,275,139,372,349,509,36,65,342,350,615,678,285,89,214,50,670 }, +{ 98,223,393,125,31,791,834,116,271,1,93,202,697,44,64,167,127,293,5,541,51,446,801,77,450,212,48,284,807,234,120,23,765,21,318,13,421,18,195,948,639,551,132,360,730,770,141,142,562,146,163,96,386,49,963,144,668,354,591,197,346,128,260,221,0,198,82,165,416,269,494,670,367,949,817,147,33,178,522,70,32,535,455,719,137,453,326,203,842,22,102,687,61,156,55,121,407,4,315,2,325,105,403,883,110,329,217,342,95,692,10,781,615,463,798,12,958,291,351,7,17,39,878,586,113,196,28,68 }, +{ 15,4,40,11,23,165,13,51,110,93,120,32,82,77,125,33,197,141,260,202,59,10,0,21,102,64,180,5,57,31,453,22,386,12,269,8,318,128,403,134,3,139,95,475,457,730,44,9,49,719,326,117,203,1,115,351,98,450,17,352,28,99,116,217,494,523,210,373,391,961,37,177,90,144,137,2,342,18,153,317,401,56,854,14,48,65,237,341,36,758,421,291,111,277,402,365,509,30,7,922,242,105,275,372,349,24,86,901,801,899,898,300,39,308,817,72,6,670,16,45,752,498,27,38,76,304,170,615 }, +{ 15,1,0,13,2,5,901,7,23,6,9,341,8,3,4,51,961,12,115,10,898,180,82,569,134,31,22,141,351,202,457,120,44,269,165,77,260,365,403,401,318,317,14,33,217,11,854,93,28,30,453,18,137,37,386,21,110,64,719,36,498,352,128,450,16,117,922,475,509,49,177,55,111,391,40,730,523,99,326,98,102,629,758,153,32,39,642,372,24,873,752,116,291,308,421,125,373,95,143,482,203,817,494,35,899,196,86,304,349,17,244,38,237,65,275,247,242,59,105,402,210,638,48,615,144,342,148,127 }, +{ 234,416,77,315,5,639,202,325,147,113,198,49,450,455,61,142,329,178,21,0,427,470,494,342,58,32,557,22,318,230,725,43,858,112,120,70,102,13,48,263,20,344,260,884,425,817,128,798,115,290,105,518,291,137,95,904,23,403,64,141,491,159,241,845,523,31,121,33,319,97,320,392,246,196,153,17,173,104,10,39,663,269,117,592,501,125,51,347,72,30,163,28,253,170,408,194,376,107,18,265,544,326,352,270,341,4,738,615,534,475,595,98,259,66,631,449,301,922,158,76,134,720,512,312,9,180,859,690 }, +{ 146,60,271,126,16,156,360,199,18,121,167,640,522,132,24,446,354,591,71,463,118,340,150,92,598,273,441,195,107,212,22,0,407,10,5,21,108,467,28,279,586,575,423,566,727,191,101,493,649,534,68,95,608,517,55,35,32,783,653,9,408,48,49,508,363,296,607,698,246,13,668,33,64,117,109,356,98,314,39,658,140,105,7,362,660,447,809,411,955,93,31,621,50,303,298,153,347,12,158,125,65,953,713,264,163,350,359,141,124,14,143,51,939,478,149,115,36,75,4,781,581,225,207,102,77,30,562,44 }, +{ 4,11,361,300,77,56,377,368,14,59,40,161,51,128,33,200,210,23,378,27,54,495,102,554,38,494,453,17,21,12,202,80,444,108,53,757,37,46,78,13,245,457,342,390,139,133,123,386,84,523,32,605,196,862,527,736,803,99,73,57,19,630,561,475,3,542,509,421,317,250,181,136,111,277,269,450,197,472,183,48,26,485,730,297,62,714,402,381,403,391,880,122,719,341,318,306,145,25,5,514,256,61,899,546,106,90,50,34,383,833,236,775,497,165,129,85,401,366,184,469,436,838,358,328,316,291,275,241 }, +{ 141,351,217,82,352,120,854,260,64,15,180,372,1,922,269,317,36,137,752,373,13,21,349,51,898,450,77,202,110,23,318,160,93,115,291,128,365,48,197,177,901,96,5,165,244,864,10,86,457,4,40,237,523,247,33,579,341,32,304,11,661,125,83,143,498,326,817,2,203,275,437,69,102,954,717,16,59,961,35,386,851,730,22,475,28,253,31,7,57,98,95,134,144,391,12,6,719,117,210,116,17,196,139,0,3,37,494,473,403,114,49,30,29,164,899,704,559,153,90,72,55,9,45,509,482,453,393,230 }, +{ 15,77,13,1,0,102,23,33,2,4,51,5,10,291,7,9,3,450,6,217,117,120,177,317,341,260,11,12,817,342,365,115,8,134,21,153,180,16,18,22,349,40,165,82,14,64,141,453,372,31,457,523,901,196,197,326,275,352,210,961,719,730,28,304,475,403,569,44,128,32,899,93,59,269,401,24,17,49,752,98,318,110,36,629,216,30,386,125,95,494,90,137,48,351,308,116,111,57,139,37,86,99,498,65,615,247,482,144,39,237,221,20,96,19,244,421,300,758,203,670,194,509,38,854,402,873,437,391 }, +{ 15,23,13,77,141,260,137,120,51,202,180,115,1,365,217,0,341,450,269,291,317,318,5,197,128,21,9,177,373,351,110,352,165,2,12,523,7,64,349,326,10,48,36,901,32,33,22,403,854,82,90,96,4,922,16,37,28,18,752,457,40,386,244,372,102,494,6,308,8,160,86,24,30,14,401,49,661,817,453,719,421,402,11,704,961,475,237,873,342,55,3,39,730,391,59,196,93,221,117,143,216,615,898,44,498,275,253,210,304,35,285,95,125,31,98,17,139,509,72,153,811,482,89,83,144,899,99,576 }, +{ 348,174,85,138,6,280,74,355,233,192,204,636,580,353,343,289,673,66,65,91,81,104,712,750,25,42,214,792,95,64,681,173,194,32,715,135,90,312,29,879,172,825,63,235,835,86,22,87,145,370,5,256,7,222,415,52,0,874,426,97,500,519,17,26,237,43,4,288,36,18,10,389,20,33,560,76,21,61,40,544,45,59,249,888,77,577,746,232,28,102,2,72,49,568,123,287,56,525,448,751,180,11,337,526,707,671,226,27,19,247,24,319,117,48,422,114,12,69,108,84,208,597,37,1,861,67,889,58 }, +{ 152,452,497,59,216,4,269,188,77,11,79,339,128,529,94,471,318,141,202,588,32,76,377,177,678,33,111,291,349,90,5,102,21,137,51,72,12,179,542,38,99,64,257,184,37,1,245,217,460,196,48,372,115,947,148,45,402,474,40,89,342,210,17,352,205,288,3,153,769,13,117,10,2,134,292,54,275,304,139,875,498,431,23,405,241,403,247,317,569,229,401,453,494,285,358,180,197,86,300,57,0,476,961,6,954,308,36,143,524,165,277,475,316,597,14,95,237,15,7,221,341,58,157,735,129,266,214,421 }, +{ 417,253,244,499,141,10,559,564,110,8,260,352,728,143,180,951,120,642,638,661,752,922,341,373,811,137,269,901,717,197,93,206,498,44,165,31,116,203,160,854,384,351,36,873,762,326,704,268,217,1,64,115,282,317,959,55,144,15,365,82,898,968,509,164,86,479,318,13,851,22,21,332,473,434,51,202,77,940,911,569,23,125,450,864,824,237,261,9,242,615,372,617,127,48,201,102,128,4,33,5,96,506,0,391,117,98,28,401,386,40,295,105,32,758,531,276,338,37,83,35,349,59,533,153,177,629,11,12 }, +{ 77,13,23,51,177,102,33,115,59,4,40,0,141,128,90,210,202,137,64,22,269,291,217,10,196,28,153,117,318,7,49,2,14,216,134,18,180,16,6,11,9,24,403,1,275,197,3,95,36,86,125,165,247,342,31,352,494,19,32,402,12,139,453,317,20,237,98,65,15,349,44,475,26,285,17,30,120,111,57,93,21,372,105,27,25,719,194,457,341,203,304,386,260,391,730,116,421,365,35,29,5,99,326,123,498,208,39,569,509,244,288,752,450,143,678,144,110,523,401,308,82,214,300,351,43,37,48,164 }, +{ 1,2,22,50,67,14,36,5,46,28,103,12,0,38,83,114,65,168,194,7,69,133,86,95,24,49,218,29,54,21,55,96,109,160,51,10,584,16,128,6,9,23,48,158,18,75,756,37,35,105,169,32,389,289,159,323,238,181,52,244,202,13,503,646,164,137,532,141,239,115,361,480,185,64,17,143,789,283,124,708,253,505,946,597,3,717,45,776,58,170,108,269,70,735,312,874,285,610,68,782,189,318,424,71,531,31,308,237,320,171,4,892,72,402,99,328,220,418,251,420,394,19,180,577,487,401,347,344 }, +{ 17,106,119,378,742,255,306,136,207,240,84,383,62,790,80,655,61,45,5,56,311,3,209,504,440,667,76,151,32,58,263,483,179,29,2,833,292,548,214,123,129,425,186,454,128,243,205,738,445,64,21,245,148,52,38,14,26,249,57,27,328,19,90,6,4,555,11,34,59,54,162,202,184,507,469,141,592,229,48,215,887,710,152,73,86,40,161,72,618,460,266,257,491,77,358,211,227,287,25,869,183,318,297,50,290,495,10,216,130,614,155,1,476,177,137,361,12,315,37,112,33,22,46,95,113,269,194,171 }, +{ 141,128,202,3,5,2,1,269,64,318,6,33,17,102,15,180,0,196,137,10,153,7,120,352,197,13,77,117,51,134,403,14,165,12,23,402,11,93,9,342,260,82,110,21,494,19,22,237,31,351,4,125,86,475,457,450,326,27,44,32,203,40,36,95,291,961,453,115,25,285,143,111,678,98,341,37,139,99,523,817,49,57,752,498,45,386,18,38,217,8,116,65,16,244,28,144,317,365,56,719,373,901,194,854,79,898,277,59,29,576,26,421,30,569,401,730,947,177,164,864,48,72,391,922,24,873,94,349 }, +{ 38,514,328,377,11,57,266,248,41,880,313,471,556,152,361,4,485,99,305,757,403,157,12,102,339,54,369,40,211,130,542,457,3,37,188,14,139,23,13,153,494,117,33,475,775,229,507,381,300,196,77,453,452,59,555,162,488,184,277,585,236,477,440,629,62,128,51,111,421,134,402,183,215,961,670,79,548,123,342,210,202,89,401,527,474,94,65,587,719,543,432,181,45,17,257,291,80,64,72,21,619,108,32,413,828,46,5,29,0,95,2,275,129,308,10,56,504,205,86,618,155,76,177,49,431,569,90,497 }, +{ 68,520,167,101,264,118,478,562,0,9,664,777,936,604,212,100,191,252,154,18,124,806,265,16,759,21,48,1,71,375,88,724,628,24,329,35,682,411,410,363,166,302,815,447,65,419,589,55,23,39,647,149,917,909,821,382,125,942,98,346,925,772,13,701,146,96,223,51,108,31,10,221,271,22,60,28,321,44,92,905,69,30,676,639,49,593,364,882,274,694,521,907,64,105,5,158,67,621,781,812,126,133,553,189,848,897,213,686,95,32,121,404,522,199,103,116,156,50,140,83,429,706,763,273,115,165,127,77 }, +{ 230,689,699,213,466,831,352,217,30,443,418,854,144,201,840,855,251,203,957,822,96,530,1,539,93,36,137,800,317,83,190,128,326,669,752,351,748,494,88,206,160,31,473,859,335,202,141,44,321,253,735,498,269,435,116,367,187,86,35,927,332,180,237,69,98,778,244,285,219,82,131,576,228,617,208,922,866,930,372,100,120,64,2,934,403,349,531,702,48,21,731,817,274,23,5,10,13,406,365,224,947,824,795,345,898,291,382,295,223,692,318,286,238,39,341,276,863,77,615,166,260,625,678,51,28,67,410,125 }, +{ 77,33,102,117,134,153,196,291,13,51,15,23,82,64,40,202,128,120,0,141,260,351,450,22,4,95,59,137,269,342,177,386,318,326,11,115,10,210,65,373,86,180,217,49,403,1,165,275,28,18,453,57,36,125,98,352,494,523,139,197,14,31,854,475,2,194,216,9,7,817,21,719,93,6,730,24,457,237,90,12,116,16,44,349,110,3,5,402,99,961,317,114,372,19,48,32,285,105,96,17,365,341,300,143,8,203,401,247,164,108,421,25,752,144,26,30,20,391,39,111,304,109,758,50,221,208,37,289 }, +{ 11,40,33,51,542,328,13,117,38,14,23,139,153,134,54,102,111,12,485,377,775,37,99,403,231,277,401,719,369,3,475,453,514,4,629,308,211,880,457,291,305,89,266,152,130,2,57,196,961,6,488,215,5,176,59,555,471,313,72,300,477,183,62,184,79,0,507,248,115,21,670,339,249,548,361,1,165,292,29,197,229,77,556,474,236,386,421,157,413,188,452,17,758,41,162,391,449,587,32,46,123,428,509,52,247,569,136,899,757,523,210,753,155,129,76,50,237,64,730,720,476,383,312,440,275,90,45,342 }, +{ 77,64,141,202,33,102,128,153,2,117,269,6,23,318,1,13,0,134,137,51,5,180,3,196,10,7,40,165,15,14,352,197,86,291,237,115,403,95,17,177,22,217,36,139,210,9,120,19,125,342,494,275,82,475,457,49,453,16,12,31,4,65,21,402,11,143,260,194,110,93,450,25,28,351,317,111,498,326,27,18,349,752,44,341,59,164,386,26,285,116,365,98,719,208,32,391,300,509,401,523,99,20,24,38,114,244,373,730,55,48,901,372,203,312,961,8,277,160,678,304,34,37,57,854,56,546,29,144 }, +{ 15,4,93,5,13,21,11,1,23,32,110,141,64,82,180,2,33,40,3,98,352,120,6,10,0,12,77,7,341,197,37,51,102,351,269,854,95,17,202,31,9,752,901,44,165,117,48,318,153,291,134,137,115,365,237,196,372,59,498,260,349,450,14,128,90,36,317,244,899,22,342,922,437,125,143,873,453,16,160,72,105,482,179,817,19,89,401,457,57,661,403,523,177,164,45,308,864,373,253,245,8,898,49,421,569,223,76,719,28,61,18,247,139,56,96,27,490,210,468,111,494,475,144,38,961,391,304,25 }, +{ 1,2,50,46,14,67,103,38,24,83,133,29,52,96,75,28,114,5,36,238,65,54,108,171,70,0,58,18,69,181,160,532,236,7,22,412,433,754,283,55,163,220,480,361,487,124,12,223,545,45,328,394,21,398,16,155,9,366,48,35,956,6,154,87,323,646,309,514,112,186,822,137,17,109,149,418,745,175,547,86,37,285,68,800,866,10,429,732,516,25,208,302,51,32,118,334,281,99,531,71,61,194,537,458,23,891,389,19,151,675,409,336,128,168,13,400,307,95,262,832,227,49,273,420,3,115,484,64 }, +{ 258,276,860,201,843,295,137,160,567,116,261,144,268,943,284,202,187,935,662,203,699,131,219,224,44,141,127,36,326,96,98,31,318,269,244,964,23,93,384,489,55,21,434,332,13,403,51,120,1,617,918,352,908,367,110,206,180,365,254,197,492,473,871,442,48,82,10,143,800,260,39,574,28,944,299,940,282,253,9,115,494,418,341,125,855,77,8,49,128,836,535,165,100,576,30,523,385,105,822,217,395,959,564,22,531,911,37,83,393,851,717,64,817,752,421,716,5,317,901,551,373,859,0,170,291,599,533,251 }, +{ 7,2,14,87,46,52,278,92,16,140,75,29,135,294,262,70,38,35,172,171,409,24,60,58,69,5,97,112,66,314,1,163,571,71,50,461,155,267,232,330,18,220,54,334,357,126,380,307,21,74,12,230,48,309,186,675,32,37,298,331,226,246,151,45,774,107,64,337,25,324,6,67,606,189,622,20,448,150,43,61,0,400,22,849,287,10,68,9,86,563,28,95,227,583,192,394,620,103,36,764,572,108,128,335,83,55,587,550,13,145,600,549,536,65,141,852,366,49,415,90,26,236,526,950,17,4,181,72 }, +{ 13,23,51,115,2,33,77,0,1,10,4,7,217,5,9,141,102,6,3,180,11,40,317,22,15,64,14,197,352,202,16,12,341,269,365,165,18,318,177,17,59,153,453,196,752,291,32,117,308,237,125,403,31,128,8,36,401,24,28,349,372,49,498,137,475,247,95,304,143,569,901,21,98,468,457,134,44,139,19,90,421,86,210,120,386,629,93,37,116,482,494,57,110,873,342,55,961,275,111,391,546,35,509,244,203,30,27,99,29,437,48,20,260,65,719,216,734,25,38,54,450,326,50,351,46,864,105,253 }, +{ 74,145,204,66,138,42,25,6,337,174,525,222,192,29,26,544,746,287,415,632,85,609,135,7,353,280,112,580,87,396,712,355,64,122,81,104,2,45,173,673,416,648,172,43,792,226,52,22,97,651,151,194,70,65,0,19,32,20,715,95,825,348,5,624,233,113,86,635,91,879,294,10,644,235,1,90,500,36,573,560,49,636,243,58,63,21,331,426,61,75,389,27,445,14,69,750,28,289,46,38,17,888,311,312,18,24,140,186,76,283,141,12,874,16,232,278,72,461,707,53,4,526,597,255,665,180,114,881 }, +{ 77,217,33,102,317,291,202,23,13,51,141,15,275,269,318,115,342,180,21,4,196,352,64,128,11,494,32,5,137,403,40,2,0,125,3,177,10,98,365,349,12,7,372,6,341,453,165,197,153,475,48,752,22,237,31,117,9,95,59,93,16,90,120,247,308,450,49,221,244,36,28,18,144,86,14,134,326,421,203,44,17,304,24,116,523,260,110,864,210,498,401,901,1,35,241,386,82,127,817,39,72,437,160,105,65,143,730,719,351,216,457,402,30,350,293,164,37,859,96,367,139,284,19,579,576,391,285,373 }, +{ 187,258,871,219,442,574,908,839,926,160,116,44,137,224,276,201,36,860,131,202,613,228,144,531,406,93,31,902,567,385,843,318,203,268,800,98,662,856,494,23,190,120,127,418,30,295,533,836,1,284,96,822,244,64,944,717,86,851,55,13,21,51,22,840,434,269,251,367,489,326,48,110,141,699,816,260,39,384,261,371,473,83,206,254,859,10,669,492,28,317,373,128,49,365,450,77,180,863,559,530,82,829,341,918,253,32,9,197,125,351,332,165,143,943,728,535,67,831,576,855,940,403,217,716,105,274,69,959 }, +{ 1,372,23,5,141,21,744,13,291,77,225,349,144,48,459,96,839,260,304,269,442,335,691,352,32,30,622,203,303,284,330,64,45,521,180,317,217,160,88,752,418,120,93,190,948,166,954,340,919,686,342,244,228,202,201,189,137,110,321,914,411,447,781,772,254,51,765,31,656,264,237,167,724,478,842,437,274,127,125,69,44,662,466,435,351,326,82,9,897,410,253,716,286,678,479,299,238,197,68,7,2,934,223,100,70,58,154,98,682,393,967,960,922,856,805,762,475,402,365,341,336,285,247,221,177,169,163,131 }, +{ 66,222,74,135,87,29,145,2,337,294,52,172,138,331,6,7,25,226,42,97,632,70,192,112,353,609,525,415,461,204,287,500,26,174,75,43,324,1,58,32,220,5,232,544,580,85,620,635,278,45,746,64,426,568,448,396,262,122,173,151,69,20,95,19,61,526,140,65,889,86,307,14,104,280,21,46,81,355,92,38,872,22,387,651,186,648,113,194,416,72,163,673,90,24,35,155,49,16,330,37,792,0,888,243,17,36,76,861,10,48,849,67,644,227,50,4,89,853,334,63,27,314,312,12,825,712,91,298 }, +{ 45,17,106,209,255,119,186,5,263,207,454,29,2,48,425,243,21,496,62,290,3,270,400,408,52,155,136,659,171,14,56,513,50,80,84,32,378,46,61,655,666,742,221,58,383,38,1,54,311,306,240,721,181,440,502,430,334,129,72,536,227,123,76,790,592,214,89,328,281,555,34,787,241,148,64,215,663,287,587,37,11,405,162,27,237,504,57,90,130,152,541,179,12,211,548,41,36,552,184,4,741,115,431,292,449,869,229,96,77,507,223,128,183,40,7,86,51,249,205,245,161,6,738,236,103,151,59,10 }, +{ 213,88,260,120,93,373,141,30,100,450,166,36,372,321,459,473,264,180,110,326,1,225,144,704,717,351,82,855,530,269,466,352,217,265,190,22,274,131,96,539,165,86,457,291,28,244,64,187,318,752,39,349,661,330,9,160,202,219,77,410,197,44,908,254,116,49,137,968,276,317,125,406,31,521,523,435,15,98,228,128,32,299,35,662,293,143,115,21,934,778,224,33,856,923,876,854,689,403,371,341,10,935,851,498,437,8,922,48,642,776,903,839,836,730,613,365,268,242,55,0,944,899,492,898,615,385,304,285 }, +{ 266,57,152,381,471,313,369,99,229,12,339,62,157,77,4,37,188,40,475,162,38,3,452,775,129,184,403,17,59,128,11,432,202,111,453,33,56,183,291,401,216,361,328,102,136,402,79,54,440,14,139,880,123,494,51,23,514,277,507,130,757,474,377,21,94,529,177,548,421,349,64,76,211,90,117,89,72,308,13,318,383,5,141,210,134,556,342,153,305,497,257,555,119,485,84,269,275,106,670,2,115,477,488,45,196,41,300,205,32,542,10,543,304,431,86,180,504,19,27,82,179,36,629,249,46,50,237,245 }, +{ 352,217,317,141,752,372,365,180,341,15,349,77,864,21,291,244,115,13,120,269,1,498,5,901,579,98,144,64,23,48,482,351,51,237,102,201,82,437,125,137,318,4,2,247,202,0,31,854,203,143,253,260,32,177,160,490,10,96,110,44,22,494,251,33,128,403,9,3,898,717,164,28,197,72,93,11,873,450,36,165,386,95,373,6,223,661,30,12,49,922,342,206,523,16,457,127,109,468,308,391,116,531,332,473,187,39,88,35,730,453,326,221,7,719,69,86,105,100,83,851,475,90,350,230,678,421,101,304 }, +{ 14,514,369,880,102,403,377,51,719,485,153,23,453,401,457,11,40,13,328,12,57,4,33,38,629,236,670,54,730,117,111,361,961,59,37,134,99,758,757,165,2,46,386,412,421,391,277,29,308,543,477,494,188,600,6,196,21,542,197,139,300,739,475,52,899,79,509,523,488,775,583,283,231,7,803,552,32,5,402,89,828,3,507,176,77,50,15,155,211,64,17,569,215,115,18,381,237,305,266,202,90,34,342,194,128,62,555,389,242,125,108,65,0,471,338,136,56,548,506,221,181,133,10,440,114,248,95,1 }, +{ 107,172,7,359,126,92,14,135,314,278,60,150,298,46,392,279,232,192,2,441,356,330,357,16,32,380,97,534,423,581,35,526,38,448,493,132,52,288,246,660,5,121,66,24,230,324,572,21,387,226,462,259,247,95,220,146,140,77,18,508,147,262,90,48,312,707,20,71,603,54,33,195,550,362,86,236,108,739,199,830,23,64,43,29,895,802,451,22,36,28,929,294,606,50,87,70,501,13,808,177,55,1,194,178,711,316,4,0,102,590,366,49,893,600,37,582,309,872,267,117,388,241,620,115,786,939,571,360 }, +{ 59,4,90,45,216,13,25,0,177,23,77,51,27,95,72,26,115,65,12,91,210,123,275,37,389,19,102,33,11,49,22,18,194,5,214,21,85,53,48,202,343,291,31,57,6,128,42,746,93,73,58,44,32,196,283,81,319,61,141,249,153,64,138,117,422,355,40,348,139,403,789,145,788,300,247,240,134,74,34,804,619,370,104,86,38,1,304,180,524,494,217,20,597,544,318,352,323,233,174,114,76,17,475,280,204,588,342,285,14,3,43,725,287,7,888,636,235,52,29,63,337,232,122,784,125,397,817,678 }, +{ 5,315,416,49,455,639,202,350,77,408,21,197,137,450,402,13,61,509,329,113,713,344,569,347,401,48,0,841,494,318,734,749,64,70,308,95,903,120,342,884,237,557,32,194,546,115,845,1,23,165,663,128,873,102,291,518,22,58,817,391,498,263,17,33,221,269,403,923,260,105,241,125,51,196,312,39,10,31,153,234,112,523,158,18,4,265,12,141,9,159,928,623,326,207,25,177,310,3,2,859,98,28,65,30,163,11,19,275,491,290,6,117,541,16,15,124,76,72,27,922,210,44,341,349,134,773,147,24 }, +{ 130,47,381,390,59,90,200,472,214,714,65,289,6,122,874,85,64,29,751,648,52,50,74,875,247,194,624,249,288,26,312,437,32,217,630,881,4,123,95,78,835,352,196,665,519,33,57,711,524,954,108,42,19,77,22,153,597,416,412,0,145,444,27,243,25,14,183,304,117,453,51,256,141,730,102,177,134,236,315,680,86,112,34,11,115,235,287,237,113,45,283,151,317,588,579,99,3,752,216,342,813,128,445,864,180,56,46,28,18,73,12,23,114,13,389,53,644,719,21,396,58,17,372,947,137,316,10,250 }, +{ 51,453,23,719,13,730,165,457,37,197,99,12,386,401,475,961,4,17,11,64,59,308,54,115,57,38,328,758,391,6,5,2,899,3,753,403,32,523,670,10,509,40,33,421,629,120,21,65,19,22,0,202,125,95,569,117,90,558,29,26,514,494,1,775,128,134,14,450,361,34,9,86,194,177,350,269,72,27,25,7,880,757,111,62,153,316,236,141,50,56,260,217,196,867,546,161,130,106,77,48,41,31,16,8,317,152,468,242,221,136,734,80,89,968,949,862,814,801,717,704,495,469,440,428,412,383,378,326 }, +{ 15,13,1,5,23,2,7,0,6,3,12,51,4,180,115,21,9,165,457,197,141,352,11,14,202,217,10,37,8,32,341,120,22,117,752,269,16,77,134,961,901,719,318,48,317,365,33,110,93,31,569,18,102,28,40,260,17,509,128,44,153,137,82,498,59,629,351,72,386,403,36,49,401,453,730,308,196,450,89,873,30,523,125,99,391,326,177,98,64,247,494,854,24,291,95,475,38,86,482,39,203,922,372,349,116,90,144,57,35,758,55,864,221,468,244,210,421,139,817,76,373,899,54,105,19,304,342,96 }, +{ 0,9,35,28,68,24,67,65,1,16,18,114,69,103,50,101,149,22,175,124,55,39,12,218,133,96,154,189,5,83,21,71,23,7,336,433,251,13,49,75,118,335,2,51,48,486,30,14,10,283,181,745,115,223,137,54,230,109,418,37,345,64,128,141,108,281,99,36,60,100,202,956,537,163,532,480,221,766,302,596,487,95,252,346,58,158,46,180,217,361,237,70,398,86,269,160,31,32,105,657,443,140,285,125,87,212,166,167,502,6,88,375,165,323,831,317,754,29,318,439,77,98,364,38,197,429,44,765 }, +{ 28,105,22,320,109,49,301,0,9,170,95,1,35,55,127,65,24,168,98,159,713,16,512,31,395,36,623,2,7,293,740,14,338,347,424,185,286,12,44,23,21,169,124,5,158,68,67,928,13,371,18,299,242,125,51,289,175,916,64,761,479,374,39,737,685,154,48,272,6,114,599,116,10,86,141,37,194,83,149,506,327,312,841,202,763,237,50,900,870,538,284,115,131,420,346,137,654,385,456,165,187,762,30,276,239,32,308,69,143,269,429,96,570,71,128,180,933,160,164,46,197,221,401,634,965,219,101,318 }, +{ 77,13,51,102,4,59,23,33,202,210,115,40,403,177,128,196,141,153,117,64,494,269,318,134,475,217,342,0,291,11,90,453,22,402,137,15,216,139,10,180,275,86,95,65,57,6,36,18,523,1,125,21,317,365,197,49,28,421,32,14,352,25,19,7,2,899,730,719,391,341,152,24,401,48,27,17,12,901,247,123,114,16,9,111,99,26,349,285,576,50,20,3,386,372,326,260,194,120,110,351,283,482,293,242,165,96,29,37,30,817,801,498,457,450,393,373,299,237,214,203,615,569,116,93,34,82,958,805 }, +{ 13,23,77,51,33,141,115,102,0,217,10,2,6,4,7,64,22,1,11,177,180,40,3,14,202,269,9,291,352,15,165,197,17,128,317,153,196,5,318,18,372,117,16,28,59,36,19,137,95,210,237,247,125,49,86,349,341,304,134,365,24,275,12,31,27,453,403,752,25,143,308,26,57,20,901,120,475,44,401,457,29,498,90,139,65,8,391,93,342,494,216,509,164,98,99,35,55,386,244,111,32,45,37,21,260,38,110,56,450,105,39,730,402,523,46,437,82,30,719,569,203,961,873,326,285,194,116,421 }, +{ 456,116,492,268,949,867,203,51,719,8,391,918,791,457,730,499,13,386,23,206,685,125,31,551,170,870,93,417,401,10,22,479,506,338,940,44,509,143,64,692,670,558,453,0,473,197,523,758,629,341,165,1,564,55,899,762,308,961,421,959,36,638,115,569,801,180,642,86,299,164,28,37,141,965,498,559,9,5,120,237,95,546,260,873,599,137,253,12,244,903,901,2,817,752,728,128,352,450,105,202,7,615,127,365,958,21,301,49,951,403,740,326,239,898,373,922,475,6,854,242,15,3,318,4,269,98,65,99 }, +{ 17,237,106,62,180,45,136,32,498,64,115,41,255,129,546,752,864,197,21,227,241,490,352,482,57,123,292,350,247,509,449,162,365,468,214,38,23,13,4,476,148,76,437,155,507,141,165,77,3,720,317,290,270,873,211,164,72,153,209,117,5,659,54,48,249,217,341,186,710,33,40,14,12,496,119,11,519,90,183,618,139,179,37,328,579,221,431,248,372,405,130,59,99,400,263,205,425,2,358,349,901,51,177,171,89,428,50,454,304,207,542,1,457,308,734,721,391,316,29,569,94,243,143,339,196,313,128,111 }, +{ 1,5,180,15,2,4,0,352,3,13,901,341,7,752,6,141,217,23,365,317,115,197,21,51,165,269,12,11,9,202,31,33,77,569,44,93,318,137,110,120,36,10,22,372,260,498,116,64,32,873,125,48,102,308,8,349,98,482,291,386,401,14,373,326,28,237,37,55,86,134,203,457,391,16,117,177,253,144,509,421,127,153,40,206,403,961,864,468,221,494,437,453,18,17,196,304,143,128,96,854,450,72,247,35,579,89,642,758,82,342,160,629,719,282,811,59,351,922,730,95,638,523,210,546,332,661,49,734 }, +{ 141,205,497,216,269,152,588,59,452,128,4,76,352,875,188,77,79,11,94,678,947,339,954,217,471,372,90,529,72,318,247,64,32,89,177,12,288,37,1,304,349,202,5,51,291,33,474,102,111,23,115,21,99,179,864,38,148,377,13,460,431,498,437,316,180,2,961,40,358,542,137,490,405,241,464,317,3,45,54,7,184,196,17,10,402,752,245,342,210,14,873,48,143,285,153,257,197,308,292,0,36,569,769,237,134,482,139,275,165,468,341,629,413,734,86,476,365,6,300,851,117,751,494,401,270,229,453,29 }, +{ 247,64,317,217,237,437,180,498,349,115,752,579,304,372,864,482,291,141,352,468,197,177,13,391,164,490,23,546,33,365,77,153,72,216,954,597,277,10,708,269,134,569,275,51,695,509,318,179,0,678,244,140,312,640,117,76,629,196,751,128,36,953,674,260,102,901,32,21,22,225,401,86,717,143,92,873,351,16,133,114,191,386,253,165,69,59,9,458,341,202,149,82,649,35,453,398,166,100,95,93,90,125,15,373,330,923,316,48,854,586,213,486,230,922,5,411,823,734,189,139,103,65,50,24,18,12,830,167 }, +{ 2,1,5,7,6,3,77,0,141,13,180,15,217,64,33,23,102,10,352,14,117,9,11,197,165,40,269,17,291,4,115,134,12,153,341,317,752,372,237,51,349,22,498,202,318,16,457,128,196,36,177,365,32,21,59,19,125,901,342,8,86,120,139,93,45,961,57,95,38,143,509,28,29,391,111,210,27,260,873,244,82,137,18,386,164,37,719,25,48,31,304,49,864,98,402,275,569,110,351,629,253,546,26,41,90,494,50,730,56,523,453,44,54,144,24,99,30,403,678,76,898,450,437,55,954,482,308,277 }, +{ 11,40,38,328,542,33,339,313,12,377,157,775,485,99,51,471,41,369,23,37,475,57,54,457,14,117,13,188,305,629,102,403,79,4,139,514,880,961,111,266,719,152,248,474,134,453,401,153,211,342,477,21,2,59,361,89,587,277,94,29,308,196,64,32,413,77,229,210,184,215,402,128,431,381,46,670,5,247,197,165,556,757,386,115,300,50,17,391,803,494,875,490,730,177,162,450,421,275,202,0,6,1,257,76,72,65,48,19,10,129,569,236,130,15,7,555,901,898,588,86,9,543,488,90,452,749,619,507 }, +{ 77,102,33,196,40,51,202,23,153,128,117,13,342,64,134,141,4,59,0,269,210,177,22,318,137,403,65,86,10,475,139,453,95,115,28,99,11,165,217,36,180,197,49,402,291,125,1,352,18,15,494,421,194,275,31,300,110,120,57,90,93,12,237,401,317,6,457,14,2,82,24,114,260,9,386,44,285,108,361,98,16,7,21,349,326,216,5,116,730,341,372,19,133,719,203,48,32,391,39,25,143,111,105,67,576,752,670,961,899,308,498,37,351,304,20,30,283,901,523,365,27,244,208,55,3,164,485,8 }, +{ 472,34,80,495,250,469,176,389,527,17,14,161,53,231,4,128,56,283,216,106,84,57,27,483,177,59,119,503,436,45,585,297,194,29,378,3,42,62,269,136,26,40,11,2,862,678,619,33,73,236,255,514,719,200,25,6,64,240,179,141,52,102,789,361,618,129,597,5,153,611,349,205,65,245,803,402,210,457,123,383,90,304,667,318,814,504,328,133,130,51,32,48,684,108,714,412,215,13,139,19,95,77,47,275,99,12,311,211,165,1,432,207,322,196,117,61,23,524,152,115,369,183,134,114,573,54,162,46 }, +{ 752,352,317,180,141,217,365,269,244,341,498,115,253,901,1,372,202,21,318,4,5,23,700,717,13,137,2,349,197,864,10,873,143,7,482,0,51,3,64,11,67,308,531,12,8,6,28,237,22,31,468,579,533,291,160,221,35,30,96,48,55,33,9,961,120,49,44,39,32,247,83,69,450,326,260,77,36,98,851,509,165,37,16,457,437,110,93,88,82,14,345,822,765,638,421,219,190,131,128,114,203,144,99,800,401,844,453,125,494,475,373,351,241,206,170,164,148,134,127,116,105,100,86,40,38,18,811,19 }, +{ 9,39,101,265,18,333,520,329,100,593,553,364,310,252,167,16,68,604,0,363,404,118,166,121,254,158,272,24,60,271,212,286,639,327,159,35,146,1,109,30,455,411,793,105,557,49,132,647,31,71,621,21,656,354,438,627,676,688,98,48,682,28,156,538,190,22,5,55,23,195,65,44,848,264,51,446,857,709,127,374,781,447,191,344,865,625,821,13,124,96,93,7,578,125,419,907,360,463,32,116,126,37,274,777,88,731,108,67,154,92,95,36,199,12,137,131,10,562,128,326,664,203,382,50,806,242,921,435 }, +{ 15,1,901,180,2,4,5,3,0,752,7,6,341,13,115,317,365,23,217,141,9,197,352,165,51,21,137,11,36,202,12,33,22,873,308,77,269,10,64,86,498,569,31,372,55,93,40,120,160,44,509,318,349,482,638,8,117,37,116,164,102,32,28,401,110,128,196,144,206,244,153,457,468,951,17,291,16,203,96,260,811,143,373,642,125,134,437,386,546,268,247,177,14,48,758,717,719,391,579,72,421,89,661,629,111,730,559,961,221,59,403,523,304,851,35,30,169,854,494,127,82,326,450,251,898,417,475,734 }, +{ 131,39,829,166,613,827,716,578,9,100,224,310,406,30,98,616,228,1,254,856,219,438,938,190,31,846,265,931,0,127,96,625,274,924,44,371,101,385,116,252,272,863,51,137,88,21,333,731,557,36,23,404,48,223,125,49,264,160,187,737,242,105,28,258,144,93,13,530,158,944,382,284,395,203,812,593,518,442,5,456,836,128,326,293,68,329,403,35,202,816,77,115,83,909,688,86,890,478,120,64,22,639,16,165,276,393,455,871,410,201,286,299,33,576,960,656,24,217,95,159,110,32,367,421,492,221,55,102 }, +{ 17,64,62,141,106,136,751,292,129,352,41,38,954,86,476,214,217,128,177,32,237,947,180,162,123,209,710,269,519,247,90,864,157,77,318,99,57,76,59,4,437,40,179,358,11,45,618,119,313,5,304,211,597,148,875,23,249,197,130,95,507,37,54,3,216,457,248,58,210,115,288,12,425,678,186,164,328,72,454,339,245,102,80,498,312,165,372,139,155,2,152,56,33,21,655,243,720,183,207,14,29,241,117,266,290,471,137,84,51,188,305,275,205,449,7,263,48,542,13,270,742,171,752,509,61,317,349,369 }, +{ 42,25,235,650,736,65,605,630,233,343,123,256,122,85,26,416,6,389,63,141,249,368,444,194,511,174,544,19,108,597,348,524,138,90,27,183,32,370,304,525,84,56,53,283,789,445,18,78,280,91,130,947,588,619,45,355,17,680,73,4,0,222,112,3,813,119,145,64,678,297,250,80,21,573,523,86,214,216,102,76,11,746,40,33,269,240,29,289,624,177,323,450,57,24,561,77,152,114,184,74,287,28,396,665,648,378,372,137,37,5,390,106,70,22,847,51,49,349,874,47,881,23,817,432,337,243,153,124 }, +{ 184,229,152,432,266,452,57,497,381,619,17,313,471,257,59,129,369,339,4,12,205,99,157,77,3,5,45,128,123,106,62,202,162,32,21,216,40,136,11,188,119,249,402,349,2,403,14,37,38,54,64,291,618,524,102,475,76,177,80,90,214,33,79,141,453,23,210,111,245,372,137,27,318,269,217,494,775,86,94,139,10,1,19,115,51,401,56,769,183,361,84,529,474,277,757,72,48,880,6,247,29,209,710,179,377,89,41,292,285,328,13,588,180,342,130,556,36,477,308,275,460,378,61,197,196,0,165,421 }, +{ 137,202,160,131,860,567,318,36,295,141,843,39,800,93,30,105,187,224,276,201,261,943,964,98,49,269,219,851,116,9,22,473,1,352,203,127,822,100,206,699,144,268,662,244,253,10,717,535,332,120,44,258,143,31,64,450,704,96,859,190,180,115,55,365,531,326,95,217,28,110,564,752,86,373,284,228,317,21,77,341,13,48,434,221,197,51,911,940,159,23,384,533,260,494,559,935,291,901,88,109,574,282,128,442,367,308,959,617,5,83,489,299,251,728,170,164,165,177,492,406,926,417,293,401,349,871,125,968 }, +{ 125,64,493,0,49,165,35,293,55,93,18,98,9,325,68,10,279,137,31,48,453,389,194,197,147,13,788,14,132,95,107,77,391,371,342,174,61,43,581,105,28,22,5,259,319,104,758,671,590,128,44,32,20,767,761,457,146,121,725,465,198,126,757,289,116,100,23,21,110,763,612,12,663,199,142,120,102,101,7,427,4,356,37,941,963,867,848,498,156,88,86,58,51,33,690,558,376,180,2,864,163,955,70,623,804,422,657,202,1,40,534,90,649,470,798,522,392,352,945,502,386,359,237,221,203,177,159,144 }, +{ 15,33,4,77,13,102,23,40,32,5,11,349,51,177,21,141,117,93,202,59,110,153,64,291,318,196,31,217,269,115,10,180,82,137,1,8,44,3,98,125,134,0,165,22,12,128,351,17,95,116,2,304,120,139,403,457,210,197,49,341,453,144,372,450,494,86,48,352,386,523,36,90,719,898,6,275,30,365,57,730,28,9,317,247,326,854,76,373,475,7,72,37,421,817,638,901,401,111,961,342,899,216,402,277,260,18,237,758,569,203,99,629,437,535,39,61,16,96,752,14,300,208,922,704,105,83,308,143 }, +{ 110,854,253,811,352,141,951,661,244,642,180,752,143,498,384,269,559,317,922,10,911,160,351,533,365,373,206,902,638,873,332,261,345,260,137,717,116,843,31,417,120,44,959,531,217,341,535,201,125,36,699,860,82,55,564,434,926,318,268,940,197,901,164,574,864,276,251,824,295,876,127,450,64,617,943,93,258,776,15,282,326,165,546,817,855,851,203,96,187,144,728,83,1,372,601,219,224,762,237,284,509,21,170,169,499,98,391,479,115,768,482,473,406,86,898,662,349,48,202,131,51,5,0,896,871,401,238,228 }, +{ 2,29,70,75,220,52,112,331,145,1,163,26,74,324,6,69,58,307,19,409,278,287,38,226,46,223,394,87,25,294,606,50,66,14,632,135,583,151,42,67,45,27,396,357,171,380,675,138,5,21,113,267,262,97,24,7,309,764,635,53,537,222,103,48,335,500,83,32,122,16,550,186,96,17,73,334,849,155,189,644,852,802,37,61,54,64,571,140,35,12,582,651,461,486,853,108,36,80,18,133,451,315,624,65,337,785,573,366,445,72,86,774,92,89,297,400,10,114,95,416,587,648,462,172,71,600,820,238 }, +{ 23,13,77,51,115,177,64,141,33,102,4,217,202,40,128,269,291,59,0,180,10,2,6,7,318,11,196,14,137,90,32,22,95,153,352,210,9,1,117,15,165,16,197,49,3,125,86,237,349,18,403,216,19,17,247,21,317,304,342,24,341,134,475,453,12,275,25,36,28,20,98,494,372,57,31,93,65,44,110,27,26,120,139,365,752,111,37,35,326,164,116,402,901,260,457,30,288,421,105,56,498,29,144,391,82,203,5,401,308,285,719,386,99,143,48,39,351,55,194,437,312,450,96,523,76,509,244,316 }, +{ 340,897,691,478,914,658,724,382,363,812,698,682,100,156,166,521,264,447,909,411,1,404,88,354,303,438,96,296,274,772,39,656,418,921,9,30,410,144,23,744,848,639,664,435,21,586,919,13,271,31,335,254,51,5,850,98,367,225,960,77,203,759,621,190,48,127,676,120,32,668,33,83,4,67,44,36,272,217,69,291,131,284,286,360,821,101,285,116,242,18,223,686,102,265,905,842,317,329,93,68,82,822,195,128,125,576,692,351,103,64,238,115,652,475,349,765,326,141,966,578,110,118,0,260,403,201,163,105 }, +{ 310,18,9,326,265,252,121,51,159,77,195,105,101,120,363,33,24,354,271,102,272,709,167,98,16,13,132,639,23,158,260,55,333,327,704,450,35,170,60,202,49,557,125,93,411,254,1,364,95,455,146,817,28,520,338,494,7,286,137,156,109,39,21,14,48,128,116,64,40,31,859,320,118,212,141,360,890,318,293,4,523,615,269,576,169,20,165,153,75,196,329,373,210,177,92,69,0,301,291,781,479,371,217,627,407,403,342,127,71,44,36,910,374,5,50,668,647,351,936,682,578,538,593,553,203,185,180,110 }, +{ 57,313,471,99,369,12,339,157,266,152,38,475,328,453,775,37,403,401,514,40,188,342,139,77,11,59,377,361,229,474,33,4,51,880,277,54,3,211,14,102,62,381,23,111,162,196,130,529,556,305,757,275,128,79,115,629,13,402,421,507,308,485,210,129,123,184,177,494,41,477,153,488,117,542,452,248,300,216,202,236,134,94,670,431,89,64,17,183,440,569,136,555,72,76,734,432,457,543,961,257,215,291,304,10,413,15,205,548,90,56,2,21,46,165,318,247,349,197,86,32,0,283,412,141,36,828,386,82 }, +{ 16,24,35,60,140,71,92,7,14,230,189,108,18,69,46,150,388,246,278,2,172,68,1,451,38,330,135,126,236,309,149,443,50,267,121,565,67,582,21,75,48,462,52,563,594,314,29,399,66,191,877,103,572,55,232,366,97,696,357,380,733,167,83,220,517,5,28,674,74,12,65,0,54,9,118,262,335,146,516,32,37,653,915,22,36,133,251,96,324,87,273,394,64,199,723,223,107,10,486,458,711,13,6,95,163,571,86,726,448,212,641,192,345,70,181,132,23,49,114,550,98,20,271,606,298,633,99,603 }, +{ 206,417,940,959,93,473,728,559,499,203,137,202,8,450,564,31,44,120,269,260,318,141,116,326,244,253,10,127,268,143,22,125,98,817,434,1,373,144,128,615,51,638,23,384,692,523,341,64,922,0,851,13,489,110,352,105,9,951,717,86,28,386,367,403,299,704,642,242,55,551,901,36,958,282,859,160,77,49,291,494,801,968,30,180,492,365,911,661,498,276,854,165,164,873,37,762,456,197,21,317,12,15,5,7,569,285,918,421,752,629,576,479,115,95,2,349,96,401,758,899,393,170,898,217,457,391,48,39 }, +{ 15,1,2,13,0,5,23,7,4,3,6,51,9,217,77,341,115,10,8,11,33,349,12,317,291,180,177,14,102,16,365,120,22,901,304,165,457,21,372,260,197,32,18,40,403,453,31,202,82,961,719,475,28,247,523,117,450,64,93,141,730,110,30,352,351,752,569,44,401,153,17,386,196,59,308,24,134,36,854,494,318,899,48,137,342,326,125,629,90,49,128,437,37,817,95,275,922,421,498,758,98,210,111,203,99,237,391,116,216,57,482,144,373,39,35,20,19,468,139,615,55,221,288,898,873,509,244,86 }, +{ 2,1,14,5,50,48,46,290,21,45,29,32,263,155,207,52,38,425,171,76,408,72,449,17,292,227,89,58,513,400,428,119,476,7,61,54,67,720,75,241,243,186,502,655,69,221,36,148,24,96,6,306,3,214,106,37,0,103,223,10,179,281,16,83,350,64,90,129,430,464,181,663,666,22,413,405,18,240,710,84,262,790,123,431,28,12,741,163,115,460,255,536,56,128,35,334,141,9,220,65,205,51,86,659,99,249,23,541,95,245,618,209,519,202,70,592,270,237,528,62,27,217,133,4,394,137,114,675 }, +{ 132,121,354,167,146,463,271,195,668,446,98,223,407,360,18,212,522,447,1,781,60,48,591,411,156,562,586,363,664,21,777,393,199,293,125,807,936,9,23,590,163,16,13,658,5,126,541,55,101,941,107,259,621,191,51,834,786,68,647,765,31,150,929,759,284,35,71,49,24,465,221,118,520,7,92,883,116,608,279,727,535,70,96,44,687,478,105,50,346,697,467,963,281,33,10,566,22,581,626,93,77,296,493,4,102,108,115,640,147,75,39,770,87,32,914,127,144,598,178,0,117,273,12,2,37,783,691,932 }, +{ 131,578,371,219,224,716,105,616,737,385,187,761,258,916,254,159,49,910,9,623,98,127,836,924,272,286,442,39,28,688,890,320,627,518,293,0,944,871,574,242,31,395,22,201,327,44,116,158,276,109,908,301,860,284,36,51,23,137,95,926,713,512,30,160,125,333,170,239,96,21,456,347,228,13,86,64,128,1,68,101,839,202,506,424,295,662,938,144,55,168,24,567,48,843,406,83,65,185,613,438,203,268,35,165,492,244,299,902,221,384,16,141,115,166,827,93,10,829,37,364,763,261,169,269,5,656,434,685 }, +{ 302,467,484,97,453,6,398,124,69,36,51,14,421,298,1,66,273,87,74,523,81,426,2,403,67,168,18,386,886,756,701,801,158,13,65,0,26,23,475,24,758,86,22,108,719,25,547,615,401,159,117,423,150,730,847,563,154,75,19,646,29,7,505,817,189,278,457,165,42,458,717,572,267,138,782,531,429,153,135,450,134,49,700,208,958,671,715,622,336,244,172,143,114,95,85,63,60,52,650,197,46,899,140,92,160,28,10,791,885,718,327,314,12,5,610,109,43,703,673,670,370,341,326,289,38,35,805,879 }, +{ 190,30,778,530,539,88,100,625,382,1,960,410,731,274,96,840,957,435,321,795,748,264,669,438,466,39,166,131,36,418,144,265,9,44,228,213,23,219,224,921,223,160,406,251,31,863,83,98,310,116,21,613,13,557,203,51,128,0,252,367,335,137,254,5,924,521,284,352,829,48,765,856,258,475,827,69,201,93,49,909,404,716,238,101,616,822,33,421,32,456,593,217,125,127,944,752,67,286,276,679,931,831,329,403,816,158,77,812,221,772,317,639,37,35,28,242,120,268,578,50,230,966,686,494,187,551,478,285 }, +{ 141,202,128,2,269,1,64,5,180,3,318,33,197,6,352,15,7,102,77,0,134,13,137,10,196,153,165,120,117,14,17,11,12,82,110,4,9,237,23,291,260,494,93,51,403,217,21,498,752,450,342,341,31,32,351,22,326,125,402,457,317,143,86,36,115,19,203,40,111,961,285,16,48,475,98,116,44,678,365,95,8,37,57,28,244,27,18,901,49,45,864,569,349,373,386,391,453,59,523,144,719,139,509,25,854,372,38,24,56,898,194,164,947,79,29,817,94,253,99,873,954,730,55,65,597,61,26,546 }, +{ 44,201,567,489,116,662,224,268,131,219,434,295,187,144,31,276,699,384,137,110,442,258,36,160,228,261,367,613,93,30,64,120,908,244,284,203,260,141,202,385,1,9,269,940,39,855,253,918,98,96,373,22,406,856,326,105,206,143,318,10,217,127,55,523,115,77,125,717,617,86,49,13,836,51,28,23,574,332,128,83,190,180,871,839,371,393,944,352,317,21,164,473,935,197,450,341,959,0,177,911,840,254,531,165,291,716,418,899,800,88,829,282,827,494,48,492,661,854,5,351,100,82,299,851,822,15,860,365 }, +{ 51,12,23,15,99,37,13,10,453,165,117,38,0,197,629,569,82,115,401,120,64,134,22,474,457,11,110,719,31,93,260,9,14,475,111,32,153,79,1,94,21,40,308,128,125,8,28,5,18,54,403,351,3,44,180,202,89,450,328,33,961,2,139,36,4,49,77,45,141,523,326,386,730,48,17,217,30,431,148,405,317,237,29,98,16,341,775,413,196,365,352,55,318,72,758,116,6,59,24,7,477,898,734,509,58,39,203,95,372,482,86,854,19,391,421,402,269,144,494,90,102,291,922,817,57,373,899,27 }, +{ 135,7,172,2,92,140,66,52,97,74,324,14,226,29,232,46,38,380,87,262,314,357,278,330,16,298,571,448,35,126,60,220,620,606,75,6,24,192,107,69,246,230,331,1,5,267,294,70,622,353,222,853,550,563,71,572,583,138,150,600,189,500,25,43,50,309,21,526,32,872,12,174,54,58,37,20,893,802,22,48,145,86,64,580,462,95,67,18,888,42,950,65,387,36,171,108,451,112,10,501,26,726,335,441,103,785,83,359,204,582,279,337,461,49,0,72,423,45,443,409,61,68,356,28,392,163,673,114 }, +{ 125,386,391,23,963,60,51,949,165,221,21,13,541,393,118,719,150,197,326,758,421,791,517,801,566,558,308,48,362,7,834,670,453,551,173,401,203,102,43,20,5,71,36,457,251,77,697,279,140,867,33,126,115,32,92,149,422,743,367,232,193,0,770,4,98,509,40,674,81,18,341,11,783,192,577,546,397,16,494,510,508,217,189,104,705,610,330,2,596,105,823,293,202,117,10,314,796,64,862,629,475,468,281,246,242,38,403,29,474,298,31,27,14,858,414,95,942,779,773,569,523,430,317,301,172,134,116,91 }, +{ 85,6,42,138,235,25,222,174,525,256,746,26,289,64,280,214,544,65,32,337,90,204,355,348,74,312,95,415,145,122,233,609,416,66,194,19,29,630,835,63,22,87,45,237,874,5,605,353,112,86,519,343,135,17,648,76,736,70,287,249,180,681,0,288,21,580,27,123,444,4,226,192,52,247,81,1,56,751,216,78,58,75,49,91,792,23,48,53,183,396,108,59,61,28,3,636,624,2,208,84,370,368,12,207,37,114,10,151,153,389,197,172,51,673,72,33,671,597,18,115,125,31,730,573,179,141,73,250 }, +{ 1,14,50,24,5,67,46,2,69,103,18,54,58,48,16,38,83,96,0,35,28,502,21,36,45,181,155,12,61,7,223,513,430,22,270,65,108,9,75,10,37,133,540,29,32,290,71,52,17,171,238,114,218,72,236,55,99,309,807,70,149,328,89,433,163,227,834,68,64,23,189,51,666,6,766,765,221,115,474,86,60,366,552,541,488,13,487,243,425,95,592,536,76,780,141,477,767,186,128,663,267,251,3,794,49,741,137,418,263,202,160,207,545,27,543,920,335,428,388,408,400,150,760,148,124,106,19,269 }, +{ 811,351,642,951,180,752,110,638,253,10,352,854,197,82,365,564,873,341,499,55,143,244,535,36,498,559,901,417,22,661,141,9,28,282,165,30,206,898,373,35,509,260,115,922,728,8,39,332,49,317,31,44,762,964,93,15,911,533,203,160,1,217,120,391,137,24,116,33,105,102,479,943,77,569,717,338,134,117,968,125,965,164,64,473,127,196,153,531,384,269,601,308,98,37,959,23,177,13,867,109,617,291,864,482,169,21,372,242,546,843,434,824,692,40,32,4,551,299,758,5,468,11,629,903,12,89,949,791 }, +{ 51,23,13,453,403,12,475,115,4,15,165,202,523,719,21,457,386,99,308,37,401,2,730,5,197,32,494,0,33,1,120,450,10,59,102,128,17,14,117,3,961,77,153,9,217,569,11,196,134,899,421,40,318,391,247,90,6,629,64,7,16,57,210,48,341,177,141,269,38,260,402,180,22,468,29,27,758,317,291,817,25,19,72,18,56,361,326,133,304,54,221,757,236,34,26,288,300,275,670,365,514,509,125,237,36,65,139,137,108,45,76,52,28,498,351,801,82,805,576,114,89,61,352,41,615,24,8,854 }, +{ 120,13,23,141,77,51,260,217,202,326,1,137,291,269,93,102,82,21,203,450,351,15,180,110,165,318,352,5,128,177,373,48,854,197,64,922,523,317,96,36,349,32,0,386,372,144,33,2,9,125,752,115,59,12,210,7,457,16,817,90,403,244,367,14,898,237,160,28,35,342,719,6,275,10,18,494,304,37,30,341,50,39,24,498,730,365,391,22,473,901,4,86,223,285,247,116,31,704,453,678,83,221,661,216,44,69,61,615,201,421,65,402,8,475,268,401,11,468,49,29,98,88,899,300,242,68,3,418 }, +{ 1,5,22,12,0,2,36,21,28,48,10,14,86,32,54,50,37,7,49,9,23,65,51,55,202,96,95,13,24,208,128,3,137,323,67,17,6,99,4,16,168,18,38,194,83,115,114,281,58,45,64,318,141,745,402,46,269,31,160,480,77,103,503,105,11,403,164,69,35,218,181,72,133,29,822,433,735,430,75,180,223,89,109,584,244,341,197,361,289,165,657,169,401,239,757,177,389,98,124,217,851,238,159,33,158,956,30,59,143,70,102,39,308,44,494,754,40,253,90,155,61,766,163,540,221,76,270,756 }, +{ 219,127,98,258,23,308,301,51,910,401,276,616,284,170,395,293,105,165,22,13,327,242,512,125,201,944,115,900,374,320,109,924,964,763,272,239,567,28,860,629,391,131,116,386,55,197,935,453,843,341,9,943,743,365,506,206,457,261,758,295,36,180,670,31,95,237,538,535,662,44,224,456,185,558,332,64,911,479,0,143,169,569,492,634,10,841,317,421,867,338,282,253,49,144,685,740,384,110,901,468,187,734,719,86,417,844,509,268,12,564,141,286,713,762,918,475,299,120,1,578,164,137,159,403,870,168,551,498 }, +{ 64,180,237,5,80,165,61,58,498,250,297,197,186,2,752,864,34,445,95,869,881,17,311,391,231,115,29,151,546,549,3,312,247,483,153,469,45,27,22,365,334,73,26,136,933,62,56,495,32,52,243,215,21,90,472,592,396,509,288,651,48,738,106,53,490,482,161,211,11,316,287,177,13,369,635,378,141,86,262,667,119,663,216,128,179,40,19,209,50,164,719,457,145,23,10,352,176,241,196,527,666,171,833,269,383,125,758,14,46,70,341,507,317,873,579,464,255,400,37,875,405,210,117,33,143,331,84,6 }, +{ 77,13,102,23,64,33,141,2,115,51,1,0,10,7,177,217,6,269,180,40,3,14,202,128,22,15,318,291,196,5,197,165,153,9,117,352,210,4,237,95,17,134,16,11,125,137,86,18,317,139,12,31,93,59,28,36,49,341,24,275,304,19,349,365,110,44,342,143,403,27,120,29,719,752,457,498,164,372,111,45,203,453,82,25,569,391,8,494,216,144,98,21,247,386,475,26,401,402,30,312,37,99,57,65,20,901,38,678,244,116,326,260,56,308,450,32,35,509,300,34,961,597,194,730,48,629,55,351 }, +{ 15,120,450,51,23,13,202,523,153,196,260,457,719,386,326,4,730,128,318,141,21,11,64,403,453,33,77,32,475,269,95,5,494,125,102,165,48,12,98,1,115,2,401,117,116,10,0,180,40,197,817,7,9,308,99,899,3,352,137,90,16,37,6,18,14,237,22,17,59,217,421,402,134,8,291,49,31,961,82,28,177,670,341,351,342,247,61,758,221,194,19,391,30,317,44,93,214,365,24,57,27,20,275,25,241,216,312,285,29,288,65,576,349,629,70,72,26,39,304,498,36,96,569,123,210,46,289,854 }, +{ 2,5,1,29,45,14,58,207,263,425,52,32,46,76,186,72,292,50,7,61,476,655,408,227,48,38,155,21,720,89,17,75,243,119,6,449,171,148,306,70,241,163,106,334,214,592,54,400,36,179,90,64,790,663,24,666,84,3,16,67,69,240,10,464,56,405,496,128,0,710,74,86,270,129,22,290,460,519,255,209,220,18,141,428,223,123,659,205,96,65,19,513,83,37,4,12,27,25,112,103,115,358,66,23,9,202,95,262,249,221,51,151,28,26,767,59,35,77,350,87,137,780,245,40,409,99,237,618 }, +{ 15,4,13,11,5,23,21,32,1,40,141,3,33,2,180,17,197,64,12,269,31,352,44,117,165,102,202,120,37,318,153,0,6,137,51,10,196,341,134,22,7,49,77,752,59,217,128,48,260,203,125,237,901,82,93,317,115,365,498,90,14,110,342,111,450,95,177,873,72,326,61,8,494,244,457,57,45,19,36,210,139,386,96,144,56,89,509,143,98,76,372,275,719,27,9,160,403,94,351,349,546,854,704,678,817,391,947,253,453,304,99,569,864,308,401,247,29,70,216,758,717,670,475,474,961,116,523,221 }, +{ 214,76,5,129,710,249,618,123,45,460,2,257,17,179,769,205,245,519,207,61,184,106,162,29,209,90,119,32,1,58,6,14,255,292,183,128,77,229,64,21,141,3,655,48,27,38,52,19,263,57,59,4,40,497,151,25,202,152,464,72,7,26,80,99,102,306,311,269,33,115,288,130,318,524,86,54,177,790,62,358,50,243,452,137,46,10,84,186,454,0,425,51,12,148,619,11,210,56,23,556,22,240,112,266,402,36,217,216,37,432,476,136,227,65,70,403,738,155,237,95,111,194,381,139,241,317,180,13 }, +{ 51,23,141,1,202,13,120,21,326,15,269,137,180,165,318,197,352,5,128,48,260,2,77,0,217,12,33,102,7,403,450,203,93,9,32,110,386,115,16,14,64,6,36,4,82,523,373,457,125,18,494,237,291,351,24,342,196,96,37,453,475,817,3,752,391,177,244,615,50,144,28,854,730,210,35,719,99,30,8,317,341,401,160,31,10,44,901,86,221,98,421,22,349,402,576,365,116,922,153,308,39,704,40,72,20,285,17,59,498,372,367,393,661,49,899,67,95,551,70,55,90,275,29,247,89,83,65,69 }, +{ 7,135,2,172,97,87,66,29,52,14,112,70,58,232,337,92,46,226,74,43,262,192,331,461,20,409,16,307,5,294,107,155,334,186,171,278,140,38,151,32,849,324,415,35,75,21,25,45,609,24,227,6,145,1,298,222,60,448,61,64,620,353,387,126,37,86,69,287,549,356,173,48,400,330,644,10,314,583,18,12,22,113,220,526,54,128,359,49,853,36,95,0,76,525,163,67,568,50,65,872,28,104,72,243,138,90,137,587,71,357,4,141,17,246,544,26,230,888,177,194,380,122,474,311,315,635,83,631 }, +{ 574,187,926,860,384,258,531,434,269,110,160,244,141,253,116,871,533,940,261,717,699,959,902,219,661,224,201,373,143,36,911,352,137,260,268,31,851,617,817,728,10,318,523,180,206,295,332,144,811,489,44,843,922,64,251,662,816,120,450,55,127,93,276,855,535,839,98,131,752,951,284,559,824,164,406,642,854,203,1,864,202,317,237,228,365,345,776,498,326,567,442,197,125,282,341,367,96,21,217,417,13,943,86,351,83,679,115,908,564,954,473,82,800,896,165,968,23,128,35,669,48,5,22,170,901,873,169,385 }, +{ 354,156,296,586,1,98,850,163,223,698,379,291,64,44,31,937,48,340,96,349,182,125,237,120,658,77,284,39,30,367,23,385,221,195,293,18,202,144,105,774,128,771,687,541,342,197,116,49,371,121,118,93,5,626,360,16,692,591,453,421,386,352,318,242,153,117,36,10,795,759,260,141,463,372,326,102,87,33,697,11,4,931,446,13,35,948,103,958,899,827,781,752,664,638,558,551,497,475,457,415,304,269,217,205,201,179,166,140,131,127,126,113,107,100,92,89,88,72,55,37,24,883,203,70,21,7,914,846 }, +{ 250,34,472,80,495,483,194,469,141,176,17,64,53,161,33,814,4,667,527,73,27,231,84,56,833,269,14,102,297,585,283,503,59,597,119,106,77,862,255,128,789,11,90,153,209,389,95,887,57,76,3,240,58,23,678,61,236,40,202,134,113,117,151,51,123,304,342,136,369,137,22,237,86,65,45,32,62,445,412,311,200,573,129,436,803,328,19,10,611,196,177,133,491,214,514,72,36,947,26,5,52,139,402,378,318,504,114,0,216,180,287,322,13,381,396,358,629,475,285,46,28,2,383,179,130,112,738,247 }, +{ 97,140,66,172,7,192,314,81,92,426,74,232,298,462,501,43,508,330,69,135,279,6,230,189,24,48,21,885,104,14,448,861,38,712,126,173,715,572,60,563,246,267,16,91,633,423,71,526,52,36,357,29,362,387,18,204,63,443,32,568,324,681,879,441,138,107,67,22,20,0,150,517,85,636,607,12,825,5,893,2,174,278,65,37,149,28,726,86,87,35,779,380,560,42,125,565,95,750,83,124,46,1,49,370,251,653,77,64,877,25,4,10,221,54,33,61,672,40,23,451,98,102,31,9,51,120,348,915 }, +{ 44,31,116,144,268,434,489,367,918,492,384,948,393,127,98,9,940,22,206,105,203,0,855,332,49,93,395,959,28,456,617,911,293,137,1,299,39,125,282,202,51,141,473,55,963,120,417,326,23,95,159,21,599,109,276,730,242,13,36,10,131,8,272,284,253,551,219,30,318,523,2,352,165,512,403,269,18,64,5,7,899,244,16,301,616,450,158,115,12,170,559,935,160,924,143,260,791,386,86,692,201,421,128,457,24,719,728,499,373,37,261,916,110,197,578,48,951,239,286,576,811,494,308,35,96,564,14,498 }, +{ 202,128,141,3,51,64,15,269,5,120,33,2,102,13,403,318,1,23,196,197,153,10,165,17,0,137,82,6,110,117,180,260,453,93,352,12,475,14,125,7,351,450,494,22,11,523,457,402,31,326,77,342,86,99,386,237,9,32,36,21,19,4,134,44,27,203,18,730,37,115,8,373,95,817,421,719,40,291,139,401,49,143,341,98,285,57,111,116,25,961,498,28,391,38,854,317,144,26,752,56,16,217,308,65,277,899,365,898,509,59,45,79,922,48,72,30,41,678,757,569,24,177,615,34,29,864,873,244 }, +{ 127,98,31,105,395,293,28,9,512,299,22,44,0,49,763,599,242,685,109,284,320,159,276,95,1,116,456,870,55,286,900,125,492,36,713,506,158,51,23,935,393,24,327,16,35,239,623,144,201,13,2,65,272,21,39,7,338,12,168,141,18,202,424,5,268,14,170,347,137,86,489,841,68,367,918,301,269,64,374,185,124,165,48,567,479,221,403,662,37,963,308,131,30,401,6,318,67,616,948,115,83,197,237,434,160,295,96,169,128,421,203,154,10,143,538,194,916,352,101,371,253,928,910,261,180,164,244,737 }, +{ 7,24,97,124,2,69,66,1,14,92,18,6,140,67,20,71,43,16,21,118,29,23,149,52,150,51,32,81,5,429,189,48,36,484,172,273,38,60,65,28,22,25,74,83,46,91,13,0,298,314,12,420,610,154,42,108,398,701,467,135,35,505,173,221,576,104,421,168,336,423,37,232,403,302,143,185,847,267,137,115,10,703,158,251,308,508,330,75,68,49,86,61,26,253,202,230,107,401,64,799,388,128,99,443,102,72,607,165,426,453,570,387,547,326,105,125,85,109,517,386,95,138,615,87,126,192,671,63 }, +{ 1,349,64,303,284,442,622,202,691,141,652,447,682,67,717,917,340,237,154,352,269,919,752,547,429,411,197,293,260,44,335,180,160,863,238,201,191,167,318,9,751,730,98,453,33,418,956,475,360,69,77,765,217,140,96,31,153,120,87,724,664,389,323,268,206,116,922,888,102,948,854,842,805,196,127,399,586,658,873,851,850,796,781,695,657,385,330,244,149,137,0,662,367,351,82,947,774,551,498,363,225,146,125,35,212,909,899,848,807,776,772,770,759,726,604,576,541,523,480,450,403,393,372,332,329,327,301,296 }, +{ 1,2,141,15,7,10,180,3,5,6,64,0,13,197,77,269,33,11,352,165,9,102,14,4,349,12,291,341,23,237,134,752,22,120,117,202,498,128,36,217,318,115,51,17,317,40,153,93,365,110,342,961,82,31,864,901,125,137,59,143,196,372,16,86,21,260,111,44,873,32,49,947,457,95,57,244,326,8,351,37,28,569,954,203,19,373,678,18,139,450,29,30,48,386,72,27,79,45,854,391,144,509,55,546,94,99,164,98,116,20,76,83,253,56,898,922,38,25,24,39,61,177,210,719,58,523,494,402 }, +{ 139,99,12,453,196,277,775,475,40,401,215,33,51,111,130,23,11,77,313,211,14,38,266,129,474,477,37,328,339,369,153,719,162,152,54,231,3,308,57,700,117,403,305,188,629,102,880,457,569,183,62,514,229,961,157,556,555,115,176,41,177,471,248,13,507,670,342,4,542,257,17,123,291,236,72,79,304,134,452,89,34,184,90,2,59,76,383,488,94,421,80,32,361,128,440,377,202,119,56,316,21,494,46,165,757,288,45,543,197,528,730,585,249,431,136,5,0,432,52,210,402,120,485,29,1,529,548,536 }, +{ 77,102,33,141,128,202,23,64,51,59,269,153,4,40,115,177,13,196,318,117,291,210,0,137,134,403,22,90,217,342,10,95,180,494,18,49,11,1,475,65,32,6,16,352,216,36,15,139,86,7,194,24,402,275,14,28,9,2,21,19,125,453,165,20,25,120,57,237,3,260,26,341,317,114,349,197,326,214,48,31,12,5,82,17,300,111,421,308,365,523,450,98,110,93,247,304,351,457,285,498,39,27,312,123,44,152,99,401,37,615,373,108,372,170,143,116,68,67,56,96,719,678,361,29,961,205,35,133 }, +{ 7,14,2,58,46,16,70,112,87,38,52,135,5,155,29,66,97,294,172,32,20,334,24,92,186,35,128,227,18,171,6,21,107,37,64,75,780,666,400,61,140,43,60,48,220,232,0,23,141,177,1,54,202,307,13,592,461,115,22,77,12,45,50,51,126,163,137,409,10,315,192,270,25,845,69,90,269,76,72,513,28,113,74,210,49,262,243,9,95,89,71,318,402,631,86,884,298,40,431,102,4,275,290,278,17,324,217,19,180,151,36,237,230,67,356,291,352,314,65,403,59,33,26,609,387,226,285,330 }, +{ 15,13,1,5,2,23,3,0,365,10,7,4,341,51,11,6,9,115,180,317,14,33,77,12,217,102,40,197,21,153,165,17,64,8,117,141,569,22,901,134,32,16,202,352,37,36,457,291,128,31,269,125,237,18,139,196,44,453,391,177,372,28,349,59,719,93,482,629,86,509,961,318,873,498,99,55,752,386,19,401,210,143,48,137,120,342,50,38,49,29,27,403,24,30,758,111,110,57,475,95,203,730,46,98,260,116,90,45,523,494,326,54,105,72,96,65,546,402,351,242,277,164,67,450,734,253,83,26 }, +{ 2,1,75,29,52,14,69,220,67,262,46,38,70,87,103,6,74,24,83,267,25,226,357,366,394,96,26,189,451,112,606,486,135,145,388,324,294,108,335,278,50,66,42,238,163,58,16,331,150,71,19,149,545,222,35,236,18,418,696,133,114,7,218,582,5,36,45,433,516,537,60,380,171,138,641,600,65,550,251,151,21,54,309,603,853,223,181,12,27,287,28,0,739,565,22,17,785,48,86,68,140,461,594,37,97,10,32,423,458,95,160,733,337,583,61,122,307,281,336,64,571,186,273,85,55,774,632,172 }, +{ 9,105,18,101,39,557,16,890,1,252,272,100,265,938,21,326,23,51,301,49,0,68,24,60,264,13,35,310,254,159,737,363,167,593,137,127,121,166,98,846,118,827,156,48,202,30,333,31,55,5,411,395,128,329,132,146,578,44,520,512,242,77,731,682,170,320,371,120,71,916,518,450,373,28,821,286,33,447,327,212,354,271,32,195,639,125,7,364,95,704,102,65,616,385,615,36,688,203,64,12,110,523,455,96,141,197,75,910,4,116,836,506,88,165,93,604,404,22,318,931,2,10,260,86,338,817,40,905 }, +{ 80,209,667,61,45,17,106,483,255,6,833,151,454,29,5,738,378,2,887,742,112,311,27,119,26,469,495,113,491,161,58,145,396,19,25,84,73,70,315,207,814,76,56,136,42,64,32,1,243,62,52,306,614,287,128,445,14,74,383,53,631,3,90,240,34,141,179,86,297,4,72,148,496,65,250,611,214,138,527,46,194,123,137,186,21,655,95,66,549,50,881,292,592,790,48,87,7,11,129,263,205,122,22,440,361,59,222,573,307,38,202,227,75,269,57,85,10,358,245,644,684,54,200,862,651,425,36,171 }, +{ 23,13,51,5,21,115,12,202,15,1,141,32,2,165,0,269,180,197,401,7,4,3,9,457,308,403,453,6,341,37,318,10,719,14,48,120,128,352,33,77,22,137,11,730,217,523,40,386,99,16,260,31,475,569,18,64,450,317,28,237,391,90,17,494,421,365,177,59,125,8,102,72,93,30,629,247,961,24,221,117,44,153,498,758,351,291,196,509,899,402,817,49,304,134,76,89,210,98,326,82,482,45,57,110,38,36,752,901,39,139,468,20,96,372,116,216,19,349,203,288,29,61,95,275,546,670,27,576 }, +{ 99,12,453,277,139,474,369,339,51,38,157,196,37,775,401,188,23,475,111,328,11,313,471,153,40,629,266,79,54,4,477,33,102,59,14,57,248,880,152,342,13,457,305,542,117,377,403,514,94,308,115,229,569,488,961,210,300,211,431,41,89,734,361,485,275,670,134,128,184,381,3,72,529,2,556,719,402,64,413,21,15,215,46,177,757,165,77,197,236,32,62,421,155,50,130,17,162,202,5,45,587,52,507,10,183,555,82,247,490,129,588,123,405,148,216,76,141,7,0,1,181,29,432,6,730,90,468,452 }, +{ 7,92,232,126,97,298,387,140,107,16,60,246,14,66,35,462,150,441,104,357,314,359,279,330,633,423,380,172,230,199,24,121,38,392,356,71,132,192,451,324,22,146,893,508,493,568,289,65,560,95,0,5,32,74,189,830,2,135,21,173,18,603,64,46,43,707,20,501,52,362,90,214,712,550,877,86,607,28,426,312,48,36,29,10,69,278,12,194,49,37,1,6,672,874,204,81,267,68,526,108,835,259,733,895,388,500,779,649,448,915,61,125,149,443,50,55,54,399,590,70,72,939,572,191,124,711,517,167 }, +{ 13,23,318,202,77,177,51,269,33,102,141,115,494,4,90,403,210,153,40,196,117,32,59,128,11,137,342,134,217,291,64,21,12,475,352,31,341,14,2,98,93,10,7,95,700,49,317,275,216,20,19,16,44,22,365,116,6,453,110,247,144,180,96,9,24,17,5,82,0,498,402,349,300,127,48,3,125,57,111,87,28,86,1,203,197,35,25,401,18,165,351,326,139,60,43,26,36,450,873,864,551,473,393,373,372,288,678,576,285,37,523,120,70,65,817,67,752,697,529,421,415,386,304,214,164,152,123,61 }, +{ 13,77,2,23,141,6,0,1,217,115,7,3,180,5,10,51,33,14,197,269,352,64,102,177,9,291,15,4,317,40,17,165,22,11,341,202,318,237,196,117,153,349,16,365,28,210,372,752,134,19,18,128,304,498,36,247,12,125,59,139,95,8,275,457,86,31,27,49,21,24,29,391,342,569,509,25,93,45,143,901,137,32,244,403,26,57,38,719,111,873,386,120,44,864,20,37,546,56,494,39,961,164,758,401,30,453,110,475,35,730,98,65,216,437,34,203,41,326,99,402,300,253,82,90,55,46,194,351 }, +{ 15,4,110,13,120,93,11,23,5,21,32,1,40,180,10,82,165,2,3,33,197,141,51,37,0,48,901,102,12,31,6,7,125,117,352,77,752,341,144,153,351,196,9,237,64,134,498,143,17,269,457,342,59,202,115,98,365,450,318,22,44,401,291,873,8,244,217,475,57,391,253,14,72,349,854,372,55,36,509,89,898,403,90,719,19,386,697,139,111,546,661,27,260,61,56,177,96,569,482,961,16,638,332,758,494,28,864,148,76,45,241,79,350,308,247,437,421,70,474,559,221,210,41,164,160,137,453,275 }, +{ 15,1,13,2,0,23,4,5,3,7,6,51,77,9,341,10,115,291,11,33,217,8,12,102,177,365,317,14,165,16,22,120,349,40,180,197,31,457,901,453,18,21,450,153,961,141,719,260,523,32,44,82,64,117,304,28,93,372,110,17,210,475,59,30,134,352,386,342,569,401,752,275,196,730,90,403,326,202,36,49,629,125,817,216,98,308,247,269,351,24,203,494,899,37,95,111,139,482,758,373,391,19,48,116,237,922,509,57,144,86,137,498,854,421,128,670,873,898,253,437,65,300,55,99,20,704,244,615 }, +{ 20,43,198,325,904,104,173,147,234,422,66,97,426,319,861,77,376,712,416,725,427,945,0,7,5,470,450,192,142,32,707,178,330,819,639,38,202,22,500,21,784,583,414,2,324,230,858,61,889,49,315,113,671,81,455,18,392,74,207,232,52,24,329,107,342,33,560,13,140,595,10,715,291,120,102,95,48,1,64,359,693,600,879,16,798,58,312,494,4,14,344,835,764,306,105,526,290,40,23,289,259,90,159,158,884,577,246,37,9,170,204,681,138,29,239,194,112,12,17,31,318,72,28,226,70,397,153,65 }, +{ 105,28,0,9,49,301,159,127,512,16,170,623,24,109,35,395,158,98,68,1,65,22,55,31,761,371,713,916,18,293,286,7,242,124,347,95,338,737,327,44,39,21,2,14,272,424,154,36,506,685,23,168,101,125,299,51,12,479,48,13,870,763,374,284,64,385,320,599,5,67,202,71,276,116,131,141,185,137,836,456,175,344,239,37,900,187,30,10,577,538,6,616,289,740,60,518,118,86,169,83,364,912,219,96,50,115,928,128,935,165,318,149,747,221,346,32,114,69,810,254,237,627,269,308,144,393,201,492 }, +{ 213,466,689,88,230,435,321,30,699,795,201,831,352,144,217,443,854,530,840,190,539,957,418,1,96,203,382,855,251,100,669,410,335,93,83,748,367,44,662,960,31,934,36,206,141,752,351,317,822,128,731,116,778,120,284,274,131,98,228,927,332,187,69,438,521,800,21,242,160,224,48,372,219,310,137,735,686,557,326,285,237,576,127,922,5,859,269,260,13,494,264,82,523,403,35,244,202,615,166,39,616,551,345,930,180,67,253,921,299,966,2,10,9,258,23,473,365,692,265,197,866,32,276,51,816,617,856,223 }, +{ 130,453,196,47,57,4,236,14,59,412,51,711,381,730,153,77,202,108,128,361,23,46,283,402,210,11,300,719,13,117,38,803,200,401,183,78,34,475,54,342,318,27,369,432,275,2,757,133,503,472,12,3,585,134,62,862,161,529,37,328,457,56,390,494,102,73,176,50,440,322,111,670,65,52,377,899,181,629,17,114,33,136,99,266,123,40,514,339,291,53,250,84,177,21,188,216,389,217,386,139,32,961,155,480,162,754,832,714,894,739,383,657,269,152,106,603,543,527,523,497,277,485,838,137,86,64,48,758 }, +{ 1,2,14,50,5,38,46,36,22,67,103,0,114,65,29,12,28,218,54,7,133,83,86,96,69,21,75,208,24,6,52,168,194,389,10,128,51,160,55,17,23,48,18,181,238,45,37,32,95,16,283,532,58,137,503,202,49,124,171,361,480,13,735,9,289,109,782,285,3,115,70,756,141,169,484,584,35,244,717,64,402,4,328,220,163,646,158,803,505,19,253,789,164,185,108,25,155,487,236,269,143,946,394,318,610,401,335,105,433,403,851,87,800,223,866,309,420,61,27,180,597,99,366,308,59,754,514,418 }, +{ 6,74,26,19,165,453,391,197,14,138,730,29,357,70,51,457,1,50,108,125,500,509,27,145,386,112,366,52,46,235,133,262,13,308,47,331,2,719,78,42,309,75,603,25,223,394,785,23,600,218,38,163,115,114,17,558,34,53,220,128,487,58,236,122,65,130,766,401,498,96,409,307,45,85,66,444,899,73,516,632,64,711,54,630,412,196,5,103,21,180,894,113,221,137,624,241,237,594,773,758,867,629,433,390,475,820,546,12,648,67,32,153,285,606,99,545,745,569,644,324,583,3,181,675,903,283,802,670 }, +{ 10,9,30,376,0,68,55,39,18,43,20,49,174,104,88,501,120,342,450,858,28,2,137,523,470,453,197,757,603,37,414,165,31,325,730,729,671,595,455,222,204,77,64,58,22,21,17,13,5,194,110,95,389,318,260,177,128,102,97,33,1,904,725,7,788,568,387,90,54,46,32,14,11,259,98,147,61,817,392,518,961,958,922,899,873,854,819,805,785,739,719,713,661,615,550,534,528,494,477,475,474,465,457,449,386,372,355,351,349,337,298,294,291,289,269,262,247,196,173,171,155,135,122,105,94,56,48,36 }, +{ 15,23,13,1,202,0,51,77,5,9,341,141,137,120,4,260,115,2,351,21,128,7,12,450,82,901,197,180,269,318,10,8,11,22,403,32,854,33,165,40,6,18,3,16,37,494,523,457,102,177,28,64,352,453,14,317,922,217,36,365,48,421,401,719,475,291,30,110,59,24,569,817,93,961,308,730,17,752,125,117,898,31,342,153,196,285,44,99,576,86,275,642,49,90,402,39,143,139,98,221,386,244,116,373,55,57,629,144,210,661,349,134,203,859,899,95,498,35,482,372,72,237,253,105,216,96,111,758 }, +{ 272,131,105,578,219,159,371,49,616,716,9,224,320,286,737,623,187,910,385,28,258,98,761,127,254,347,916,424,22,109,627,158,713,95,924,239,0,242,836,39,201,31,301,912,944,442,125,170,116,327,293,44,538,688,374,23,55,168,276,36,64,284,51,871,185,395,35,506,221,512,518,202,890,137,101,13,860,169,68,574,479,86,908,10,24,333,16,1,65,144,269,364,308,228,344,141,21,338,567,30,577,165,128,160,747,18,763,124,839,926,299,261,456,268,295,164,662,406,197,67,312,175,7,928,421,685,154,810 }, +{ 457,51,13,23,961,719,12,453,629,99,401,57,515,3,4,165,11,45,62,41,14,17,2,569,37,77,33,32,5,0,40,59,1,308,76,115,197,38,72,79,730,21,474,102,7,475,6,54,9,64,403,10,56,775,237,477,202,29,152,188,341,328,90,509,111,89,215,128,880,734,339,247,757,134,386,84,421,317,313,217,129,94,22,318,157,34,130,117,361,210,670,555,369,365,285,269,266,186,181,153,123,24,899,485,120,542,25,391,758,514,468,277,270,243,227,196,180,179,155,148,137,52,50,49,46,18,471,236 }, +{ 202,318,5,120,450,494,77,33,102,260,21,1,128,13,165,403,523,23,269,342,12,326,817,32,475,141,402,64,2,17,82,457,180,137,48,730,125,291,197,453,37,93,51,615,922,719,386,210,15,177,854,351,98,7,899,576,275,6,44,25,961,4,196,117,115,285,95,14,217,31,391,352,237,65,38,29,27,20,758,40,10,9,153,194,367,116,110,105,50,49,35,16,139,498,341,61,163,39,30,11,349,293,216,144,108,99,76,58,54,43,0,203,3,134,113,70,959,958,940,933,923,900,855,841,750,725,704,639 }, +{ 141,269,352,180,217,202,349,64,160,137,317,318,372,494,752,418,244,954,864,437,753,237,13,341,291,165,717,22,197,115,304,260,365,93,36,21,351,247,120,922,77,82,48,498,32,5,579,144,10,23,342,373,33,854,95,128,0,391,164,143,125,98,482,51,403,28,326,898,386,76,72,1,951,678,638,453,201,86,110,30,457,312,253,221,163,96,44,475,102,901,719,421,196,134,190,166,131,100,88,474,401,203,859,597,521,509,466,459,435,393,321,284,228,108,65,59,40,4,851,576,350,308,288,241,216,214,179,99 }, +{ 70,145,29,112,74,26,2,75,287,52,220,226,632,87,294,6,135,307,163,66,19,396,278,138,635,409,25,151,58,113,1,122,331,222,5,97,42,644,324,461,27,849,500,69,651,45,7,172,262,853,337,53,648,573,624,64,334,445,171,21,67,186,32,73,297,46,38,416,14,17,140,80,61,50,436,155,884,223,24,22,85,48,380,852,92,65,86,889,12,315,36,774,571,103,549,37,10,95,243,491,83,16,72,665,227,89,357,394,76,309,35,106,54,675,808,267,474,250,609,71,881,209,133,606,96,232,583,400 }, +{ 351,82,317,141,752,898,901,180,352,341,15,365,1,498,217,115,33,253,32,143,10,160,55,0,854,5,197,269,21,77,4,36,137,23,64,2,110,482,169,873,120,244,96,7,89,13,349,86,164,102,72,93,372,148,922,40,16,345,90,531,9,83,437,22,251,35,260,457,546,165,202,6,864,48,291,51,28,719,59,238,18,308,247,128,11,304,117,12,569,237,65,961,817,509,450,535,196,95,125,730,523,468,144,98,49,3,899,661,342,318,373,153,579,734,14,490,116,203,134,559,391,312,130,123,109,84,76,326 }, +{ 39,9,310,254,101,252,265,272,100,0,557,30,49,688,455,105,190,166,329,627,159,286,625,709,327,333,18,68,158,404,520,578,131,438,731,16,553,24,98,364,31,676,35,118,593,1,518,48,344,44,167,23,65,21,93,604,829,795,127,60,890,96,88,616,22,363,656,51,242,28,419,716,125,124,846,71,274,36,264,613,13,137,95,116,212,938,109,224,827,411,154,910,160,639,371,664,128,5,374,144,530,395,228,170,219,865,67,10,203,759,121,83,301,382,320,737,55,682,37,647,86,271,793,7,821,115,916,285 }, +{ 2,58,29,151,52,186,70,5,549,75,1,112,45,400,61,163,113,227,307,315,311,287,220,46,7,14,155,74,243,87,409,66,27,80,209,631,845,780,69,262,135,48,50,171,767,496,869,454,331,6,491,17,334,278,106,32,19,64,614,21,73,145,26,294,24,592,67,25,38,659,223,16,97,255,172,72,226,502,852,128,37,140,721,666,89,667,290,36,103,324,86,849,267,76,141,54,35,83,65,207,22,148,96,270,12,635,10,4,95,92,738,474,18,445,119,611,425,137,431,263,114,396,663,0,122,133,90,237 }, +{ 141,217,269,352,317,180,23,13,21,115,77,349,202,137,51,64,372,165,197,32,365,752,318,291,341,5,237,102,15,177,498,33,48,244,304,128,125,4,864,253,39,30,44,11,247,22,9,0,31,901,308,403,1,717,201,342,49,10,98,16,7,221,95,144,40,88,494,90,12,28,117,93,678,120,68,326,100,203,86,96,468,2,475,206,116,546,457,160,437,8,873,210,127,110,76,65,55,37,418,386,350,72,18,453,223,143,24,153,851,351,260,284,579,576,401,268,482,196,35,421,82,3,402,166,101,954,391,83 }, +{ 68,35,101,149,124,154,0,65,9,175,24,398,28,16,189,71,118,429,55,346,67,114,7,345,18,230,399,364,133,14,252,722,39,283,1,547,140,69,108,484,302,694,100,439,103,46,705,83,166,267,389,2,458,92,336,50,212,289,21,246,375,251,419,109,36,520,329,158,22,637,12,60,952,48,265,236,702,596,96,806,30,732,5,826,604,64,194,49,412,701,388,88,420,191,535,264,562,167,886,23,796,168,51,650,238,570,782,868,86,13,218,95,917,768,38,10,32,309,404,706,37,54,221,602,125,159,105,676 }, +{ 66,7,29,112,52,97,2,192,20,151,74,43,145,173,222,135,226,525,415,172,644,104,337,544,353,580,32,45,25,287,186,609,58,70,204,155,14,5,21,712,122,87,227,174,331,61,849,549,426,90,355,81,334,560,6,232,416,243,632,46,0,92,324,177,64,113,673,624,107,59,37,635,216,140,396,138,22,500,16,38,4,707,128,65,48,307,17,77,86,137,91,35,12,721,665,789,141,24,294,884,85,42,414,194,115,526,72,311,825,11,126,262,597,76,89,10,28,75,1,387,209,60,304,171,51,147,651,40 }, +{ 31,125,44,299,116,22,170,55,242,456,599,685,36,870,64,393,492,268,1,479,164,86,558,28,506,144,10,740,23,206,903,9,2,0,963,237,127,546,301,13,434,143,367,5,169,93,51,239,12,654,965,384,137,498,7,923,203,918,489,98,180,95,391,141,762,115,352,417,638,841,253,6,105,14,951,8,940,165,197,844,128,948,457,401,959,244,160,308,282,185,21,312,109,286,202,332,341,49,168,386,752,269,538,365,4,37,24,512,911,473,873,509,551,634,499,318,719,3,208,395,708,217,450,421,96,901,35,16 }, +{ 188,11,79,12,99,377,542,94,339,33,474,37,40,139,111,102,453,4,51,775,475,277,13,471,23,196,629,153,431,401,117,210,134,266,152,403,115,38,961,128,59,300,57,77,880,342,157,485,313,569,3,229,202,14,177,275,477,54,308,184,488,328,21,89,72,670,32,64,2,76,10,402,15,90,165,369,148,141,5,162,318,405,17,269,257,205,216,413,757,129,62,361,0,494,734,41,421,179,45,452,197,217,291,120,82,22,130,386,123,1,50,237,358,125,381,497,498,6,137,285,36,180,48,482,372,29,46,341 }, +{ 658,698,340,303,31,363,919,98,44,156,296,850,586,668,354,87,914,120,163,30,127,70,23,385,51,48,1,478,125,49,77,774,223,260,291,82,691,349,13,854,225,217,116,39,10,724,21,922,898,447,351,293,201,75,9,269,284,759,541,480,281,268,221,165,621,141,442,622,411,371,318,187,153,115,105,102,65,777,93,64,33,652,352,202,744,453,433,398,330,191,180,177,137,128,117,95,69,35,931,638,40,5,888,372,146,140,100,88,565,457,450,335,326,317,219,190,159,158,134,36,32,22,518,482,401,394,276,947 }, +{ 15,82,4,197,13,33,1,23,901,21,5,11,10,165,32,0,120,180,2,40,3,51,110,77,642,7,8,351,326,115,6,386,365,217,457,9,117,401,12,37,102,260,523,134,719,758,569,22,36,59,317,730,31,57,342,898,961,450,453,153,17,141,291,137,475,55,177,48,116,90,196,93,44,403,14,64,352,629,54,372,817,28,143,18,269,139,16,958,96,202,494,349,421,275,752,210,128,49,94,86,244,29,498,899,801,318,851,38,670,72,615,474,304,148,41,89,25,19,308,482,160,373,253,70,61,30,277,125 }, +{ 15,4,11,13,23,5,21,180,141,32,202,269,3,40,1,352,318,17,12,64,33,165,197,31,2,0,51,120,128,117,326,59,457,10,153,196,134,817,6,48,125,93,237,82,44,137,450,77,494,403,49,203,386,752,37,523,7,22,961,217,260,8,115,110,341,57,177,498,719,90,615,9,317,102,365,139,14,730,901,210,98,402,72,453,19,116,65,18,111,391,45,56,95,351,27,899,99,349,293,291,300,475,86,28,36,401,25,55,144,244,275,509,247,216,38,678,76,61,393,29,372,576,485,373,30,253,551,468 }, +{ 91,233,370,718,85,6,81,25,65,256,63,235,42,138,511,397,123,26,343,74,650,87,249,643,355,544,18,64,194,510,636,45,174,280,90,22,108,348,681,104,1,84,86,114,389,4,415,66,19,0,673,283,214,141,122,524,289,56,53,193,208,95,240,750,297,29,119,605,27,573,445,436,736,10,14,11,287,597,32,630,49,24,192,57,5,17,204,475,103,61,102,70,947,152,51,588,23,16,183,77,619,730,523,453,444,59,561,2,813,701,874,323,75,33,28,804,129,96,403,368,21,9,145,177,396,255,693,611 }, +{ 23,51,202,13,21,128,318,141,403,120,450,137,48,494,269,5,1,165,125,64,32,260,15,523,102,475,115,12,14,457,31,33,197,77,817,44,98,453,2,308,95,49,99,16,7,180,18,93,326,37,221,6,4,352,421,401,116,291,61,386,203,82,59,36,9,40,30,24,719,117,110,20,217,153,730,17,615,351,402,237,50,854,10,196,39,19,342,3,922,25,96,341,35,28,22,11,105,177,90,72,58,38,317,247,54,961,805,576,207,68,57,46,349,210,134,86,704,75,70,899,373,65,901,670,0,391,89,45 }, +{ 365,180,317,752,341,217,115,352,901,482,372,498,291,15,253,244,141,13,1,579,269,349,7,5,21,4,318,23,351,82,0,2,51,77,93,125,10,898,89,160,202,44,6,854,165,3,96,308,221,148,137,332,247,197,33,11,304,851,531,144,120,494,40,717,468,251,403,72,177,391,32,12,546,453,421,260,203,437,961,574,258,533,48,509,55,922,880,661,615,373,261,134,241,873,475,345,949,867,734,728,699,569,490,473,434,295,288,237,219,143,127,110,27,17,16,187,153,117,876,350,99,36,9,947,128,86,64,679 }, +{ 115,498,901,197,341,468,13,352,482,546,165,509,237,569,9,873,64,23,365,22,180,95,391,317,758,558,49,752,734,109,28,105,217,51,844,86,837,143,629,131,254,876,12,159,158,719,39,406,308,148,141,679,117,490,83,637,457,10,708,166,36,706,102,89,35,505,168,442,372,125,55,530,221,37,208,669,535,332,272,153,103,98,903,401,261,219,768,114,33,864,364,187,169,345,4,574,434,258,242,224,67,30,3,253,961,868,164,228,816,77,843,120,438,384,351,230,134,128,100,99,2,753,50,44,31,584,347,170 }, +{ 23,13,51,202,141,21,180,165,5,197,125,1,115,269,32,120,12,128,318,64,15,137,523,2,33,386,7,260,14,403,48,457,102,4,450,6,93,99,82,401,719,9,730,110,16,31,237,77,326,308,421,98,453,352,37,221,475,90,44,117,30,0,18,144,899,153,10,817,3,203,391,196,11,59,351,40,217,494,177,17,341,134,116,39,8,24,95,752,498,402,20,509,615,61,28,96,19,247,961,291,36,72,365,86,317,285,241,76,49,373,38,29,25,342,70,304,58,57,242,546,576,22,350,349,901,629,801,551 }, +{ 214,289,90,174,874,280,355,138,65,85,64,6,751,81,312,194,249,835,233,348,636,875,91,343,288,519,32,0,524,247,415,104,29,370,681,750,74,204,22,95,217,437,235,86,123,25,352,192,42,597,954,256,77,18,673,63,864,752,671,306,87,353,746,287,712,237,397,389,115,588,222,177,180,145,580,715,21,141,59,474,317,207,66,56,49,52,33,28,579,45,544,10,84,61,784,102,4,511,202,693,57,40,24,117,173,76,319,240,208,5,216,26,304,134,291,205,114,525,72,17,153,577,168,11,108,422,718,498 }, +{ 15,4,11,5,13,23,21,32,33,1,37,31,2,141,3,180,64,102,44,12,49,196,120,77,40,6,17,7,153,117,352,134,0,82,269,197,51,22,93,10,752,260,165,217,98,317,137,365,342,202,901,318,95,341,450,115,48,30,9,128,177,351,125,523,110,498,854,291,237,89,90,8,817,45,59,14,57,86,457,873,326,373,372,72,61,922,139,56,275,482,36,864,391,96,898,386,111,403,144,27,38,509,899,453,70,116,29,58,253,244,76,160,475,437,304,316,210,16,41,569,308,300,203,719,288,221,546,148 }, +{ 217,33,15,13,117,196,153,134,23,51,77,141,0,2,64,115,102,10,4,5,7,6,180,3,1,11,165,352,202,22,9,40,317,269,197,14,128,318,341,237,17,177,16,291,12,95,365,120,125,18,752,28,453,372,59,137,498,349,49,36,31,24,403,32,110,98,210,386,19,457,401,8,391,901,475,44,86,260,342,304,143,247,308,730,93,275,244,494,164,719,21,864,65,509,57,961,523,25,90,105,546,139,216,55,38,482,569,402,35,29,450,99,873,421,48,670,45,27,26,326,20,37,437,39,629,579,56,203 }, +{ 15,33,77,4,102,117,40,115,134,11,153,13,217,21,1,5,317,196,32,23,3,2,59,12,291,341,365,51,139,120,177,180,372,349,48,141,260,17,342,110,6,197,37,7,72,482,90,165,111,57,352,93,898,752,0,326,457,210,82,854,901,450,269,202,14,36,64,125,523,373,10,137,89,922,203,719,498,730,961,569,244,817,143,44,318,8,76,304,277,403,253,275,31,494,128,386,308,160,22,247,56,899,148,144,453,468,61,638,579,300,96,437,221,116,873,38,485,94,99,237,216,9,27,49,45,19,86,401 }, +{ 15,13,217,2,1,23,0,4,5,3,317,51,341,7,6,8,115,9,365,202,10,11,291,12,22,33,269,31,82,180,308,457,120,28,901,30,18,77,197,450,351,21,961,40,221,372,523,165,730,318,719,854,141,102,64,453,110,260,14,569,93,117,44,16,817,36,32,349,386,498,482,98,403,898,196,134,35,153,24,49,125,752,579,326,899,237,128,137,247,401,342,48,475,177,39,304,661,20,922,509,494,19,116,59,37,203,468,95,329,144,758,55,17,65,244,86,111,391,90,118,437,113,91,122,143,629,864,99 }, +{ 135,66,2,7,192,337,97,52,14,20,673,355,29,43,104,107,331,226,415,376,353,222,294,147,74,112,46,172,560,155,32,5,324,470,609,173,174,21,825,16,64,58,298,145,92,707,38,232,77,35,356,4,10,414,22,525,287,262,171,888,86,632,544,595,635,568,178,90,48,580,87,334,202,597,72,37,60,587,474,6,151,95,307,49,177,59,25,0,142,17,858,61,409,128,1,12,721,583,318,259,362,500,141,126,269,198,102,319,70,494,13,230,853,45,227,54,849,612,400,65,204,186,33,819,246,76,644,279 }, +{ 195,132,146,142,271,167,121,363,878,178,687,647,786,212,354,77,522,929,60,202,411,120,35,234,147,259,101,360,520,626,446,781,98,0,450,668,5,199,55,771,562,23,16,706,777,49,936,18,621,604,48,158,318,639,13,31,407,22,125,21,591,590,465,481,159,534,51,109,198,419,24,126,364,191,141,7,682,551,252,28,20,806,634,156,105,14,447,948,494,107,10,116,39,43,1,269,260,33,265,128,640,291,93,403,137,326,95,203,421,379,102,765,9,82,692,110,416,32,883,664,553,455,694,475,842,523,293,239 }, +{ 202,77,20,318,104,66,269,291,494,102,177,43,128,0,342,216,173,5,2,97,52,450,234,22,7,33,750,29,112,319,74,275,90,337,32,49,198,210,678,544,147,204,58,24,141,789,21,349,64,18,304,16,10,14,580,120,192,194,325,13,416,142,403,500,196,61,59,137,115,86,712,153,113,12,226,174,415,40,23,81,4,28,70,525,402,1,9,230,72,35,178,214,636,46,11,6,904,37,95,87,48,217,355,597,334,31,798,39,17,38,427,186,222,65,376,117,426,285,36,135,51,208,353,673,155,792,172,260 }, +{ 107,362,612,359,414,356,97,392,683,259,819,43,298,660,465,147,581,729,173,779,7,595,501,20,319,470,534,858,246,376,279,126,230,14,5,178,427,232,493,35,92,49,132,426,885,60,32,104,387,0,786,423,66,38,21,121,878,22,16,146,861,441,95,357,560,830,142,2,199,61,172,10,81,707,150,70,590,422,207,48,140,46,58,929,52,324,603,192,18,508,202,314,77,37,347,33,263,13,135,28,241,12,23,29,125,1,345,124,102,98,74,64,568,24,198,380,40,4,687,626,105,607,117,72,177,577,65,318 }, +{ 6,19,13,26,453,165,457,386,51,23,14,74,401,391,308,758,719,603,47,867,29,138,2,70,730,27,366,309,108,324,197,1,25,196,743,711,78,235,262,130,42,475,133,50,115,145,670,487,112,58,53,52,85,17,421,894,96,34,412,5,331,516,509,163,33,500,569,629,482,388,45,468,153,218,128,64,341,283,594,545,444,65,125,600,217,114,236,754,75,899,73,785,630,137,95,38,801,328,895,103,961,550,901,200,11,350,558,117,4,220,180,54,46,745,3,134,433,766,287,739,122,223,317,226,390,241,21,357 }, +{ 179,205,72,245,317,247,152,180,216,490,76,752,352,79,217,59,864,94,498,4,497,452,89,148,11,875,111,141,405,115,188,21,468,588,873,197,579,471,365,464,37,645,372,482,5,77,64,431,341,237,10,529,349,1,12,23,2,474,128,134,316,339,291,36,32,51,38,413,437,629,954,734,308,99,13,143,48,102,165,14,288,90,377,749,184,401,460,542,33,428,3,7,269,449,961,569,901,350,86,40,257,244,202,0,270,117,6,304,54,241,402,45,137,221,457,403,177,9,164,139,318,17,528,15,453,421,358,769 }, +{ 107,359,7,314,392,298,387,279,581,32,232,60,14,126,97,493,534,150,356,121,423,362,172,92,259,147,441,95,35,501,22,357,21,16,246,590,0,380,786,49,18,465,13,64,132,5,28,146,178,10,508,779,23,140,48,24,71,939,929,660,51,135,607,324,603,115,230,43,46,241,38,192,683,462,247,66,612,568,941,835,819,77,12,550,90,36,560,199,4,312,33,9,893,347,330,65,59,52,20,519,2,278,50,626,58,202,37,345,771,294,117,40,102,70,470,451,156,448,350,316,707,236,173,288,31,75,54,672 }, +{ 156,354,586,271,195,591,668,132,48,360,340,121,23,21,463,446,1,5,13,18,658,296,407,51,146,70,698,883,626,55,60,221,777,163,32,363,379,621,590,562,58,49,167,467,647,522,150,61,118,24,411,781,115,447,223,767,786,7,16,31,87,308,687,22,9,259,279,212,44,17,518,346,71,10,371,45,98,2,919,241,761,33,12,93,64,39,541,37,608,35,774,341,759,75,664,941,663,125,846,581,401,120,638,566,303,68,936,260,0,932,199,105,634,270,706,30,453,141,102,95,86,110,107,771,273,535,82,727 }, +{ 23,51,13,453,4,475,0,12,457,10,2,115,401,15,11,403,5,1,40,99,14,59,961,165,569,629,9,32,77,37,308,3,719,7,57,421,21,64,17,494,6,22,33,102,18,202,177,128,730,197,523,670,139,141,899,16,90,341,8,56,217,210,402,48,24,386,125,27,318,95,45,86,72,775,269,758,50,65,19,76,111,38,317,180,89,62,342,54,46,734,28,247,41,29,36,509,237,26,880,196,352,365,275,468,120,216,153,152,108,25,137,757,349,221,181,117,277,49,477,123,34,291,304,801,82,31,678,597 }, +{ 48,125,221,21,165,23,197,13,763,423,508,193,98,293,457,391,5,867,693,386,441,81,18,16,51,92,60,314,64,683,401,49,237,96,104,43,430,35,397,558,241,180,126,523,105,32,758,140,38,72,510,308,474,356,230,95,279,102,501,784,517,663,858,541,31,633,498,718,149,127,91,422,97,418,118,900,159,144,115,511,44,203,246,366,24,223,480,453,361,350,218,160,71,22,701,719,393,40,173,124,963,421,370,148,69,643,93,743,598,493,298,253,191,170,164,116,7,1,939,730,120,74,33,20,326,63,192,269 }, +{ 202,5,450,77,120,132,494,195,523,318,326,1,260,146,121,271,167,576,203,0,817,615,18,21,403,692,234,604,354,142,49,13,35,23,7,212,20,14,2,682,158,252,147,137,101,102,128,32,33,265,48,16,291,551,342,419,364,60,22,966,475,43,107,9,178,363,51,639,17,10,687,12,821,6,859,159,520,416,97,848,805,31,360,269,109,93,198,329,259,39,55,64,562,786,402,92,82,553,878,70,61,647,455,180,411,95,315,191,4,842,105,239,165,822,638,115,98,634,24,453,346,126,99,156,899,199,522,28 }, +{ 39,166,9,101,404,158,333,30,0,190,310,252,274,68,438,419,100,344,88,49,254,124,694,865,154,530,656,364,577,28,810,265,65,35,131,455,159,857,16,21,24,793,22,539,212,777,105,625,747,677,709,562,95,48,286,1,329,703,18,228,71,125,272,36,109,13,10,289,538,219,676,706,778,51,31,98,557,86,23,175,60,553,406,55,962,671,840,118,224,168,221,83,669,67,213,382,96,570,64,960,346,327,170,613,731,191,242,44,115,759,439,957,627,748,114,634,264,688,593,37,251,137,320,127,7,520,167,518 }, +{ 15,110,4,120,11,5,1,23,13,165,93,21,10,2,32,40,180,82,197,3,51,6,33,0,7,125,351,901,391,352,77,9,115,260,102,341,117,217,317,134,31,141,752,453,12,48,8,153,386,509,873,203,457,401,196,37,898,372,59,326,475,55,14,202,569,57,498,403,719,17,64,308,237,494,318,269,94,90,253,961,22,44,730,36,697,342,177,482,56,474,137,89,72,421,349,38,670,576,139,111,30,28,210,148,96,758,143,734,629,16,244,160,128,18,291,41,805,247,25,19,84,373,245,61,488,579,205,523 }, +{ 2,29,52,1,26,58,6,262,5,50,14,70,103,46,19,38,309,27,96,112,67,516,75,163,133,331,218,145,108,223,17,236,45,83,287,25,487,74,114,171,785,409,357,113,238,24,433,151,53,36,388,220,739,34,545,396,307,532,583,675,61,600,181,42,65,73,764,160,635,21,603,394,12,80,594,186,150,324,894,632,3,7,334,99,54,137,315,891,69,445,37,412,323,48,745,537,18,283,87,458,138,822,308,243,155,765,86,711,895,398,285,28,651,366,226,115,766,849,294,23,480,820,51,221,297,22,732,209 }, +{ 120,77,260,141,51,13,217,23,317,1,450,291,15,202,137,326,373,110,177,180,21,269,165,318,128,197,352,115,349,64,32,203,5,342,351,0,102,48,341,96,854,93,82,523,2,244,457,9,160,752,386,36,922,12,365,372,37,898,7,304,275,403,86,10,210,253,817,16,704,28,83,90,901,498,143,6,615,4,719,22,494,237,18,661,730,473,30,24,308,50,221,40,76,72,55,8,59,35,11,33,391,285,67,89,144,125,61,961,99,39,401,14,3,475,247,402,44,31,70,453,49,509,642,153,208,482,17,216 }, +{ 444,183,291,297,358,196,554,255,56,59,123,269,33,605,108,122,153,177,275,210,77,57,341,117,130,128,475,467,730,152,134,42,403,4,50,880,19,381,315,401,51,65,421,216,630,349,283,21,503,235,133,85,23,11,719,368,46,202,99,494,432,229,40,14,29,561,665,339,670,480,736,588,523,453,102,15,899,650,326,256,249,236,197,125,318,2,775,757,711,624,396,365,328,524,78,64,3,529,194,18,13,0,250,12,6,690,25,445,266,48,511,402,285,26,789,678,260,242,165,120,343,769,543,488,409,390,369,366 }, +{ 23,13,51,12,165,14,120,153,38,197,117,37,99,401,134,386,453,54,128,202,141,196,64,5,328,40,237,21,137,139,15,260,33,2,719,475,125,133,180,457,0,46,403,242,77,236,6,208,1,36,96,32,4,391,361,115,308,52,194,629,17,569,730,477,86,102,546,817,450,19,10,758,961,933,923,903,558,160,11,29,22,18,3,188,111,79,114,108,65,48,95,291,56,349,157,94,41,338,221,89,82,34,59,277,177,49,317,304,506,372,351,50,26,421,217,44,31,7,72,341,352,350,316,312,207,183,143,130 }, +{ 95,64,348,33,467,56,343,174,554,511,77,312,233,120,108,180,0,561,6,355,543,13,306,370,197,165,859,25,18,29,297,256,91,63,899,237,49,770,650,412,235,85,138,19,42,523,65,671,90,102,22,9,32,368,194,40,23,10,4,576,426,416,204,161,153,117,116,86,26,27,104,448,775,721,719,457,450,344,326,275,217,72,24,605,730,283,245,196,98,76,17,5,577,519,123,835,475,192,81,78,353,588,386,365,269,260,222,220,214,179,170,141,134,125,119,105,97,66,51,28,11,881,273,242,172,746,707,643 }, +{ 120,51,260,326,450,202,23,77,141,203,93,13,137,318,21,1,82,165,110,15,523,5,351,269,197,64,102,373,128,33,217,48,180,386,32,291,457,125,817,352,922,854,403,115,144,116,177,349,210,12,96,196,615,475,7,719,372,367,237,40,730,2,342,704,4,98,391,10,275,59,494,453,401,0,37,6,421,317,50,16,90,36,44,752,308,9,498,160,31,393,18,899,221,341,14,3,30,45,402,8,898,304,83,692,99,24,551,72,947,247,216,28,961,153,864,678,661,473,88,509,70,22,285,17,576,300,76,35 }, +{ 15,4,11,13,5,23,21,32,1,64,93,33,2,3,180,40,22,37,141,10,82,0,6,77,102,44,31,352,7,120,117,165,341,12,48,49,110,197,98,134,9,752,17,901,153,498,342,269,196,115,291,365,128,260,36,317,137,51,95,59,217,318,237,202,349,72,8,509,391,14,873,177,16,523,86,922,386,247,143,304,210,125,29,45,57,457,453,90,854,482,403,111,579,160,244,18,569,437,89,61,253,76,27,899,351,864,275,450,719,56,758,116,875,961,277,468,164,148,25,817,401,316,84,139,546,490,216,46 }, +{ 15,341,13,141,23,33,217,4,77,180,1,102,40,317,5,137,0,365,202,51,11,21,351,854,9,269,82,10,115,372,32,64,922,901,22,117,260,352,197,153,128,36,28,196,752,134,165,59,318,349,3,120,2,12,30,177,244,37,450,143,291,31,86,457,48,139,160,16,8,7,898,247,253,125,523,18,49,44,57,403,304,55,730,569,961,6,111,110,14,96,498,494,17,308,719,72,39,237,642,386,475,90,98,24,342,45,401,817,326,873,661,76,277,95,509,105,421,210,93,811,453,717,144,391,99,89,164,221 }, +{ 272,105,131,327,286,320,578,109,22,28,219,239,224,159,9,616,371,49,95,623,538,98,716,910,713,127,258,737,187,185,385,761,424,168,170,64,55,254,347,169,928,916,0,158,164,1,924,31,23,301,51,293,39,627,374,125,913,201,44,836,242,912,36,395,13,116,65,479,634,24,442,654,86,346,284,276,35,312,137,308,512,160,115,194,420,10,175,2,154,7,338,21,128,16,944,83,143,456,12,67,601,202,762,141,908,124,535,289,574,871,688,165,401,900,5,763,96,892,933,384,317,506,237,860,14,37,68,30 }, +{ 16,68,35,71,18,60,118,24,191,126,92,101,150,212,167,154,302,175,9,346,55,0,273,7,124,108,107,375,628,28,566,14,722,149,815,199,589,439,882,575,520,363,121,562,246,467,21,364,1,806,279,140,22,49,48,252,517,695,65,230,345,847,647,97,621,411,69,146,336,46,653,39,10,109,694,604,535,5,189,768,399,446,637,50,441,2,755,419,125,298,608,43,314,423,13,649,158,706,463,398,100,67,818,508,38,12,37,20,826,95,354,264,23,32,169,166,132,271,105,96,221,674,83,51,932,429,356,54 }, +{ 20,470,147,43,904,376,798,427,325,595,142,178,858,198,319,0,97,173,414,22,259,61,422,819,77,945,202,14,32,5,362,49,426,392,107,207,887,725,660,481,263,465,234,104,450,534,494,861,95,28,18,33,120,10,612,64,344,105,13,30,324,39,21,455,817,115,46,146,102,31,132,4,246,356,318,65,158,66,260,40,7,48,523,581,9,35,159,315,113,729,23,230,125,347,112,38,128,878,359,59,36,60,12,239,600,182,237,192,153,342,196,683,98,16,170,2,306,298,357,54,279,101,70,560,501,345,199,845 }, +{ 51,23,13,12,99,453,33,202,128,64,153,102,15,196,37,403,141,40,120,117,475,38,134,115,14,137,77,401,139,10,0,165,318,269,82,308,21,2,5,197,54,3,180,260,22,31,494,421,17,86,93,1,95,44,111,457,277,237,402,450,9,110,18,6,98,719,125,65,351,32,28,217,49,342,326,328,730,629,352,386,285,361,221,11,50,36,19,341,48,569,177,41,59,8,194,27,24,89,79,523,29,775,4,961,365,7,670,291,144,373,210,114,46,317,391,34,116,509,757,203,236,108,30,26,817,55,498,57 }, +{ 383,136,17,62,84,440,119,504,56,240,548,3,80,129,378,123,106,128,555,205,4,184,507,59,162,11,14,183,57,361,249,38,202,469,152,64,179,495,483,90,32,215,257,214,245,130,209,54,161,27,250,503,328,229,618,211,5,73,402,45,12,306,318,40,34,514,790,76,452,77,65,26,86,297,141,19,53,497,742,269,814,283,37,33,255,311,194,436,667,114,177,61,217,803,95,207,266,2,50,432,769,757,236,102,21,527,36,556,46,22,10,72,115,41,494,611,381,29,196,99,216,210,151,248,445,137,0,576 }, +{ 70,652,48,5,638,846,1,21,163,340,888,767,221,125,761,349,260,562,269,303,518,658,591,586,13,698,623,23,883,774,98,87,49,31,9,371,296,223,51,763,850,863,120,541,360,346,141,634,64,535,39,30,2,0,845,7,622,156,318,195,44,95,202,900,32,12,931,379,6,558,768,293,271,115,777,401,58,354,818,61,55,17,132,668,450,308,385,914,351,919,93,922,391,457,128,22,590,212,291,77,807,762,758,252,159,101,663,352,538,372,100,446,75,520,18,937,284,96,146,626,326,127,118,116,771,522,463,69 }, +{ 66,135,74,97,278,6,172,69,324,140,267,808,462,14,550,204,7,357,138,87,189,85,298,75,29,2,500,52,335,38,25,92,582,802,174,571,572,841,563,42,380,1,24,314,21,350,16,451,67,46,280,220,501,443,150,620,230,103,486,423,35,353,622,60,83,226,71,192,32,889,26,22,65,903,95,5,48,232,330,64,108,86,565,792,641,580,36,448,70,509,197,222,43,348,558,426,241,726,125,262,0,877,893,50,872,81,309,63,233,950,37,749,18,388,149,145,12,91,237,10,355,606,294,246,114,508,673,28 }, +{ 51,23,33,102,13,128,40,196,202,77,64,65,139,141,99,12,14,453,117,153,475,403,134,10,86,137,4,11,22,0,318,269,115,401,36,114,108,21,38,5,120,180,421,165,402,59,28,15,95,82,210,37,2,177,494,31,342,9,260,217,277,523,386,3,308,450,6,457,730,17,133,18,719,24,46,361,1,352,49,194,143,111,54,50,351,197,300,94,44,237,341,164,365,221,389,67,32,48,283,19,485,291,29,236,27,854,93,961,758,110,326,817,317,285,125,275,90,52,45,34,26,7,391,181,57,8,752,670 }, +{ 88,264,435,100,166,274,772,921,478,382,909,639,438,960,521,96,897,410,30,1,466,190,530,778,265,321,682,691,418,144,724,329,686,39,9,447,93,31,914,131,404,203,44,411,765,335,593,475,795,367,98,625,254,664,120,213,613,403,0,744,539,116,83,656,363,238,5,48,13,576,77,812,805,110,23,21,141,966,69,125,616,829,326,286,201,82,35,520,225,51,821,127,604,285,284,165,260,217,33,36,310,731,340,842,223,102,137,101,615,64,831,252,228,49,10,67,224,557,219,443,692,406,272,268,910,506,197,351 }, +{ 440,62,136,548,504,56,84,3,555,383,507,129,361,128,123,162,4,17,59,119,184,14,202,183,152,161,402,495,328,57,205,514,527,229,215,80,27,257,38,11,378,73,757,497,472,240,211,130,503,452,803,54,469,77,53,34,494,381,318,283,266,250,106,12,102,33,245,210,432,64,403,19,40,880,236,90,5,556,179,21,412,377,2,32,200,300,99,196,269,585,153,488,141,51,275,216,45,37,117,249,529,194,214,372,76,862,177,134,133,313,26,421,0,139,471,41,305,65,248,483,13,114,678,23,217,50,72,775 }, +{ 911,617,959,332,206,253,244,141,282,120,110,384,951,143,352,260,269,10,160,373,717,531,811,417,940,55,728,661,533,36,434,450,93,137,559,203,473,498,642,116,180,326,855,261,295,44,268,638,922,854,752,31,499,164,318,351,201,535,144,851,564,341,365,64,8,115,165,197,843,1,217,317,704,864,187,699,567,127,202,873,237,251,22,258,574,824,98,86,968,860,489,23,817,82,125,21,169,509,926,219,13,276,15,601,28,345,9,372,51,901,349,943,871,5,367,291,776,308,131,391,96,523,105,83,386,902,338,35 }, +{ 120,260,450,141,77,15,1,23,351,326,137,64,373,82,203,33,13,291,51,21,217,523,269,177,102,128,922,165,110,197,854,5,318,457,180,352,48,32,125,144,93,817,160,202,386,96,50,7,372,36,349,304,210,2,342,730,115,898,719,16,0,196,247,494,59,10,9,473,22,4,403,116,18,86,67,341,752,615,95,75,901,317,275,704,24,475,453,437,367,208,164,163,143,37,90,899,244,98,12,3,365,968,551,300,237,206,55,35,29,6,801,805,678,576,401,393,391,288,268,216,194,99,72,61,58,49,39,242 }, +{ 15,0,1,2,5,51,9,23,7,13,6,901,12,3,8,180,4,141,82,115,14,10,341,120,197,33,93,730,21,40,125,401,260,202,102,22,110,64,569,719,457,165,37,961,898,453,18,351,31,28,203,16,137,352,217,450,77,326,11,403,629,308,128,196,32,30,36,269,44,98,116,318,365,99,475,373,670,237,24,899,854,523,391,95,421,49,48,317,177,221,817,153,55,117,752,39,86,144,38,642,105,922,242,291,54,143,17,134,494,498,244,59,661,96,473,65,160,509,139,170,247,89,114,90,638,20,704,482 }, +{ 104,7,97,107,356,560,66,232,707,359,298,568,289,324,712,392,192,38,14,426,173,65,95,64,172,387,22,43,92,32,357,362,214,20,259,526,90,0,330,380,126,246,501,49,5,86,893,74,500,194,874,147,135,612,230,10,204,779,52,2,729,808,550,140,35,835,21,28,314,77,312,60,16,465,132,715,279,423,414,600,885,802,683,18,81,24,36,13,636,861,150,33,178,29,819,519,288,4,31,58,660,448,121,534,12,168,61,48,581,278,70,37,146,102,441,23,46,199,142,6,751,249,76,319,202,189,124,237 }, +{ 6,66,1,2,74,67,29,14,24,69,83,135,25,458,52,150,108,451,75,38,103,380,267,278,7,87,26,42,324,36,357,138,602,114,97,19,85,238,594,273,65,149,398,335,172,46,160,204,70,18,711,550,50,16,309,220,71,732,96,696,5,133,603,12,891,86,174,28,280,500,418,467,226,32,22,21,222,189,27,60,124,423,486,547,895,302,733,236,532,388,208,64,63,0,35,17,13,298,95,262,45,906,336,646,582,37,145,194,571,20,531,112,23,58,140,516,484,48,886,218,118,115,99,81,462,429,54,55 }, +{ 51,23,13,453,12,115,202,21,403,401,5,4,457,719,475,37,99,165,32,308,64,3,1,2,523,10,730,0,128,17,197,15,141,494,11,22,14,6,269,961,7,318,120,386,77,899,18,247,421,450,817,48,16,117,59,90,33,125,217,9,19,153,180,629,26,758,237,24,177,28,221,95,57,341,40,25,38,54,569,391,27,260,402,29,216,317,36,72,291,102,56,134,365,45,76,49,468,304,352,137,210,203,34,89,196,342,82,275,194,349,437,46,123,326,50,20,8,670,482,86,509,139,498,316,53,61,576,288 }, +{ 57,59,77,4,381,11,412,369,210,291,421,283,803,53,250,542,377,14,339,471,275,108,99,670,19,300,453,403,23,27,401,368,40,51,202,361,775,21,12,554,236,183,402,813,33,342,38,378,475,503,46,37,444,10,736,390,152,90,56,561,285,153,134,123,117,650,73,899,523,281,0,529,494,63,386,880,432,162,514,128,58,605,102,817,743,690,495,349,277,256,196,137,111,79,18,9,801,235,139,78,867,391,200,119,758,130,42,26,480,389,719,714,467,341,80,269,122,730,221,216,188,177,161,133,114,45,29,22 }, +{ 15,1,5,2,0,7,23,6,13,51,9,3,180,115,12,457,4,8,14,141,901,719,197,33,21,82,961,365,22,120,165,341,31,351,64,202,308,77,37,401,260,117,16,153,28,11,110,93,730,10,32,44,269,137,217,569,18,98,102,49,128,317,453,125,30,36,99,523,48,352,134,752,450,196,386,318,326,40,95,24,758,898,17,116,629,39,373,203,86,72,899,237,403,59,177,35,873,90,89,55,291,105,817,144,734,475,244,139,421,65,498,76,247,494,20,38,854,349,160,253,509,372,96,482,221,216,615,143 }, +{ 64,237,180,95,312,197,146,32,90,247,316,929,352,126,165,288,317,132,304,13,60,490,77,217,955,522,92,314,86,22,4,23,7,5,21,626,40,14,11,12,652,498,291,177,232,164,199,33,10,482,51,141,115,150,633,462,579,340,216,16,529,128,37,360,638,388,121,359,143,468,275,59,107,49,534,125,202,658,509,269,888,267,1,598,581,588,76,17,467,451,296,28,751,660,441,349,194,29,31,71,698,279,253,45,640,57,48,546,134,117,18,2,830,647,372,102,65,437,493,351,98,733,622,423,273,241,309,137 }, +{ 1,23,13,51,120,15,202,180,5,21,260,141,0,326,2,137,7,77,197,450,269,33,165,318,9,128,352,110,48,6,102,523,12,115,342,317,4,32,16,386,14,403,373,203,817,36,18,217,64,96,37,457,93,752,82,28,341,494,24,615,3,22,291,351,401,8,475,10,308,453,421,391,901,221,196,59,719,730,854,30,177,90,160,365,402,125,35,498,31,285,99,39,11,244,237,72,20,899,44,40,704,86,17,922,83,50,210,349,569,576,98,95,67,76,372,509,49,143,116,253,961,65,144,89,55,551,661,29 }, +{ 14,46,2,16,24,75,69,35,220,52,7,38,1,140,267,29,71,50,309,60,87,92,70,171,189,67,18,54,163,262,335,108,230,58,366,103,150,5,675,236,181,112,223,278,409,537,21,83,294,48,155,68,12,486,149,37,571,582,96,0,246,334,135,186,443,45,328,28,32,133,641,97,451,151,388,64,307,126,25,9,502,760,394,281,357,22,65,66,774,36,10,55,172,114,61,6,565,462,461,251,552,563,400,74,820,330,238,218,600,72,99,86,606,314,17,380,430,227,587,433,20,13,23,583,516,545,121,115 }, +{ 127,98,31,44,299,276,284,9,935,293,116,599,49,0,456,201,492,28,39,105,144,371,662,22,159,125,272,137,242,131,737,489,393,567,268,395,51,1,761,578,367,202,158,30,109,918,916,685,219,254,203,616,23,434,36,21,55,141,295,95,13,24,16,187,93,385,128,18,96,948,48,269,763,160,318,64,5,165,86,101,244,326,115,518,35,286,836,261,37,512,7,10,68,327,623,716,384,120,403,253,688,110,333,224,2,890,457,143,100,197,12,386,252,301,320,258,963,310,65,14,237,924,221,170,494,421,83,699 }, +{ 53,573,445,297,436,73,6,27,151,113,26,250,491,19,614,145,611,200,315,112,45,396,881,138,80,42,58,70,34,684,25,631,17,222,287,106,74,472,122,61,624,714,690,235,5,90,32,65,255,64,648,29,14,66,95,85,322,2,209,243,549,311,644,22,1,52,665,280,47,161,86,76,87,194,312,651,3,667,133,416,75,307,114,128,78,62,137,51,57,4,226,141,50,136,46,862,483,49,289,884,119,440,632,814,12,21,176,237,148,56,236,283,174,36,135,63,123,337,10,453,33,412,84,469,214,59,108,23 }, +{ 90,788,804,32,115,693,494,81,84,56,725,403,119,21,18,681,99,77,202,526,65,240,214,576,64,817,91,0,784,350,241,102,397,342,690,848,104,61,24,945,318,69,825,453,421,365,210,134,123,117,33,20,707,402,60,293,263,207,194,114,49,888,370,97,43,673,671,523,726,326,125,510,879,773,718,715,701,462,283,249,180,153,59,57,51,11,887,835,814,111,23,4,889,468,289,247,221,95,89,86,66,120,719,325,192,899,730,683,595,422,757,486,484,426,351,312,306,302,285,275,260,238,216,203,196,177,174,165 }, +{ 24,7,14,149,71,16,18,108,65,69,28,154,189,35,2,140,124,92,68,150,118,175,429,302,0,66,273,67,336,38,55,97,251,46,60,36,547,1,267,484,22,458,230,29,83,6,9,388,86,650,172,314,95,109,114,52,135,21,64,886,602,74,505,10,232,5,20,12,596,823,705,398,32,103,49,101,420,570,236,531,289,533,50,298,168,169,48,133,462,451,380,23,882,246,283,51,799,13,43,25,185,797,194,847,75,357,278,158,37,439,346,594,330,733,399,423,610,164,192,535,701,104,345,467,143,443,125,137 }, +{ 68,0,101,9,212,65,124,35,154,189,69,149,114,230,67,39,252,100,1,336,702,329,16,265,520,83,103,191,264,755,64,589,88,562,28,705,30,24,283,167,118,18,777,732,478,12,21,723,71,166,23,49,175,133,398,335,596,55,664,218,237,429,389,532,818,604,364,50,158,115,484,289,246,352,238,410,141,22,759,419,323,375,345,36,13,10,806,128,51,547,796,269,213,5,48,722,140,247,321,96,565,480,164,180,251,330,803,553,37,676,95,143,202,86,75,490,443,7,936,724,99,2,190,694,346,197,782,917 }, +{ 5,2,186,61,29,52,45,58,311,17,171,80,227,209,48,155,1,106,243,496,50,46,334,454,592,21,513,14,502,255,869,666,151,663,262,223,75,207,38,32,270,667,62,6,27,738,659,119,56,3,807,54,780,287,378,84,721,74,220,290,96,163,483,72,263,89,67,549,103,281,136,37,583,76,430,181,536,7,70,408,12,394,64,787,73,675,148,495,469,69,161,400,409,36,833,86,65,34,19,474,587,742,767,221,26,324,128,4,309,115,24,83,306,425,25,22,431,10,241,760,90,141,764,541,133,240,95,383 }, +{ 15,1,13,2,5,3,4,0,341,7,6,23,10,11,14,12,9,33,51,17,165,153,197,365,569,180,77,40,102,8,115,117,21,901,64,217,317,22,141,16,128,32,457,196,31,134,28,36,291,18,177,139,137,237,719,961,37,57,120,111,352,349,386,59,202,453,629,86,752,19,758,38,93,873,269,44,391,372,49,143,95,342,730,30,475,498,509,260,210,318,125,110,304,55,27,29,403,82,48,24,277,72,482,275,116,494,25,450,98,54,351,76,90,326,41,79,373,99,899,546,523,194,144,474,94,56,203,39 }, +{ 13,23,15,51,0,1,10,4,2,5,77,9,115,3,12,14,22,102,11,197,33,457,7,961,165,453,403,40,59,6,21,475,494,18,719,64,180,28,202,569,32,401,31,37,17,16,8,210,177,341,523,120,141,386,730,49,217,99,44,318,57,450,308,36,629,421,125,93,153,342,90,117,24,111,498,139,269,237,30,196,817,291,134,317,326,98,95,365,899,260,352,19,48,82,275,391,72,38,89,110,509,482,86,873,216,76,349,148,247,79,27,54,116,474,65,203,901,615,55,45,351,128,758,137,304,752,94,50 }, +{ 15,13,0,1,23,2,10,102,5,9,33,7,4,3,6,77,51,115,12,11,341,217,196,40,14,117,153,18,317,569,22,8,457,365,523,16,342,180,197,165,120,719,453,961,59,134,730,21,64,141,260,31,901,401,291,899,386,28,139,82,210,177,349,269,49,24,482,202,17,372,817,44,450,93,629,111,32,125,351,326,300,352,37,318,110,128,30,36,475,95,579,468,57,308,19,137,38,98,247,437,304,275,20,65,752,237,498,391,494,758,615,90,86,373,854,116,277,99,72,96,48,421,203,45,216,105,898,89 }, +{ 166,39,274,190,438,310,30,333,530,100,252,656,625,539,265,404,778,88,101,455,9,0,557,960,593,329,254,131,1,676,382,709,724,158,553,840,731,228,98,31,669,23,68,219,264,48,21,748,957,812,406,49,224,127,44,13,344,36,272,286,51,159,520,419,105,96,116,125,613,83,5,93,795,124,213,28,863,22,223,35,478,10,816,352,293,69,67,829,16,827,258,616,364,160,64,242,639,578,120,167,128,65,518,217,321,154,32,137,187,604,180,4,679,435,118,18,251,212,144,86,95,759,141,77,410,793,371,37 }, +{ 734,94,148,308,79,111,413,468,89,37,431,115,179,401,569,197,629,341,188,13,873,474,490,365,72,12,11,134,205,245,317,117,4,247,358,59,40,152,509,51,482,901,961,76,99,528,23,180,10,498,217,216,477,339,77,139,102,38,165,55,749,421,196,743,579,143,33,542,428,391,875,752,471,497,54,1,452,153,177,21,488,588,3,64,141,349,453,485,670,277,291,457,2,128,5,57,403,36,475,529,184,540,202,48,377,90,7,372,14,50,405,210,437,15,758,402,464,386,352,300,157,6,17,0,45,794,9,342 }, +{ 539,228,224,219,190,816,840,871,30,669,530,957,258,748,863,406,93,187,778,531,160,213,88,466,839,36,131,137,116,202,728,679,926,120,44,352,39,321,373,318,274,276,851,31,574,442,860,144,730,217,201,203,613,251,856,55,559,533,944,141,435,1,450,242,230,22,127,86,110,64,800,28,49,326,473,9,260,752,268,254,166,418,717,567,456,98,96,776,902,385,968,100,719,180,269,616,317,918,351,83,827,492,10,625,931,494,125,831,908,197,21,365,372,82,371,35,77,716,854,795,689,295,704,5,332,345,244,291 }, +{ 801,393,125,791,386,730,23,551,51,21,144,116,48,203,98,221,175,165,949,93,575,31,126,13,958,326,697,601,421,345,788,293,367,22,963,541,110,455,60,608,670,273,197,44,463,4,32,677,623,127,33,259,834,35,948,453,375,133,107,120,77,40,223,0,407,342,68,719,121,43,14,446,621,590,523,373,308,102,49,16,899,1,815,475,199,770,725,191,493,804,96,36,319,141,101,92,39,146,690,71,55,7,118,38,805,352,649,735,615,602,533,531,480,323,279,246,208,201,196,180,160,105,64,743,589,132,117,598 }, +{ 13,23,77,51,115,141,33,217,4,2,177,6,0,102,40,7,64,11,10,14,3,1,180,269,22,202,9,59,16,15,17,352,318,128,18,197,291,247,32,165,196,153,117,134,317,19,5,90,341,125,237,24,137,210,36,28,304,349,403,49,12,95,86,25,275,372,453,365,31,308,752,216,342,20,143,139,475,93,27,98,498,57,26,401,21,120,386,391,457,326,8,569,316,494,421,111,65,901,203,110,105,30,260,468,288,164,437,241,45,48,29,35,99,44,482,719,82,402,509,144,37,244,55,546,56,285,961,293 }, +{ 2,52,29,70,112,7,58,14,75,87,46,220,307,186,171,163,151,1,334,262,135,278,66,5,69,155,294,97,38,140,74,16,45,172,287,549,92,227,400,24,849,226,331,113,61,324,25,48,852,32,35,21,37,6,461,67,409,50,19,12,644,315,267,145,26,243,223,311,27,64,60,54,232,122,71,18,83,17,571,583,189,86,36,853,103,72,65,394,380,587,780,774,309,20,43,22,357,42,96,314,298,128,209,335,536,95,474,767,675,270,337,76,80,89,330,222,0,90,721,290,230,10,137,108,246,126,28,448 }, +{ 321,88,213,435,466,100,689,382,30,230,1,795,352,410,96,217,699,921,190,831,521,530,443,36,83,686,144,418,840,264,438,854,128,251,539,957,44,141,180,557,752,335,69,223,317,960,31,265,48,137,855,116,934,201,98,748,160,669,909,93,166,203,812,731,403,21,274,351,593,39,778,206,367,772,219,64,228,131,455,202,9,284,5,372,35,326,238,127,23,735,82,51,656,285,67,158,310,125,639,800,221,187,224,332,269,120,365,576,494,13,897,252,345,822,478,765,349,702,77,268,421,242,208,110,318,859,101,237 }, +{ 363,520,411,354,101,195,668,132,447,9,156,905,364,664,121,146,360,23,18,759,781,1,98,765,271,51,96,676,252,264,13,777,5,31,586,621,591,478,223,167,848,21,100,691,936,551,33,393,857,70,48,883,125,682,77,16,39,687,948,821,44,367,116,93,24,407,265,127,593,834,110,49,842,522,296,4,293,166,626,812,865,64,404,203,333,102,538,212,36,638,40,55,446,50,647,118,291,656,897,144,639,60,771,697,128,403,379,67,35,692,541,165,463,163,604,453,658,199,590,69,791,286,7,32,12,317,217,724 }, +{ 51,23,13,453,401,475,12,403,457,730,719,21,5,308,99,115,2,32,11,4,3,421,961,1,165,15,629,899,0,670,37,10,6,17,197,9,33,18,22,523,569,64,40,202,28,19,56,26,7,57,27,16,72,48,196,194,24,59,494,177,153,45,36,139,77,386,210,128,117,65,758,34,8,391,341,817,468,217,54,29,450,275,221,76,757,509,350,141,134,90,89,46,38,291,180,880,237,102,304,216,775,734,546,402,361,277,137,130,129,67,41,25,14,247,148,62,901,498,477,283,262,260,133,123,74,42,801,365 }, +{ 72,76,89,205,179,90,245,528,148,54,184,37,12,431,38,308,152,4,257,59,474,316,428,401,464,57,460,749,32,288,358,405,229,23,477,645,743,99,11,21,51,115,497,77,217,1,794,79,157,14,5,629,540,488,453,216,45,449,17,155,2,221,770,165,48,670,421,569,328,266,50,452,197,341,181,3,128,769,10,365,137,64,13,317,587,241,36,457,734,188,247,0,339,313,7,536,350,471,9,202,94,468,524,509,721,482,141,46,129,102,773,697,33,432,40,180,270,237,281,619,741,381,86,361,961,543,476,720 }, +{ 376,43,147,470,20,595,173,107,858,97,319,142,427,819,414,178,729,362,426,325,5,259,7,32,861,392,61,798,246,14,104,198,230,560,885,324,77,21,422,904,356,0,465,126,357,48,707,234,38,330,22,49,207,35,501,612,66,13,202,95,534,359,298,2,10,577,76,28,16,70,113,64,132,4,17,481,318,715,102,60,58,18,784,59,120,40,72,11,90,29,500,23,74,279,879,146,33,1,112,660,387,56,52,45,315,81,232,9,494,177,140,36,115,37,153,600,57,199,217,31,12,121,347,51,403,878,671,164 }, +{ 202,269,141,494,318,51,137,403,128,77,453,4,475,217,678,349,421,5,342,352,96,102,291,177,372,317,64,341,180,21,2,40,10,59,32,752,33,11,61,3,515,120,304,36,0,365,6,31,13,22,7,39,30,95,125,260,237,12,717,275,115,28,23,98,244,482,268,105,947,851,402,805,203,194,144,954,576,450,351,48,859,289,283,86,65,55,49,44,795,197,82,90,498,312,285,241,201,182,165,160,57,56,14,411,293,284,9,822,326,899,523,931,921,897,863,854,839,821,735,691,668,579,569,442,360,251,214,207 }, +{ 77,202,318,102,494,33,128,269,23,13,51,196,153,177,117,342,134,291,403,0,141,137,64,15,349,82,22,351,203,49,275,615,373,21,551,393,473,217,95,859,31,210,4,475,402,1,352,65,11,10,450,120,32,180,86,285,36,18,2,7,3,453,12,260,6,28,98,14,125,39,421,48,90,5,372,40,194,59,44,165,817,16,9,115,326,341,523,17,678,216,30,197,317,116,576,96,127,237,61,93,300,24,365,124,70,401,105,730,214,160,114,304,289,110,329,20,704,163,35,386,208,899,144,692,244,67,50,719 }, +{ 253,951,352,110,811,499,244,854,10,638,642,752,559,180,143,141,564,8,260,341,498,417,922,661,901,197,206,165,911,373,137,93,282,873,351,384,15,959,55,332,120,762,717,728,269,160,898,82,473,64,326,164,36,365,203,22,704,533,317,509,31,479,86,968,116,318,115,202,531,1,268,217,33,535,28,44,9,617,237,13,434,4,261,23,77,940,125,5,372,11,851,864,40,32,338,21,102,0,569,386,30,96,482,349,169,824,421,51,105,546,12,401,242,758,576,391,35,127,98,170,2,117,144,844,295,457,24,291 }, +{ 141,23,13,5,4,269,352,51,180,21,317,115,202,217,1,197,2,11,365,318,32,341,3,6,372,137,7,498,77,64,349,291,48,752,33,0,165,237,9,15,22,12,901,221,253,16,144,244,143,403,93,28,401,30,453,110,475,24,304,40,39,120,125,494,421,203,308,72,160,569,18,386,177,35,102,482,31,14,260,44,10,36,391,95,473,373,153,49,468,864,247,117,873,128,100,88,59,134,69,546,241,76,717,89,86,196,17,37,437,166,509,351,164,98,854,67,8,90,704,629,82,851,450,96,811,367,326,284 }, +{ 252,101,18,9,0,68,16,118,329,35,364,24,39,167,60,333,265,109,158,553,71,212,677,28,419,604,100,793,49,286,159,154,191,105,55,310,272,694,327,455,124,810,806,48,22,166,254,593,21,7,374,344,1,520,146,121,538,5,917,65,346,706,857,634,92,562,23,627,404,126,925,13,98,185,51,108,30,14,907,271,169,709,31,942,95,10,446,96,149,628,557,125,375,170,175,67,688,199,363,132,639,239,190,656,107,621,320,12,912,638,137,36,150,44,815,302,50,463,865,221,438,32,37,578,671,439,848,131 }, +{ 28,109,158,9,168,49,39,175,35,159,22,0,55,185,65,289,272,67,95,194,114,346,333,577,169,584,254,1,344,327,105,570,286,336,24,83,86,30,747,68,627,374,124,505,69,101,810,610,837,439,36,154,535,133,103,7,310,16,14,835,131,756,601,345,2,429,874,149,389,50,799,793,252,347,283,208,547,51,251,46,23,100,128,10,189,312,164,424,912,21,484,5,64,688,637,12,190,578,455,96,239,420,13,518,143,634,137,419,533,364,18,398,166,48,709,320,218,538,127,160,170,230,323,125,71,37,98,202 }, +{ 15,13,1,5,2,3,4,341,11,23,0,33,6,51,7,12,40,115,10,9,77,102,14,197,365,180,17,901,21,217,317,196,165,32,569,22,141,8,64,961,453,457,16,153,59,117,18,352,31,202,125,37,139,291,401,629,28,386,269,134,719,177,475,237,93,318,120,730,44,48,372,110,24,111,899,36,210,403,19,57,523,391,349,752,326,49,38,128,308,342,260,494,498,116,95,509,98,137,30,873,304,758,90,801,27,56,86,203,615,144,275,45,482,450,65,670,373,54,41,50,734,94,143,25,82,244,105,79 }, +{ 173,693,18,104,422,20,102,0,77,49,61,5,784,560,526,707,226,32,13,33,397,64,193,344,134,117,91,66,21,153,715,263,81,95,172,232,207,196,31,11,6,65,510,42,25,414,197,180,135,48,29,22,10,43,72,819,4,470,324,40,85,546,86,887,347,51,319,204,57,28,27,426,359,283,498,376,138,128,90,194,392,643,879,701,474,87,74,59,52,38,9,387,681,7,862,597,192,814,847,718,713,334,291,270,217,165,125,83,37,56,23,202,177,141,122,825,241,509,330,942,817,523,370,269,115,98,84,44 }, +{ 23,51,386,308,13,401,221,421,801,949,719,165,468,730,21,770,341,125,697,453,867,14,115,670,457,6,391,403,1,475,958,523,450,117,102,197,629,365,33,569,607,7,2,758,120,66,899,515,743,134,217,791,342,97,16,326,67,733,74,350,150,773,749,260,202,52,29,18,9,501,456,805,809,734,482,56,0,317,135,4,906,458,153,3,380,103,645,579,558,490,24,93,83,388,196,108,817,11,99,903,685,177,69,32,561,267,236,335,5,180,594,696,554,451,642,576,564,559,546,349,291,238,122,89,87,76,75,73 }, +{ 49,0,24,16,105,159,28,9,35,158,68,320,18,109,239,55,65,170,124,7,1,154,301,347,71,95,14,286,518,101,2,344,327,272,127,118,39,21,60,374,890,98,577,623,12,149,22,5,916,338,512,168,36,713,395,23,31,67,51,371,13,48,185,175,125,137,10,424,169,64,202,737,479,30,747,538,6,761,37,108,128,346,242,32,740,293,131,46,50,302,654,69,44,252,419,289,810,86,114,92,83,616,141,385,846,299,164,254,364,506,403,677,310,671,375,191,221,116,938,318,634,100,165,439,115,143,333,96 }, +{ 2,5,29,45,207,58,61,1,76,292,32,655,263,14,476,52,72,6,119,17,306,70,186,7,106,46,179,214,790,90,148,243,720,38,227,50,240,112,151,710,255,592,84,89,64,48,25,464,75,241,209,21,129,74,155,460,358,3,128,454,496,425,36,77,19,22,141,738,10,115,56,26,86,16,123,66,408,311,27,245,0,249,95,65,205,287,519,290,618,40,24,177,549,171,202,87,4,59,163,307,54,334,237,51,23,62,269,12,102,37,18,449,869,137,80,69,113,28,99,33,67,13,135,180,318,315,769,288 }, +{ 125,21,115,95,715,197,49,165,64,56,66,32,6,278,13,33,713,681,808,350,204,237,120,408,263,241,172,135,81,22,324,87,509,74,0,85,97,4,90,86,468,65,888,353,174,558,391,841,192,180,23,950,872,645,571,554,650,580,141,5,2,412,283,467,341,673,59,138,38,108,903,177,91,51,7,511,370,164,75,31,620,475,203,893,170,98,712,104,44,19,885,10,1,561,426,415,308,63,403,196,153,117,102,84,389,128,27,825,569,210,77,347,53,123,386,316,159,143,835,194,900,448,93,11,546,232,18,572 }, +{ 612,325,427,202,107,494,5,403,470,147,518,376,64,362,49,21,392,788,465,98,14,342,125,623,318,178,48,31,845,804,534,858,423,70,690,595,414,278,93,422,269,453,7,660,102,77,33,693,61,953,767,798,819,581,307,298,234,198,116,110,97,39,32,30,10,237,4,671,663,389,289,194,128,43,0,20,904,725,761,711,678,509,501,493,366,319,236,232,220,174,104,99,95,88,87,68,55,44,38,37,18,9,900,293,13,715,441,315,105,291,163,141,391,112,848,397,22,763,713,558,846,835,828,822,757,657,557,546 }, +{ 32,76,21,72,14,241,449,50,292,2,350,5,1,155,48,221,46,38,89,179,270,45,476,90,54,720,214,430,148,464,17,281,129,460,37,205,413,741,181,36,245,519,29,227,52,290,257,184,405,12,123,710,3,528,162,7,773,243,541,10,358,0,288,431,67,57,249,536,316,152,99,96,23,106,171,51,513,4,743,308,618,128,137,6,115,64,474,477,103,408,86,207,769,229,263,9,328,83,133,180,59,183,119,552,794,787,540,114,217,488,425,218,62,11,421,659,77,645,760,721,22,524,202,58,400,401,141,770 }, +{ 24,154,149,28,124,16,35,0,71,7,14,68,175,108,65,18,55,92,109,302,118,9,336,570,484,398,69,140,60,2,420,67,189,22,101,46,150,185,158,346,230,1,439,169,252,273,168,419,289,39,49,38,505,251,83,345,701,535,799,610,637,267,21,36,97,10,650,50,95,12,429,246,103,533,114,388,458,133,5,48,399,314,86,6,671,375,159,66,364,29,236,329,962,703,105,547,23,51,172,601,333,283,64,265,886,126,96,194,52,13,232,722,32,20,389,54,37,677,164,100,143,125,327,602,75,917,344,286 }, +{ 5,14,1,50,48,2,46,38,67,54,45,103,24,270,21,96,513,155,290,83,58,61,281,69,32,36,181,72,502,0,29,171,17,12,16,7,76,263,37,18,28,52,227,35,425,207,89,666,22,221,243,133,541,663,65,10,741,218,408,223,114,536,108,474,75,9,186,6,592,552,51,23,99,238,328,115,309,794,540,3,433,834,86,292,760,477,148,449,428,64,476,128,400,528,119,655,55,236,241,106,202,141,765,766,487,70,13,163,137,366,95,71,587,697,488,720,179,160,19,418,807,308,659,149,27,90,431,4 }, +{ 961,13,569,37,197,23,474,94,148,79,12,629,401,111,901,341,15,51,165,405,734,873,99,4,413,188,134,89,10,11,358,152,179,117,308,115,40,59,72,468,245,139,457,33,153,247,365,477,205,277,339,317,77,758,5,38,498,76,579,453,216,180,0,3,542,762,36,490,2,177,102,143,482,217,196,471,14,452,128,437,55,1,54,304,22,210,9,377,64,638,202,17,21,488,349,431,300,775,528,485,32,7,141,318,372,86,8,509,157,45,291,497,137,184,6,864,402,670,275,880,403,110,543,328,529,875,90,657 }, +{ 102,33,51,77,23,40,128,202,64,13,141,139,196,318,403,153,269,117,99,137,22,4,453,134,59,115,12,10,11,475,0,14,86,65,95,180,15,2,120,1,210,494,342,28,18,165,352,6,36,49,177,217,300,260,82,719,401,421,24,402,386,21,5,457,7,197,730,3,125,37,450,19,291,48,523,17,351,237,27,114,326,93,50,111,38,341,317,25,285,98,26,277,110,54,194,46,9,391,361,275,16,44,31,961,32,308,96,349,899,34,133,854,569,29,485,757,108,105,283,67,144,373,57,509,678,498,221,116 }, +{ 24,35,1,67,0,28,18,16,103,9,68,69,50,65,83,149,12,5,71,133,14,7,22,114,75,96,2,55,189,218,108,48,21,54,223,175,281,251,181,23,46,58,37,124,101,51,336,238,36,70,13,154,118,163,418,10,99,60,745,766,137,537,39,128,38,335,202,141,487,49,361,64,32,45,115,486,155,765,283,109,502,345,230,140,87,430,171,29,269,398,30,267,95,221,543,92,86,820,236,217,6,412,285,17,160,302,77,177,596,61,318,180,458,488,31,52,540,165,352,4,237,105,920,545,125,657,705,273 }, +{ 384,617,940,911,959,855,332,206,282,434,244,253,141,268,352,93,120,144,10,269,137,110,160,201,417,36,143,450,116,203,260,44,811,31,717,951,55,295,318,64,187,261,373,567,202,276,489,258,326,498,98,642,559,180,473,127,22,728,860,217,1,661,219,499,86,23,851,638,8,197,692,341,13,531,165,224,351,523,817,115,9,854,164,125,752,365,28,533,367,51,922,15,564,131,21,96,317,128,82,5,662,699,843,105,871,372,615,237,0,83,386,30,864,509,242,800,901,284,291,551,77,2,776,349,7,704,37,574 }, +{ 93,30,203,473,326,704,137,652,450,31,800,269,848,160,127,190,274,144,254,219,187,625,349,303,166,352,120,372,116,521,224,110,131,752,435,88,217,202,141,260,291,77,367,156,340,228,822,744,5,382,197,296,658,438,180,863,410,44,730,698,578,317,418,1,859,165,850,829,735,494,102,795,616,159,264,921,98,960,373,36,100,23,13,341,128,21,64,258,10,0,523,330,318,39,717,321,778,709,7,968,125,919,942,177,49,86,158,9,365,225,901,478,105,686,531,33,924,888,851,96,2,363,371,442,385,747,691,615 }, +{ 53,73,27,250,26,200,19,297,630,714,472,611,42,122,235,25,17,34,6,436,65,684,106,680,690,80,14,256,113,322,57,813,85,108,64,45,59,648,283,4,161,194,573,445,236,389,128,862,444,114,624,390,469,78,56,51,141,133,2,90,22,84,11,176,491,0,18,255,495,453,416,32,3,412,23,47,145,137,63,29,665,123,95,269,46,378,62,61,614,483,86,361,814,10,5,605,136,396,216,177,112,50,249,619,730,77,129,119,503,13,432,202,179,12,719,285,318,24,597,102,151,183,76,21,130,742,37,209 }, +{ 15,2,1,5,7,3,0,6,141,180,10,4,13,33,11,352,77,197,9,217,14,134,64,12,341,317,365,165,752,40,498,372,269,102,23,17,115,117,291,8,349,22,51,153,196,59,32,237,16,901,36,120,21,260,202,342,961,128,569,143,82,57,864,37,45,318,873,110,93,111,457,18,72,391,386,76,28,86,351,125,137,509,95,31,56,954,326,450,79,48,27,854,139,29,482,19,38,44,546,89,373,99,49,244,90,55,84,719,523,94,403,35,177,54,579,453,277,24,164,922,41,253,30,203,730,61,20,58 }, +{ 254,530,960,613,39,829,688,221,406,190,166,475,827,438,30,9,669,269,180,23,98,51,31,228,21,541,202,274,141,840,318,131,938,105,48,158,127,125,96,44,846,137,453,49,393,219,352,116,13,1,679,421,856,625,286,317,36,308,100,333,310,403,115,890,144,217,791,101,931,616,569,10,386,551,401,0,876,272,910,55,258,88,102,77,327,656,224,629,252,64,468,731,160,385,860,518,926,28,697,344,326,159,33,5,197,93,944,627,128,165,816,293,574,455,187,765,371,364,843,404,242,120,22,284,95,32,345,506 }, +{ 39,9,166,28,158,35,101,30,175,364,68,168,190,0,67,346,194,100,49,88,131,36,333,420,274,310,570,344,404,252,83,289,706,109,55,69,208,1,86,160,137,610,96,65,967,251,438,352,637,336,114,16,577,159,128,254,756,154,345,219,22,64,230,799,228,810,95,24,51,747,224,185,141,818,149,584,768,202,103,419,429,21,826,752,124,530,857,31,656,10,13,169,323,505,237,143,865,562,189,165,793,238,694,535,23,217,874,455,164,116,105,7,197,127,44,547,125,286,180,213,868,539,71,2,703,272,498,115 }, +{ 62,555,548,56,3,507,161,440,34,215,527,136,514,162,361,4,211,17,130,328,383,757,14,84,183,123,205,152,494,11,184,57,585,38,236,202,377,59,54,504,452,129,402,128,176,556,229,880,80,372,300,381,495,40,33,378,37,469,106,266,472,119,12,214,497,248,102,803,403,342,249,73,53,77,245,412,313,51,196,27,153,543,257,485,210,471,76,283,488,99,305,200,421,13,139,157,23,349,432,79,45,90,339,32,117,240,46,179,714,457,292,108,134,250,719,318,41,217,64,21,22,369,710,188,72,133,277,453 }, +{ 126,107,92,356,493,279,359,7,246,97,298,362,392,441,508,60,199,35,423,16,146,132,121,14,43,230,501,232,939,20,649,150,173,5,779,660,414,607,672,314,590,259,534,21,66,140,729,683,387,191,18,71,941,955,953,32,104,49,48,22,38,0,46,319,640,95,819,172,147,167,24,357,28,10,2,13,858,603,324,195,68,598,12,1,345,595,426,61,64,653,522,407,612,470,4,885,77,23,52,236,125,37,33,702,31,687,581,6,118,74,98,711,399,212,40,75,70,376,465,517,360,135,271,105,102,50,192,156 }, +{ 291,141,349,373,372,82,15,260,351,120,922,854,326,217,318,77,450,1,352,898,93,269,523,102,202,21,203,144,13,64,23,304,5,752,137,437,32,51,473,98,704,247,180,177,317,237,197,342,59,457,947,817,494,316,76,33,719,615,300,961,12,36,968,954,475,386,367,268,165,115,86,83,69,67,48,39,22,2,851,341,275,210,201,110,662,576,418,403,391,365,284,241,194,116,105,96,88,54,44,31,7,730,485,205,125,40,117,875,873,864,661,579,498,490,482,468,393,332,308,244,221,190,185,169,160,128,109,100 }, +{ 141,217,352,115,269,180,317,752,341,244,13,291,21,77,23,197,365,5,372,165,51,64,237,349,48,9,4,304,482,102,32,864,28,318,247,137,11,202,308,33,39,98,7,3,1,498,351,125,2,468,437,110,10,82,490,253,120,100,88,954,515,177,93,901,31,12,401,201,0,49,922,72,203,569,55,30,6,342,260,143,22,117,898,717,44,89,35,153,144,854,128,36,386,350,101,68,196,40,373,221,134,96,206,873,391,316,288,241,164,160,105,16,90,579,403,326,645,629,523,421,284,116,65,61,961,59,24,18 }, +{ 78,47,390,108,130,711,813,19,453,412,27,283,730,444,690,196,250,123,236,128,389,503,200,650,183,14,59,4,26,65,472,133,73,34,381,297,153,51,177,57,269,11,53,318,33,216,719,17,194,630,680,322,619,114,113,368,714,46,684,803,432,56,77,29,657,6,480,141,117,3,445,22,603,122,42,235,84,361,90,899,13,64,23,102,249,2,754,524,605,457,99,63,0,475,349,789,40,38,588,210,18,152,106,134,678,436,24,10,25,597,50,529,291,594,401,52,245,95,402,894,129,266,86,471,339,119,523,137 }, +{ 250,297,34,80,472,495,311,64,53,17,667,61,148,27,56,483,469,136,90,73,141,161,45,243,194,3,106,597,527,176,128,751,352,151,436,62,86,874,738,4,209,153,833,491,881,614,396,32,383,84,26,76,445,231,95,5,659,14,887,237,29,378,573,431,947,196,405,58,23,255,119,117,65,11,113,59,33,719,134,814,292,287,57,177,721,240,12,585,611,247,269,51,22,283,200,498,2,583,304,180,19,145,312,165,678,205,202,10,835,349,72,217,114,514,40,555,315,588,137,130,37,875,389,197,207,179,0,13 }, +{ 51,23,551,421,453,13,33,102,77,21,326,153,401,958,308,120,615,196,5,48,202,221,115,692,523,791,403,899,342,4,801,475,210,805,260,107,450,291,966,93,730,576,32,117,842,541,468,18,1,16,203,116,110,697,60,96,126,121,386,68,31,40,2,494,259,125,463,407,137,154,24,704,427,373,218,180,92,10,575,244,35,104,64,175,302,628,351,318,197,160,98,71,817,770,743,670,612,12,859,158,17,590,199,650,7,945,815,752,346,949,851,717,642,597,473,439,402,367,253,252,217,146,56,44,6,3,36,847 }, +{ 98,223,393,363,411,834,478,664,1,691,791,284,156,447,724,914,759,697,293,354,541,807,51,586,421,48,948,668,765,848,264,195,9,163,658,23,801,18,125,551,21,386,96,340,772,909,682,963,730,698,31,453,360,13,371,949,905,770,520,5,621,781,221,744,271,296,116,202,647,857,132,70,118,335,821,44,656,842,367,897,719,121,167,446,32,69,457,450,318,101,100,670,379,638,127,634,144,137,410,761,662,217,846,758,146,401,932,615,75,777,883,538,87,165,33,225,936,591,286,93,166,269,197,812,326,141,105,919 }, +{ 232,7,107,92,14,46,135,172,359,220,314,278,60,5,171,192,2,526,16,620,21,262,52,75,35,32,126,294,29,872,24,132,18,77,246,87,448,571,230,48,1,54,12,58,38,236,50,606,247,86,23,70,177,112,461,298,121,380,97,71,37,888,217,392,66,279,150,356,155,64,13,20,441,108,678,304,751,572,147,226,115,334,140,61,291,785,153,739,579,43,451,178,146,186,947,437,387,394,90,51,330,195,194,875,307,216,352,597,587,357,117,0,269,181,45,603,349,210,199,137,415,128,267,95,366,315,156,31 }, +{ 32,76,2,241,21,14,292,1,476,72,48,5,45,720,50,179,270,214,46,89,90,29,148,129,464,155,17,290,519,38,227,460,205,123,245,350,243,358,52,184,54,257,171,710,249,408,7,400,186,221,405,513,3,36,162,618,12,106,37,288,181,57,502,413,0,263,10,428,316,99,281,207,6,229,4,58,152,64,115,425,430,769,67,741,119,59,22,128,659,308,773,183,23,202,96,86,431,83,75,62,141,9,524,51,16,103,328,645,69,237,497,255,209,217,130,11,24,496,666,28,137,403,528,18,247,536,452,77 }, +{ 15,77,33,102,13,23,51,117,4,32,11,202,40,90,0,1,5,141,153,247,177,128,134,214,288,21,137,269,17,453,3,318,291,403,8,110,82,180,10,59,165,494,22,6,342,197,457,351,64,475,260,9,93,2,120,523,326,48,31,217,115,57,421,386,12,373,44,196,16,19,719,730,25,139,96,352,341,36,961,49,210,317,349,203,125,194,401,18,275,7,24,28,98,817,285,898,365,95,308,901,450,30,99,661,372,86,223,65,854,615,922,402,56,899,697,758,208,103,14,237,116,105,569,37,304,221,704,638 }, +{ 66,74,135,69,6,380,278,267,97,14,2,29,1,75,24,87,324,52,150,38,335,138,357,189,204,172,67,103,25,388,85,7,462,220,83,423,108,550,149,71,603,42,733,571,696,174,26,582,140,36,458,565,16,808,895,802,486,46,238,35,19,70,298,21,18,114,65,226,22,86,60,418,32,251,192,92,64,451,280,273,500,309,95,594,222,501,12,50,5,145,563,398,353,0,889,28,443,48,607,711,641,517,112,262,336,348,37,125,580,596,906,705,622,572,10,160,81,43,63,54,58,133,792,68,620,124,165,294 }, +{ 152,471,4,339,59,188,79,77,11,377,128,94,529,102,33,202,402,111,12,99,51,216,542,452,291,40,474,342,210,196,13,141,184,64,403,37,453,153,134,318,17,177,117,494,23,961,139,5,32,76,431,3,300,257,205,757,497,115,401,275,269,10,229,179,72,475,21,2,86,90,14,57,89,349,1,0,180,157,285,277,148,629,137,266,197,38,36,304,45,217,485,6,498,678,129,405,700,95,569,245,437,734,247,460,22,413,313,352,19,372,775,308,421,292,880,48,237,143,769,503,358,873,488,54,7,618,710,386 }, +{ 15,1,196,0,33,13,2,77,5,10,9,102,217,23,7,6,3,12,117,14,4,134,177,153,40,11,457,291,210,275,22,730,16,115,18,165,21,386,341,719,120,82,180,64,197,51,141,523,317,8,569,365,450,202,32,961,372,260,28,349,342,125,352,95,37,31,899,351,17,128,318,269,48,110,49,403,19,93,901,59,475,401,72,326,24,139,36,65,111,61,237,758,494,90,99,30,854,304,817,44,482,137,391,56,509,898,437,25,308,752,98,38,629,247,76,922,421,86,57,373,670,26,253,70,203,221,801,579 }, +{ 209,106,17,207,45,255,119,655,5,742,306,378,61,62,136,425,263,80,311,84,240,29,790,2,58,56,186,32,3,383,738,243,454,592,869,76,151,14,179,129,290,123,48,72,440,148,21,52,292,64,90,504,287,667,214,46,1,128,54,408,507,50,476,34,27,833,549,57,38,548,155,227,162,86,241,19,70,152,89,205,6,334,171,26,496,483,112,183,181,141,130,400,249,59,245,266,184,555,663,75,270,358,77,229,361,37,215,95,445,4,297,10,211,25,33,666,519,881,11,257,202,73,710,269,237,40,221,180 }, +{ 120,450,260,817,523,15,23,1,51,326,98,13,202,82,125,64,5,351,318,21,31,269,457,32,116,93,115,165,102,77,33,12,95,922,719,30,494,110,44,615,128,48,14,180,141,36,2,730,61,9,137,342,403,899,197,86,49,10,704,551,386,237,8,203,96,83,67,37,7,177,291,352,90,22,18,16,402,196,153,373,179,144,76,39,17,6,961,854,475,898,692,401,241,207,148,105,100,65,50,20,453,349,344,3,217,901,678,341,293,263,247,210,99,88,69,45,40,11,958,801,317,132,126,107,35,24,752,661 }, +{ 116,268,492,918,93,206,203,940,23,51,551,417,523,499,473,959,22,421,8,125,791,692,730,120,31,401,949,10,0,13,899,165,44,386,450,260,867,453,64,9,629,115,36,719,559,341,728,170,55,137,599,299,197,615,569,180,457,28,391,141,1,326,685,301,564,479,475,338,506,86,509,105,638,202,95,817,308,242,253,762,244,2,373,801,670,127,901,21,49,870,951,5,558,237,143,269,37,752,239,12,642,922,403,873,7,352,4,758,365,318,128,18,965,456,32,320,221,14,805,512,317,498,961,16,704,98,33,898 }, +{ 15,13,165,23,197,4,0,1,180,12,11,117,5,8,82,901,719,341,2,120,51,9,523,260,509,7,3,730,141,386,10,450,351,6,33,752,758,134,115,498,352,961,317,365,153,898,14,899,854,64,217,922,873,22,569,326,93,128,817,31,269,237,291,202,21,110,391,37,801,615,28,318,17,457,44,16,77,18,32,98,99,36,49,30,349,401,453,403,102,38,373,958,35,629,116,40,137,125,55,19,482,203,304,242,86,546,474,96,24,144,65,308,475,139,143,247,210,402,89,54,69,177,196,48,485,661,83,734 }, +{ 14,24,69,66,7,108,2,398,267,150,67,97,189,29,149,74,38,71,36,6,83,52,273,388,140,1,135,18,46,172,602,65,28,124,429,302,154,380,336,451,547,16,278,114,732,68,484,324,75,733,92,175,103,118,22,462,0,25,251,357,86,596,55,160,87,705,594,35,60,531,133,467,423,711,236,95,650,109,458,443,298,21,886,5,50,138,26,12,505,238,168,309,314,42,32,10,646,220,49,70,335,192,232,906,420,204,48,20,64,37,43,603,13,19,533,96,85,23,565,51,330,226,550,221,570,208,283,54 }, +{ 330,335,96,839,523,662,367,443,615,418,141,403,717,244,692,576,922,372,1,352,269,217,752,349,64,498,36,854,966,180,822,831,954,873,864,317,284,291,776,201,318,144,69,98,351,678,7,21,5,160,77,203,83,82,442,137,551,2,260,223,622,187,494,44,13,385,128,202,23,475,75,341,901,48,31,437,238,304,247,230,765,93,373,120,393,22,67,251,371,293,125,661,342,859,285,898,163,365,30,32,450,29,110,459,326,934,51,10,197,842,851,399,246,189,800,421,237,0,37,116,221,165,16,579,127,9,321,88 }, +{ 184,257,205,90,245,229,769,524,152,432,497,619,17,57,5,452,32,45,381,266,106,2,59,21,179,4,292,217,313,460,288,1,214,129,14,76,77,3,128,216,48,207,471,339,157,141,710,11,202,38,64,519,369,6,61,209,12,37,119,79,99,123,29,317,72,188,7,62,255,33,58,162,269,247,40,54,102,115,177,51,618,372,476,318,10,89,137,86,249,148,241,263,180,316,352,402,50,403,655,155,19,210,23,94,136,291,308,349,358,237,453,377,111,56,139,425,365,27,341,46,143,277,401,153,588,221,0,186 }, +{ 7,14,16,46,107,32,35,24,70,60,23,307,172,5,18,2,38,87,92,58,13,21,20,10,177,51,202,77,135,48,37,128,0,97,232,115,171,112,126,43,9,220,140,318,12,141,102,71,852,155,4,54,291,22,90,1,269,52,163,33,137,298,192,28,66,64,217,356,61,132,294,278,359,147,349,461,95,29,45,609,448,121,259,186,314,76,474,304,362,17,108,6,150,415,59,400,780,146,36,342,31,275,67,86,246,402,334,279,678,75,247,50,620,30,409,502,39,372,72,49,230,40,494,227,69,465,872,68 }, +{ 140,66,97,172,92,7,267,189,14,314,16,69,298,380,60,135,451,230,150,35,24,71,74,357,423,232,330,38,324,246,192,443,278,563,2,572,877,550,462,126,448,52,893,508,67,501,6,568,29,21,603,46,565,607,83,388,204,633,22,279,18,149,723,733,399,65,48,1,95,64,526,915,5,32,726,28,75,36,841,25,350,87,138,108,68,500,895,10,43,0,251,808,125,104,12,426,49,81,50,20,37,309,517,674,86,802,174,107,103,653,173,582,220,226,85,387,26,55,712,903,241,197,121,237,262,54,711,191 }, +{ 121,167,354,212,132,407,191,107,147,146,271,199,101,446,126,647,195,35,259,18,16,60,55,20,590,465,43,411,68,363,178,198,142,562,9,427,463,92,640,14,346,7,727,798,941,520,364,325,815,5,581,13,1,621,21,23,522,534,0,589,279,158,28,806,706,125,439,109,98,97,118,48,22,694,955,393,604,362,150,932,608,51,105,33,252,165,234,265,108,49,598,156,96,419,818,10,467,197,154,493,12,765,376,120,70,786,169,777,967,102,687,38,202,32,682,246,64,39,31,447,781,612,58,159,61,260,40,450 }, +{ 76,90,460,205,179,257,245,32,288,184,21,45,769,358,316,524,229,241,152,5,57,48,497,2,476,148,720,619,452,266,72,155,1,17,38,432,14,54,243,290,292,227,449,381,12,4,89,247,50,29,313,645,270,59,350,11,129,216,51,217,106,157,221,128,99,58,37,471,64,188,77,214,408,339,141,115,186,3,369,23,52,202,79,46,428,425,308,6,317,464,7,255,405,162,413,33,171,519,496,372,365,341,269,401,10,0,94,36,137,875,318,263,237,62,588,352,123,474,181,431,40,177,291,180,102,61,207,618 }, +{ 147,259,427,178,798,581,878,786,198,534,465,325,929,142,362,20,376,43,107,771,35,481,132,470,234,5,626,146,590,279,97,522,49,70,77,345,21,199,640,450,612,202,13,48,14,102,150,0,33,725,595,846,941,23,22,7,58,195,423,660,501,121,687,126,518,260,117,904,120,858,953,39,342,60,455,1,196,165,125,158,105,159,246,92,28,153,10,31,360,315,346,271,761,683,603,212,18,298,128,711,167,379,318,113,623,817,95,32,291,61,16,134,72,359,108,221,197,115,98,163,767,523,493,191,329,30,87,50 }, +{ 473,778,450,203,855,144,93,617,30,704,141,466,530,330,372,459,201,326,934,321,88,839,254,36,505,403,128,559,83,120,523,217,86,213,131,613,717,110,332,728,344,251,264,352,686,434,82,39,578,317,206,35,625,435,44,795,840,961,539,274,244,116,137,55,662,265,228,863,577,406,96,924,601,564,417,384,351,341,225,95,49,28,800,418,21,831,719,531,367,219,202,31,64,822,224,335,960,968,922,854,829,688,365,197,22,160,410,165,873,752,716,518,456,347,242,125,731,269,180,948,498,478,349,237,98,77,33,9 }, +{ 523,475,899,730,453,51,23,403,719,13,421,457,33,386,196,817,801,4,120,117,153,11,450,260,102,202,515,361,670,165,758,494,125,108,128,961,283,236,99,21,3,880,5,401,32,59,77,543,615,10,6,318,402,221,183,137,650,57,40,7,2,1,90,847,412,247,241,210,207,115,12,208,181,150,133,114,63,42,467,775,389,342,111,56,39,31,30,28,22,9,0,576,558,304,229,216,177,152,123,113,47,29,25,958,554,391,629,968,967,966,965,964,963,962,960,959,957,956,955,954,953,952,951,950,949,948,947,946 }, +{ 1,5,15,2,13,0,7,23,10,3,317,341,6,9,4,365,11,115,33,180,217,77,17,64,197,165,102,117,141,40,14,21,51,32,134,12,8,291,901,752,16,569,22,509,352,237,482,372,143,18,498,153,457,59,128,349,269,125,202,177,961,546,31,391,342,196,45,36,873,57,38,28,37,86,48,386,24,19,139,318,111,95,29,44,403,27,719,304,120,41,110,629,93,72,164,275,61,55,253,99,56,90,49,137,730,210,864,758,35,260,76,50,579,116,94,300,221,26,25,277,326,98,54,475,453,30,79,244 }, +{ 19,119,40,4,27,84,77,56,202,73,102,59,757,33,485,26,300,210,504,494,128,80,862,23,402,63,42,139,880,342,129,32,5,361,25,13,196,51,12,11,2,99,21,6,153,469,123,10,710,53,65,618,64,161,117,736,90,38,22,106,17,803,95,76,0,45,37,14,548,813,250,245,108,297,453,378,162,57,113,460,403,611,255,205,256,383,217,1,235,114,86,742,209,152,292,630,576,240,343,790,667,475,16,48,133,122,18,136,134,85,115,15,283,34,179,436,180,78,29,9,200,605,561,318,49,269,684,495 }, +{ 32,20,13,21,2,38,5,43,29,23,61,12,52,115,90,6,202,37,64,48,95,207,51,81,66,7,25,49,17,74,26,76,178,147,98,46,362,54,22,63,19,14,0,259,128,577,125,97,58,91,77,56,182,65,197,465,376,27,141,427,316,1,241,291,113,878,217,247,312,137,120,4,858,481,142,595,165,31,237,93,230,379,534,482,180,116,86,72,42,11,44,203,263,470,356,352,279,102,84,40,33,687,626,835,786,107,683,260,18,318,24,414,298,468,367,326,304,216,117,105,99,3,933,612,415,347,501,344 }, +{ 339,188,11,377,79,4,99,94,12,542,102,111,474,37,51,33,471,453,152,40,475,342,77,403,59,196,277,139,153,57,134,117,13,775,229,128,401,38,880,23,210,64,184,202,431,115,961,157,300,3,266,72,485,402,89,629,21,54,15,129,177,76,14,162,32,17,216,10,148,275,269,5,757,452,361,477,141,90,205,313,569,494,2,65,179,120,257,381,421,237,197,405,86,488,328,36,318,48,22,137,165,413,50,308,0,1,341,130,82,95,49,457,161,543,245,18,304,260,62,45,285,180,291,41,529,498,125,56 }, +{ 128,283,503,34,318,529,432,176,495,275,231,412,527,291,402,161,381,202,59,3,389,469,177,803,53,585,216,14,269,57,200,17,73,472,27,56,250,136,678,4,152,51,862,361,80,245,11,789,619,194,123,719,401,23,714,84,507,210,77,12,65,322,106,99,436,130,129,46,62,2,13,38,162,369,236,108,33,183,133,457,153,64,483,211,297,741,514,403,114,18,629,961,378,555,440,119,383,597,475,29,453,229,40,165,240,215,196,655,611,556,21,249,117,54,667,134,102,308,814,19,50,86,391,22,0,197,95,26 }, +{ 15,217,13,341,317,141,365,115,23,51,180,349,291,1,120,77,260,269,202,137,21,5,450,352,373,110,0,372,64,33,36,128,177,4,318,351,102,9,197,2,304,854,10,901,7,12,32,165,326,752,40,244,922,160,96,22,523,117,11,48,16,86,661,90,457,82,386,494,403,308,59,28,55,253,247,18,498,134,8,143,153,221,14,6,83,30,196,93,3,37,615,453,401,898,421,817,24,95,961,285,475,719,873,17,35,39,391,730,125,67,237,49,98,811,704,642,717,216,203,69,482,99,342,402,851,50,57,569 }, +{ 13,961,15,4,11,12,457,51,3,37,2,197,5,10,569,99,115,23,6,72,89,14,0,1,134,7,59,33,40,38,165,111,196,76,405,79,139,117,148,498,873,339,719,300,277,485,17,471,157,152,128,21,94,431,32,177,188,509,474,64,45,54,482,730,153,36,629,386,41,22,28,141,901,864,18,180,77,523,9,401,678,437,102,304,210,308,16,775,579,48,31,317,179,413,365,758,352,57,24,341,86,752,546,137,58,318,245,44,27,402,95,899,19,108,269,216,202,49,184,110,93,954,880,56,55,452,358,8 }, +{ 15,13,1,2,0,5,10,23,33,9,7,3,4,6,12,102,115,14,11,217,51,117,77,40,569,153,341,196,317,18,457,22,8,16,961,197,719,180,64,365,165,730,120,134,21,141,899,202,82,31,523,291,125,372,386,28,17,139,93,349,128,304,269,177,110,482,32,342,111,37,318,95,453,579,36,901,59,24,352,450,44,437,137,403,49,260,401,210,237,247,326,817,494,98,99,57,752,19,48,203,30,86,351,485,758,116,402,391,26,898,308,38,27,25,275,801,498,854,65,56,629,76,90,300,922,468,144,35 }, +{ 76,292,5,214,45,32,2,519,710,460,129,179,29,1,90,58,123,249,464,207,205,618,17,14,245,257,72,61,48,263,106,21,358,425,769,241,119,52,184,6,162,186,50,46,38,7,655,148,209,243,128,255,3,155,288,183,290,64,141,454,227,89,77,476,54,115,4,25,59,19,57,229,36,202,269,408,152,99,70,151,130,86,177,75,592,216,720,62,318,12,217,40,26,10,37,27,496,306,33,247,524,311,316,56,497,350,84,51,137,171,790,102,270,23,0,112,11,22,16,452,334,237,432,402,96,180,95,449 }, +{ 76,32,72,21,38,4,54,89,57,17,179,12,14,99,148,45,23,59,51,90,488,3,11,241,401,2,428,37,543,152,205,528,453,128,5,421,13,115,129,77,10,474,245,184,350,670,449,413,1,569,137,79,403,629,475,328,308,221,155,464,0,361,123,743,202,460,214,257,33,40,64,794,292,165,405,770,805,41,476,62,162,270,229,358,86,285,36,402,775,316,341,94,197,50,576,106,431,720,46,29,540,217,139,773,119,838,48,15,216,181,657,177,290,514,288,7,457,227,961,9,22,102,247,828,6,141,365,180 }, +{ 98,223,393,1,834,284,791,264,697,724,293,909,772,905,541,478,51,821,807,363,897,48,682,421,765,447,411,730,801,410,163,948,386,96,9,31,963,23,21,691,664,453,125,5,382,100,13,521,949,551,656,44,116,770,686,670,639,221,39,367,914,265,166,144,719,335,812,848,371,0,101,842,318,321,127,88,252,520,662,329,354,32,759,438,33,698,93,202,593,201,286,156,450,658,281,115,165,49,401,120,604,586,82,2,22,36,225,217,77,744,10,498,141,102,615,180,118,435,69,30,921,404,326,197,433,475,83,70 }, +{ 341,13,23,509,762,638,569,242,901,629,165,8,197,873,10,961,506,456,391,499,116,338,180,457,492,206,12,51,115,268,143,365,951,1,93,965,642,867,417,37,2,253,546,64,5,203,3,498,758,752,719,0,401,15,352,44,31,7,36,244,86,4,141,386,734,237,6,22,308,730,55,844,164,918,473,326,125,82,564,949,898,551,940,791,120,38,9,260,523,137,661,373,559,110,14,854,959,615,317,11,54,33,102,692,269,99,351,903,89,870,740,217,708,170,824,40,801,728,864,817,717,160,128,28,117,776,479,77 }, +{ 818,230,755,443,352,420,1,2,244,50,14,5,38,46,29,36,114,218,65,96,22,133,52,181,58,0,17,28,21,103,75,54,45,86,67,175,48,171,7,12,323,137,24,285,208,51,487,6,283,18,10,70,23,155,32,83,194,361,3,503,163,389,328,128,223,37,803,532,16,19,168,735,69,13,124,61,202,160,186,433,9,115,484,27,236,514,238,782,95,25,754,108,64,657,112,141,281,220,412,289,55,756,401,394,584,151,308,49,545,851,822,4,227,717,866,334,269,646,403,402,26,400,87,35,745,366,99,143 }, +{ 481,878,32,202,5,21,23,269,13,318,494,142,77,51,70,1,182,557,141,137,33,291,58,178,415,465,61,48,590,259,922,115,2,929,640,403,207,884,4,260,120,87,817,626,534,349,342,102,195,0,132,351,59,427,252,109,35,7,961,678,345,247,153,72,845,158,169,49,12,10,6,196,112,798,450,687,279,841,713,475,457,128,40,146,28,3,416,290,265,75,767,854,771,947,795,753,704,637,631,597,592,581,546,509,493,354,352,341,326,316,288,285,241,237,212,197,159,90,54,52,46,38,37,36,17,14,39,9 }, +{ 15,1,5,4,2,13,11,341,0,3,7,12,10,6,21,365,9,180,32,134,317,197,33,23,37,117,40,165,17,77,217,498,8,752,153,901,64,102,569,141,873,51,14,961,196,115,59,110,352,509,22,128,57,111,120,143,125,72,38,48,372,36,291,308,349,99,139,31,90,202,260,269,457,44,16,89,76,49,55,401,342,237,27,93,177,94,82,18,45,29,326,28,19,386,221,351,137,86,277,546,391,41,50,35,403,453,54,164,318,719,474,629,373,203,98,95,475,854,253,304,148,24,450,244,56,758,542,300 }, +{ 25,26,119,42,19,6,27,45,122,84,469,4,17,790,814,113,80,76,59,73,483,2,29,611,128,32,202,40,1,77,90,862,106,56,209,33,240,0,684,136,102,14,292,416,5,311,11,504,196,318,123,680,378,255,12,129,161,22,690,151,53,117,63,179,667,10,85,72,61,115,65,210,402,396,57,141,64,614,134,757,153,137,62,18,99,445,51,269,66,177,7,3,24,710,256,648,36,655,235,38,23,306,58,618,70,491,48,454,21,403,742,361,49,34,86,494,275,383,342,28,300,145,13,74,112,52,297,245 }, +{ 14,7,24,2,1,16,69,6,38,67,108,22,65,28,124,0,46,18,29,86,66,35,83,5,71,398,36,12,168,289,140,95,610,189,150,149,10,21,92,756,52,302,23,109,97,20,584,25,50,267,194,64,49,51,32,60,103,55,505,13,429,172,128,273,420,158,37,458,19,547,118,48,75,115,137,74,135,9,185,164,143,388,154,202,26,701,650,251,133,336,17,114,169,68,230,236,43,54,141,244,671,253,703,105,208,90,3,160,159,278,99,462,314,403,380,87,389,175,357,324,484,318,232,708,125,799,451,886 }, +{ 128,51,202,23,141,120,403,15,64,13,318,82,10,269,99,33,12,197,475,453,260,153,137,165,196,0,3,402,351,5,494,1,22,14,110,117,180,102,93,17,2,31,37,38,125,9,326,450,49,21,86,44,401,457,7,6,36,352,115,18,77,523,237,28,134,95,285,386,421,719,32,48,342,98,11,54,203,730,57,341,961,373,139,8,854,361,757,111,898,45,4,40,308,194,65,16,922,277,41,880,678,116,291,24,498,19,27,391,143,56,217,899,59,569,30,79,365,775,50,503,208,55,144,817,61,105,901,94 }, +{ 16,24,35,18,71,68,9,0,65,189,1,7,133,50,69,149,60,28,103,101,108,537,67,118,230,75,114,23,335,55,167,21,124,92,12,191,181,433,13,39,140,5,14,48,223,64,212,96,51,218,443,281,487,154,141,163,22,217,99,37,70,565,2,115,49,267,58,54,394,766,46,246,545,83,30,128,10,330,820,202,32,361,137,622,125,238,237,100,121,77,165,412,175,87,143,352,399,171,317,86,126,745,146,486,418,177,36,291,269,318,283,336,105,302,398,695,4,98,197,180,31,345,251,271,109,309,430,38 }, +{ 50,2,1,46,14,29,38,52,171,67,5,58,103,96,36,24,218,133,223,83,114,236,45,70,54,181,163,186,108,155,75,28,65,238,334,151,18,433,160,745,328,0,366,112,532,48,516,17,514,61,832,400,281,21,227,22,760,19,6,69,754,766,412,12,7,309,545,409,27,361,283,137,16,220,675,480,55,86,765,822,502,552,32,10,307,99,956,285,25,113,9,398,323,37,51,800,26,388,394,64,891,128,124,243,549,828,3,458,194,208,35,646,95,262,23,311,150,966,820,866,894,149,13,115,87,430,80,287 }, +{ 21,32,5,76,72,14,17,2,3,38,54,89,45,51,1,12,23,4,10,48,90,137,36,148,221,401,22,0,421,179,115,86,99,543,11,453,13,37,128,270,46,241,285,29,290,64,428,57,6,361,202,59,540,50,403,328,114,475,528,65,155,449,77,308,794,569,181,7,805,27,40,141,292,133,33,576,263,129,514,205,341,9,413,350,208,19,838,629,323,28,430,480,119,657,474,214,741,123,245,402,102,720,15,770,476,408,494,56,425,106,269,62,207,775,243,152,477,670,180,318,197,405,165,95,58,281,18,697 }, +{ 434,384,268,144,940,855,617,206,959,911,332,116,93,203,137,489,282,244,141,120,36,44,160,269,253,367,110,450,10,127,202,276,417,219,98,258,326,131,260,31,64,373,201,9,187,318,692,473,22,224,523,817,143,86,352,1,55,30,23,51,28,295,567,105,559,499,261,717,811,0,125,951,180,8,115,13,217,128,551,39,165,49,96,341,284,77,21,851,728,564,662,498,317,386,752,48,351,531,5,642,365,197,83,661,237,615,800,291,242,15,170,164,494,82,95,638,704,349,37,854,228,7,32,24,935,968,35,16 }, +{ 2,5,1,15,7,13,0,10,6,3,180,217,23,9,141,11,317,4,341,17,352,117,197,14,77,33,64,165,134,365,115,12,102,752,237,40,498,153,291,32,372,51,22,21,8,349,901,269,16,196,457,45,569,128,36,143,59,57,509,125,27,38,19,342,86,202,864,873,120,31,546,318,110,37,28,961,29,164,177,95,48,244,111,137,93,391,18,719,139,44,49,82,386,629,54,24,482,56,99,26,453,260,50,579,76,25,304,35,98,253,326,41,55,277,210,72,275,30,730,437,90,523,403,203,351,61,79,450 }, +{ 113,25,2,29,6,833,45,61,145,7,32,74,151,0,42,1,210,128,177,5,19,4,72,14,64,106,655,59,22,122,26,112,174,66,40,77,738,209,525,402,138,90,148,20,483,104,684,141,51,76,17,27,425,18,21,416,23,10,202,95,16,255,52,13,115,624,318,137,102,311,33,269,85,81,49,887,87,746,544,491,275,86,119,790,454,690,65,24,9,222,216,665,291,117,80,204,58,243,134,48,476,814,217,46,349,287,70,28,285,43,348,36,84,342,11,757,194,91,207,315,31,38,73,153,192,355,135,300 }, +{ 116,268,918,551,203,692,31,940,403,791,421,206,417,93,499,523,299,44,8,473,23,51,805,22,13,450,120,475,202,0,959,730,386,125,599,326,137,9,10,401,899,105,1,576,817,559,453,564,165,393,494,21,28,36,456,5,127,949,64,670,728,638,391,242,685,2,260,762,457,197,180,615,569,141,170,253,308,963,49,115,341,492,55,143,719,479,873,37,18,4,86,7,77,506,48,244,801,867,95,318,269,901,512,98,951,33,6,301,958,642,338,30,352,870,39,221,365,12,16,395,373,24,237,629,164,102,159,239 }, +{ 107,612,126,132,362,146,259,199,279,660,493,590,121,20,939,683,534,43,147,941,376,35,595,953,649,581,60,470,640,955,356,522,5,97,195,150,407,49,465,16,92,14,7,687,359,298,22,858,246,0,13,360,21,48,18,427,271,167,423,191,10,441,325,392,32,598,929,28,33,31,178,414,1,77,232,173,55,230,156,125,24,68,23,95,345,4,904,626,105,212,319,98,786,783,70,61,202,142,44,702,58,71,40,314,37,198,51,64,2,623,163,159,819,93,446,158,59,346,357,12,501,118,260,46,663,116,120,102 }, +{ 15,13,1,2,0,23,5,4,3,77,102,33,10,51,6,7,9,115,341,12,11,217,342,317,14,117,40,22,365,180,120,8,569,18,196,165,457,141,21,210,197,64,177,31,291,153,16,961,59,523,817,453,719,450,134,730,93,260,352,44,269,275,49,386,401,32,901,110,82,28,17,629,125,349,139,475,899,24,128,37,326,111,752,95,202,36,318,403,372,498,216,90,308,247,30,98,482,137,86,237,116,615,300,48,65,203,19,57,351,55,391,509,99,38,734,922,468,244,144,221,854,304,579,373,39,143,758,148 }, +{ 53,27,161,17,469,73,378,527,136,250,383,19,862,495,62,26,56,200,297,106,84,585,440,80,34,14,436,128,119,45,4,3,472,123,129,813,504,240,483,361,59,444,205,65,611,5,202,548,108,255,742,514,283,78,814,113,179,162,690,57,402,183,38,555,714,6,245,390,122,54,42,803,184,25,61,33,630,318,209,12,194,64,77,684,11,141,328,757,503,269,99,236,2,102,389,51,22,618,176,152,257,453,47,21,48,210,86,680,40,381,148,133,217,880,650,215,46,10,130,377,18,0,412,497,23,114,13,229 }, +{ 209,45,17,106,207,119,5,255,454,243,263,425,290,655,306,186,84,29,62,61,2,408,136,58,742,378,21,56,311,240,3,592,48,32,383,50,52,80,227,790,270,46,171,14,72,440,148,287,334,76,659,400,666,179,504,496,869,64,155,241,129,1,123,54,38,214,738,75,663,162,90,141,89,221,151,292,57,358,237,507,513,130,34,548,152,70,205,37,128,183,211,184,667,41,229,328,476,266,115,555,181,86,549,405,6,281,163,269,215,12,96,245,11,220,502,720,257,36,313,430,288,180,833,40,202,165,449,27 }, +{ 152,4,452,59,128,471,529,339,79,216,11,188,377,77,291,202,318,94,102,402,32,33,99,5,90,51,269,76,349,12,184,257,542,474,17,177,111,141,37,21,342,210,23,205,275,678,13,72,403,38,285,3,2,40,64,229,588,57,10,769,494,48,134,45,372,196,117,217,129,6,497,1,148,460,757,245,453,475,0,137,153,157,89,139,7,115,961,292,179,498,304,524,266,197,14,629,431,477,405,775,288,437,180,15,165,214,237,86,401,308,119,123,54,22,221,120,9,162,27,619,300,62,317,316,31,488,277,880 }, +{ 15,1,2,5,0,7,3,4,6,13,23,115,9,12,51,180,8,317,197,10,961,901,11,22,77,21,752,33,202,141,110,341,14,16,217,134,120,102,31,165,365,40,93,269,457,352,64,44,28,18,37,351,260,117,569,82,308,125,32,196,49,36,153,719,128,482,318,99,17,401,326,137,450,403,203,111,177,730,386,291,55,873,523,373,98,30,237,24,453,89,48,95,221,475,39,59,116,372,349,105,144,139,509,143,72,96,758,391,898,494,854,86,342,899,210,629,57,468,247,90,304,65,148,83,817,421,160,20 }, +{ 951,752,638,811,642,253,351,180,10,197,341,901,873,352,110,244,143,762,165,8,898,55,564,141,15,365,854,499,82,137,417,498,509,36,535,922,479,559,206,661,373,317,282,115,31,22,338,160,93,569,164,260,717,217,391,86,533,33,44,1,28,9,242,965,728,120,116,77,64,968,21,102,203,125,37,117,506,30,13,386,5,4,531,269,40,911,153,23,0,169,384,2,326,372,105,196,851,170,134,109,704,332,268,349,96,127,48,291,32,758,237,318,24,177,202,35,11,961,401,39,308,83,3,629,51,210,12,434 }, +{ 6,197,350,74,262,841,509,26,47,115,13,196,583,903,165,4,235,138,50,308,21,130,749,324,675,19,38,331,391,145,711,569,33,75,241,453,734,64,153,223,52,558,236,468,99,220,34,70,112,11,117,546,237,125,3,27,32,1,42,134,409,51,78,25,163,29,14,648,23,645,180,820,46,2,85,108,65,773,802,624,122,394,341,785,22,730,95,386,606,57,412,247,923,316,66,498,357,221,630,133,457,59,853,90,53,226,873,632,48,113,719,629,45,889,17,307,141,766,69,12,37,444,83,171,54,600,5,765 }, +{ 125,391,165,867,558,386,221,758,23,457,21,51,13,197,401,308,963,115,961,97,719,77,791,743,451,603,949,48,180,670,770,341,89,120,730,352,291,148,450,426,607,304,7,403,393,66,64,350,316,217,134,135,14,421,74,247,177,50,380,24,696,236,172,87,629,10,141,475,144,35,901,801,523,453,138,509,467,456,241,210,150,98,18,565,357,267,103,582,545,342,301,278,237,216,20,16,99,69,903,650,551,412,389,283,81,32,298,739,543,498,370,365,317,309,300,260,170,140,116,85,52,37,33,30,25,5,273,203 }, +{ 14,1,46,2,24,16,38,50,5,69,58,35,7,75,18,67,54,48,0,155,513,171,163,61,103,45,29,52,430,270,37,223,21,70,12,28,9,780,32,267,60,290,83,227,71,36,666,767,22,189,140,807,10,72,96,65,108,181,64,186,220,309,17,335,92,394,23,592,243,89,536,663,115,281,51,6,474,55,68,112,141,400,128,133,87,13,425,99,741,236,95,675,278,230,76,221,114,86,263,113,820,552,502,27,269,202,49,760,537,149,262,328,408,90,366,137,150,207,77,357,315,307,218,241,19,148,25,66 }, +{ 23,51,13,115,453,12,0,2,4,10,403,1,202,5,401,475,15,21,457,59,77,165,9,3,37,99,32,11,197,719,308,6,14,64,7,569,17,629,961,318,180,22,33,494,120,18,730,141,40,102,269,217,177,57,16,128,523,450,341,8,90,421,386,237,28,48,125,19,117,31,247,402,72,210,899,221,260,291,134,89,342,317,365,509,38,24,391,216,352,468,817,153,54,36,45,49,27,196,56,326,82,65,76,304,349,139,50,25,86,275,44,137,482,372,670,498,26,734,546,62,95,758,29,41,46,93,351,79 }, +{ 129,84,17,27,56,495,80,378,19,548,123,162,161,53,469,618,73,26,504,106,40,257,205,59,3,183,184,862,4,136,62,6,128,202,14,77,11,65,769,5,527,108,45,57,383,361,2,497,250,249,200,130,23,34,22,90,402,483,245,240,12,51,214,38,0,139,25,99,64,318,102,152,32,210,300,10,297,757,21,494,880,775,114,710,111,33,54,29,460,403,452,36,42,133,18,61,86,141,436,177,814,269,13,194,119,179,49,28,342,453,217,95,115,514,229,556,76,137,37,1,742,283,485,401,503,488,475,24 }, +{ 28,109,49,9,22,67,168,158,39,185,159,420,1,55,0,83,35,95,194,272,86,105,69,103,36,114,169,327,50,254,208,175,65,584,286,323,535,346,251,345,797,30,131,756,374,12,333,533,128,2,218,68,96,133,344,160,101,23,64,289,7,597,189,24,646,577,874,896,13,5,601,51,46,503,531,837,16,238,747,627,115,14,347,10,98,310,789,137,124,21,202,127,164,578,54,799,141,154,230,532,547,31,312,708,285,480,37,810,637,596,48,143,336,100,389,835,252,439,237,38,518,912,219,424,44,239,253,868 }, +{ 242,391,456,116,23,13,492,8,51,341,401,165,93,206,499,457,867,338,268,569,417,509,386,22,1,762,479,638,10,629,918,758,64,551,203,730,901,719,12,31,197,791,115,5,86,14,125,949,0,559,37,2,642,951,873,959,237,961,692,55,170,752,870,120,44,180,940,9,141,564,523,3,308,36,7,4,15,899,450,365,728,137,21,473,253,898,558,143,128,453,740,164,801,260,903,6,685,202,403,670,965,54,114,28,854,326,817,844,352,95,82,498,11,923,244,98,299,922,239,110,38,317,105,599,373,661,160,99 }, +{ 211,162,248,130,556,57,507,4,305,266,183,41,152,361,11,229,129,471,62,38,377,313,300,514,77,339,184,157,381,59,128,452,99,3,328,40,202,123,54,210,440,494,369,555,342,136,117,542,402,757,64,548,139,23,196,188,880,457,775,33,153,56,14,102,432,13,177,205,257,497,17,12,37,291,51,89,403,215,961,111,141,90,349,216,488,269,485,803,477,180,165,115,10,475,437,383,79,197,95,21,84,134,503,421,86,453,318,308,1,670,76,194,719,618,106,32,629,15,730,65,22,5,245,94,214,45,482,288 }, +{ 92,7,97,298,140,16,126,232,314,60,246,279,35,173,230,71,107,14,43,508,423,150,779,653,441,607,66,189,359,501,24,362,20,172,104,387,356,21,48,38,18,399,199,330,5,674,192,877,81,191,729,517,74,672,426,939,560,633,0,267,2,649,69,121,149,392,324,135,462,22,95,29,46,52,125,598,37,723,707,49,10,357,68,345,6,32,830,98,64,1,702,380,118,28,900,12,695,251,861,885,493,783,603,146,65,715,61,55,278,36,236,273,138,33,75,25,31,124,175,221,293,83,165,763,712,451,414,319 }, +{ 15,1,2,5,0,7,13,6,23,9,3,12,180,4,51,115,8,901,457,117,14,165,22,341,82,120,141,10,37,197,961,31,21,11,202,351,64,260,77,365,110,16,134,28,217,93,269,33,44,36,569,18,719,308,450,317,128,102,125,137,32,629,153,98,401,55,352,30,318,373,49,116,898,730,48,17,752,523,196,237,386,24,95,86,326,403,291,99,453,40,39,72,38,177,89,203,873,391,144,247,349,498,899,59,734,90,475,372,54,494,421,143,482,304,854,105,758,35,210,65,76,244,160,216,221,83,45,546 }, +{ 403,18,0,102,25,523,64,6,91,85,42,74,342,32,24,13,51,306,95,49,22,33,475,151,681,880,421,128,899,750,397,214,122,757,730,77,28,519,288,247,23,5,817,805,317,879,861,673,273,177,145,21,120,52,283,81,275,701,577,453,104,59,202,193,697,636,401,287,249,216,207,196,180,165,138,125,123,118,90,84,60,48,43,587,260,389,16,10,4,1,351,326,318,933,804,635,498,280,237,197,186,172,153,148,137,134,117,99,61,29,9,671,289,958,838,814,579,312,238,124,65,56,847,719,654,650,457,424 }, +{ 56,65,554,33,561,18,84,123,63,64,343,194,0,90,49,22,6,27,19,289,240,129,73,659,431,214,475,523,370,368,233,899,701,287,257,95,85,28,102,183,736,650,467,256,153,25,207,124,108,80,32,24,120,26,389,874,718,635,51,525,891,752,751,730,648,614,498,496,450,249,237,209,184,177,162,114,59,45,29,235,77,42,817,497,444,137,112,74,53,352,511,681,630,643,196,947,942,847,764,719,696,651,615,610,603,602,543,457,412,386,337,326,312,288,262,260,247,227,226,179,152,139,134,119,117,105,86,76 }, +{ 127,98,31,293,299,395,44,9,105,0,49,599,284,28,276,116,242,685,159,456,22,763,125,935,272,492,158,1,623,393,109,144,201,39,36,95,18,51,24,320,137,23,286,55,16,512,916,489,202,21,662,301,268,367,327,371,35,761,567,13,434,65,7,101,918,616,2,5,141,737,506,870,12,64,131,68,30,48,900,948,86,128,295,10,219,239,269,910,403,627,338,578,143,14,37,124,160,203,318,384,170,244,165,261,96,347,254,713,963,168,457,237,187,93,67,154,421,221,253,401,344,424,164,479,6,386,83,855 }, +{ 1,14,5,2,46,50,38,58,171,61,45,155,7,48,69,270,290,24,21,29,75,52,16,67,54,666,32,663,227,72,502,0,425,223,18,592,89,17,35,243,37,207,76,186,103,263,36,163,96,83,741,6,408,10,400,22,181,28,9,428,12,536,64,221,220,70,262,281,23,267,115,106,65,807,292,309,119,148,474,449,394,128,141,86,241,3,655,430,51,189,476,140,431,541,587,95,334,738,675,90,114,13,780,108,71,720,19,133,27,202,335,413,4,767,112,77,25,405,513,179,659,99,218,787,55,180,528,151 }, +{ 23,51,13,453,457,12,719,401,961,4,629,730,99,475,115,2,11,14,403,17,40,5,15,165,1,3,64,0,10,57,33,21,77,569,32,50,37,308,7,386,9,16,38,670,197,59,41,217,128,494,46,6,758,62,22,775,65,45,18,86,48,29,72,899,514,361,328,139,102,247,153,54,56,421,468,79,523,95,108,757,196,52,19,317,117,482,342,341,24,734,509,210,202,180,177,237,488,402,114,36,134,880,76,498,90,275,111,34,28,291,67,20,474,120,743,125,82,391,130,752,490,437,405,318,277,27,141,89 }, +{ 968,967,966,965,964,963,962,961,960,959,958,957,956,955,954,953,952,951,950,949,948,947,946,945,944,943,942,941,940,939,938,937,936,935,934,933,932,931,930,929,928,927,926,925,924,923,922,921,920,919,918,917,916,915,914,913,912,911,910,909,908,907,906,905,904,903,902,901,900,899,898,897,896,895,894,893,892,891,890,889,888,887,886,885,884,883,882,881,880,879,878,877,876,875,874,873,872,871,870,869,868,867,866,865,864,863,862,861,860,859,858,857,856,855,854,853,852,851,850,849,848,847,846,845,844,843,842,841 }, +{ 2,1,29,103,75,52,14,67,46,309,6,83,70,238,38,24,108,220,218,133,74,96,262,36,114,87,388,26,50,25,366,236,69,160,112,5,65,58,66,394,19,145,226,7,532,135,163,42,18,45,150,545,458,433,891,331,357,594,17,28,412,27,294,418,86,278,21,124,398,149,732,894,324,537,283,223,273,222,71,12,606,739,16,646,547,138,267,48,696,171,137,151,0,175,602,800,22,37,487,181,99,208,32,194,287,785,336,64,23,13,113,55,95,335,54,97,323,154,61,711,128,68,302,118,10,308,600,484 }, +{ 7,92,71,97,140,60,150,16,298,24,189,230,14,149,423,35,508,314,18,43,279,232,66,399,273,246,251,38,607,69,126,172,517,674,2,173,28,375,74,467,104,68,0,809,20,823,336,118,267,175,135,108,191,154,21,345,501,796,36,52,125,653,29,81,330,107,124,362,356,6,387,55,359,46,779,302,192,22,5,575,48,67,877,462,10,388,441,9,566,723,783,221,1,65,49,398,101,37,278,702,83,91,357,705,392,12,109,121,236,426,380,32,212,695,443,86,596,103,868,608,560,165,830,167,13,558,25,541 }, +{ 51,23,202,120,141,13,1,260,128,21,269,450,77,137,318,48,115,165,15,32,102,5,197,64,180,494,82,351,326,125,291,817,12,349,342,98,523,403,203,93,7,33,854,352,2,31,14,719,457,6,110,144,44,4,386,177,730,96,116,308,99,221,9,217,10,153,17,210,922,453,18,16,402,237,90,704,37,36,117,25,421,11,615,95,20,898,373,30,475,40,401,391,19,317,8,3,304,498,576,69,285,901,275,223,293,247,196,86,899,134,83,341,127,59,45,39,365,216,692,372,50,0,801,752,367,163,139,100 }, +{ 77,102,33,13,177,23,51,141,202,64,40,128,115,4,269,59,318,6,217,137,210,291,0,7,2,1,180,196,14,22,10,95,153,11,117,125,165,15,86,352,197,134,90,403,216,275,3,16,9,18,237,453,494,342,49,31,19,139,25,65,28,5,17,317,349,93,36,304,475,26,82,12,98,44,341,27,120,365,57,24,20,110,372,386,21,247,457,719,194,402,498,116,29,730,99,260,8,143,144,523,164,114,569,48,32,111,326,285,208,391,401,244,30,509,312,961,300,752,56,160,105,203,34,450,546,67,482,170 }, +{ 101,9,363,676,264,18,411,682,604,905,520,821,271,167,621,647,364,121,252,404,118,39,166,848,781,265,100,16,382,664,447,212,777,478,354,146,907,812,132,446,360,724,0,60,463,759,24,329,23,1,88,71,35,936,68,857,195,21,48,593,865,639,932,156,897,31,98,96,51,191,13,286,333,125,656,49,694,30,254,105,591,55,806,562,109,158,44,438,419,272,521,124,154,407,274,5,65,310,553,28,144,691,33,116,159,127,93,32,77,22,67,50,410,37,538,108,706,393,115,83,36,92,12,199,327,223,10,418 }, +{ 144,203,326,382,166,96,822,418,438,93,859,88,921,1,367,141,744,269,349,110,576,473,83,77,410,23,966,21,403,120,692,39,494,274,521,317,291,217,615,523,855,303,817,13,639,264,800,32,100,909,691,225,36,478,914,765,506,5,498,652,44,435,265,321,260,160,910,551,404,137,48,772,202,897,453,450,208,101,960,254,31,863,342,286,190,51,30,593,831,616,419,730,682,98,340,372,341,197,69,33,9,625,724,848,686,284,466,704,656,223,180,102,335,125,617,352,285,363,0,662,244,530,919,812,393,374,351,318 }, +{ 21,13,180,23,32,115,48,125,197,191,165,51,5,199,237,146,12,225,18,16,93,901,350,271,22,241,375,0,71,118,408,49,447,264,126,1,167,31,24,522,302,98,65,64,575,864,569,92,566,247,744,86,58,391,352,713,212,141,60,44,9,4,88,562,459,308,303,203,202,100,45,37,17,2,818,463,360,316,919,897,698,586,478,363,293,221,213,103,72,40,691,909,608,558,509,166,68,35,727,340,517,217,724,629,546,467,446,341,304,156,120,108,11,640,288,110,7,734,296,150,591,914,346,354,321,317,269,114 }, +{ 15,13,23,51,102,0,8,77,1,5,12,33,9,4,2,10,180,82,165,197,115,110,18,403,202,22,120,326,457,7,11,351,260,898,141,342,14,373,401,901,961,64,36,386,3,291,453,31,16,40,28,93,21,6,352,59,44,99,27,341,450,217,719,49,117,48,125,475,128,37,391,308,153,95,269,24,318,177,854,730,203,615,421,98,30,32,38,137,922,317,498,704,523,57,817,509,56,569,629,116,899,133,83,365,758,105,752,144,661,196,304,638,494,134,300,670,206,402,221,210,208,86,535,143,65,532,109,35 }, +{ 77,33,102,64,202,141,128,51,40,196,23,13,117,318,269,153,134,1,177,115,10,342,137,180,210,2,0,95,6,139,403,86,14,22,15,7,217,291,4,352,165,197,36,59,237,275,3,11,5,494,65,125,49,9,453,475,16,19,28,18,120,82,216,17,402,31,93,110,260,326,12,341,194,349,401,203,98,25,99,27,24,457,44,317,365,498,372,26,351,285,719,143,386,450,300,21,752,391,116,29,312,38,114,304,111,244,164,961,509,57,247,569,523,144,308,373,901,34,421,96,56,160,437,35,20,678,32,8 }, +{ 174,104,544,151,624,74,525,25,644,66,29,177,636,416,0,204,750,122,216,6,81,45,186,222,319,138,2,145,287,112,665,192,64,59,243,7,77,32,355,22,715,128,784,17,173,20,311,135,789,280,52,33,549,113,879,4,227,21,194,90,5,141,491,102,86,42,95,43,137,58,12,27,496,275,65,529,614,11,348,678,304,651,402,580,712,503,269,422,49,37,14,318,210,673,396,202,792,10,18,500,869,36,148,85,426,247,405,681,19,226,97,825,72,16,196,40,61,609,597,115,24,217,233,51,28,881,91,153 }, +{ 372,141,304,352,947,954,291,177,217,269,349,128,318,437,498,77,678,202,864,64,102,115,86,210,873,137,751,597,247,13,180,5,275,32,16,35,21,950,752,92,197,83,87,7,457,160,776,70,33,24,179,36,317,245,165,126,107,569,288,717,95,402,237,23,263,108,774,156,546,509,340,37,18,12,946,342,872,75,800,244,114,103,851,735,365,341,146,121,99,60,579,312,120,1,195,354,296,140,888,71,51,260,223,418,758,622,537,473,363,196,98,69,10,526,48,820,817,765,704,586,450,316,246,208,148,96,90,50 }, +{ 200,161,714,53,73,27,472,383,17,440,34,585,62,56,136,250,106,78,527,322,19,862,361,4,3,514,80,84,390,14,176,179,236,378,162,377,129,548,202,47,469,495,217,26,11,494,128,757,555,453,402,412,130,880,328,507,257,183,51,45,5,38,300,184,123,497,54,12,57,33,444,59,556,283,205,245,108,485,297,209,803,152,342,40,119,99,318,452,2,46,102,211,23,196,64,229,65,77,215,684,21,814,6,240,0,153,368,403,90,730,475,13,117,133,61,37,317,305,32,255,813,22,504,181,503,29,436,95 }, +{ 32,76,72,21,38,14,241,89,54,428,449,5,45,148,37,181,90,179,2,17,221,350,12,292,46,129,48,476,155,1,794,99,477,205,720,3,770,50,464,773,4,540,308,36,57,460,270,245,413,743,184,214,741,328,115,23,123,474,137,257,10,358,11,0,281,431,29,488,421,405,162,51,288,59,64,401,710,536,430,152,290,128,218,519,22,316,697,552,7,587,86,670,361,487,6,227,13,52,618,133,249,543,77,106,62,165,769,141,243,202,403,229,114,453,263,67,475,745,341,119,197,207,497,285,9,40,180,920 }, +{ 128,141,202,64,102,33,23,77,51,13,196,318,269,153,2,3,180,165,40,137,5,15,1,6,403,10,117,139,197,86,352,134,14,17,0,19,494,210,120,342,22,7,402,237,453,291,177,475,125,115,93,217,95,21,12,82,260,110,36,457,11,65,341,450,31,25,27,194,99,9,4,326,498,275,961,349,26,49,111,401,317,44,203,391,351,277,38,28,386,18,421,37,752,164,16,143,29,285,98,24,48,678,114,116,32,373,509,300,244,208,54,719,56,59,365,57,8,50,546,144,20,523,30,569,372,898,90,308 }, +{ 39,137,96,840,30,202,9,0,613,88,406,669,100,141,180,576,160,28,49,530,403,1,269,22,228,822,829,679,856,190,244,166,219,352,816,966,765,827,36,55,68,83,128,274,418,23,318,98,44,442,35,10,253,258,51,863,77,31,317,251,21,876,158,494,475,213,95,65,116,254,859,268,125,48,13,16,931,187,367,131,805,574,105,5,365,800,102,177,93,115,33,224,127,242,120,110,291,924,217,960,144,64,842,616,165,531,385,351,101,159,276,839,778,203,201,492,109,67,24,284,748,860,345,692,295,421,272,456 }, +{ 180,352,141,752,1,901,269,365,115,5,217,2,15,4,317,23,197,7,13,341,0,244,3,253,6,51,498,202,21,318,31,372,873,165,44,77,98,9,33,10,116,137,237,93,482,125,64,864,105,12,32,48,349,509,128,131,22,120,579,11,143,8,102,569,717,37,391,177,260,127,308,110,28,30,291,450,40,559,49,39,401,160,203,144,14,437,373,564,72,24,453,403,386,546,421,96,326,16,95,36,148,661,951,247,533,494,219,109,201,159,55,961,251,475,728,468,642,117,254,221,134,18,811,153,210,82,345,224 }, +{ 1,67,28,50,46,2,103,83,14,65,114,24,0,38,133,69,36,55,18,75,9,54,124,29,22,283,7,218,5,238,16,154,35,52,96,160,480,109,108,547,12,68,398,429,646,323,181,732,175,220,21,361,171,71,335,236,389,418,70,394,48,49,149,86,58,866,531,87,309,366,37,484,208,328,251,118,194,6,10,302,412,487,420,189,336,23,168,545,800,51,803,433,185,137,128,163,754,39,45,505,169,285,596,486,13,503,533,60,101,155,95,64,32,289,570,223,158,267,927,140,745,516,17,115,514,346,956,99 }, +{ 180,352,365,317,115,217,752,901,341,1,253,141,873,2,15,4,0,5,197,3,244,308,951,31,7,498,318,44,6,372,291,165,269,202,98,137,120,127,160,36,116,373,105,260,482,13,131,33,509,110,51,125,77,39,569,349,304,437,9,11,8,450,96,64,22,21,391,221,23,93,638,717,28,219,12,421,10,403,187,83,17,102,49,661,564,851,401,128,247,811,351,523,117,535,546,468,224,201,86,35,559,48,16,148,494,134,143,579,968,922,854,817,800,551,475,55,801,758,728,615,196,177,153,144,14,32,30,533 }, +{ 32,5,21,347,13,95,49,713,51,48,197,23,107,60,126,64,237,180,153,77,165,241,33,379,850,1,263,296,196,195,4,121,134,132,102,28,115,22,117,217,0,291,16,841,929,928,652,534,660,39,493,247,31,279,18,50,36,626,150,90,76,40,407,883,509,362,349,260,9,356,125,10,177,92,441,340,259,35,24,752,351,199,65,11,71,809,546,953,933,854,312,75,61,56,37,30,7,598,207,44,423,372,298,522,783,590,354,156,645,608,591,939,937,638,498,450,437,391,359,303,273,86,57,342,316,59,640,446 }, +{ 341,365,180,901,317,115,752,15,873,217,564,82,951,197,110,165,0,1,141,351,4,3,482,352,6,372,2,12,269,13,10,559,253,854,5,468,7,244,282,23,535,18,898,14,661,417,349,308,318,102,33,509,125,811,704,36,143,77,964,28,498,326,237,137,51,533,692,638,38,475,31,22,9,642,867,391,30,8,202,120,203,966,758,373,338,206,24,569,291,922,494,403,332,144,116,49,44,697,55,450,386,128,943,842,768,728,706,405,346,299,295,261,260,258,242,160,148,39,27,26,19,17,11,50,48,46,843,634 }, +{ 45,17,106,21,227,209,62,243,5,155,32,3,290,38,255,119,54,270,14,2,207,181,587,48,263,12,794,29,46,552,540,186,659,37,430,408,770,496,721,50,454,136,84,52,221,425,56,76,308,828,99,697,400,328,115,123,741,80,488,1,528,474,401,57,218,281,41,129,541,513,421,36,487,128,10,787,61,241,378,477,543,64,51,742,306,133,240,413,11,72,428,4,165,734,23,152,655,453,211,34,920,311,59,90,236,137,214,58,162,629,431,179,832,341,6,366,583,89,77,202,313,361,383,317,514,86,745,365 }, +{ 16,24,35,18,50,7,71,75,60,14,69,0,9,1,189,108,68,67,21,181,28,12,48,223,92,5,23,140,46,103,51,133,13,2,267,230,54,163,149,65,22,335,70,281,10,32,55,96,87,37,64,171,128,394,114,141,502,58,115,486,236,99,820,98,766,202,38,137,83,309,118,246,269,49,36,95,125,191,155,167,121,430,39,218,101,77,6,150,237,126,641,774,31,318,221,487,180,443,177,433,251,545,220,565,388,29,86,72,352,399,165,217,552,112,61,105,537,17,852,45,44,30,212,175,124,89,307,102 }, +{ 127,308,293,98,165,395,258,219,13,286,23,629,401,51,115,301,569,197,457,276,512,391,509,105,616,239,924,338,22,734,170,55,961,295,31,758,169,910,272,567,116,763,201,320,944,341,143,261,237,506,180,479,873,365,141,185,206,36,242,86,374,762,498,546,913,131,44,64,923,327,843,601,386,332,492,160,125,860,317,654,964,900,284,95,28,634,943,164,137,10,901,282,224,740,468,456,144,109,841,558,719,268,120,417,535,384,299,844,482,903,110,93,9,1,935,662,578,217,253,928,730,187,393,2,752,244,531,434 }, +{ 748,957,840,213,669,539,466,88,30,251,863,321,217,679,190,137,93,144,317,530,352,831,228,230,160,617,800,689,219,203,816,96,418,202,36,473,258,406,141,871,326,83,855,752,120,854,778,82,44,100,187,201,1,435,224,351,345,719,335,116,110,443,274,28,310,55,21,450,332,382,822,574,86,931,494,531,365,31,839,128,39,180,341,367,898,23,613,498,372,731,860,9,410,926,197,704,5,817,131,69,35,125,434,166,22,944,318,924,856,268,64,48,567,244,206,291,922,523,269,32,876,717,98,49,13,349,169,859 }, +{ 5,48,21,14,1,2,54,50,36,430,38,32,181,270,45,281,12,72,17,67,46,0,290,218,99,22,28,83,76,155,24,541,37,10,513,89,114,65,58,133,61,103,96,488,51,221,425,263,3,9,328,29,23,487,697,207,741,115,18,86,745,160,428,474,148,408,6,16,502,7,64,171,137,794,108,52,920,477,842,227,55,236,552,543,13,119,514,361,449,202,238,828,536,128,308,292,476,243,592,90,241,186,179,666,285,4,27,655,663,480,421,401,106,208,141,165,433,528,532,19,834,95,283,197,11,180,720,403 }, +{ 13,23,51,115,217,33,77,0,4,2,9,317,102,141,7,11,1,10,180,5,40,202,22,197,3,6,352,365,12,269,341,165,14,18,16,28,64,15,59,318,177,403,752,31,24,196,308,32,372,125,128,291,498,137,17,247,153,21,49,401,453,349,98,117,44,8,95,237,901,36,86,93,494,342,475,30,482,210,468,457,304,873,569,90,105,143,421,391,386,37,509,39,134,139,110,116,35,275,244,144,120,326,55,961,19,546,203,46,864,27,719,221,111,65,164,253,285,216,127,402,730,50,437,38,67,20,288,54 }, +{ 13,23,165,15,37,54,134,12,117,38,457,51,64,197,99,115,153,89,961,719,33,10,82,509,14,128,120,237,3,196,308,86,141,328,0,1,629,72,450,277,139,102,523,386,351,77,8,401,65,4,546,95,155,202,180,21,2,498,391,40,352,7,5,32,11,6,730,474,31,475,110,137,899,854,453,922,569,291,114,108,22,898,44,9,177,403,148,49,361,342,285,260,514,269,93,17,758,901,210,864,479,59,34,29,28,67,217,494,318,236,179,90,76,56,50,18,242,417,528,488,206,98,413,94,817,789,468,402 }, +{ 5,21,32,14,2,48,17,3,1,12,72,38,45,54,51,10,36,22,76,23,0,89,540,13,137,86,37,4,430,270,50,114,11,221,99,285,115,64,6,61,46,361,29,181,290,65,58,403,208,155,28,133,480,281,148,128,323,453,657,401,514,541,754,421,697,202,90,9,7,475,241,263,40,56,328,308,95,59,207,576,805,165,838,513,57,27,402,19,425,18,775,488,119,283,218,741,428,341,24,141,77,33,794,408,227,197,102,194,52,179,832,55,180,494,269,365,449,164,236,350,745,318,171,859,244,474,108,880 }, +{ 202,318,77,291,128,275,102,33,269,342,177,210,402,678,141,403,494,40,20,196,0,137,7,23,49,32,64,216,4,416,104,139,285,59,352,43,61,66,13,304,234,90,22,475,319,450,11,349,117,300,113,5,153,58,947,17,112,21,6,115,120,70,544,38,16,142,2,315,194,134,95,18,498,9,74,597,237,51,329,884,25,12,453,864,24,789,173,415,639,859,155,277,52,81,86,222,178,10,48,560,14,230,665,198,97,31,355,557,65,1,186,105,817,111,39,226,57,546,121,29,147,28,15,87,60,96,265,523 }, +{ 1,24,46,2,14,67,69,75,103,38,35,50,52,83,29,108,18,16,71,220,149,394,309,236,189,70,96,133,171,54,68,366,28,58,5,238,181,163,87,7,433,0,335,60,218,114,251,487,65,267,537,36,328,418,223,9,486,55,516,262,112,150,155,12,388,48,21,45,675,175,336,22,409,118,37,186,281,140,412,696,6,124,25,514,151,294,61,99,154,10,334,32,17,273,92,135,160,283,760,278,458,227,766,64,307,19,86,361,398,230,552,641,532,400,137,565,23,502,345,51,13,95,765,26,66,72,128,399 }, +{ 15,1,5,2,13,0,7,23,6,3,180,12,51,4,9,115,457,165,197,21,8,14,141,901,37,752,117,16,77,10,32,120,202,11,317,217,110,961,22,33,365,341,82,269,719,93,352,31,102,18,128,153,134,28,260,48,569,64,137,40,318,196,386,351,509,17,44,30,326,125,730,308,450,49,177,36,95,453,89,72,98,99,203,873,523,401,498,403,59,291,116,38,24,629,372,90,349,76,55,391,373,144,758,494,237,244,96,482,475,54,854,39,468,143,45,139,105,221,247,86,899,50,148,253,35,210,304,421 }, +{ 28,65,124,14,0,154,24,67,69,55,175,7,9,429,46,2,109,35,149,336,68,1,189,83,114,251,108,16,133,398,484,103,36,18,38,22,50,267,420,140,283,289,71,570,158,236,389,101,505,230,86,346,185,39,12,169,168,799,194,118,49,596,29,732,782,302,309,5,533,52,252,95,388,419,535,21,439,458,705,75,797,160,412,6,10,54,531,218,92,345,208,96,159,610,48,60,64,323,756,105,37,23,646,238,51,128,329,886,547,278,13,650,637,32,172,135,364,164,143,584,602,115,701,601,137,333,399,443 }, +{ 162,403,56,775,129,880,161,527,99,3,17,40,33,475,23,4,361,128,196,14,200,183,34,202,102,184,548,402,383,53,130,153,757,494,27,257,108,453,38,12,136,117,51,485,123,64,57,65,19,585,141,73,13,139,421,134,229,106,11,80,556,469,670,84,59,152,62,78,714,412,378,77,5,495,21,54,236,488,497,2,6,90,514,86,111,730,22,180,26,46,507,440,95,269,37,472,115,32,401,45,283,452,618,0,328,47,18,29,266,390,10,211,165,899,250,24,300,862,719,504,133,543,197,318,277,50,176,457 }, +{ 151,29,112,2,58,311,186,52,70,113,315,45,66,74,61,631,5,87,287,243,491,209,1,869,6,227,614,135,7,307,75,80,27,145,496,226,25,454,17,14,549,26,845,19,32,46,73,106,294,163,155,64,255,659,849,667,632,644,592,72,220,331,21,334,222,172,42,69,400,48,76,138,396,337,148,635,50,86,611,445,128,171,97,122,141,95,738,119,16,37,38,4,207,67,425,290,409,53,24,65,262,89,90,12,297,278,192,461,137,22,624,36,20,483,881,84,292,684,43,10,833,56,651,655,114,263,204,115 }, +{ 6,74,75,1,70,66,138,29,25,85,26,42,87,220,52,2,135,226,222,802,324,112,145,357,103,19,278,108,380,67,114,309,235,14,500,69,451,133,606,280,38,24,582,83,65,262,163,86,97,394,294,267,486,96,50,36,889,388,603,641,58,256,32,895,238,223,853,45,122,594,46,537,64,21,204,150,27,335,792,102,7,115,337,218,13,418,71,33,160,632,5,189,696,571,308,461,95,565,16,545,331,125,4,137,134,153,113,117,17,35,558,54,287,149,22,171,18,711,174,630,247,63,12,23,0,194,462,90 }, +{ 15,13,23,51,1,120,0,180,202,5,260,9,2,102,450,115,77,7,141,12,21,269,318,197,137,523,403,6,165,326,33,351,341,817,110,901,342,128,365,36,14,4,16,457,308,401,18,494,8,48,32,59,64,82,352,22,475,10,217,386,730,317,28,93,37,3,373,854,453,719,752,31,615,24,44,30,421,291,11,210,221,39,899,99,96,961,55,86,98,40,116,177,402,922,160,898,244,203,35,576,17,569,117,509,144,391,90,49,372,704,349,153,873,285,498,253,275,125,89,143,300,196,72,247,67,95,629,127 }, +{ 5,45,17,14,46,2,50,48,186,181,227,61,29,38,155,281,54,52,80,106,400,209,21,58,3,171,243,487,540,32,328,311,103,218,133,430,255,62,67,12,828,454,36,56,536,236,27,1,207,496,787,119,697,366,114,37,19,108,6,760,513,541,600,587,592,84,745,842,99,920,96,502,151,76,13,26,270,583,263,86,221,115,83,832,666,51,23,136,34,334,65,10,290,72,308,137,663,869,739,361,514,25,721,738,794,4,659,543,89,401,667,11,64,576,378,148,22,24,834,0,474,357,73,483,754,516,41,53 }, +{ 18,16,35,60,68,121,265,158,159,24,329,105,9,132,167,252,327,709,101,55,286,39,21,71,146,49,7,109,374,23,22,126,604,107,419,333,271,14,28,1,48,0,191,120,92,212,20,310,272,890,553,118,5,326,137,199,260,455,51,95,446,320,13,32,450,259,170,627,621,639,2,10,195,647,128,98,364,301,557,463,43,37,239,77,576,848,64,100,351,82,102,125,65,285,202,12,354,6,363,346,178,344,197,165,493,407,147,29,523,242,907,96,538,932,403,33,279,916,97,704,36,31,402,520,318,156,912,846 }, +{ 467,650,389,108,283,56,412,123,177,216,670,619,349,269,33,475,899,775,453,503,789,401,678,65,543,51,196,403,730,128,84,23,194,523,13,421,719,576,457,11,597,153,880,141,249,847,3,801,117,817,57,133,18,0,202,114,59,24,150,32,386,64,40,95,291,4,183,450,130,524,162,5,554,152,90,22,9,361,134,236,102,17,27,120,304,19,961,629,210,432,21,770,86,16,14,10,77,165,46,28,594,381,377,240,137,26,229,494,947,372,602,342,318,275,125,98,630,743,701,605,184,103,97,63,50,49,958,444 }, +{ 514,11,377,328,361,3,4,880,507,403,485,57,130,14,757,152,38,102,300,211,556,215,54,176,236,62,229,56,494,40,585,555,266,34,183,59,342,12,162,440,453,548,51,37,77,402,488,305,184,196,542,421,775,471,123,527,210,369,313,33,457,136,719,23,202,231,13,128,153,381,629,452,803,543,129,412,157,17,248,339,111,84,139,497,475,205,99,119,32,828,188,177,961,349,383,117,46,89,79,730,216,504,277,401,161,134,308,291,322,76,249,283,72,65,64,21,2,22,670,503,241,41,257,90,108,618,472,94 }, +{ 3,555,62,266,507,215,130,440,99,514,229,152,471,40,57,139,403,12,56,548,305,33,475,38,313,775,361,14,123,211,880,328,196,102,23,556,381,184,136,757,377,77,277,54,183,494,453,421,4,11,205,349,291,129,162,452,34,236,84,17,369,37,59,485,497,111,401,402,51,153,157,477,585,13,670,128,117,339,176,161,41,488,248,202,383,300,457,249,119,76,432,46,342,134,79,188,89,214,2,474,72,527,961,21,32,308,719,543,165,177,257,730,412,133,413,64,283,216,210,245,106,618,803,90,15,629,115,460 }, +{ 120,318,450,260,77,15,202,13,817,51,269,5,33,494,922,128,1,326,102,23,403,523,137,141,21,177,351,40,342,48,291,82,854,153,125,64,7,615,32,196,22,704,210,402,98,4,475,12,373,115,93,2,96,453,285,44,275,349,36,61,31,116,216,859,197,117,49,28,16,899,678,203,165,59,90,180,139,50,24,6,144,217,95,898,692,170,110,45,18,17,10,0,730,352,72,37,207,457,576,341,237,35,20,9,661,372,194,961,223,214,958,949,811,805,791,551,424,391,365,244,242,221,208,160,127,99,89,76 }, +{ 23,1,15,51,13,2,5,0,7,6,180,12,9,115,21,3,197,165,4,457,386,120,141,33,202,453,14,730,523,719,401,37,40,32,341,8,31,403,260,82,450,352,16,48,110,269,317,77,217,308,44,137,22,102,18,365,318,901,93,351,421,117,475,752,11,326,28,391,49,98,153,498,128,99,64,30,569,10,899,509,36,196,961,24,221,59,39,89,177,758,854,134,494,116,17,629,90,817,670,468,86,247,72,95,35,105,96,203,482,55,373,125,372,873,144,210,922,291,38,244,237,898,54,50,20,349,615,65 }, +{ 15,180,351,317,82,115,365,217,141,898,10,854,901,197,143,77,23,752,341,352,33,110,13,36,64,102,51,4,1,260,253,244,120,9,21,5,22,40,498,55,165,137,117,28,11,873,372,922,482,134,59,0,72,153,196,160,32,48,202,3,2,961,90,12,35,811,164,291,177,349,31,86,30,308,7,125,509,642,450,128,6,139,17,96,210,237,89,951,523,342,457,93,730,57,37,39,661,16,83,437,373,546,269,49,18,14,531,8,717,318,111,45,24,569,247,76,533,719,221,67,326,282,468,386,203,52,44,38 }, +{ 104,289,707,66,712,173,97,214,90,64,426,20,874,414,568,43,65,32,194,715,7,204,312,560,74,500,192,835,324,0,38,376,819,861,147,319,95,636,22,86,729,21,470,879,288,5,107,526,52,81,178,2,751,49,10,519,142,595,427,247,77,356,232,249,4,750,237,597,28,885,784,36,889,858,51,202,802,14,135,298,115,13,59,524,808,1,330,325,23,92,180,359,392,31,24,583,681,61,18,259,172,48,177,123,825,798,37,357,12,208,33,174,387,362,140,102,35,76,40,17,137,198,11,216,600,16,671,91 }, +{ 84,65,56,18,194,249,0,108,123,643,847,554,63,524,416,141,453,24,26,403,22,511,467,630,475,128,73,137,33,9,80,899,95,64,370,76,45,16,133,42,289,19,650,214,27,240,730,719,210,196,119,114,49,494,402,304,102,90,32,11,10,588,561,283,235,202,523,183,25,736,609,580,576,500,457,433,357,349,343,209,124,60,57,39,28,3,1,757,150,23,368,670,51,597,947,813,667,659,529,431,291,287,243,236,233,216,179,177,153,134,122,117,112,89,85,72,31,30,6,421,389,165,125,895,874,619,519,361 }, +{ 21,350,308,13,346,197,826,352,101,841,570,68,165,509,23,115,100,694,749,569,903,51,212,401,9,0,221,734,391,154,777,252,88,124,610,265,237,39,558,125,48,30,217,230,421,35,289,468,64,55,535,475,213,546,175,909,1,403,382,166,589,28,645,812,419,180,32,706,98,593,410,703,759,141,317,629,65,241,83,194,818,773,22,321,752,689,923,341,962,96,671,699,158,95,16,329,429,854,264,724,190,439,31,722,316,72,900,144,10,93,247,49,831,676,372,24,223,36,553,269,293,69,365,490,191,5,639,251 }, +{ 92,16,60,24,7,71,126,18,35,140,330,14,246,46,50,267,121,146,236,108,75,220,199,571,394,68,309,150,132,107,314,448,230,54,232,633,5,366,118,2,21,9,278,38,388,37,87,64,1,181,328,12,641,55,70,672,582,726,48,526,0,622,172,516,563,86,69,32,103,10,133,36,156,167,28,65,101,135,195,52,171,950,149,22,830,189,99,649,191,451,67,13,29,262,294,606,83,545,58,517,462,271,23,572,95,163,696,128,675,594,620,392,514,77,785,45,155,192,217,653,335,279,522,212,237,51,177,565 }, +{ 15,82,898,365,33,77,341,180,115,901,21,10,102,197,55,5,4,351,13,165,117,36,11,1,217,23,317,141,40,752,120,153,450,134,253,12,2,260,143,196,873,51,89,457,32,3,177,352,349,854,372,244,160,59,7,719,961,64,202,96,6,110,291,137,523,498,111,0,210,482,28,31,30,17,951,125,318,22,128,509,139,811,730,386,169,304,9,391,37,164,48,326,269,203,93,373,237,148,535,342,72,569,704,308,247,38,533,49,98,922,86,734,109,14,45,275,216,95,817,403,44,437,57,899,661,41,39,968 }, +{ 16,24,35,71,18,68,108,140,189,69,103,60,267,50,149,118,230,7,1,133,191,92,46,167,9,75,246,0,2,443,309,236,486,335,14,54,212,330,218,516,65,67,38,394,641,21,181,55,28,101,48,83,399,366,563,412,545,114,220,696,388,51,328,13,23,5,64,458,273,124,126,12,238,487,52,345,37,537,87,121,29,915,723,150,175,32,302,154,163,361,146,375,674,22,10,171,271,96,514,251,86,433,70,336,36,571,622,223,906,796,237,726,398,602,283,39,262,115,702,565,891,58,695,562,199,128,894,49 }, +{ 60,20,16,43,7,71,18,92,118,14,35,628,608,68,154,28,375,126,175,107,0,279,150,173,22,356,97,149,566,55,153,169,49,140,69,33,13,230,117,38,23,10,362,51,2,77,783,414,421,109,298,246,359,196,125,124,446,102,104,386,722,66,21,1,601,575,621,326,439,429,12,392,134,32,882,192,74,345,551,533,419,185,336,191,4,232,37,273,595,81,189,791,314,202,158,917,576,467,570,6,5,302,48,422,115,801,319,197,165,677,535,925,420,387,9,423,399,251,517,515,403,291,199,260,694,553,64,40 }, +{ 187,258,871,295,434,489,219,201,224,268,839,384,699,940,110,261,116,160,131,44,36,574,228,144,141,93,137,567,406,244,926,120,98,253,260,373,64,442,206,269,127,908,318,55,31,911,959,855,617,10,1,531,332,523,202,613,203,661,326,352,860,217,717,367,276,21,51,143,180,96,23,105,13,450,22,385,533,284,662,197,851,86,77,251,30,115,83,9,48,816,164,282,811,317,365,39,856,165,351,843,669,473,899,341,125,922,902,752,291,817,372,918,345,417,177,728,82,293,242,951,498,968,854,386,559,15,349,49 }, +{ 66,97,7,172,192,712,232,204,324,387,74,426,448,526,104,173,107,568,560,43,356,825,808,500,729,135,359,52,707,92,32,95,330,20,636,64,65,22,140,38,138,81,298,2,289,715,885,5,802,392,29,49,14,174,0,889,91,86,226,348,90,750,861,6,357,280,314,312,126,214,246,792,353,10,36,24,380,580,21,835,37,28,414,58,230,69,222,595,362,194,673,16,278,12,77,85,33,46,874,18,819,61,60,681,147,858,888,612,600,13,241,25,501,102,48,35,67,189,87,71,40,4,583,519,779,1,237,150 }, +{ 15,1,5,341,4,13,0,3,2,134,33,12,11,7,10,77,6,9,21,23,40,197,8,32,365,37,17,901,111,102,51,117,180,317,961,153,217,165,59,14,22,16,82,141,31,457,94,202,115,291,453,403,196,57,36,372,475,318,719,28,349,18,401,72,269,99,48,386,110,498,64,494,120,352,93,351,54,139,27,509,474,177,45,44,30,670,90,421,326,76,56,89,128,898,642,629,304,260,450,19,482,137,29,55,391,873,342,24,49,730,203,62,373,143,210,79,752,41,39,758,661,817,157,152,98,523,579,402 }, +{ 0,24,35,28,124,68,9,154,65,16,109,149,55,175,158,71,39,252,7,419,14,108,101,346,168,22,185,289,429,49,18,420,169,67,439,671,703,336,302,1,159,92,610,962,484,118,333,95,69,2,677,398,344,100,364,810,272,345,105,46,329,114,60,535,265,327,577,30,10,189,21,12,254,286,133,194,83,23,140,793,553,86,36,50,570,637,13,103,5,722,310,51,374,230,48,38,64,32,747,706,505,701,273,251,150,164,601,455,166,627,143,634,125,283,424,239,458,799,128,246,267,388,547,6,137,96,37,538 }, +{ 7,92,14,16,46,140,220,60,35,24,2,126,38,87,75,278,71,172,262,135,52,314,107,54,294,246,394,150,18,50,330,29,309,267,230,171,1,70,232,108,21,5,121,620,97,236,69,622,32,572,563,950,366,409,58,199,12,48,64,328,37,571,189,146,448,132,66,68,155,872,112,192,461,67,441,181,675,279,13,298,28,226,0,451,23,163,423,606,9,582,128,20,86,526,36,334,307,55,380,462,888,357,335,61,43,10,22,45,83,337,331,186,353,359,103,726,133,633,95,51,65,202,72,74,785,114,141,149 }, +{ 92,7,126,16,314,172,60,140,35,135,278,14,232,2,107,246,46,150,330,24,66,38,71,230,52,380,97,298,279,448,563,192,357,262,199,121,87,18,582,309,462,441,29,75,74,132,220,5,146,451,526,324,423,50,21,550,69,32,68,226,508,1,70,37,633,64,12,108,606,267,48,572,493,54,189,726,366,0,392,359,22,95,43,58,571,603,28,10,20,86,236,55,171,600,36,9,388,163,65,607,387,6,67,49,294,649,830,583,356,362,90,622,394,620,167,259,939,149,443,83,580,114,25,103,118,672,61,45 }, +{ 235,26,53,297,6,436,73,113,27,445,42,25,250,611,90,19,65,214,648,614,85,624,289,64,122,200,491,684,416,32,17,194,45,665,145,34,80,95,573,151,112,322,86,680,714,315,630,106,690,14,29,472,255,141,396,56,312,57,22,247,76,209,4,128,61,288,123,84,352,249,11,874,108,3,138,5,217,256,70,119,59,74,0,835,283,161,114,751,269,597,525,389,136,77,51,10,40,115,287,47,2,52,78,176,881,62,13,524,519,23,137,33,133,28,46,177,746,311,18,236,12,63,180,453,237,631,179,243 }, +{ 352,141,752,854,36,1,351,217,230,244,661,110,816,258,160,224,180,219,82,201,269,567,144,295,260,373,922,93,120,203,489,64,35,202,406,317,206,699,137,116,268,871,717,10,839,251,434,228,864,253,326,96,21,131,9,30,83,384,44,442,39,450,574,69,332,48,318,418,728,898,55,127,187,642,365,86,276,88,28,341,831,498,22,901,443,100,367,523,128,531,940,213,5,689,748,190,860,679,0,31,811,843,559,164,7,669,143,662,851,77,564,372,165,335,98,800,261,2,959,349,284,170,115,291,824,345,50,855 }, +{ 126,60,16,35,107,18,191,121,68,92,279,446,598,463,375,43,167,493,7,20,118,199,212,566,14,150,97,28,575,608,589,55,407,101,246,154,146,24,346,21,0,175,48,71,362,815,354,49,628,132,939,5,467,22,649,10,9,1,356,259,147,271,149,783,439,140,23,108,32,109,230,376,683,125,13,621,345,441,363,31,51,647,612,273,124,562,173,695,768,105,38,252,2,727,169,818,640,195,755,590,637,158,722,364,104,37,953,535,12,44,64,66,359,33,202,806,298,46,419,98,221,95,77,185,660,399,653,520 }, +{ 1,15,2,5,4,3,13,0,23,11,7,6,341,115,77,51,10,9,12,33,180,197,102,40,217,165,141,365,901,21,317,32,202,8,14,64,177,22,269,352,59,17,291,31,569,318,125,210,16,93,386,453,196,457,401,18,494,403,153,752,37,28,475,961,117,110,498,120,342,523,139,116,629,44,326,134,349,203,98,372,49,128,275,57,308,48,237,391,719,30,509,24,95,36,86,19,421,260,758,247,90,730,615,216,137,373,450,873,111,482,144,29,899,304,817,670,25,300,143,801,55,20,244,82,45,27,39,242 }, +{ 51,23,13,202,21,5,403,137,32,141,318,128,1,120,165,125,12,48,15,475,269,180,453,197,115,64,401,33,2,7,450,6,523,308,260,421,221,4,494,37,386,99,16,14,196,457,730,237,93,817,102,77,61,82,352,9,719,98,110,10,20,899,326,19,18,3,117,90,17,391,402,95,0,341,31,11,217,25,961,629,351,96,134,72,49,153,30,26,569,801,203,372,40,509,24,50,317,285,27,758,116,349,342,70,59,58,76,39,44,291,89,57,45,29,854,28,22,144,177,35,194,576,86,670,54,365,678,247 }, +{ 131,716,371,224,737,385,219,254,616,924,836,187,258,98,761,916,944,127,39,105,442,578,9,49,272,31,688,44,116,242,137,871,908,159,395,518,890,28,293,284,574,202,623,51,160,23,0,201,276,36,827,938,839,22,333,125,456,299,286,144,109,438,158,13,95,910,64,30,829,228,327,166,101,1,860,926,613,96,86,512,846,310,21,295,10,406,55,318,252,320,93,843,128,301,627,567,203,165,48,662,492,100,268,37,531,457,221,190,434,403,68,384,421,239,393,261,902,35,533,169,170,120,110,260,244,308,5,506 }, +{ 15,5,1,2,3,4,7,0,6,11,13,10,180,197,12,217,341,141,33,134,77,17,165,9,352,40,365,32,317,64,498,752,102,21,117,901,59,14,237,8,23,291,349,36,864,269,372,153,57,37,82,961,22,115,569,196,120,509,873,342,202,48,51,351,110,16,93,45,31,457,125,19,76,72,111,244,27,260,128,143,318,79,546,56,139,28,18,86,44,98,90,391,94,61,55,854,95,38,386,29,482,898,49,99,89,253,210,177,137,730,450,35,221,84,25,304,954,758,326,922,474,403,203,20,373,50,247,523 }, +{ 66,74,192,173,222,226,174,7,29,712,52,204,353,43,20,500,2,138,145,97,104,673,426,355,6,64,560,87,0,580,331,172,414,90,32,25,337,65,22,49,135,825,861,112,280,5,287,81,95,525,86,21,707,42,38,792,415,85,750,889,356,36,324,819,10,632,232,45,526,330,1,107,544,91,319,140,746,151,294,194,58,92,28,14,67,289,4,636,115,37,17,12,262,715,470,16,155,59,27,61,233,387,298,18,376,568,216,26,122,69,77,113,24,23,888,70,13,114,51,75,448,729,11,609,102,348,312,33 }, +{ 786,259,5,534,590,493,465,929,581,21,279,941,49,13,612,132,32,362,23,147,61,48,35,121,939,626,683,146,178,107,771,687,408,347,713,345,58,427,126,70,18,60,4,197,878,150,344,640,379,1,195,841,33,120,263,356,51,509,522,260,28,22,0,115,55,10,376,663,207,350,199,16,423,142,407,221,156,246,623,595,241,105,31,903,298,11,71,68,95,92,64,17,40,450,441,90,167,308,165,518,44,783,316,247,953,360,351,98,30,102,82,65,159,955,290,87,817,134,20,182,39,24,230,117,59,501,315,569 }, +{ 278,14,135,2,140,16,267,69,92,24,7,46,35,189,38,52,71,29,60,75,357,172,87,309,66,380,262,74,324,230,462,220,1,451,150,335,226,571,108,18,97,50,443,606,563,103,67,246,550,6,641,126,330,70,388,366,5,83,149,68,21,486,48,314,25,12,54,565,298,394,600,622,32,423,294,232,37,582,236,222,572,28,65,251,603,36,192,64,58,145,0,171,331,55,950,853,95,133,86,22,10,114,112,399,620,138,448,26,163,353,508,500,583,96,45,877,238,42,726,9,785,121,279,181,696,72,19,223 }, +{ 165,13,308,391,197,23,401,509,758,457,569,51,629,734,180,115,873,317,901,961,3,453,719,29,46,546,80,34,2,482,217,468,181,867,48,106,45,341,52,17,14,287,297,5,730,445,386,552,428,62,221,186,15,11,171,56,50,12,38,365,250,328,133,61,211,540,153,215,119,53,41,903,670,58,743,311,99,305,231,176,27,236,4,54,130,881,403,151,6,600,57,136,84,40,764,787,114,475,862,472,469,73,32,26,33,400,227,137,21,1,255,196,270,281,155,65,752,635,440,405,326,161,110,549,477,430,396,592 }, +{ 1,14,22,2,28,7,67,168,65,24,49,0,35,46,55,50,95,69,12,159,36,105,16,114,109,158,5,83,194,103,38,133,239,169,9,289,164,185,18,424,6,21,10,708,124,170,320,283,312,389,29,68,51,23,420,143,189,347,505,336,37,175,835,892,86,149,108,64,874,54,13,577,251,48,32,654,756,547,96,71,115,301,286,128,154,202,236,344,160,253,484,638,52,75,208,230,747,610,308,39,218,533,137,140,267,141,374,3,345,31,127,237,799,98,601,597,244,272,323,125,398,401,118,17,327,99,412,101 }, +{ 34,453,130,196,322,3,14,236,361,47,51,377,11,730,514,711,4,412,153,57,161,440,485,102,176,59,162,108,17,62,283,757,202,56,136,38,328,880,77,494,184,12,719,128,402,403,200,23,78,117,27,475,21,300,40,381,54,472,33,53,183,152,129,99,2,714,452,13,585,803,80,210,862,555,383,73,46,123,37,139,84,670,556,503,548,6,507,421,5,111,527,29,19,342,229,457,26,775,134,318,469,133,115,90,106,257,277,401,250,497,205,1,543,266,211,542,629,899,45,488,215,217,65,72,275,339,432,32 }, +{ 48,18,23,21,35,60,16,24,156,51,13,71,121,221,5,132,46,141,163,7,1,43,271,202,115,92,411,178,340,137,447,308,32,363,150,698,125,223,195,781,541,318,147,142,28,22,0,108,360,621,401,241,2,463,354,49,658,586,67,303,269,97,20,761,50,296,146,70,65,763,867,691,638,182,647,93,82,10,767,167,31,914,670,290,128,107,75,61,225,98,64,4,120,14,12,758,110,29,949,457,316,165,105,95,293,30,668,932,180,39,446,724,743,666,421,391,372,351,114,96,86,66,591,352,33,942,922,459 }, +{ 13,165,629,457,961,569,23,197,341,401,41,758,901,719,17,509,51,115,38,421,62,54,157,12,32,45,117,57,37,339,328,106,188,14,365,734,99,546,488,477,76,873,2,453,308,542,248,72,10,184,40,721,214,211,4,386,305,479,474,152,3,243,90,139,11,5,1,153,313,21,468,134,471,217,148,129,123,179,77,89,670,255,162,130,94,7,391,136,59,102,111,536,196,828,247,237,743,428,6,514,277,556,128,33,475,155,266,229,29,528,209,720,413,241,64,361,476,183,9,0,519,405,317,202,181,805,775,431 }, +{ 77,141,2,102,33,1,64,6,5,3,7,269,202,128,180,23,318,14,0,10,13,291,352,153,40,197,165,137,237,51,17,177,15,217,117,115,196,9,86,4,139,134,11,19,22,12,210,403,16,342,95,125,36,457,317,21,498,752,349,275,143,59,341,120,27,93,82,18,28,111,494,110,164,38,25,365,901,475,391,57,8,203,509,260,31,961,49,453,386,48,678,351,326,56,37,719,402,99,401,546,372,569,44,65,304,864,32,730,300,194,26,45,244,873,277,29,285,41,208,597,20,253,160,523,24,98,54,312 }, +{ 212,68,154,124,562,101,191,0,9,375,118,520,167,149,818,65,16,722,302,21,777,35,24,71,604,350,100,806,252,478,346,264,664,841,1,759,265,48,13,695,429,55,701,329,51,23,724,398,589,18,936,115,882,484,755,88,749,69,903,125,189,410,22,221,535,382,108,308,166,917,411,39,28,223,67,92,509,32,10,197,64,5,694,650,114,558,95,246,60,909,7,83,241,96,165,363,391,593,98,230,321,103,364,826,553,925,639,49,458,734,628,419,336,447,768,399,140,105,175,37,886,682,905,674,821,404,109,812 }, +{ 48,23,51,98,125,541,598,259,293,13,807,126,21,115,221,493,963,223,35,31,670,386,121,0,107,770,165,144,90,203,116,719,949,783,727,279,590,197,32,326,10,284,146,49,401,407,132,64,199,16,955,342,97,39,834,1,194,453,191,522,427,114,105,92,30,14,7,465,393,763,271,50,725,615,195,108,22,77,44,9,640,291,20,202,269,941,767,671,591,498,467,360,147,128,28,704,551,389,289,33,150,141,60,43,697,534,362,589,58,325,621,523,475,403,260,237,218,210,140,137,127,109,102,87,83,46,36,867 }, +{ 21,23,13,5,1,586,32,48,167,51,781,31,647,33,271,165,49,141,591,44,115,522,77,197,221,22,360,18,93,146,391,558,105,932,217,447,118,153,961,352,60,900,317,761,196,459,0,363,260,241,82,4,12,698,463,7,291,98,27,247,815,156,120,36,623,35,10,191,628,95,65,46,17,50,922,341,202,45,411,64,521,372,102,16,934,308,269,663,410,351,326,14,116,686,349,225,110,457,29,2,509,71,621,854,701,475,354,342,159,158,132,127,24,478,446,321,246,199,640,848,777,759,371,318,316,273,223,126 }, +{ 2,29,61,52,7,1,5,14,58,70,45,425,6,290,112,738,32,207,46,72,66,186,87,76,655,38,243,263,74,151,21,75,16,227,25,50,135,17,148,64,89,255,292,128,24,106,155,141,315,476,209,226,90,26,833,19,113,27,306,115,48,454,549,592,18,4,163,307,0,20,119,77,10,86,36,270,54,177,35,171,720,22,65,137,496,202,40,887,59,179,95,294,790,23,69,269,220,172,631,334,9,67,449,28,408,318,483,311,145,13,97,845,84,287,240,214,51,37,43,241,405,33,49,102,663,80,12,180 }, +{ 39,265,9,333,100,310,411,254,363,101,447,404,18,272,98,639,264,166,1,286,203,327,682,676,31,905,156,520,821,16,93,656,593,30,625,354,105,24,438,44,664,688,23,116,51,557,0,326,329,21,812,195,49,190,159,35,759,60,478,125,118,121,48,364,132,627,13,167,33,110,921,242,68,274,158,96,127,252,137,668,77,5,731,578,692,102,795,865,131,435,165,22,604,586,271,473,455,382,146,120,10,88,144,65,64,966,212,71,67,128,83,691,897,160,576,551,36,724,615,223,82,50,647,7,95,197,621,115 }, +{ 6,26,2,25,74,1,29,19,42,138,51,108,114,70,324,14,23,386,133,103,5,96,85,13,719,75,453,52,27,66,730,602,220,38,309,65,388,457,58,17,112,122,50,128,323,357,64,235,280,238,670,421,135,165,150,475,7,523,197,32,145,278,87,500,899,401,550,3,218,273,758,208,113,86,83,603,532,222,115,711,12,137,21,895,394,46,24,163,53,45,97,67,125,283,28,458,236,117,34,11,262,294,90,36,801,792,141,516,484,341,302,33,802,297,204,57,95,4,756,594,226,256,134,480,891,545,99,450 }, +{ 20,43,356,414,49,595,858,359,819,107,392,319,97,7,422,470,376,612,173,5,246,0,427,14,683,147,197,22,660,95,230,347,945,713,32,344,92,61,830,362,325,259,33,31,21,12,4,904,707,623,126,509,18,2,77,357,232,165,140,105,102,729,196,153,426,117,408,841,518,98,64,10,17,16,501,663,560,76,44,104,38,558,125,391,23,324,178,134,46,54,29,13,40,51,330,120,493,279,168,581,263,180,158,116,241,455,159,81,28,903,298,90,900,66,465,441,423,202,198,30,534,237,58,24,3,52,887,845 }, +{ 68,35,0,101,65,9,124,154,175,114,336,67,28,69,149,189,103,133,1,24,39,83,50,230,55,345,16,429,251,7,283,218,252,346,18,389,547,71,118,364,100,2,238,140,646,109,46,22,12,439,166,289,36,23,49,484,30,399,14,51,732,13,86,930,532,398,64,96,54,323,694,88,21,722,158,265,5,75,38,48,329,181,705,212,194,952,480,361,419,443,208,302,868,782,520,10,95,108,503,128,191,115,246,237,335,267,637,37,167,160,137,723,702,141,806,565,309,105,264,831,826,701,604,535,60,330,562,375 }, +{ 23,13,51,115,15,5,202,12,1,165,2,0,21,197,453,457,4,318,269,10,32,7,141,9,6,401,3,180,14,403,37,11,341,77,22,719,120,569,217,475,308,177,33,18,260,365,17,961,64,59,99,16,317,237,48,28,629,128,450,730,90,117,137,386,352,523,31,40,494,291,102,247,8,421,509,72,24,498,125,391,196,76,49,44,57,221,36,93,468,203,326,30,45,153,210,899,89,304,216,482,372,38,110,95,82,19,275,134,402,758,342,139,349,98,901,678,752,670,873,546,734,27,56,351,65,817,61,86 }, +{ 121,195,407,126,60,271,146,199,167,16,107,493,98,132,191,223,35,279,1,212,20,362,727,92,48,43,18,21,150,522,446,259,393,467,5,783,590,598,360,640,612,939,649,354,71,246,7,156,834,68,49,125,293,24,0,147,55,608,591,163,14,376,534,31,660,541,463,683,807,97,13,345,589,23,953,668,562,22,32,818,221,108,955,118,284,96,581,595,10,50,28,470,765,695,575,346,116,2,37,61,356,535,566,95,12,51,105,101,70,281,64,273,423,230,202,441,44,9,755,75,697,653,465,38,768,173,175,77 }, +{ 31,44,299,116,393,492,144,268,918,367,456,434,105,489,22,948,127,384,963,9,98,28,0,49,125,242,293,206,395,940,36,512,55,51,203,1,855,93,911,617,159,95,272,23,959,332,763,301,137,21,13,141,64,109,86,282,10,170,120,286,320,551,202,417,599,239,165,685,7,2,616,5,128,730,143,457,352,719,48,39,8,253,160,37,692,326,327,386,450,421,158,269,12,276,18,506,791,473,115,24,16,244,391,164,558,318,403,338,623,131,219,14,523,401,284,30,197,499,900,951,308,479,221,260,728,169,910,935 }, +{ 23,457,51,401,13,758,719,165,629,453,961,730,197,901,386,569,308,670,391,3,29,14,12,739,231,34,52,153,832,828,115,341,2,40,46,514,176,365,5,21,33,0,838,181,4,328,45,54,555,130,509,494,540,734,552,583,215,196,507,227,11,211,99,117,361,180,38,10,1,351,894,134,27,26,186,50,48,543,152,749,369,202,62,236,421,102,600,468,403,171,161,155,57,9,528,17,880,753,36,477,19,440,903,488,377,22,585,108,37,7,6,697,899,757,523,475,576,326,67,479,469,281,867,805,801,659,657,587 }, +{ 105,131,22,36,127,115,180,341,201,219,272,31,365,169,98,1,44,317,9,64,239,187,141,197,498,143,873,320,752,286,901,352,86,164,160,258,327,244,224,185,109,159,217,13,535,253,538,144,116,0,374,276,261,776,170,28,83,634,531,2,569,533,269,616,95,896,251,824,482,165,37,55,128,282,10,5,578,49,546,654,947,913,371,384,295,208,8,860,21,137,202,954,312,284,30,23,567,509,125,574,39,285,318,268,206,203,843,623,33,708,12,77,716,385,837,7,638,120,237,301,254,308,293,16,951,3,395,15 }, +{ 6,1,2,29,14,25,52,38,74,66,26,65,67,114,42,19,108,5,69,83,46,388,75,86,324,135,103,7,17,27,85,380,36,24,70,150,278,87,138,97,594,886,357,267,50,51,18,484,650,23,458,45,646,21,732,398,95,208,64,96,273,13,238,0,124,22,711,550,12,532,323,302,28,220,160,37,335,63,32,194,421,133,262,451,602,283,386,309,730,10,172,467,453,235,168,3,401,782,115,610,670,48,719,81,145,16,20,500,137,226,58,280,165,603,244,866,141,308,222,197,189,112,547,53,99,73,475,180 }, +{ 51,453,386,23,719,730,670,13,758,6,457,401,899,475,629,19,2,29,569,47,26,165,14,894,421,130,801,236,197,108,412,27,74,1,308,754,5,50,17,961,133,45,52,285,523,711,657,78,324,196,128,137,65,34,115,25,99,138,357,59,480,42,114,46,361,867,53,739,58,4,743,403,603,366,11,859,38,262,12,594,202,22,235,153,64,391,218,0,516,487,10,145,200,3,33,444,70,117,901,57,223,134,54,745,390,112,283,95,123,309,96,21,66,803,220,86,341,18,365,402,176,37,328,77,488,73,322,250 }, +{ 252,121,18,101,16,9,167,132,271,60,146,419,364,35,265,363,212,0,158,604,329,682,68,647,109,848,907,191,520,463,39,24,333,28,446,159,821,55,621,553,118,126,593,411,49,71,407,23,286,634,105,195,354,107,404,857,13,676,374,310,259,22,538,562,92,100,31,10,21,793,199,1,327,639,108,48,98,806,51,7,709,346,522,932,166,147,5,590,96,137,254,465,272,20,150,694,64,706,12,14,203,169,95,36,124,77,2,116,360,44,865,402,125,154,128,33,627,576,185,810,455,156,822,777,37,326,127,842 }, +{ 283,503,128,432,269,529,63,26,275,789,193,678,318,389,102,122,291,77,59,177,256,6,862,342,25,18,235,57,216,445,27,4,573,605,349,65,11,85,403,523,643,84,813,630,494,397,233,40,56,73,475,202,138,416,210,718,42,32,133,415,381,736,453,412,511,19,619,91,240,255,80,22,64,114,23,289,194,0,17,123,561,87,174,152,343,81,436,66,300,297,148,95,78,3,217,51,803,510,370,341,139,137,130,49,45,119,396,372,90,237,544,141,74,476,129,86,21,650,421,378,352,209,196,33,288,247,402,701 }, +{ 2,75,29,52,87,74,226,69,220,1,278,135,46,262,70,267,14,380,6,66,324,38,357,294,7,394,222,140,145,97,331,25,335,189,24,67,92,16,112,853,571,26,42,309,163,50,138,35,550,582,103,172,83,96,337,451,71,108,150,5,58,486,785,537,21,60,298,19,462,583,600,461,171,32,230,48,65,366,45,500,606,54,774,12,18,36,149,223,114,37,443,641,133,632,287,563,64,409,85,22,764,388,314,238,151,950,95,61,27,307,155,86,28,415,565,17,246,423,43,572,113,0,186,609,251,396,10,802 }, +{ 97,298,172,140,69,66,7,189,267,92,501,314,60,423,135,24,232,81,71,16,43,150,462,74,14,330,192,517,173,426,733,149,251,35,885,273,6,279,38,18,221,67,278,508,83,607,2,91,380,52,125,448,124,29,387,458,87,20,36,443,230,861,108,915,711,302,104,21,568,526,723,324,12,68,48,5,362,1,336,335,0,28,22,46,541,126,357,103,25,451,877,726,246,398,565,50,138,879,175,963,65,86,165,809,391,715,197,705,191,118,117,42,712,386,204,160,823,674,54,107,467,399,441,633,831,572,563,236 }, +{ 475,421,805,899,403,453,958,615,817,51,801,523,120,401,670,730,450,326,494,23,576,202,386,629,569,260,115,365,697,77,165,110,153,351,318,24,117,13,317,0,341,221,16,704,137,5,196,342,308,757,543,22,719,197,11,4,457,20,9,302,484,758,300,10,7,217,6,193,901,391,91,361,1,791,515,862,291,273,118,102,66,38,36,2,402,125,114,661,643,352,474,134,82,33,133,756,642,511,48,373,240,847,735,608,480,172,135,52,43,21,14,859,244,116,29,370,124,754,180,35,42,898,886,851,842,811,770,558 }, +{ 7,128,20,14,177,97,16,112,43,202,269,77,107,66,415,318,2,135,141,275,147,38,18,58,35,52,307,173,10,356,298,29,210,414,172,32,6,0,137,192,24,291,70,22,102,494,9,87,334,13,104,60,115,64,40,678,342,46,49,186,33,217,5,121,48,90,23,21,4,155,86,232,403,59,28,74,132,37,227,324,319,61,362,402,36,126,95,92,431,337,178,400,609,1,376,71,51,294,665,631,392,151,549,105,81,359,353,304,230,196,67,349,15,134,544,311,285,278,884,352,259,76,427,262,194,50,496,171 }, +{ 24,14,7,28,2,16,0,22,124,1,65,35,108,168,149,67,109,69,71,18,46,55,158,49,289,12,92,95,185,38,6,169,5,420,83,10,189,154,159,584,140,150,36,68,429,164,21,671,484,50,398,60,105,175,29,302,143,703,239,103,86,23,64,344,424,32,51,9,336,251,230,273,577,114,747,133,37,118,194,66,13,48,267,97,128,835,505,52,170,137,320,892,253,115,236,570,388,347,374,125,286,54,20,345,202,458,314,638,246,654,610,25,75,708,17,172,312,96,135,677,141,19,221,3,650,799,547,601 }, +{ 26,80,122,73,27,25,42,684,19,209,445,573,667,17,680,690,106,6,255,297,611,483,4,495,59,119,250,45,84,378,113,469,65,436,128,311,85,64,29,53,200,56,648,396,235,61,742,11,136,76,383,77,0,86,32,161,62,22,814,361,256,14,12,5,137,123,40,389,194,491,503,813,283,269,862,21,3,95,112,454,179,63,141,129,33,177,233,57,202,803,2,102,70,10,34,240,402,18,416,624,275,145,605,614,52,358,504,665,527,343,133,114,108,139,50,881,151,58,205,51,790,24,210,38,174,49,216,285 }, +{ 107,259,465,362,376,595,534,660,683,470,581,147,612,20,858,43,427,49,5,178,246,786,0,35,97,356,279,878,21,423,929,61,142,14,230,126,70,132,146,904,590,325,319,493,22,199,48,32,501,392,298,953,95,77,414,640,347,345,359,798,31,13,198,7,173,58,64,121,105,711,28,125,150,344,12,518,10,941,713,603,4,60,33,450,1,481,92,202,98,120,687,55,207,23,16,18,626,197,102,522,819,163,232,771,113,577,17,318,37,65,357,263,40,324,422,260,623,59,44,663,408,702,494,441,68,455,845,237 }, +{ 131,30,190,856,228,406,224,530,88,863,219,778,274,944,613,539,816,258,187,100,435,871,39,160,321,840,44,116,31,166,93,625,137,36,957,531,127,442,213,669,466,716,385,1,144,839,492,202,827,829,96,382,908,242,662,731,9,254,120,367,276,456,371,960,203,795,201,98,730,574,83,13,924,410,800,926,326,21,217,851,318,523,836,717,268,473,931,352,533,418,23,49,141,28,260,110,77,22,86,310,567,494,457,64,10,55,244,737,251,373,728,128,299,125,105,0,51,48,679,822,489,5,616,265,295,284,615,102 }, +{ 113,311,611,6,491,80,667,25,209,45,26,27,684,42,122,73,85,396,255,145,106,17,614,29,648,297,690,19,454,61,64,624,4,5,416,445,112,32,2,138,76,65,74,151,483,90,174,66,665,119,22,287,1,59,86,378,128,833,194,573,881,141,70,52,0,525,742,214,315,243,544,680,14,87,216,469,11,746,179,250,495,887,95,12,10,222,21,348,814,289,280,204,84,72,436,77,123,56,33,114,177,235,53,137,102,81,161,631,136,46,790,503,58,240,292,208,200,153,36,202,63,7,186,50,135,57,49,37 }, +{ 15,0,1,5,23,9,51,13,2,7,12,120,115,77,260,82,180,341,202,4,450,141,10,8,351,197,21,901,6,817,403,137,102,14,64,22,165,342,457,269,93,16,3,32,11,110,37,128,318,177,401,40,494,18,365,523,854,453,33,36,421,352,475,217,28,210,922,31,569,898,317,125,44,719,30,730,59,86,144,24,48,203,961,17,49,373,116,98,99,308,326,117,752,386,576,153,55,291,39,629,899,95,221,196,139,642,661,402,237,143,244,134,160,90,509,670,391,65,498,349,89,54,127,57,805,275,253,758 }, +{ 219,127,258,98,395,924,421,276,293,697,944,567,201,284,453,401,242,512,308,51,860,475,23,105,295,131,137,272,770,301,843,670,116,299,578,386,935,125,261,13,763,31,576,456,791,115,44,492,403,221,662,268,9,730,801,269,202,49,365,964,55,805,616,159,699,943,22,141,506,224,327,206,541,21,551,144,39,393,165,326,0,842,535,203,36,743,910,28,170,332,318,282,494,949,716,253,569,197,1,143,10,341,533,5,160,615,457,391,916,317,911,187,737,286,384,93,24,599,109,371,180,900,783,244,352,12,623,48 }, +{ 15,352,752,317,180,217,854,141,351,82,1,898,36,341,260,115,23,13,365,21,120,110,10,33,291,922,64,901,372,77,349,160,143,244,51,137,32,498,661,269,5,4,202,304,197,48,253,40,237,102,450,457,373,318,11,22,35,482,251,67,55,9,719,165,59,117,72,153,177,196,12,83,28,961,579,247,326,45,96,17,864,69,523,2,468,125,0,86,730,811,128,817,134,93,90,148,144,437,37,111,403,342,76,57,546,230,704,345,308,139,89,58,873,29,203,164,531,50,30,3,275,559,127,855,629,473,8,56 }, +{ 129,123,257,184,162,17,205,249,183,769,80,119,497,229,106,5,45,130,84,90,59,152,3,99,128,4,618,27,57,77,245,40,62,452,556,378,19,214,460,136,14,12,240,56,26,2,202,432,6,33,61,266,11,209,402,403,64,21,269,102,381,25,141,29,504,76,139,318,54,73,305,34,217,619,179,1,10,32,177,38,361,207,475,383,37,483,22,210,255,115,494,58,196,524,65,23,710,775,53,306,153,742,86,180,421,36,469,137,117,15,51,216,48,134,313,0,111,72,161,285,288,7,757,250,880,503,151,372 }, +{ 102,33,128,64,77,23,51,202,141,269,13,137,40,10,196,22,0,86,117,153,403,318,342,210,65,1,115,139,15,95,134,475,453,180,165,2,177,217,14,6,494,291,197,99,36,4,59,49,28,5,7,11,402,120,12,114,194,3,18,9,19,31,125,237,82,352,17,16,21,110,275,401,44,260,24,285,719,349,25,93,326,457,164,351,111,300,216,27,317,421,133,26,37,203,143,312,116,108,8,277,498,730,365,678,341,98,244,20,386,523,308,105,29,752,372,32,485,450,901,391,361,57,283,48,30,208,96,38 }, +{ 7,14,172,107,92,2,16,135,46,35,232,294,60,97,87,5,278,24,126,29,220,52,38,21,262,66,192,202,58,20,70,48,43,171,359,54,32,448,356,337,37,353,226,112,75,298,1,526,18,12,872,132,64,409,140,22,155,387,334,128,121,392,357,318,307,461,331,0,150,314,49,146,61,415,86,69,71,620,673,230,494,380,324,6,362,355,330,45,259,77,888,137,10,13,246,95,186,141,74,23,50,279,147,194,28,25,51,9,4,609,151,177,55,849,145,199,31,115,102,550,597,59,36,216,90,17,441,222 }, +{ 576,403,615,805,523,475,326,817,494,421,120,51,450,859,137,202,453,260,670,402,77,23,551,401,386,33,958,318,704,342,269,197,196,0,165,480,373,323,65,153,899,753,629,10,803,697,102,7,569,59,4,2,351,90,12,13,962,677,110,9,801,118,40,6,95,5,128,28,143,730,446,124,122,114,14,917,306,207,82,621,407,86,16,164,115,154,64,842,886,848,735,661,484,397,302,247,174,149,141,71,60,1,719,216,104,81,925,628,457,208,168,49,25,22,844,824,685,338,175,109,259,810,236,933,932,854,804,788 }, +{ 141,352,202,269,137,217,180,372,349,9,18,0,51,115,23,13,16,365,221,318,165,317,2,494,752,7,125,120,77,98,20,10,64,49,341,291,22,901,95,260,854,351,308,55,30,28,403,144,93,44,922,873,326,223,82,48,39,35,21,14,197,203,24,153,33,102,753,498,473,156,88,65,386,32,717,275,268,31,196,177,817,730,704,678,661,482,450,437,393,373,288,241,195,132,121,118,110,105,101,36,1,947,475,237,5,253,244,206,201,168,164,158,143,128,961,954,864,751,615,576,551,546,523,509,489,453,442,421 }, +{ 23,202,51,141,13,165,1,21,5,180,197,269,318,137,48,128,15,7,403,120,12,102,125,64,2,33,14,326,523,450,260,93,37,16,386,32,9,4,237,6,115,352,77,203,457,153,196,82,18,117,0,110,421,494,453,401,40,24,817,98,351,475,99,221,730,144,391,31,3,44,96,291,30,719,308,36,39,341,342,11,217,35,8,899,50,20,402,854,615,922,116,160,72,28,17,22,45,10,373,317,89,88,61,59,285,509,752,365,372,58,19,901,46,139,70,349,25,177,65,86,293,90,247,498,54,576,758,898 }, +{ 25,151,145,6,122,174,29,138,74,665,42,416,113,614,45,746,525,287,348,311,396,544,85,66,26,81,280,243,624,355,52,222,32,64,65,680,4,59,19,0,491,2,22,90,7,204,194,104,77,216,112,445,1,61,5,128,86,177,651,91,214,17,95,209,611,141,648,297,80,415,21,102,87,233,454,33,27,43,881,503,20,137,636,573,10,18,14,117,289,76,58,869,202,153,337,496,186,196,789,106,315,11,40,28,135,49,667,269,192,36,13,57,12,115,134,750,70,208,63,72,73,46,597,529,51,48,684,173 }, +{ 166,190,382,254,30,100,731,829,438,264,274,88,795,131,613,578,716,625,9,93,921,616,435,404,265,1,530,203,31,44,960,36,39,827,160,127,272,326,98,924,96,473,224,23,410,116,252,77,144,310,137,856,105,219,101,33,83,0,863,110,800,13,812,51,128,406,478,228,125,521,120,639,21,49,836,102,593,217,242,28,897,772,931,5,688,957,286,115,64,141,691,269,656,317,321,10,494,159,187,197,291,86,363,576,944,67,22,450,201,523,55,411,373,82,822,557,260,456,704,329,367,225,276,48,202,268,213,32 }, +{ 132,21,379,5,32,13,23,195,626,51,48,121,70,1,850,296,687,883,156,771,61,49,407,95,146,125,105,55,652,4,98,761,77,58,33,518,260,18,623,586,349,340,120,82,523,522,354,163,24,16,0,293,45,87,786,165,929,75,64,888,763,535,308,102,31,698,40,269,202,159,37,35,9,845,622,207,663,153,117,900,608,386,817,591,351,347,310,241,221,199,170,158,115,76,65,59,28,22,706,223,774,640,629,461,415,116,101,71,303,60,941,638,427,421,401,391,372,197,196,127,299,937,854,768,475,453,450,403 }, +{ 254,9,272,0,49,688,39,101,578,131,159,518,158,327,333,105,286,68,716,224,252,28,890,344,616,310,846,829,219,827,228,613,24,35,364,16,30,18,938,371,406,166,419,65,455,22,95,627,793,709,98,910,124,154,51,100,31,127,48,1,21,385,190,23,320,242,137,187,374,347,258,36,44,13,301,404,109,856,116,170,125,118,96,160,442,656,424,865,438,931,67,168,64,55,239,623,128,737,265,924,553,221,202,10,71,677,86,83,88,916,60,329,293,538,7,577,512,5,761,395,912,421,212,144,816,944,506,346 }, +{ 16,35,60,20,7,18,126,68,14,43,92,107,118,101,55,71,28,121,9,154,0,97,109,24,621,150,2,191,419,252,5,202,279,363,917,22,21,124,364,169,439,604,199,49,346,446,175,158,12,167,575,48,38,13,493,246,185,10,362,32,95,51,259,375,1,39,598,628,932,566,421,6,23,64,29,108,146,925,61,46,356,494,318,132,140,345,694,149,359,147,65,407,329,376,125,403,697,273,302,212,96,69,137,50,848,25,467,298,77,453,173,230,570,826,221,66,70,143,677,535,265,608,551,58,815,128,907,100 }, +{ 15,1,13,2,341,5,0,11,4,3,10,7,33,23,12,6,117,21,9,40,17,901,197,8,134,77,22,37,365,14,32,165,317,153,102,180,217,457,202,51,961,569,141,128,115,318,38,31,64,19,16,291,137,269,196,372,111,59,44,36,25,352,349,57,99,18,509,72,30,27,752,120,93,54,45,41,342,48,110,49,453,498,79,177,28,719,94,403,402,386,89,82,474,29,285,139,86,482,56,237,361,95,55,391,26,277,116,873,34,210,76,758,326,50,39,143,90,328,260,308,247,125,898,164,24,494,401,421 }, +{ 78,444,47,19,26,390,813,130,108,453,711,27,412,730,65,122,680,283,690,113,51,235,236,73,128,630,196,297,14,250,123,53,194,183,200,133,64,445,368,90,719,3,381,42,23,389,269,6,472,650,249,56,475,32,59,4,57,45,34,648,605,624,503,114,17,25,736,256,22,803,141,318,153,315,95,214,0,684,119,99,18,432,216,899,85,289,46,457,243,33,11,436,480,50,322,177,29,152,129,54,13,657,304,285,84,52,401,117,881,255,714,202,665,597,2,961,12,339,38,361,77,524,115,58,24,145,670,402 }, +{ 2,29,7,52,66,61,45,112,738,113,74,14,5,151,6,315,20,592,70,128,32,425,16,25,1,222,87,135,177,43,64,491,186,59,38,655,21,72,76,46,290,90,243,141,115,77,631,58,106,19,337,207,145,137,4,24,454,833,97,0,26,40,227,311,402,192,36,27,89,210,35,292,269,48,86,10,202,209,496,18,217,22,102,226,138,17,887,204,122,65,318,33,28,104,172,51,255,13,23,42,148,644,216,790,307,287,174,180,92,69,291,95,49,415,75,416,483,549,179,275,263,270,107,9,334,869,214,155 }, +{ 145,112,74,66,26,6,29,70,396,287,138,87,135,222,226,25,644,151,42,19,122,307,651,624,635,337,648,45,2,113,294,58,85,632,849,5,416,75,52,172,61,573,445,27,1,315,884,665,64,7,53,204,32,461,95,17,97,297,174,163,436,220,280,525,192,65,792,73,14,186,86,609,881,353,36,311,549,72,243,22,194,331,148,500,235,80,69,46,680,278,38,312,48,90,21,106,37,409,491,128,10,114,614,631,209,67,415,227,50,108,237,250,580,155,76,141,171,544,262,24,620,12,43,133,611,4,334,389 }, +{ 92,126,60,16,7,24,35,232,71,14,150,140,121,246,314,146,172,132,199,107,18,267,46,278,572,230,108,451,330,236,380,388,462,135,68,38,830,633,392,279,97,2,448,309,649,517,672,32,357,21,5,75,9,118,22,55,167,87,582,192,526,594,366,156,359,298,191,195,64,653,28,50,189,324,563,13,220,0,1,66,467,12,10,423,441,149,733,52,262,877,48,29,70,95,49,516,133,36,54,508,407,360,354,598,550,101,69,37,58,65,271,640,711,212,571,86,345,895,696,273,125,522,23,90,603,72,739,163 }, +{ 13,115,569,734,219,341,127,365,197,509,629,23,98,538,873,901,286,762,55,206,258,165,253,332,170,169,638,535,180,391,116,276,844,31,44,12,546,0,395,164,1,293,10,752,911,36,964,143,282,37,384,512,237,498,308,616,301,740,5,141,352,8,261,9,2,943,654,317,120,284,38,338,913,601,295,244,105,7,3,201,468,924,125,923,910,144,239,21,4,479,482,242,6,86,131,417,961,185,22,64,758,374,110,841,533,401,93,160,15,944,434,82,951,567,843,268,14,564,837,299,272,719,28,860,109,11,351,935 }, +{ 151,58,396,53,287,74,27,73,297,549,29,651,145,70,445,112,113,315,436,26,331,6,573,250,75,45,334,52,307,17,5,34,80,163,2,138,19,491,61,881,220,409,631,262,1,614,632,226,171,106,611,186,32,200,66,50,62,311,25,46,845,767,500,21,135,644,243,223,87,14,48,42,64,3,472,108,324,76,122,161,635,684,65,294,56,38,136,95,72,255,114,849,780,278,209,37,90,852,84,714,7,51,89,148,624,237,383,36,207,236,502,22,12,133,86,322,659,227,119,69,222,11,4,96,309,263,179,33 }, +{ 214,289,90,874,104,751,64,835,312,249,204,65,750,288,875,348,519,174,247,194,74,715,81,138,32,280,524,784,192,636,319,437,879,0,95,85,6,681,217,173,954,91,29,177,86,597,792,77,317,671,422,22,115,864,888,52,202,752,216,673,588,712,18,123,180,233,306,43,355,304,352,20,76,693,579,66,4,5,25,51,21,343,59,237,2,28,61,426,235,577,33,10,397,316,707,287,145,370,24,102,49,291,17,108,84,945,222,97,57,208,56,401,42,526,560,13,730,40,402,23,117,207,474,7,484,72,494,36 }, +{ 9,39,166,28,35,158,49,30,101,175,439,0,346,1,364,64,88,274,100,168,36,67,404,310,333,952,159,55,345,505,190,706,254,420,86,237,23,336,68,22,251,344,51,69,194,114,164,131,570,208,180,756,10,799,143,399,109,83,50,115,141,967,438,768,584,868,128,752,105,95,103,189,286,252,352,5,323,2,230,65,596,289,137,498,7,702,165,13,12,577,503,535,160,125,202,48,547,455,244,610,96,21,16,253,169,857,217,154,797,646,656,228,197,530,747,149,810,124,930,272,865,597,98,185,31,24,389,625 }, +{ 341,901,15,1,365,10,569,0,2,5,180,4,3,115,6,31,7,197,9,13,22,317,951,165,44,629,143,23,253,401,116,244,762,55,93,242,479,752,30,217,51,37,141,28,873,137,638,36,202,203,12,21,86,386,421,77,24,758,11,268,453,318,269,110,33,576,64,811,352,326,164,16,494,506,498,308,670,82,717,642,351,206,120,338,170,261,32,125,40,851,805,260,102,859,8,403,54,661,961,291,144,105,965,98,35,898,482,391,373,153,509,492,958,117,17,499,615,38,824,559,456,384,854,457,282,89,564,237 }, +{ 202,450,120,77,260,318,494,128,102,817,15,269,51,13,342,403,23,291,5,523,137,326,21,141,33,1,922,32,82,351,48,854,177,859,402,64,196,70,615,31,475,40,4,153,285,59,0,12,22,10,2,9,95,98,61,90,28,210,30,17,453,194,117,139,8,352,96,49,275,35,678,899,113,349,165,65,180,6,730,93,692,115,58,704,217,37,203,719,116,576,125,50,457,75,44,421,163,216,36,134,7,39,3,416,14,67,197,25,373,110,341,207,112,86,386,87,56,127,99,11,223,551,365,300,105,16,19,237 }, +{ 241,32,13,115,197,180,165,316,64,288,125,21,23,237,247,141,95,16,22,92,167,522,191,546,498,391,341,28,752,177,586,4,48,509,447,118,459,90,5,352,59,901,264,225,304,350,35,199,126,363,18,217,24,410,468,691,246,841,744,10,478,102,77,649,386,117,86,49,317,308,302,212,146,33,71,954,156,72,46,674,93,31,0,640,411,923,903,645,686,271,698,2,521,140,602,591,120,36,375,68,12,864,321,695,873,758,340,336,318,269,179,143,65,897,772,446,880,839,682,366,190,57,30,818,781,303,953,388 }, +{ 16,24,35,71,60,14,267,18,46,140,69,1,7,108,189,2,92,50,75,230,309,68,236,38,335,220,394,54,366,52,486,21,150,149,246,48,29,87,67,5,571,388,9,181,133,0,103,443,28,163,537,171,55,223,126,545,121,70,12,96,262,328,565,83,32,118,65,516,58,218,37,191,330,563,64,167,22,114,13,51,23,238,251,622,281,278,487,294,399,99,696,115,36,10,582,135,514,86,6,128,517,950,675,674,273,98,101,594,172,49,72,146,95,314,451,155,45,409,212,433,221,345,141,66,247,97,733,125 }, +{ 15,898,180,197,901,341,638,165,33,10,115,77,365,1,4,217,317,5,102,117,253,13,951,752,3,134,2,762,153,569,37,21,0,196,40,11,244,23,6,82,7,120,143,291,32,141,137,51,31,873,55,12,351,44,260,349,352,401,372,479,177,93,22,342,116,36,9,629,308,59,758,450,386,210,854,139,110,111,482,457,164,17,922,421,961,202,719,269,203,373,247,523,28,125,160,48,437,64,326,242,57,704,509,304,14,318,730,498,403,506,148,817,670,8,90,453,494,282,144,72,127,275,579,221,206,899,54,89 }, +{ 523,193,18,84,730,817,90,56,65,240,214,475,453,196,33,719,4,233,202,32,51,153,289,152,123,421,11,194,403,129,99,96,386,249,135,102,40,27,23,361,847,352,59,511,91,457,177,370,134,128,117,510,13,561,75,753,643,388,278,247,204,115,494,450,415,304,77,524,217,216,64,6,5,3,174,701,880,659,609,437,433,432,381,287,260,257,165,139,120,111,87,74,66,1,402,372,318,269,21,899,183,63,141,650,605,770,743,735,718,667,629,611,569,544,543,348,306,288,209,207,162,95,93,86,61,57,49,48 }, +{ 151,29,112,74,222,66,145,2,287,624,52,6,416,45,7,113,186,25,122,665,549,337,87,204,243,5,135,644,311,58,884,226,138,396,61,32,192,70,42,525,415,614,315,19,64,491,651,26,4,227,174,609,544,20,21,43,14,27,128,22,172,632,0,59,209,65,353,97,631,72,1,85,580,86,17,445,80,454,307,104,90,334,81,496,177,46,635,141,255,48,37,77,75,10,155,869,659,76,294,106,49,73,11,95,38,36,115,673,69,18,216,712,148,173,792,33,331,102,280,12,16,24,137,881,89,297,91,28 }, +{ 13,2,23,0,77,5,217,7,1,6,33,3,15,51,10,115,141,102,180,64,4,9,40,317,11,197,14,117,165,153,341,22,352,237,17,365,134,269,291,125,16,202,12,196,372,59,349,177,752,498,128,28,18,32,318,8,36,95,457,19,86,49,210,143,391,901,24,342,21,304,569,31,509,137,139,120,27,386,57,25,164,98,29,111,401,403,45,26,244,864,482,546,110,44,961,308,38,275,453,37,35,93,48,402,247,629,20,50,46,719,873,55,475,65,56,30,72,579,203,523,99,253,494,468,170,54,116,76 }, +{ 28,67,0,65,1,114,103,83,69,50,9,55,2,109,124,46,133,24,14,35,22,154,36,68,38,547,389,218,7,283,323,16,54,18,12,160,194,420,49,251,175,5,75,185,238,39,289,429,158,96,208,168,532,29,86,480,505,531,484,189,503,169,149,797,782,361,21,101,570,52,346,71,181,336,927,533,48,95,37,108,51,596,10,252,23,159,128,799,105,285,418,64,118,535,335,398,732,6,70,803,419,137,220,13,866,171,756,394,30,32,309,328,140,115,87,60,230,433,345,141,58,439,831,402,610,366,99,754 }, +{ 121,271,132,167,146,18,363,101,411,621,354,212,520,60,9,647,932,446,806,16,195,407,463,777,364,562,35,360,522,68,55,1,98,118,31,252,706,694,191,0,24,107,936,664,676,604,199,48,126,781,23,590,156,28,591,150,21,447,39,125,5,109,264,49,759,265,96,22,404,33,13,10,100,44,51,905,259,71,346,857,682,116,223,848,941,7,92,154,93,105,108,478,77,467,286,821,166,64,638,907,765,691,628,279,178,14,203,102,12,30,120,393,158,159,593,834,724,419,147,50,293,163,815,786,367,70,634,2 }, +{ 26,6,85,122,396,624,42,25,573,445,174,416,665,19,680,648,138,145,348,881,64,436,214,113,235,65,297,544,194,90,45,746,525,280,112,289,74,233,32,53,27,355,29,222,287,389,17,151,86,80,95,813,81,73,256,5,249,141,283,91,597,0,343,76,22,66,87,204,415,874,209,312,690,524,611,255,288,63,644,123,243,70,614,216,4,128,2,77,119,61,370,106,52,491,315,58,10,56,651,21,12,519,18,14,835,59,250,352,247,114,49,179,636,205,684,619,311,57,84,28,337,667,177,108,11,208,503,240 }, +{ 146,16,199,24,71,18,126,60,92,121,271,156,360,953,640,108,132,674,35,246,118,273,32,354,195,649,7,314,150,458,522,95,517,167,446,191,21,140,340,463,22,388,68,107,566,575,241,727,10,345,591,359,296,48,586,14,407,28,5,608,149,672,594,602,660,1,467,363,212,13,9,823,49,267,101,225,124,55,232,37,653,0,392,877,50,447,330,702,12,809,462,441,230,508,46,668,189,77,303,236,733,23,698,621,115,423,411,399,298,97,350,247,72,796,451,64,658,217,69,589,309,51,928,264,168,102,163,133 }, +{ 51,23,13,453,475,730,719,899,403,202,401,21,15,64,523,115,95,457,33,12,141,308,32,102,4,128,40,19,11,421,5,117,386,3,99,22,153,125,26,817,120,25,6,961,165,1,180,196,17,197,494,57,134,221,0,194,2,237,260,7,670,48,27,365,37,629,450,49,170,65,14,569,137,342,236,38,352,10,56,29,20,16,468,316,241,402,391,77,177,350,84,34,283,269,217,82,9,247,546,351,318,42,59,372,903,841,558,317,129,86,47,46,41,28,18,326,615,341,90,291,164,801,509,119,76,63,54,24 }, +{ 151,396,53,113,73,445,145,6,27,297,573,26,287,315,112,436,74,58,138,491,45,70,881,19,614,34,250,61,29,549,611,80,17,631,632,5,307,2,200,644,32,222,64,25,52,106,42,1,243,87,66,75,845,226,311,186,334,849,95,122,472,322,294,21,651,714,255,684,48,171,331,194,65,161,209,14,128,86,72,141,46,624,50,135,22,635,262,227,85,108,136,7,220,90,76,163,235,176,114,312,280,62,409,10,337,4,148,56,454,283,237,12,469,37,51,780,214,667,236,3,767,133,36,89,495,155,0,23 }, +{ 223,774,1,888,385,260,98,863,202,269,421,730,96,349,697,453,141,393,622,834,318,751,87,418,791,765,801,922,163,21,335,352,5,7,120,13,291,854,64,23,717,851,293,30,284,372,31,678,371,217,947,351,70,51,32,137,48,77,128,82,442,450,44,49,36,752,125,386,541,931,304,873,0,498,22,2,201,276,807,317,10,670,180,102,6,75,237,39,373,33,69,770,144,177,95,17,16,160,116,100,842,203,197,968,949,221,115,275,165,494,475,127,898,58,963,523,403,12,954,537,45,50,433,872,652,526,268,241 }, +{ 60,16,126,92,121,35,150,246,7,598,279,199,191,167,441,107,71,97,146,195,271,18,298,24,407,356,517,230,1,14,98,508,423,140,674,132,359,223,653,212,48,68,399,783,345,21,314,108,607,43,467,232,362,649,118,392,189,20,5,0,149,702,727,55,22,695,28,446,672,69,66,49,493,10,50,388,809,273,2,522,31,46,640,293,125,9,13,95,101,267,173,501,393,834,877,38,575,67,32,75,37,796,346,779,608,12,156,589,236,566,163,96,221,104,360,375,535,64,711,463,23,175,755,172,414,562,953,354 }, +{ 22,105,28,1,239,95,55,170,320,301,127,36,98,31,49,109,9,2,0,168,35,67,185,169,12,14,86,512,7,44,395,159,5,194,293,312,114,64,83,928,713,740,65,24,23,623,21,299,10,338,16,51,242,50,125,141,933,420,13,237,37,164,844,286,143,69,175,584,892,202,48,6,46,371,103,133,269,116,685,39,916,137,115,160,599,208,272,128,96,284,158,737,762,638,180,244,276,187,763,308,165,841,761,479,505,401,347,424,318,389,30,352,870,18,131,32,197,219,965,327,538,54,456,900,506,253,385,874 }, +{ 2,292,6,119,29,207,76,61,306,45,5,790,17,240,32,58,106,1,151,476,710,14,214,209,25,179,84,52,70,64,90,7,112,26,311,19,618,72,128,129,27,255,123,655,460,59,249,141,86,4,80,40,113,22,115,46,10,245,464,205,145,243,263,358,77,56,36,74,65,315,504,454,148,3,186,95,0,519,50,177,75,202,21,269,38,257,66,42,137,23,16,769,51,738,48,136,33,162,18,184,62,241,99,227,24,318,194,87,491,37,11,12,57,425,833,180,402,49,237,89,287,216,13,720,102,54,631,138 }, +{ 51,221,23,115,254,438,48,421,530,541,13,21,401,613,308,39,688,386,125,840,228,551,453,960,827,1,166,96,406,326,393,627,670,158,49,697,656,829,846,770,333,856,404,5,180,30,863,190,202,669,518,890,219,83,159,98,50,131,33,102,310,217,165,137,743,77,32,101,31,752,679,15,105,615,468,391,341,317,0,224,9,498,352,258,286,455,364,187,778,197,344,44,865,539,457,482,272,128,116,37,28,949,403,876,385,963,373,709,931,719,64,574,68,35,160,274,268,616,345,442,95,492,450,293,843,839,22,261 }, +{ 5,1,22,21,2,12,14,36,48,0,54,86,32,10,28,50,65,37,38,23,51,17,7,208,3,9,114,45,281,13,4,137,323,46,24,6,99,95,18,49,58,55,115,480,72,202,96,745,285,194,181,67,64,16,270,89,133,218,83,168,403,11,430,29,61,155,128,160,503,361,540,223,77,244,221,389,318,757,164,103,141,283,76,402,502,401,59,859,920,40,341,543,290,31,803,269,513,735,124,165,308,33,75,253,421,143,838,754,69,90,180,197,125,102,19,494,453,475,966,105,27,289,109,584,576,569,765,148 }, +{ 182,23,363,284,296,447,340,98,1,291,698,367,93,668,658,156,144,21,269,70,433,379,31,318,478,354,203,44,691,335,180,13,223,125,116,937,586,411,326,110,107,48,18,421,664,724,273,197,141,51,692,195,87,5,67,914,687,486,759,349,551,386,375,268,232,149,102,60,35,33,115,795,251,69,65,49,415,364,77,771,626,163,453,281,165,127,121,24,10,360,806,791,393,336,39,475,372,217,850,662,942,682,518,484,361,359,221,196,146,133,128,117,75,64,22,12,7,883,591,457,132,16,647,153,120,68,801,670 }, +{ 45,498,17,106,546,115,32,62,873,41,197,180,509,54,129,468,243,255,123,752,165,155,38,341,13,241,292,217,720,449,57,136,536,734,569,148,51,476,248,428,214,139,76,369,221,482,328,237,542,365,72,89,339,181,23,227,350,64,90,211,117,11,519,270,290,405,721,587,457,21,901,50,128,741,710,141,552,313,430,162,2,540,130,202,15,102,528,247,488,317,209,157,77,48,14,3,391,152,431,308,629,4,618,743,281,179,5,183,33,40,12,37,358,361,266,46,86,961,828,471,773,372,421,543,249,507,119,10 }, +{ 32,95,64,237,92,180,246,22,241,197,125,115,312,652,126,638,49,316,13,21,5,165,288,534,7,4,48,0,28,23,498,392,296,107,888,340,90,303,658,626,247,70,441,10,16,365,953,468,260,230,546,18,24,774,12,379,883,98,490,482,863,31,877,508,391,141,51,830,933,354,9,517,347,150,314,385,177,132,65,146,645,40,653,76,33,2,341,217,14,269,44,698,263,156,195,850,649,633,199,120,360,359,563,923,509,216,128,86,60,733,873,267,35,1,442,168,330,293,929,545,11,622,591,87,77,641,437,660 }, +{ 15,33,341,217,13,77,141,4,317,102,23,40,115,180,365,351,117,21,5,352,854,1,137,197,11,10,153,51,82,901,32,134,59,64,202,196,36,244,269,22,922,165,2,291,260,177,752,143,0,120,898,48,3,318,12,9,372,253,128,457,31,569,28,37,160,30,247,86,139,55,44,72,7,57,349,110,90,237,498,342,304,111,719,579,450,96,8,730,403,308,811,49,523,164,386,35,125,482,437,17,6,14,961,39,98,494,116,93,275,642,401,210,95,221,76,277,105,717,373,203,216,38,873,899,18,817,326,509 }, +{ 120,260,1,15,141,217,352,13,77,82,93,351,110,23,180,317,349,51,202,21,854,326,165,64,269,128,137,5,291,304,752,36,373,372,922,450,318,177,203,197,115,48,457,10,342,2,0,898,102,160,12,16,901,22,125,386,86,9,144,32,96,35,719,28,7,365,341,244,275,494,210,730,18,95,83,661,4,403,237,523,498,247,143,864,473,90,14,961,437,33,817,40,37,8,678,482,253,579,569,98,72,24,50,475,391,67,69,954,717,288,164,65,49,6,206,216,55,17,134,947,899,576,308,76,316,196,490,402 }, +{ 23,13,51,115,77,217,141,177,33,202,4,64,269,102,0,128,10,2,7,318,40,59,32,14,6,11,352,22,9,291,90,247,180,237,137,1,165,16,317,21,210,197,117,153,196,18,125,49,403,3,95,15,17,349,341,304,12,372,216,365,342,19,36,134,453,86,98,28,308,24,31,244,494,93,275,143,475,57,401,44,48,5,498,457,241,120,203,20,8,105,144,221,25,326,110,752,29,65,523,164,37,55,30,719,421,402,139,39,160,27,116,260,26,96,35,300,437,961,82,569,38,45,901,99,72,253,678,316 }, +{ 478,264,724,520,682,98,1,772,905,664,759,821,9,223,21,48,411,604,909,447,363,23,265,100,13,410,897,166,5,907,293,31,88,329,252,39,101,0,51,125,639,848,32,167,96,647,691,807,781,541,686,382,284,521,44,321,777,393,621,274,118,212,18,676,116,163,69,271,936,834,221,593,812,16,24,914,30,10,127,765,115,37,49,354,335,217,144,68,93,386,105,404,586,22,33,4,83,70,806,165,553,697,932,60,77,50,744,463,71,64,286,421,254,281,435,102,35,12,656,371,191,225,963,446,121,213,201,763 }, +{ 29,20,128,7,43,77,174,74,2,23,32,416,52,102,66,491,104,113,81,33,13,6,51,342,222,202,173,14,0,21,525,59,137,45,192,141,319,5,318,64,10,210,22,291,631,18,72,122,90,145,269,196,151,86,61,58,16,665,4,177,40,355,204,153,134,402,28,285,42,738,544,135,48,216,25,275,115,85,24,65,217,9,12,87,76,833,415,226,179,198,38,138,114,49,97,84,243,337,315,311,287,36,426,869,422,172,89,255,17,209,784,112,454,317,425,35,349,117,95,27,494,208,91,194,503,232,30,11 }, +{ 2,1,5,14,58,7,52,29,46,61,290,45,75,38,592,425,50,270,70,16,32,163,24,155,21,186,171,72,6,227,69,334,263,207,220,17,243,663,48,18,89,76,0,67,400,655,738,35,408,54,112,87,148,36,64,449,66,23,106,22,307,10,262,128,292,74,409,115,119,135,9,476,90,65,141,278,37,767,103,83,86,28,720,140,95,780,255,96,25,405,27,77,3,241,51,12,13,306,20,97,666,179,223,40,19,177,4,428,92,151,496,209,172,26,502,113,84,202,790,137,60,431,833,240,659,331,217,324 }, +{ 80,483,209,106,6,26,17,495,255,833,378,469,113,742,27,25,19,814,119,445,161,887,45,42,76,667,61,64,491,151,90,573,73,235,84,29,65,32,136,614,179,383,128,112,145,297,122,2,527,396,214,62,56,240,85,5,53,862,194,648,123,311,611,624,207,141,58,86,315,95,14,22,306,292,34,4,454,436,59,684,790,0,1,289,440,250,129,738,205,70,416,361,3,249,245,57,269,287,665,52,108,402,202,46,12,177,11,114,216,21,137,36,10,200,33,115,72,180,74,138,50,28,318,247,312,51,585,148 }, +{ 98,223,393,834,1,354,195,791,697,447,293,284,360,541,781,807,51,664,591,156,421,411,48,801,163,883,948,668,765,386,18,586,132,121,23,963,363,125,21,446,551,759,31,621,949,770,407,777,271,658,146,730,167,670,13,116,936,453,5,367,296,478,144,371,221,96,70,9,44,202,105,719,127,687,379,49,118,55,60,698,101,842,626,318,771,217,647,212,691,137,281,638,340,165,75,522,463,706,724,32,93,401,39,364,269,16,520,562,35,141,77,50,265,914,450,33,203,197,268,498,264,69,857,335,22,317,103,905 }, +{ 679,876,36,816,141,144,93,137,752,406,669,228,180,269,96,251,332,21,1,48,352,203,351,202,855,160,831,318,345,498,83,5,116,187,120,617,201,64,317,902,258,261,840,23,839,613,473,110,864,466,190,574,219,32,860,13,873,418,450,326,539,926,748,856,260,44,51,384,704,143,50,295,531,197,489,843,661,206,10,944,778,530,217,567,871,88,82,268,901,800,128,822,125,372,365,86,957,31,30,165,37,442,244,728,224,768,851,373,854,505,625,863,386,367,276,55,827,237,115,922,349,420,274,523,223,169,72,61 }, +{ 15,13,2,1,341,5,23,3,0,4,7,11,10,6,51,12,14,9,33,165,115,569,197,180,17,365,217,153,77,64,196,102,22,21,40,453,317,8,32,901,141,457,117,961,134,31,18,37,16,386,629,291,719,110,28,44,475,177,120,93,269,202,86,237,372,24,95,19,125,59,49,403,57,401,352,318,48,349,730,36,111,326,137,128,98,38,82,391,27,139,65,30,873,275,242,203,54,260,29,45,494,55,25,342,210,450,99,56,46,116,509,498,482,752,373,50,351,899,523,308,247,90,143,35,437,76,72,26 }, +{ 202,13,23,51,403,21,494,5,141,128,48,269,450,125,120,523,64,12,318,180,165,453,95,475,15,33,817,32,197,1,137,115,102,7,260,899,4,37,10,99,2,98,326,93,49,196,730,719,221,457,77,16,237,9,31,22,401,6,421,14,386,308,0,117,134,18,352,40,82,20,19,177,615,59,44,61,402,17,391,203,116,110,27,25,90,341,351,153,30,28,285,105,217,3,291,8,958,854,96,24,50,805,922,54,961,758,576,39,26,801,247,347,509,46,757,342,317,365,498,11,194,72,670,210,38,139,275,170 }, +{ 16,24,71,146,60,18,92,199,126,118,246,35,121,108,140,167,132,230,649,271,360,267,7,9,640,388,150,156,232,191,133,522,273,68,236,101,107,212,0,672,55,446,953,14,149,458,674,330,46,67,314,566,95,189,602,633,392,562,195,64,591,103,21,467,39,354,69,463,407,114,247,98,32,5,50,172,10,1,733,399,278,366,49,36,653,309,412,65,823,22,28,915,288,877,316,124,75,345,340,264,37,12,594,516,135,563,598,451,225,86,38,572,830,125,31,30,359,517,115,571,363,164,726,398,48,237,116,251 }, +{ 269,141,177,678,202,77,318,947,128,349,33,291,40,102,352,210,498,137,954,120,205,864,216,64,196,597,304,275,217,494,461,23,402,115,342,90,13,403,450,300,95,49,197,111,14,326,22,139,237,10,0,125,873,372,182,751,86,117,615,7,44,195,36,31,83,67,752,356,153,98,46,96,59,252,109,97,800,357,285,774,523,550,208,609,569,546,391,247,116,93,66,24,19,18,17,15,6,5,3,2,30,922,414,373,180,159,147,105,20,485,75,859,854,392,376,317,298,288,277,260,143,134,107,39,28,735,415,409 }, +{ 16,71,24,92,35,60,18,191,167,108,246,126,150,118,140,68,7,273,121,149,212,21,388,14,399,314,517,267,796,230,48,146,823,199,271,458,1,467,189,695,877,674,345,9,55,97,46,702,101,575,602,594,733,841,0,350,22,375,107,95,232,28,236,462,32,566,69,298,50,672,13,2,5,727,133,451,154,302,125,653,463,23,446,124,10,589,223,132,64,67,175,38,37,49,98,65,354,423,398,103,649,172,562,755,75,66,336,221,197,903,508,915,809,363,359,51,380,411,309,608,237,330,412,241,12,640,509,36 }, +{ 2,14,75,46,29,52,1,70,171,69,163,220,58,38,112,24,16,7,409,67,262,223,35,334,155,186,5,151,267,394,54,307,87,140,103,309,50,45,83,189,400,18,71,60,92,335,760,227,502,48,21,181,108,61,96,537,12,820,25,278,6,852,113,549,66,357,366,32,287,587,17,37,19,536,27,606,36,150,135,97,74,64,26,380,486,65,0,552,583,28,230,281,600,294,787,582,849,68,149,133,675,22,315,311,236,72,474,243,114,10,324,571,238,86,226,764,9,55,780,218,145,209,80,462,328,95,430,767 }, +{ 265,166,252,100,404,9,329,382,520,593,812,39,88,274,604,101,264,0,553,1,639,676,438,865,664,333,310,68,30,656,167,821,118,363,411,96,23,682,18,158,48,21,478,364,190,105,286,51,98,49,254,435,759,724,647,13,212,16,907,272,124,921,159,31,223,419,125,905,557,5,447,93,154,321,44,393,83,410,327,455,848,35,67,621,293,271,127,191,71,530,354,344,32,24,60,625,213,418,242,109,131,36,69,33,221,144,765,28,121,806,65,50,777,116,22,238,960,146,834,781,897,697,778,165,163,466,115,948 }, +{ 16,35,60,18,24,68,158,71,0,7,55,118,109,14,49,22,159,105,9,28,329,126,344,92,20,107,10,154,553,265,2,191,101,95,424,23,21,5,327,121,13,1,286,239,43,747,51,419,48,455,108,374,168,39,272,677,137,169,124,149,12,199,310,150,46,128,38,279,320,37,709,170,346,6,64,98,167,202,31,185,252,67,810,65,36,125,917,175,577,97,212,32,942,44,518,29,925,628,86,301,69,146,375,132,538,575,913,890,566,403,634,439,333,61,33,50,326,147,165,120,66,446,102,273,421,96,493,116 }, +{ 13,15,23,51,0,1,2,5,77,4,10,115,3,6,9,197,7,177,202,165,961,22,11,12,457,318,217,180,31,14,21,141,33,403,40,102,32,120,453,269,8,341,59,18,16,28,44,17,64,291,93,210,719,37,352,401,110,569,49,317,134,117,90,203,475,260,365,30,450,386,494,36,730,523,125,326,196,153,24,498,98,275,901,111,99,421,308,137,349,817,48,139,752,82,72,95,116,237,86,304,391,247,873,19,509,76,372,216,482,629,57,342,899,128,373,39,758,89,65,864,351,437,105,55,221,38,144,96 }, +{ 160,251,137,93,317,36,180,1,345,120,352,752,617,318,217,332,202,96,365,531,269,498,10,901,141,83,851,341,55,143,64,816,35,968,679,800,260,473,351,230,144,21,373,244,717,82,831,201,876,533,110,372,295,559,258,418,206,203,50,28,704,855,237,349,22,669,86,261,48,898,115,860,253,926,482,9,406,748,197,67,854,873,574,7,434,564,839,69,661,450,15,902,164,228,2,219,843,268,125,187,98,5,728,16,922,165,221,613,335,109,224,442,367,384,868,77,539,840,871,291,822,417,579,116,31,918,44,326 }, +{ 42,25,6,59,85,611,233,128,122,26,4,27,19,343,91,269,614,318,45,177,283,503,138,680,77,80,73,11,216,573,145,102,445,297,0,402,235,210,275,209,174,63,202,389,84,14,803,311,18,33,529,396,255,648,416,280,40,65,256,483,10,64,2,57,678,1,667,624,250,81,24,348,304,17,196,76,194,5,544,454,114,789,151,285,133,90,74,106,51,29,690,12,349,141,61,123,119,152,137,32,355,9,52,56,7,153,525,21,237,28,13,881,36,22,87,436,111,576,300,117,605,495,370,361,291,53,23,494 }, +{ 95,64,81,91,32,237,51,65,180,7,347,74,343,207,204,511,498,577,38,197,348,56,312,128,23,20,370,49,104,43,18,138,22,233,124,86,0,90,554,28,10,681,453,21,14,280,87,750,202,141,25,546,561,29,306,115,63,16,636,241,172,165,147,85,52,24,11,467,650,580,353,192,84,6,13,713,194,673,500,283,9,368,718,151,145,72,57,33,355,263,19,544,475,412,324,318,269,235,173,140,125,108,102,4,933,174,899,519,42,643,879,751,525,403,278,247,221,217,148,123,120,112,111,97,75,73,61,59 }, +{ 326,202,120,817,260,450,494,318,403,137,704,859,128,523,77,576,5,615,553,51,342,291,23,13,1,421,234,475,142,15,48,269,178,968,147,16,21,33,639,922,285,20,49,351,7,854,682,70,58,363,265,373,198,252,402,401,158,82,416,60,132,55,455,354,0,68,102,24,2,329,141,35,101,64,18,6,121,43,95,325,165,31,9,848,798,341,36,12,805,195,32,14,411,10,146,107,75,912,569,116,96,793,424,374,167,156,98,125,17,670,692,163,604,465,25,965,629,349,115,907,427,61,457,65,621,86,71,520 }, +{ 43,20,107,356,362,595,126,92,7,359,319,858,392,493,422,246,441,259,173,683,414,49,97,5,819,279,21,104,60,16,230,35,945,232,0,612,376,48,660,121,32,199,147,132,649,22,18,71,14,663,61,423,470,13,146,672,81,623,298,1,105,693,125,159,408,58,427,98,51,165,501,263,729,95,68,4,24,12,325,779,140,55,23,953,426,28,560,72,804,715,241,581,767,314,939,885,202,118,40,204,102,33,37,17,955,192,713,70,221,598,397,77,2,387,251,344,64,44,31,10,941,75,6,465,603,534,46,761 }, +{ 42,25,6,77,210,483,690,29,102,33,122,342,0,27,4,59,177,40,19,91,300,680,18,21,648,153,196,26,475,202,117,494,128,119,790,48,22,2,343,85,145,56,36,24,32,757,81,1,684,106,292,269,28,833,9,814,151,402,137,84,45,134,70,64,23,139,112,464,396,73,655,115,52,20,614,14,10,403,50,216,63,13,358,233,370,86,7,5,76,37,17,12,485,72,65,397,476,291,57,51,80,611,209,881,665,491,179,99,74,49,416,11,667,624,453,174,148,113,95,235,138,275,61,742,544,341,510,746 }, +{ 31,44,299,116,599,393,456,144,492,125,22,268,242,367,28,963,9,0,105,489,948,434,301,918,36,127,384,1,95,55,49,170,98,512,109,506,206,51,320,23,940,93,558,13,900,86,203,2,10,239,64,5,959,457,141,395,143,7,293,282,855,911,137,202,12,253,165,8,417,159,338,21,24,332,115,401,498,327,551,286,719,197,352,16,791,617,269,391,128,120,870,37,763,244,180,479,14,168,386,308,65,164,39,421,473,160,6,18,692,841,403,276,499,326,730,48,951,272,685,523,713,365,169,903,450,424,559,35 }, +{ 410,521,686,367,321,662,201,772,144,335,88,934,1,98,96,921,264,284,897,274,435,443,909,744,692,203,225,551,120,393,33,960,639,44,418,382,190,217,260,93,64,523,442,197,77,9,100,30,237,166,102,948,244,31,326,765,475,438,165,615,82,10,791,473,717,351,238,206,125,12,805,498,466,213,69,842,617,268,778,899,576,127,116,110,37,5,318,187,0,699,530,303,230,855,854,822,817,613,403,269,39,35,32,21,2,489,141,23,291,704,160,478,131,966,539,905,851,768,730,352,272,247,180,175,137,36,22,922 }, +{ 878,142,178,234,786,132,195,929,416,202,146,147,77,639,522,259,687,167,271,450,481,771,626,212,590,465,49,534,455,427,198,5,315,407,120,0,360,318,48,640,325,23,125,329,113,35,883,22,562,163,346,70,581,13,21,31,98,591,1,61,121,199,107,798,279,150,818,159,20,260,379,668,354,446,44,557,494,269,43,32,10,371,293,95,55,105,141,386,58,33,344,884,64,158,467,116,768,102,93,18,16,362,342,817,60,30,518,191,296,128,711,99,223,39,535,87,170,291,777,97,51,75,402,783,7,156,363,347 }, +{ 254,39,131,578,272,9,716,310,827,829,0,224,518,166,616,333,613,846,228,938,101,30,49,252,105,890,100,219,404,406,371,159,190,265,98,286,158,688,127,68,438,385,455,931,327,910,31,242,856,1,187,709,28,924,737,258,23,329,16,21,557,51,137,96,656,625,125,44,442,116,24,18,48,35,36,13,160,88,65,731,124,863,274,22,95,293,344,395,5,93,109,553,816,128,299,627,530,916,364,761,836,301,154,284,871,118,202,676,201,144,83,276,165,419,944,456,203,10,55,512,32,7,320,724,520,60,115,593 }, +{ 699,854,230,855,473,450,831,704,351,137,217,498,352,800,251,202,160,144,253,203,201,418,206,317,332,752,443,141,1,96,36,180,326,82,822,372,93,244,83,494,335,35,365,817,69,859,237,689,898,21,617,864,318,901,44,702,384,922,954,349,345,341,98,10,48,64,824,367,187,128,295,873,284,120,67,531,579,269,7,86,5,22,678,268,2,261,840,927,957,930,28,735,13,291,31,559,947,116,143,30,851,669,373,723,23,16,260,959,661,125,868,717,403,9,748,437,110,50,213,115,223,539,55,615,466,946,285,533 }, +{ 403,475,202,453,77,318,51,402,494,23,13,33,342,102,128,576,269,141,137,450,120,899,421,523,196,4,117,40,90,275,153,365,349,59,177,291,65,210,64,217,84,0,134,670,15,372,95,197,401,817,1,180,805,341,237,96,260,194,3,285,139,114,99,18,873,326,615,503,393,386,317,293,125,24,11,389,165,70,216,800,752,745,730,719,697,678,657,277,115,108,87,83,69,36,32,21,859,111,457,901,788,323,300,283,266,130,118,86,76,57,12,352,351,9,7,6,2,842,725,541,361,329,312,221,168,124,49,945 }, +{ 144,23,291,268,197,182,202,116,98,44,264,284,415,96,70,100,125,367,141,203,39,110,905,411,1,107,93,363,120,180,296,658,82,310,447,692,897,238,361,190,77,664,260,105,88,520,48,478,166,682,118,576,340,30,18,966,51,865,13,349,379,403,795,551,921,326,687,301,254,581,223,101,676,457,404,156,812,195,242,213,208,9,165,364,323,269,65,60,615,498,21,765,621,271,137,128,917,914,890,855,481,217,154,102,68,232,883,593,523,354,131,948,318,219,691,842,846,771,272,252,0,626,382,149,87,824,822,791 }, +{ 15,23,13,77,1,51,202,120,180,115,141,260,5,0,21,9,137,450,269,128,12,2,318,365,7,197,326,351,48,102,341,177,342,352,523,217,291,403,165,6,64,110,32,373,4,317,18,16,37,36,901,22,14,10,494,90,457,28,854,453,82,24,386,817,40,33,308,8,11,475,401,752,96,922,93,3,244,30,275,719,730,349,210,421,86,160,99,17,898,285,31,961,50,39,569,44,221,59,704,49,117,35,372,237,153,55,143,899,391,253,203,116,134,615,576,144,196,402,65,125,629,98,247,482,83,20,873,509 }, +{ 0,95,18,577,32,207,64,193,29,784,65,887,715,102,52,61,671,138,49,91,74,180,104,701,237,693,474,280,403,241,804,847,22,263,6,174,344,583,453,862,475,77,85,643,500,397,38,37,306,498,494,312,289,2,81,33,5,681,942,510,370,27,283,422,316,192,25,155,347,84,901,319,113,576,24,835,355,348,43,933,814,353,72,194,240,204,42,19,298,650,523,125,86,718,173,247,51,721,389,124,879,490,707,291,153,141,58,54,17,889,202,97,402,1,546,342,134,482,36,511,421,805,750,673,426,196,120,117 }, +{ 101,9,0,252,68,364,166,100,265,124,154,329,39,16,419,212,24,404,71,118,191,676,158,35,88,18,274,553,520,382,65,562,694,28,962,677,671,60,55,30,333,302,706,149,167,604,375,49,109,857,21,703,967,917,865,1,264,593,806,344,310,438,346,190,48,254,96,105,439,23,22,701,812,13,125,175,777,67,925,51,159,656,83,589,570,7,455,95,628,289,108,98,31,286,10,5,221,429,69,810,826,336,36,435,92,131,557,639,722,32,168,793,638,272,273,14,44,128,126,114,50,170,146,37,238,127,484,634 }, +{ 16,24,191,71,167,118,212,18,35,68,149,375,101,108,302,589,60,92,755,9,21,562,674,124,154,246,0,273,48,1,126,363,398,411,55,7,447,146,458,350,841,695,140,65,818,150,388,199,628,345,478,264,22,13,189,647,95,271,602,32,69,823,267,121,28,50,67,796,14,346,23,650,49,175,5,621,520,664,51,882,399,10,903,133,815,777,252,98,100,197,649,64,115,781,46,847,314,517,566,221,509,223,103,575,12,953,125,114,236,230,354,37,336,2,39,96,107,308,640,749,463,936,165,724,462,886,604,237 }, +{ 69,14,2,24,46,267,71,189,38,29,67,278,52,35,135,1,103,108,149,75,309,16,388,83,150,7,60,87,18,236,74,66,220,335,68,251,262,6,50,140,582,357,451,324,133,28,226,366,238,516,172,565,65,36,25,486,114,70,336,0,92,55,594,5,443,458,273,175,54,418,96,571,97,394,906,733,21,26,124,380,12,118,9,218,58,22,154,641,606,398,86,230,48,222,160,37,19,705,42,596,331,550,112,10,412,138,95,45,399,181,294,171,163,145,64,462,32,831,600,603,345,696,517,711,602,545,894,302 }, +{ 13,23,1,4,115,51,2,0,5,3,11,180,33,7,77,10,15,9,341,141,6,365,12,102,217,202,197,317,40,22,165,269,352,318,59,403,64,901,17,21,14,32,752,28,31,49,177,308,457,401,498,453,8,18,873,128,291,494,16,125,117,475,569,196,95,509,36,93,237,153,24,98,372,137,961,386,349,37,139,44,30,326,210,134,342,48,719,482,391,90,120,55,111,86,110,247,203,39,421,116,523,304,260,450,19,546,629,65,105,734,730,27,275,57,468,402,758,143,35,864,351,38,54,144,244,216,300,373 }, +{ 447,1,698,411,125,98,31,21,363,5,919,848,48,44,691,144,759,293,225,914,459,120,13,478,354,156,4,116,922,32,23,127,64,668,163,857,371,202,49,82,30,839,284,586,70,17,223,93,865,664,621,340,165,87,51,39,421,321,260,897,110,551,88,724,330,264,335,318,221,77,3,2,821,772,744,442,190,242,195,634,520,360,201,682,963,916,898,854,685,372,351,349,291,269,217,180,141,105,102,96,95,75,59,40,686,622,949,938,687,658,228,909,100,931,867,638,446,407,761,558,463,456,342,310,237,197,166,90 }, +{ 854,351,180,82,217,352,141,752,898,317,15,244,1,922,21,36,10,64,77,115,260,372,365,35,110,22,291,28,13,341,40,48,120,901,349,4,864,5,661,32,23,160,304,498,237,137,33,11,269,51,202,143,373,93,144,59,164,96,326,98,83,450,318,165,203,102,253,230,55,45,197,2,247,201,67,128,579,17,125,86,76,177,69,37,57,0,16,31,44,728,117,72,27,9,52,116,251,482,342,817,457,7,523,811,367,559,50,719,12,134,961,717,494,187,127,105,49,3,90,873,569,899,418,196,18,316,6,61 }, +{ 13,1,5,0,4,10,33,23,9,2,82,11,3,77,120,6,21,7,40,12,102,8,51,31,117,260,351,134,22,16,153,110,64,450,93,32,196,457,523,115,28,165,18,719,98,59,44,730,30,17,326,386,116,197,898,854,217,961,180,177,291,36,49,817,125,48,342,95,141,90,317,341,922,57,758,202,373,899,139,14,365,352,349,24,203,37,372,901,801,615,128,275,318,269,210,453,39,144,111,237,401,391,72,55,137,105,752,403,86,38,569,494,642,704,99,475,509,498,661,304,811,277,61,247,65,873,308,551 }, +{ 51,403,475,23,13,21,12,494,453,115,99,1,5,523,817,202,7,421,49,22,64,450,899,95,221,32,0,120,308,730,6,180,37,141,48,2,20,10,401,128,44,31,14,753,125,402,3,719,260,11,9,318,801,40,33,19,17,4,386,289,237,105,90,86,16,457,326,36,361,269,170,102,76,39,38,30,165,26,25,961,341,958,576,365,247,240,197,117,98,89,77,61,35,34,350,137,93,82,805,782,756,701,671,670,569,503,484,468,413,405,352,317,241,217,216,214,208,179,134,8,281,316,270,144,83,68,945,901 }, +{ 752,180,352,864,498,317,141,217,237,39,365,115,901,30,88,930,579,230,0,83,101,9,197,372,482,873,128,546,64,100,341,36,1,166,437,927,702,35,213,96,23,13,175,285,68,252,269,349,251,28,689,190,69,868,443,735,304,21,562,723,457,137,399,759,509,244,831,419,10,274,77,321,539,165,818,67,530,201,219,194,228,840,418,345,410,93,131,144,86,570,143,48,154,854,247,646,224,866,49,12,699,669,402,596,954,212,203,208,160,158,800,31,177,694,358,24,117,51,957,406,382,202,22,346,134,7,438,16 }, +{ 16,24,35,71,7,0,18,28,60,14,22,158,109,68,154,118,124,92,168,2,55,149,159,49,747,185,169,424,1,108,105,95,10,577,150,344,175,126,20,239,65,9,677,69,5,67,302,6,12,21,671,46,329,38,107,97,164,23,51,43,286,375,170,48,50,125,140,327,64,320,39,420,29,36,701,374,289,83,101,273,570,37,143,32,13,347,137,191,345,189,230,86,66,553,265,638,128,202,429,455,252,54,272,703,403,246,535,103,52,221,421,654,398,279,98,194,121,114,310,336,467,584,298,165,25,453,346,96 }, +{ 15,341,23,13,0,51,77,1,141,202,33,4,137,9,260,115,120,180,102,269,351,40,11,291,5,318,82,7,2,21,10,901,197,12,22,128,854,922,165,450,16,117,352,59,8,177,217,28,3,64,457,349,90,32,36,403,37,110,18,30,14,401,6,17,523,134,898,365,317,453,48,752,57,31,719,386,817,308,196,421,153,93,24,244,139,86,143,475,730,569,39,99,494,961,373,55,642,44,49,498,285,96,210,253,275,661,125,342,35,237,203,372,95,899,326,144,402,247,629,160,98,391,61,304,576,221,216,208 }, +{ 68,35,24,149,18,71,16,118,189,108,14,7,101,154,0,9,230,175,140,336,69,124,65,267,28,114,67,133,302,46,55,398,251,375,345,2,1,236,458,103,388,83,399,596,60,50,283,38,92,346,732,412,602,36,22,212,309,21,273,39,650,722,246,12,109,48,172,429,29,218,191,906,75,52,364,443,5,86,167,547,54,10,135,252,49,64,238,95,330,37,278,723,96,23,705,516,520,439,628,891,13,51,366,565,158,915,930,232,562,30,868,6,335,637,696,150,952,194,451,484,32,220,100,694,702,886,389,168 }, +{ 308,13,197,115,391,165,546,509,125,629,569,237,749,468,23,9,558,28,903,338,217,801,734,317,352,401,740,254,341,49,36,180,22,386,51,39,159,901,873,95,365,490,506,530,168,961,498,131,166,438,64,482,247,219,579,83,185,109,93,752,656,187,345,439,613,857,457,688,316,101,86,21,158,627,258,843,89,829,637,312,10,55,679,105,967,224,170,251,574,332,406,221,175,228,48,758,902,261,960,505,44,31,876,116,37,12,868,840,72,424,347,1,371,98,15,518,274,141,32,827,333,77,190,892,816,272,253,143 }, +{ 90,64,217,32,115,128,141,216,77,312,86,597,95,59,4,33,247,875,13,172,352,197,147,237,177,288,102,437,210,22,97,5,194,137,202,37,57,11,182,208,153,76,61,14,304,134,117,65,40,751,23,291,947,10,864,342,196,21,362,49,356,178,60,45,874,317,0,54,48,612,165,107,51,259,588,752,324,192,819,298,275,180,20,678,372,307,289,173,43,120,112,415,285,207,164,72,36,35,707,44,7,359,89,46,802,414,156,2,789,729,579,168,123,104,98,92,55,24,712,524,125,87,70,66,470,387,465,148 }, +{ 1,22,28,105,36,95,67,49,2,55,239,0,5,12,83,170,50,9,159,312,86,109,7,114,320,21,208,14,103,69,35,168,301,31,164,64,194,23,892,127,169,323,160,654,98,51,141,65,48,158,10,96,143,133,37,505,13,218,584,38,6,46,751,54,115,24,185,244,347,128,424,44,824,202,253,503,597,16,269,32,237,238,39,137,286,180,512,420,3,352,740,533,29,646,165,638,251,242,318,338,623,175,125,4,18,776,395,797,480,285,713,197,531,116,532,30,928,68,341,401,293,371,99,933,124,789,844,272 }, +{ 18,9,16,101,159,68,252,35,24,105,0,60,310,265,49,39,890,329,320,71,455,118,272,557,7,55,167,28,327,121,286,1,137,170,98,364,271,100,518,333,301,65,14,520,51,23,254,13,212,553,21,604,5,363,109,202,938,128,239,709,30,31,127,95,419,64,22,125,578,846,132,191,616,2,154,158,146,124,371,48,647,395,92,67,621,12,242,627,10,916,411,344,424,116,44,403,32,108,512,338,446,737,374,326,166,86,149,793,36,120,688,421,69,827,318,93,293,126,346,731,20,463,37,260,639,450,848,264 }, +{ 129,123,249,618,214,257,460,205,769,184,17,5,245,162,106,45,90,119,76,183,128,2,209,229,61,80,179,497,6,59,130,1,64,202,99,3,152,27,77,19,710,14,207,84,4,306,40,12,29,141,255,57,240,62,26,452,10,790,58,25,269,177,619,556,21,524,38,266,32,742,217,56,136,86,102,519,7,137,115,432,318,33,292,311,11,151,22,402,48,0,216,51,37,378,288,23,210,54,655,667,381,95,36,34,113,65,72,194,403,139,50,305,111,361,504,483,46,833,285,15,494,180,475,317,112,16,263,275 }, +{ 51,719,23,453,899,457,730,13,475,386,670,4,523,15,401,961,11,12,196,99,153,403,32,3,57,117,21,33,450,59,775,165,40,115,130,421,236,77,308,202,128,120,134,758,108,6,65,391,217,90,64,125,177,197,0,361,5,34,26,260,2,19,1,629,300,183,47,216,54,141,328,817,78,123,22,17,180,342,801,7,95,27,37,241,210,214,269,221,14,10,56,237,275,242,194,494,317,558,412,25,743,73,38,247,48,102,28,488,381,318,9,82,29,326,291,711,288,137,53,304,129,46,277,402,339,283,266,24 }, +{ 173,192,66,204,104,74,636,560,426,825,20,7,43,289,750,707,712,97,861,414,214,348,65,715,81,500,90,138,95,64,835,32,312,174,319,22,526,194,280,874,792,52,0,580,91,681,232,29,6,819,330,889,673,879,5,888,86,77,568,519,422,85,376,288,135,729,387,172,370,2,222,33,38,61,10,21,784,355,49,353,107,249,324,25,69,24,18,42,36,577,226,28,356,102,140,76,448,59,92,751,207,115,671,40,325,4,237,31,359,247,524,343,180,470,145,147,397,16,392,153,117,13,120,26,177,597,125,45 }, +{ 23,51,13,202,21,141,5,1,165,120,269,180,48,12,197,32,15,2,318,115,403,125,128,260,450,137,7,9,523,64,82,33,352,93,386,326,0,6,308,4,453,401,421,102,237,37,457,475,31,14,110,351,77,16,3,221,341,391,99,494,30,44,18,117,8,11,817,203,98,730,17,217,39,719,153,899,373,40,196,24,10,61,498,402,72,365,509,50,90,854,569,317,116,28,144,247,134,19,291,59,96,752,45,285,961,89,615,922,342,58,49,25,35,36,22,349,177,20,546,241,57,670,88,54,29,105,576,65 }, +{ 200,78,34,322,472,27,390,714,161,136,19,59,283,444,250,128,236,176,862,108,47,62,527,14,57,412,53,813,73,3,381,17,453,711,56,585,210,4,46,361,77,196,440,26,65,129,51,153,130,432,383,730,216,183,297,803,690,402,401,45,469,202,133,389,123,529,5,495,162,33,90,275,318,754,194,12,378,177,291,32,257,102,38,719,117,184,114,789,480,13,23,11,106,48,503,814,2,61,629,84,684,54,475,245,21,657,555,231,40,678,152,99,300,507,137,119,80,0,436,113,457,369,650,6,403,86,22,523 }, +{ 347,33,204,498,66,546,681,56,174,5,426,95,135,348,97,172,353,864,49,22,928,923,873,808,73,263,241,10,568,370,27,197,180,77,554,207,81,580,102,21,42,237,368,32,751,526,192,134,117,19,0,350,86,63,715,448,468,115,380,123,76,25,4,29,64,44,31,36,6,91,7,511,40,645,387,85,74,861,408,298,80,736,69,173,872,13,501,355,108,712,138,153,87,61,28,17,901,18,467,72,673,59,620,343,232,161,233,312,800,509,324,278,125,45,30,14,650,636,90,3,451,415,577,500,65,561,165,70 }, +{ 131,224,219,187,385,442,258,836,371,944,871,908,737,924,254,127,98,31,827,716,574,44,39,829,116,201,613,276,839,616,242,860,926,284,137,228,395,144,293,36,96,9,1,578,406,30,456,0,299,567,93,21,13,125,202,23,843,160,166,49,51,64,856,105,846,902,203,761,935,938,662,492,128,295,159,83,48,916,438,268,190,100,115,269,5,403,310,272,318,489,367,110,77,141,931,28,10,531,55,326,165,918,688,32,86,576,22,699,88,158,120,717,530,261,244,143,421,341,434,217,2,512,197,960,625,164,37,333 }, +{ 1,4,5,2,13,180,3,15,7,141,6,115,23,352,901,341,51,0,217,317,197,77,752,365,33,21,11,165,12,269,32,9,202,102,291,177,318,93,40,372,247,10,137,31,349,498,22,120,8,308,403,44,17,873,569,110,401,203,116,59,125,36,457,28,326,196,48,304,14,37,494,386,373,98,144,134,153,128,90,64,117,475,758,260,509,72,18,16,206,55,49,523,86,237,210,95,961,629,421,482,453,30,391,253,450,951,719,342,139,638,730,576,39,864,275,268,579,241,19,82,221,24,546,437,89,57,127,811 }, +{ 370,91,681,636,397,718,510,74,81,240,355,66,84,582,278,289,214,511,701,138,90,18,782,6,104,288,5,65,64,32,693,117,247,77,63,192,56,0,814,306,750,673,312,233,85,40,453,847,671,415,11,643,317,207,134,72,61,42,33,102,4,942,519,343,123,115,27,1,86,25,348,249,22,580,537,461,396,352,153,75,484,784,475,403,304,194,21,10,235,29,3,193,119,583,287,196,114,76,59,52,319,256,124,26,23,13,874,579,389,610,462,302,238,17,710,817,597,353,129,96,51,48,217,164,89,835,804,751 }, +{ 15,13,23,4,197,51,165,1,2,120,180,341,0,260,386,5,8,82,12,7,9,3,141,450,317,153,11,10,391,217,6,351,326,115,64,77,14,457,117,901,498,523,854,509,291,110,134,730,401,758,33,961,237,352,22,202,898,125,922,93,21,365,308,196,31,44,615,269,128,817,99,453,801,28,203,899,116,373,873,752,629,18,40,55,349,137,98,37,318,372,403,36,49,475,569,32,38,86,546,95,16,661,143,704,102,719,30,342,59,39,35,17,642,304,494,482,48,24,638,144,177,300,194,139,958,29,54,492 }, +{ 32,76,292,2,5,476,45,214,72,29,1,241,14,519,464,460,21,179,48,129,290,90,17,710,148,205,123,263,249,50,58,358,52,425,186,243,408,46,257,618,207,38,245,184,89,227,155,769,162,270,171,350,3,7,288,119,61,6,106,57,316,64,54,400,449,128,183,229,255,75,4,141,36,496,115,152,524,655,99,209,720,334,497,62,12,202,59,77,37,86,10,405,0,56,51,221,130,666,23,25,40,592,22,181,237,269,11,247,432,137,16,217,454,84,27,452,428,24,663,619,19,513,318,177,659,26,67,341 }, +{ 13,569,115,165,509,197,629,734,17,873,23,659,106,457,180,45,41,32,961,901,38,536,341,428,62,155,587,474,391,54,21,431,99,546,255,51,243,528,308,365,136,241,37,468,405,89,123,129,14,482,181,2,211,401,139,72,12,148,542,719,221,117,794,214,76,749,498,449,350,317,292,157,743,540,29,758,328,152,552,188,162,11,3,119,720,488,339,770,413,237,227,179,50,248,48,209,697,313,90,741,476,130,4,477,128,1,773,519,277,40,421,507,46,266,57,249,33,245,361,137,153,202,453,369,471,64,133,358 }, +{ 68,101,24,35,71,16,154,124,9,0,149,118,175,65,302,18,108,375,346,28,55,92,252,364,212,429,191,7,439,60,694,39,520,14,398,806,100,22,109,329,166,167,484,273,336,604,67,69,419,189,562,21,826,589,1,701,695,345,95,140,230,265,246,49,10,264,48,158,114,637,755,168,103,917,133,46,628,2,64,722,126,650,399,88,404,535,125,768,570,289,150,458,13,706,83,30,50,36,388,32,420,23,267,12,185,5,882,674,818,96,169,51,676,925,37,363,283,602,86,105,38,221,333,967,159,286,942,553 }, +{ 0,9,68,35,1,65,101,230,69,28,124,23,83,39,141,154,67,13,21,352,212,217,51,30,100,252,88,16,336,115,48,175,864,103,24,317,189,5,180,114,166,128,96,443,36,399,10,12,238,64,329,562,264,478,177,32,18,265,752,77,55,22,321,372,291,218,160,702,149,520,167,50,437,304,202,498,247,137,118,269,99,49,596,365,589,221,759,486,349,197,165,382,346,323,410,2,664,480,223,419,213,777,604,433,418,75,7,4,335,482,15,547,532,37,251,363,237,125,936,72,143,755,341,553,308,190,109,201 }, +{ 909,265,100,410,382,812,88,593,321,213,1,30,252,166,676,639,264,435,466,230,689,39,9,48,724,352,478,21,98,553,96,329,190,223,101,23,274,51,217,13,83,5,921,310,699,438,795,125,69,821,905,530,293,752,759,35,36,656,557,128,144,393,443,520,0,541,284,521,604,137,419,32,682,831,141,455,317,418,664,855,854,251,31,165,772,221,404,386,93,201,180,203,33,686,421,335,539,840,115,55,127,44,957,160,285,158,28,344,68,67,367,77,202,345,254,697,102,669,562,897,807,702,765,286,10,351,64,269 }, +{ 113,61,904,43,0,204,848,453,389,315,788,198,174,5,22,899,222,59,37,102,33,207,422,290,288,128,97,329,306,46,31,30,77,470,817,523,159,58,40,942,122,65,725,690,324,291,104,64,263,450,426,20,54,337,304,247,205,196,153,134,117,105,95,49,408,757,615,351,326,194,115,82,28,18,9,177,137,32,350,887,372,347,331,325,217,90,48,2,701,344,342,320,316,158,317,804,376,341,819,319,849,685,666,600,580,579,553,501,498,403,392,365,357,349,330,301,270,262,242,237,180,112,76,44,39,36,7,147 }, +{ 24,16,141,71,18,0,352,269,75,108,140,7,60,35,330,12,199,217,65,9,486,28,498,864,87,246,64,92,68,50,318,267,126,954,118,115,55,230,70,5,146,177,950,545,13,372,197,752,271,101,98,14,133,77,180,641,349,317,99,36,726,458,23,537,487,156,102,437,22,10,622,165,21,563,516,832,202,2,341,149,48,565,86,457,304,273,220,237,116,44,674,526,117,100,39,33,120,49,37,365,360,830,58,137,103,291,135,522,181,166,121,88,54,51,412,167,284,223,46,15,394,1,696,852,463,361,264,212 }, +{ 271,167,121,60,199,146,191,463,18,446,212,132,575,126,598,354,407,16,955,727,640,566,1,608,195,35,562,279,522,21,48,107,98,71,118,783,223,493,150,467,68,589,24,5,360,781,92,156,363,591,411,668,447,55,13,534,818,101,23,9,108,346,581,647,777,590,49,621,0,259,125,362,936,664,939,7,273,28,31,22,51,163,32,807,10,535,834,221,147,520,246,33,293,541,50,37,586,14,815,375,393,4,116,12,105,96,70,2,44,77,39,93,252,149,281,441,46,158,75,61,759,154,97,649,95,423,364,140 }, +{ 15,115,217,317,365,341,180,13,141,33,23,260,120,4,82,110,102,351,51,40,854,77,372,137,352,21,64,1,5,32,36,10,197,117,898,752,11,901,269,202,922,165,59,9,160,244,0,661,373,134,2,143,22,48,457,349,153,253,450,12,386,196,318,482,247,326,128,308,177,55,72,90,498,523,7,125,961,719,93,28,37,86,3,291,811,509,237,96,57,873,16,437,89,579,391,730,111,203,31,864,18,6,615,35,468,210,216,14,569,275,139,164,304,17,342,76,899,403,221,494,642,316,817,251,30,531,717,95 }, +{ 173,97,356,7,43,387,107,426,104,729,414,359,232,20,560,392,595,885,858,861,707,819,66,81,612,5,49,22,362,319,126,192,230,32,660,330,0,74,357,92,246,147,784,715,14,324,298,172,470,879,95,263,2,422,259,16,427,38,314,207,683,61,376,140,21,681,35,6,29,397,91,60,18,241,10,279,28,64,52,77,24,830,500,493,31,636,33,37,501,12,4,86,779,204,135,58,577,370,65,568,441,40,199,48,526,13,98,581,712,105,534,125,325,17,102,72,44,347,750,138,120,70,59,46,465,25,45,30 }, +{ 15,23,13,82,120,51,110,93,31,33,116,98,95,196,453,4,165,40,197,260,117,0,386,2,180,217,12,1,351,11,77,5,8,134,102,9,141,326,457,115,341,291,3,153,10,401,21,450,317,523,854,202,352,14,7,391,898,6,64,961,373,719,22,125,475,901,28,922,615,403,18,177,269,498,203,237,44,349,99,758,509,32,30,318,128,37,817,16,899,629,308,57,365,670,36,421,49,139,275,661,730,111,569,137,24,39,48,86,704,144,801,752,35,17,65,109,494,342,558,38,372,551,221,216,170,46,55,638 }, +{ 100,9,120,260,30,827,795,373,264,77,137,166,202,326,127,578,1,39,254,82,704,318,217,450,18,101,395,737,351,0,731,291,265,317,156,349,341,31,716,105,102,93,141,197,55,33,968,98,269,5,296,128,478,131,24,851,252,371,342,32,859,938,921,44,616,411,403,404,385,924,144,109,165,40,456,274,180,10,494,836,16,512,854,410,299,195,110,68,28,7,518,442,36,438,286,242,13,244,167,96,363,850,379,656,521,284,95,523,125,64,658,615,340,116,67,922,212,115,447,187,937,935,916,724,936,856,822,372 }, +{ 14,24,2,67,69,46,28,108,1,65,38,83,7,398,18,0,124,154,114,103,36,50,267,133,29,55,236,189,149,35,16,547,52,68,429,175,283,71,336,9,160,118,309,22,302,251,109,458,646,75,6,140,388,86,135,484,278,412,12,596,5,389,650,172,531,54,238,60,218,420,602,96,21,66,208,87,886,220,194,505,782,150,185,169,92,64,10,891,168,95,25,101,797,335,289,533,570,532,74,906,37,230,48,357,49,273,262,323,366,696,346,158,23,516,443,39,32,799,70,565,58,705,137,51,13,439,418,128 }, +{ 66,69,14,267,189,24,71,7,150,172,140,97,149,16,60,380,135,462,2,35,67,74,388,92,38,18,451,278,108,29,83,68,251,6,357,52,46,1,230,443,36,324,423,298,458,65,273,28,336,517,314,823,232,192,398,330,711,118,594,103,87,0,75,565,175,55,335,399,705,124,22,86,25,21,603,448,906,568,204,95,48,12,50,236,5,563,309,43,550,10,154,138,64,32,345,302,37,596,893,20,133,572,54,467,114,126,607,42,26,160,246,220,733,375,809,226,429,526,501,723,9,895,49,808,70,500,602,915 }, +{ 15,1,13,5,2,341,4,365,3,0,23,10,11,7,12,180,6,117,9,17,33,21,134,115,77,14,32,217,197,102,317,165,8,141,457,153,64,40,901,37,51,128,22,961,569,291,202,196,16,31,269,177,352,36,137,38,873,372,28,93,19,351,59,55,349,111,44,509,342,498,752,18,48,125,318,99,304,139,120,386,143,237,116,308,72,401,86,391,110,30,95,54,629,27,482,210,76,45,164,24,89,79,29,90,453,403,25,719,57,275,203,216,82,98,41,758,579,277,247,46,260,49,523,244,26,285,326,144 }, +{ 1,22,12,5,28,36,0,21,2,86,49,48,95,55,37,23,10,50,9,7,96,13,202,32,51,105,14,54,208,168,65,115,128,24,83,16,160,67,4,141,137,31,64,99,318,3,269,194,109,6,323,18,164,159,17,114,35,170,239,281,402,285,180,11,238,745,69,584,103,197,165,480,158,45,341,181,169,403,77,244,44,46,38,218,143,98,433,289,401,30,223,58,717,125,657,503,352,217,851,33,177,185,29,946,597,757,708,39,365,312,317,72,800,253,75,789,102,678,124,418,133,237,59,956,90,127,308,430 }, +{ 123,605,630,63,108,736,444,65,650,368,19,561,619,389,122,216,25,114,183,177,26,53,27,813,133,42,102,194,84,445,249,899,297,56,421,349,90,401,33,597,588,250,137,78,73,130,11,730,51,283,45,524,629,235,59,57,14,141,196,153,32,40,343,255,719,134,117,467,304,119,76,17,13,0,152,6,436,77,390,4,323,511,678,475,457,136,64,594,342,23,403,256,12,129,503,218,208,86,62,61,5,416,233,372,52,3,469,184,275,381,106,947,789,554,214,112,680,450,95,309,217,18,9,529,432,291,269,80 }, +{ 127,39,9,254,98,395,371,31,0,385,836,44,1,30,299,284,100,166,116,578,131,187,272,28,935,49,293,276,21,125,23,16,219,310,599,51,737,442,827,48,242,616,137,18,101,908,5,144,13,846,24,265,456,716,35,512,96,252,93,88,202,22,201,68,159,36,158,7,77,55,224,924,938,141,492,203,128,190,688,269,518,258,32,333,64,37,318,228,2,65,829,326,274,244,761,165,12,115,67,286,120,931,217,110,367,404,105,839,33,102,567,83,268,916,662,95,438,14,86,50,944,109,574,557,69,327,625,10 }, +{ 2,29,61,45,151,6,655,112,207,52,25,425,32,833,76,7,70,106,1,113,14,119,292,790,58,26,72,5,887,64,209,128,17,90,255,315,66,19,145,4,186,306,243,476,115,59,483,27,77,74,21,177,311,38,87,86,40,263,141,738,46,290,36,23,148,454,287,10,240,95,42,22,84,16,137,0,179,202,135,33,631,491,814,75,227,51,269,89,50,210,65,214,20,12,80,222,48,318,24,28,49,13,11,216,18,155,358,102,99,56,464,122,37,644,138,549,710,54,180,337,205,117,496,67,172,869,123,720 }, +{ 2,17,5,29,27,3,6,401,45,58,51,26,23,19,53,52,14,34,46,453,151,133,366,13,61,236,50,218,114,1,73,99,308,487,603,108,21,25,181,670,287,421,297,80,115,396,48,74,56,137,171,412,764,445,202,38,281,62,457,42,65,629,516,480,475,341,113,549,64,573,600,386,57,403,894,250,106,730,54,436,651,491,86,145,12,334,208,155,832,128,328,614,361,262,165,283,84,32,719,323,745,200,90,141,37,36,711,657,631,67,760,754,583,739,635,569,7,594,488,315,161,10,285,59,402,758,243,430 }, +{ 22,170,31,301,127,1,98,44,28,36,239,105,55,299,512,293,86,395,116,685,242,841,9,95,125,338,599,900,2,0,5,654,23,320,169,109,13,456,870,49,64,185,763,10,51,7,237,12,141,144,164,479,143,965,312,35,137,923,21,268,115,14,933,492,128,168,393,284,506,67,286,762,276,83,37,244,6,114,202,160,180,928,24,352,634,194,367,201,197,159,308,165,269,253,558,844,401,538,48,65,208,272,935,391,584,50,420,341,365,131,203,913,318,16,498,3,489,327,96,4,457,374,317,892,386,32,434,638 }, +{ 14,21,50,48,5,2,1,32,270,46,38,290,76,72,45,155,54,17,263,181,408,207,425,281,29,430,221,67,36,96,292,89,449,52,428,37,476,513,241,83,103,119,0,171,7,541,720,528,3,12,10,24,227,148,22,58,179,61,536,502,214,243,655,6,413,90,9,350,23,218,106,51,16,86,69,129,65,186,28,133,115,114,99,431,552,400,760,794,464,64,474,128,433,123,328,460,18,405,137,487,306,84,108,477,245,710,35,236,205,4,13,787,27,238,308,587,309,770,141,540,19,56,790,240,95,223,488,202 }, +{ 17,119,106,378,240,383,136,84,62,80,306,790,56,504,742,3,440,207,209,128,255,483,123,45,5,667,61,32,57,64,179,27,129,14,205,548,297,4,245,2,214,311,141,90,11,76,833,655,184,151,29,361,59,469,152,249,26,38,162,19,58,215,328,257,73,495,161,34,54,229,269,202,250,266,292,21,12,402,514,555,216,113,194,887,130,1,445,503,507,183,6,25,318,237,186,72,52,814,710,618,99,10,86,211,148,452,263,243,65,137,37,40,41,23,36,33,155,497,13,403,53,95,313,227,494,180,77,738 }, +{ 13,1,2,15,23,5,115,0,51,10,4,3,6,341,7,11,365,217,180,317,9,33,197,77,165,40,22,12,14,102,64,141,117,153,196,453,457,8,202,901,17,21,269,18,128,28,125,569,31,386,59,318,32,16,134,349,352,291,372,237,36,719,403,752,475,873,961,730,509,391,177,137,24,401,95,57,44,37,93,498,120,308,139,494,110,98,326,111,247,86,304,30,482,49,143,48,55,629,210,260,758,523,19,351,65,450,72,116,46,76,342,29,275,203,50,170,105,164,89,82,734,242,27,38,54,144,899,90 }, +{ 772,335,662,96,367,744,897,1,303,686,264,521,652,340,116,520,141,31,919,201,966,260,888,203,44,64,905,321,144,225,269,98,691,658,349,284,410,698,692,363,120,88,848,717,863,187,551,914,909,418,576,202,646,443,850,639,523,69,404,336,958,293,128,730,131,615,274,382,296,166,960,948,258,228,224,219,751,486,160,125,82,411,191,765,244,223,475,453,352,326,100,318,676,596,67,351,899,703,403,389,435,947,589,498,102,33,954,291,265,156,922,854,402,93,759,664,447,372,212,137,478,329,724,562,530,286,217,942 }, +{ 1,28,5,0,36,24,65,83,50,14,67,22,12,96,2,48,218,114,281,54,18,21,9,133,55,103,46,181,37,58,160,38,16,7,99,10,223,69,238,32,430,433,502,45,35,51,766,49,108,86,23,124,361,155,487,765,532,283,75,137,270,115,17,838,163,109,480,95,13,61,6,543,154,754,513,70,29,72,202,540,822,657,323,920,398,89,68,64,141,966,3,221,208,285,128,290,956,547,488,269,236,175,168,429,194,474,800,646,171,39,412,775,52,308,531,866,149,880,389,4,180,403,318,842,834,402,217,185 }, +{ 138,174,348,42,25,6,145,81,544,280,525,74,85,26,648,204,355,287,396,91,233,66,636,104,122,746,416,29,64,65,90,45,0,235,194,681,87,22,222,651,95,624,573,32,214,289,750,415,343,445,192,52,112,86,17,370,19,5,135,881,7,151,2,337,113,605,243,63,389,256,49,59,10,4,673,680,77,18,297,61,312,76,614,97,72,249,283,11,524,70,353,33,27,28,216,114,874,173,311,57,43,21,14,597,36,1,141,102,58,24,217,12,436,665,80,172,715,792,148,123,619,56,133,20,491,75,784,117 }, +{ 24,16,35,68,0,18,158,28,71,159,49,7,55,154,109,14,22,60,105,124,344,65,118,424,9,239,95,1,320,2,149,577,286,170,92,169,108,347,12,21,327,374,175,185,67,10,272,5,101,51,48,23,302,455,39,6,671,301,46,13,69,310,20,518,64,150,36,346,50,32,137,202,709,677,191,126,98,125,375,168,538,289,164,38,37,128,638,30,703,747,890,273,127,634,31,419,140,143,439,86,403,114,252,83,962,654,221,762,623,338,115,29,212,103,701,570,308,107,512,189,54,97,167,230,479,345,312,913 }, +{ 854,699,230,352,93,689,144,251,160,137,855,202,617,203,217,36,669,332,450,120,473,351,831,201,213,752,326,800,206,141,258,748,82,418,345,30,180,816,957,318,840,190,443,228,44,35,863,968,10,1,219,871,704,317,64,22,679,83,466,539,498,224,55,96,898,31,116,406,851,384,86,244,295,28,873,98,817,531,187,822,864,373,494,131,559,372,530,901,574,365,69,127,839,735,128,268,67,533,442,868,860,922,88,269,927,859,9,367,613,253,564,930,567,261,260,728,39,237,109,284,276,164,730,489,166,926,125,776 }, +{ 15,13,5,1,2,23,3,0,317,51,115,4,10,11,7,6,217,33,9,77,17,14,341,165,102,117,180,365,134,40,197,153,64,22,12,32,196,21,8,141,391,110,752,372,291,498,352,125,569,16,36,901,202,59,260,28,237,482,349,18,269,457,961,120,318,93,57,509,37,29,128,177,49,31,19,401,48,453,342,38,719,873,45,55,629,111,24,44,143,468,386,50,54,403,86,139,27,308,304,95,210,546,730,475,46,137,98,247,35,72,90,99,82,76,437,494,864,30,326,758,96,52,275,116,402,277,164,56 }, +{ 104,173,20,319,43,66,426,355,712,77,97,0,202,7,198,74,580,204,174,500,32,5,59,2,102,337,90,325,226,234,4,52,22,450,904,155,222,376,861,21,750,33,192,414,194,147,324,342,889,58,544,636,18,291,416,112,784,81,334,64,707,95,331,422,639,715,36,400,14,141,560,792,65,29,177,49,37,315,427,28,57,10,120,24,1,40,48,107,673,11,494,318,230,61,524,128,196,16,12,470,632,232,138,115,329,455,113,142,186,153,819,294,17,525,526,70,117,87,25,247,587,105,269,583,588,158,171,348 }, +{ 23,13,51,5,15,1,2,115,0,141,12,7,4,21,6,165,32,3,269,9,10,457,202,180,197,14,77,11,37,453,22,318,352,120,33,719,217,341,401,403,16,961,17,40,308,18,31,28,8,48,64,475,569,730,260,365,59,128,247,317,137,177,90,93,237,102,99,629,523,44,386,117,36,450,110,153,30,752,899,38,349,72,134,98,509,498,49,326,901,125,24,391,196,421,57,82,291,76,95,19,203,494,89,45,817,304,468,221,139,210,758,351,546,65,373,372,96,54,482,734,144,116,86,39,29,216,402,288 }, +{ 15,1,13,0,2,5,4,23,3,317,115,51,7,6,341,9,8,365,217,22,10,33,77,31,457,197,44,901,18,12,28,180,11,120,165,202,961,102,719,569,40,308,21,730,20,260,351,523,141,36,401,64,482,82,55,49,450,453,403,269,93,318,16,30,498,468,342,14,372,352,110,61,817,125,137,386,117,70,899,25,898,291,509,196,494,475,24,629,854,39,153,349,98,32,134,221,391,416,234,758,59,37,237,95,86,19,91,48,27,177,247,326,903,17,734,873,89,128,421,105,922,57,111,143,638,300,304,90 }, +{ 15,1,3,2,0,4,10,5,9,13,82,12,8,11,16,7,31,23,351,898,365,93,44,854,22,64,21,457,217,180,6,141,317,730,110,318,18,752,719,352,341,51,961,28,269,33,260,77,922,120,202,291,98,55,372,197,349,901,105,165,30,450,14,817,494,523,403,899,128,125,453,95,36,115,116,475,386,326,49,401,111,94,811,642,758,479,474,391,373,203,201,187,153,144,137,38,37,24,102,59,421,282,206,48,569,342,275,216,210,864,846,801,795,692,661,597,559,442,253,244,230,196,177,170,143,127,123,89 }, +{ 2,5,14,1,29,50,38,46,45,17,52,58,114,133,171,218,21,181,48,186,36,6,155,3,19,65,487,12,32,54,27,61,480,323,70,22,51,86,361,137,96,0,208,115,285,227,283,151,23,412,10,281,28,108,37,236,112,328,7,334,163,400,25,4,223,26,67,75,657,194,18,103,128,24,13,514,745,99,401,202,308,532,59,803,389,16,760,11,243,72,64,80,106,9,502,83,832,113,453,56,552,421,403,503,402,95,735,341,956,69,124,782,366,90,141,409,77,57,160,822,433,89,209,244,40,76,177,484 }, +{ 68,101,0,9,212,124,154,65,149,35,16,100,118,24,252,71,562,589,189,336,114,167,265,191,39,329,398,88,67,429,1,264,478,69,166,484,55,30,777,18,399,520,759,13,818,722,175,419,230,48,283,664,796,115,23,28,375,724,346,140,133,103,410,21,705,806,64,51,701,604,83,246,7,345,158,389,60,36,382,302,14,2,108,50,755,5,695,694,237,702,547,917,92,639,411,936,732,213,267,238,32,404,190,10,364,321,289,49,180,553,447,247,650,72,218,46,593,925,468,458,96,905,596,217,95,546,223,439 }, +{ 14,2,1,22,46,67,7,65,28,24,0,69,38,168,50,36,83,289,5,12,16,29,35,55,86,114,103,133,109,49,18,158,95,108,6,194,584,124,185,610,52,169,10,159,189,105,51,23,21,484,283,9,505,389,236,128,239,267,420,164,13,547,143,54,32,64,71,115,149,75,37,140,251,68,48,208,160,253,708,309,137,96,154,244,312,170,782,202,320,412,577,175,308,424,25,141,336,429,218,344,60,892,835,874,347,398,401,531,230,17,278,388,92,135,797,638,732,237,3,323,39,19,286,99,747,4,66,403 }, +{ 23,13,51,15,0,10,115,1,4,2,9,961,457,77,11,5,453,12,33,3,403,14,40,102,197,7,22,165,59,475,64,6,37,401,21,569,719,18,308,99,32,17,177,730,16,141,523,8,341,31,629,217,180,117,386,202,153,196,120,57,28,49,111,125,95,139,899,494,128,421,72,65,210,317,36,342,391,90,19,93,89,44,86,269,365,24,291,237,110,76,318,873,509,482,54,48,300,498,247,134,450,82,275,260,352,98,27,137,326,38,304,758,148,50,79,817,45,670,372,30,179,29,203,734,152,116,349,216 }, +{ 15,1,0,2,5,9,7,23,13,51,901,8,6,12,3,4,180,10,719,341,120,14,31,115,22,141,898,197,82,260,93,21,28,44,457,37,217,125,202,16,153,351,64,110,401,18,11,33,36,961,569,30,77,49,352,450,98,269,139,317,117,116,32,40,453,326,308,128,523,318,365,203,137,730,24,629,854,403,102,39,237,165,55,291,99,475,95,196,48,86,498,134,752,899,373,391,817,244,38,105,242,421,922,59,144,386,57,143,35,349,54,509,482,372,65,253,221,177,304,494,247,638,17,170,72,127,164,114 }, +{ 100,252,265,88,724,101,382,410,48,676,213,909,321,9,593,0,812,329,553,21,352,1,30,230,166,39,419,520,23,51,264,217,221,478,689,435,190,664,13,604,466,677,694,125,752,777,36,98,699,639,83,759,96,35,158,68,128,562,141,223,344,274,310,69,455,115,5,180,404,317,656,364,203,293,831,438,175,308,443,401,333,31,144,570,154,854,105,137,212,346,49,857,530,418,840,855,201,55,921,28,539,421,557,806,821,127,124,67,251,10,634,165,936,22,610,795,16,286,957,167,541,32,962,905,682,686,241,44 }, +{ 58,171,2,46,5,50,14,29,186,1,52,45,334,151,400,38,155,61,103,96,67,227,502,281,223,54,48,17,83,181,552,69,70,309,75,163,24,549,21,311,27,366,80,536,243,113,218,787,106,36,112,433,765,430,209,133,12,6,236,487,19,780,675,394,766,238,587,545,32,37,767,807,834,7,108,114,328,287,315,65,262,820,16,496,583,26,18,454,513,0,3,600,220,25,474,86,307,73,28,35,255,869,537,631,22,72,89,491,409,357,64,270,828,267,189,845,160,221,10,592,137,119,99,659,128,516,541,785 }, +{ 23,202,120,141,51,13,318,269,21,128,260,165,137,197,180,326,1,450,5,77,33,82,15,48,93,64,110,351,32,125,403,203,102,523,854,386,352,457,922,115,7,2,12,494,373,817,615,196,342,153,221,217,16,6,210,144,402,453,36,4,391,14,37,730,9,96,475,291,98,0,99,901,3,421,551,177,18,40,401,237,752,349,31,898,86,719,341,24,704,285,117,11,308,393,116,35,61,160,8,30,65,90,59,44,275,10,241,50,39,216,509,372,67,72,961,247,22,899,28,569,293,83,139,801,473,76,95,46 }, +{ 341,197,901,10,13,569,23,638,15,479,8,873,961,180,165,143,12,115,0,1,951,509,116,37,642,365,499,498,242,253,5,36,898,4,752,2,352,141,268,206,51,55,401,391,7,22,3,417,506,492,82,9,93,11,137,456,338,244,457,64,317,120,110,629,351,546,431,33,21,386,31,86,260,217,164,6,758,965,28,762,474,918,661,326,551,153,125,14,719,94,421,854,203,801,373,269,44,16,730,202,615,237,844,791,811,523,450,40,18,128,864,282,117,111,148,824,940,102,959,17,139,559,170,32,958,867,968,38 }, +{ 23,1,21,51,202,13,15,141,120,5,180,2,197,165,7,269,352,48,12,318,260,326,137,33,386,403,9,450,0,32,6,4,115,128,14,16,523,457,102,37,110,82,93,18,217,3,64,221,752,421,203,453,237,125,77,153,351,494,308,475,196,401,719,31,44,391,373,817,24,730,8,342,30,36,11,40,341,901,96,50,99,615,98,116,117,39,10,22,498,317,17,59,35,160,144,86,28,20,854,961,291,244,177,899,72,402,509,90,922,350,349,95,29,247,285,19,127,661,365,372,49,569,758,65,576,241,898,61 }, +{ 2,29,58,50,262,52,53,27,6,151,14,1,171,5,287,34,324,17,74,46,26,113,309,396,45,223,61,334,96,73,635,445,583,38,19,75,67,103,80,357,70,331,181,573,112,785,236,675,163,281,549,145,366,54,108,315,760,218,220,491,453,297,12,138,62,250,133,436,51,409,200,487,600,128,502,37,64,106,114,651,48,83,394,24,25,820,433,59,766,307,23,155,36,614,311,65,66,137,57,4,765,186,69,21,99,202,56,13,3,587,165,767,7,631,238,86,780,115,283,161,322,545,221,42,32,739,400,47 }, +{ 13,51,23,141,202,115,217,77,317,4,269,33,5,11,318,352,0,102,180,2,64,10,341,7,21,9,137,3,40,128,32,6,22,291,752,15,197,12,365,1,165,31,125,28,498,177,16,403,494,237,18,308,44,59,372,98,349,24,93,48,244,386,49,90,30,342,95,901,475,39,120,196,14,117,457,116,453,17,247,391,153,8,143,482,36,304,203,110,509,326,450,260,37,134,144,210,468,523,86,221,401,569,873,546,719,139,253,35,160,127,285,105,373,421,961,864,576,82,367,437,351,55,579,19,216,275,402,164 }, +{ 1,24,67,50,69,103,35,18,16,14,28,0,5,83,9,54,223,2,96,58,181,12,46,68,48,65,108,133,71,281,149,22,7,163,21,114,36,75,38,55,155,502,238,37,189,99,70,218,45,10,430,433,236,60,765,251,171,61,175,540,23,820,32,51,418,270,29,487,513,52,124,118,336,17,64,49,920,154,13,141,115,545,72,267,221,537,745,290,86,488,309,128,335,39,227,89,328,160,95,834,361,6,101,486,514,543,112,137,474,394,186,202,388,109,150,140,552,807,412,283,307,345,87,780,366,398,77,516 }, +{ 13,23,51,141,202,115,77,269,64,217,102,128,318,33,32,291,177,180,137,10,352,4,21,16,197,0,11,22,9,7,165,90,40,494,125,2,210,247,14,18,153,49,59,31,6,95,317,28,196,349,24,304,5,341,403,342,98,237,117,120,372,44,3,275,35,86,48,1,93,752,36,15,241,12,475,144,30,19,17,216,110,365,260,116,326,134,82,105,143,308,203,20,39,402,386,221,901,127,72,498,437,244,453,76,401,65,38,96,285,316,160,55,351,25,288,482,164,57,139,457,678,490,201,523,509,391,83,817 }, +{ 115,365,180,317,873,498,752,482,341,569,217,901,13,197,352,546,468,1,864,457,509,579,165,23,143,21,15,2,185,36,7,148,12,134,332,22,351,9,261,51,16,5,10,0,346,93,30,141,868,734,372,253,345,116,474,94,77,876,76,28,896,679,384,203,160,39,37,6,98,14,391,109,530,187,843,177,86,629,33,637,11,437,18,4,902,574,434,144,120,44,31,837,72,613,295,169,349,505,228,190,102,95,49,48,706,406,405,96,83,961,617,597,254,237,926,903,717,531,420,258,164,110,860,268,661,477,464,449 }, +{ 184,257,229,205,432,497,152,619,452,17,381,57,266,524,5,45,90,106,313,471,245,32,128,129,59,4,214,2,339,119,769,77,369,12,123,21,14,99,157,3,202,38,710,1,618,216,64,217,292,188,162,76,11,40,249,141,62,51,33,19,372,102,179,37,209,23,27,6,111,318,29,61,403,86,460,349,207,54,269,402,10,48,139,115,36,136,79,137,7,255,72,80,177,519,291,453,529,401,288,58,0,153,475,377,247,306,25,56,26,94,210,22,84,494,50,790,89,775,474,361,328,148,241,588,285,317,678,277 }, +{ 13,23,1,2,0,51,10,5,115,4,15,3,365,7,9,33,11,180,77,6,217,341,22,102,317,40,197,14,12,64,141,165,18,8,17,31,202,28,125,16,269,21,117,901,453,196,177,59,153,36,128,475,318,569,32,24,352,291,403,134,93,401,98,44,752,237,391,372,49,509,457,961,873,308,498,386,95,342,349,116,137,37,139,494,19,30,210,247,143,304,86,629,48,203,111,55,57,719,523,110,482,546,120,38,65,54,326,421,216,730,50,99,899,758,402,260,105,275,39,72,450,96,144,35,25,242,29,437 }, +{ 626,70,687,771,379,767,846,518,878,49,937,591,82,761,31,786,481,407,845,195,590,351,98,44,163,557,13,120,125,48,87,883,371,623,360,817,450,260,178,522,21,5,854,523,116,326,105,291,142,4,296,929,884,259,127,0,132,922,615,77,713,293,217,197,165,22,146,64,931,608,465,457,349,196,32,941,455,279,621,315,202,201,126,110,40,16,11,10,391,666,467,446,373,354,346,144,58,33,581,763,512,916,535,795,768,658,558,447,344,150,92,51,28,24,9,265,212,93,586,562,180,156,147,134,117,1,783,663 }, +{ 264,909,410,897,772,1,686,521,478,914,98,335,96,284,691,639,382,44,744,321,724,100,765,438,223,662,88,144,475,367,31,265,125,116,921,9,682,656,166,363,127,225,21,201,842,0,447,905,393,48,443,421,5,82,329,252,120,805,411,51,821,13,919,69,834,948,934,664,33,23,435,551,274,77,217,131,268,7,93,854,418,520,340,110,30,213,141,453,165,101,39,791,260,922,403,238,698,898,351,102,593,433,64,203,83,303,286,293,197,32,960,812,697,523,466,285,180,692,404,658,35,873,254,163,352,553,190,615 }, +{ 13,23,2,51,1,5,115,0,10,77,15,217,7,6,180,33,3,317,40,4,141,102,9,197,11,341,14,64,165,22,365,17,117,196,352,202,12,269,153,16,291,237,453,128,457,498,752,32,18,134,177,59,21,125,386,318,901,28,8,372,31,349,391,403,95,475,36,137,569,49,308,961,401,509,482,143,98,19,24,44,730,86,120,719,139,546,402,342,93,304,110,29,210,421,873,45,38,629,57,260,326,247,111,275,30,523,55,90,450,46,116,253,50,37,244,65,494,105,99,468,758,25,170,48,96,216,35,27 }, +{ 141,269,77,115,13,318,64,202,177,23,137,217,102,291,5,51,180,48,21,352,0,32,7,16,33,18,11,2,197,128,4,15,10,752,24,244,14,494,317,165,96,9,3,349,247,237,93,35,28,12,6,49,44,1,421,60,20,403,36,341,95,22,475,372,326,308,275,196,144,90,40,39,117,31,678,954,901,304,284,268,221,203,110,98,89,68,46,365,153,134,76,67,576,453,432,402,381,342,179,125,118,86,72,71,69,59,50,17,498,160,164,143,120,111,82,961,873,851,401,377,335,288,285,241,223,210,121,116 }, +{ 23,13,51,15,0,10,453,2,115,1,40,961,33,11,14,4,9,457,22,401,77,102,7,5,569,475,197,12,64,3,21,165,59,719,629,6,196,18,177,386,37,32,17,111,153,57,117,139,31,16,28,730,308,99,38,141,8,403,36,128,670,391,217,210,72,90,523,79,482,341,202,237,45,474,180,125,41,509,46,494,304,275,48,54,95,94,899,29,277,134,120,76,758,65,44,247,498,24,291,148,89,468,86,49,437,82,56,30,402,143,365,349,317,93,50,757,269,734,342,98,352,450,678,62,188,19,152,328 }, +{ 1,22,36,5,12,0,105,28,2,49,31,21,95,9,86,55,13,23,128,7,141,98,170,44,115,239,37,48,127,83,160,4,180,164,51,202,10,269,3,96,6,208,159,137,67,244,320,197,312,50,318,352,64,285,301,125,341,32,165,109,116,217,14,402,708,39,365,16,654,35,30,242,317,169,168,99,253,15,678,11,69,751,569,54,531,752,8,901,947,338,735,77,24,238,143,323,498,158,65,401,17,237,293,946,18,717,740,597,93,512,638,286,403,395,892,144,347,308,299,424,457,185,418,713,194,221,757,824 }, +{ 100,252,101,88,265,0,382,759,329,410,724,9,213,321,553,676,419,593,166,39,21,30,909,694,562,520,68,13,812,264,23,435,677,230,35,352,478,48,190,154,689,212,1,217,570,51,466,639,124,221,83,806,604,175,699,826,703,125,98,308,55,671,664,346,32,158,610,706,96,962,274,31,317,289,344,69,438,49,28,831,917,115,656,455,936,404,165,116,208,777,310,5,854,857,16,201,128,36,333,752,194,67,24,71,144,795,391,197,589,141,818,364,921,131,44,86,203,251,748,105,65,22,180,557,149,702,350,855 }, +{ 539,88,840,190,30,321,530,957,435,748,669,778,144,96,100,466,418,863,410,203,228,213,382,274,795,406,613,131,36,822,1,83,326,856,219,352,335,494,251,230,679,31,224,960,44,831,855,141,859,944,217,9,367,160,201,137,625,128,166,93,258,662,120,800,521,403,116,98,187,28,576,752,816,269,202,557,39,931,21,265,686,616,443,921,10,180,731,438,689,523,473,125,871,317,23,77,197,457,827,55,264,35,617,692,254,33,719,260,86,966,817,32,829,206,276,127,242,475,456,284,51,615,252,0,854,238,492,551 }, +{ 7,97,173,92,232,298,314,107,387,729,356,43,359,126,246,140,362,441,501,426,392,230,560,20,14,707,885,104,16,66,330,779,172,683,60,35,493,861,22,357,5,0,95,49,81,279,38,568,18,24,21,74,192,71,414,830,423,259,324,2,121,526,125,633,508,32,672,52,319,10,150,48,28,147,29,46,715,347,6,64,199,380,189,61,858,69,660,33,204,135,649,713,36,595,1,98,37,879,31,146,132,75,819,263,784,443,408,607,448,54,12,663,138,68,58,117,102,70,13,267,65,55,712,91,153,77,399,165 }, +{ 14,2,7,58,46,1,38,16,75,5,70,52,24,155,29,45,220,35,163,69,50,171,61,186,87,227,18,270,92,48,666,54,32,290,140,21,278,592,513,307,67,112,262,6,66,60,37,0,135,243,97,767,64,425,23,89,71,72,409,400,128,845,113,17,334,36,22,172,20,10,315,115,76,141,9,28,51,12,663,103,86,74,77,207,13,65,177,90,263,83,267,202,95,137,43,269,151,294,189,27,25,431,19,49,428,430,68,40,223,536,852,106,738,324,226,655,474,780,96,502,496,217,114,108,318,230,102,148 }, +{ 447,411,664,363,647,478,936,621,354,271,98,781,759,223,777,1,360,18,691,668,48,932,167,156,132,121,212,195,591,446,724,520,118,586,146,21,23,463,31,293,9,264,393,16,51,914,13,125,807,101,49,834,284,44,60,163,682,24,848,221,658,541,5,105,35,71,68,55,96,39,116,562,407,32,905,604,22,252,772,0,33,765,522,69,10,963,67,191,93,100,638,676,166,340,364,120,281,698,608,286,821,404,50,115,382,144,77,265,697,64,28,102,909,126,410,30,628,82,662,95,367,7,815,127,744,335,40,296 }, +{ 14,2,1,46,67,65,38,7,69,36,29,24,83,28,50,0,22,103,5,6,52,124,108,484,168,12,114,86,75,133,208,18,16,194,236,283,289,389,21,610,10,109,756,160,25,267,35,23,51,95,32,309,55,505,135,584,71,13,185,66,547,128,189,37,732,54,96,48,169,646,17,49,412,9,420,158,87,19,323,115,278,244,26,64,218,164,70,143,253,74,238,140,220,398,172,45,137,58,149,262,797,141,92,308,4,3,503,302,202,60,68,388,154,159,118,650,531,90,516,366,150,285,105,532,335,251,671,429 }, +{ 386,421,51,791,801,697,958,730,453,23,165,551,221,670,615,326,401,391,576,403,13,102,457,899,805,523,842,770,48,24,450,475,0,203,125,949,541,719,566,77,193,115,308,197,21,18,398,153,33,393,317,117,43,202,137,743,120,300,7,124,467,5,91,108,9,71,342,291,118,42,32,16,97,134,85,279,61,260,173,289,281,517,494,14,859,817,196,60,809,758,692,36,882,25,194,388,20,373,302,140,65,547,429,273,851,717,458,412,122,104,95,509,233,81,492,318,6,362,832,110,69,92,49,149,35,508,298,608 }, +{ 319,104,945,422,81,20,715,43,0,879,693,681,306,32,784,74,173,207,61,7,22,52,397,671,414,904,887,636,240,95,6,115,835,192,5,707,91,426,18,2,76,29,819,330,316,263,56,85,138,84,28,232,577,365,64,97,113,519,312,725,526,17,344,370,204,49,202,214,329,24,38,560,403,750,66,494,10,804,500,241,25,105,289,718,159,587,523,77,124,102,86,861,348,498,450,292,51,288,90,117,140,65,899,510,168,347,158,16,448,45,817,237,107,324,33,9,194,180,120,318,92,790,40,280,21,356,320,874 }, +{ 2,29,70,1,52,262,75,112,26,145,46,163,309,58,103,67,14,50,6,220,96,74,38,394,223,331,357,19,83,238,45,69,5,324,171,287,27,409,151,25,366,307,24,583,218,537,133,108,632,42,267,396,451,53,36,433,87,114,65,17,113,635,186,764,550,545,226,600,138,675,388,66,37,21,61,54,48,181,122,516,12,606,294,236,418,73,35,189,18,80,86,486,487,651,135,155,150,7,32,16,137,644,243,739,281,222,445,334,278,380,573,149,849,106,227,582,603,160,335,34,64,283,696,648,765,624,297,72 }, +{ 771,929,786,941,590,626,687,259,465,178,70,878,132,5,13,21,534,146,49,518,279,48,107,35,379,493,31,147,125,767,105,108,87,195,221,481,126,121,44,163,22,623,23,127,61,581,407,362,0,150,165,937,427,58,846,345,371,142,883,467,167,761,120,33,10,640,98,75,591,360,391,1,663,271,77,30,199,4,845,763,522,60,185,102,291,7,349,159,156,137,128,246,450,51,308,296,293,239,32,11,158,423,558,557,342,269,116,39,260,112,17,386,232,502,441,281,196,153,95,37,12,783,953,612,535,401,197,15 }, +{ 5,186,45,2,61,29,50,227,52,400,58,17,46,48,171,209,14,155,106,243,80,311,38,1,430,281,496,54,502,536,255,181,454,513,103,96,592,760,3,334,207,21,666,67,119,552,587,869,663,62,151,541,27,32,583,309,721,84,56,37,659,218,133,366,221,136,83,540,6,834,72,36,223,270,667,290,738,12,328,34,807,89,287,263,474,19,487,262,236,238,148,76,75,115,69,425,240,378,99,26,394,24,766,433,483,128,114,306,70,549,65,324,600,675,828,357,764,53,780,108,545,73,137,161,7,833,90,765 }, +{ 0,95,453,64,32,389,494,817,342,207,312,365,577,690,194,403,848,237,202,316,180,671,5,482,757,61,490,805,102,289,498,450,65,835,475,523,113,49,401,241,887,115,120,263,329,21,17,18,576,22,33,137,344,13,318,402,77,3,1,899,11,48,347,4,210,141,118,125,90,51,933,942,260,23,645,874,306,308,117,134,597,615,27,247,12,196,24,122,19,6,2,751,697,743,317,468,291,25,16,288,177,730,629,28,86,84,349,770,421,214,611,592,491,483,476,425,56,36,670,300,275,153,217,621,350,39,71,60 }, +{ 23,13,51,202,115,15,5,1,12,4,2,77,403,165,0,21,10,318,453,32,457,33,128,197,9,7,6,141,3,401,475,59,177,269,14,11,308,17,37,494,22,719,217,99,64,341,180,117,18,90,40,102,120,16,317,730,961,569,48,365,28,421,386,352,629,8,38,523,450,237,31,291,402,125,210,137,247,216,19,391,196,57,221,36,509,326,260,72,93,24,349,275,153,203,49,95,498,342,304,899,45,134,82,44,76,30,468,372,98,89,27,817,25,139,86,110,758,65,54,29,111,546,351,116,241,46,20,482 }, +{ 119,292,6,45,306,76,2,26,240,209,17,61,710,106,5,80,29,19,27,25,214,84,113,32,64,618,129,255,128,1,179,90,123,4,59,65,151,14,58,667,40,460,311,56,504,22,245,86,249,207,0,790,141,205,42,95,77,483,3,833,10,112,115,202,7,23,18,887,137,194,11,52,57,36,62,136,269,476,177,162,99,33,491,21,257,73,769,454,12,70,38,28,402,13,24,145,16,48,72,318,184,196,614,445,122,102,53,114,49,117,153,210,548,285,46,54,464,134,180,51,396,50,297,183,315,243,237,814 }, +{ 15,1,23,13,51,180,0,2,120,5,7,9,450,523,33,12,115,260,197,102,165,6,202,77,4,21,141,14,457,351,403,341,16,901,8,326,82,308,365,3,269,18,36,137,93,318,48,128,386,59,31,37,719,217,453,401,730,817,22,110,44,475,64,317,352,10,32,28,421,494,40,30,116,98,11,899,342,373,752,196,24,615,221,177,86,291,49,854,203,39,99,509,961,96,144,569,898,55,922,35,391,210,117,244,629,125,349,498,873,17,50,247,372,89,160,758,237,670,300,95,127,143,153,65,285,402,90,801 }, +{ 6,138,222,280,74,85,66,226,337,87,42,204,235,25,145,294,64,135,95,174,609,29,112,415,256,26,65,525,792,461,353,32,580,22,52,122,746,172,630,544,289,70,348,416,237,287,19,278,49,312,86,605,75,10,108,2,0,194,192,5,620,1,7,21,90,97,736,220,63,45,632,500,114,214,61,355,36,151,233,396,180,58,69,24,125,141,72,28,14,648,27,519,673,889,872,624,241,444,288,18,343,197,48,426,33,207,133,665,263,232,113,73,347,91,17,568,448,316,103,208,165,128,104,53,380,12,81,498 }, +{ 39,9,333,101,0,158,252,310,254,272,455,68,49,627,327,344,159,286,419,364,18,16,709,329,24,688,105,265,109,30,100,553,118,374,35,557,166,124,190,154,677,131,65,578,912,71,793,22,60,518,1,538,51,167,21,23,98,28,212,48,95,438,604,625,13,404,7,31,96,55,127,520,36,731,137,890,857,125,320,616,694,656,806,716,44,577,5,10,170,224,67,83,829,168,242,219,228,128,191,14,239,827,88,86,301,347,12,424,160,747,810,37,115,64,846,346,371,613,69,910,221,33,149,2,562,93,865,676 }, +{ 21,32,14,5,38,76,72,2,48,54,270,45,1,17,50,46,221,290,181,89,36,430,3,741,428,218,408,155,37,540,281,449,0,10,12,148,179,90,241,263,207,29,292,133,425,22,477,328,99,51,697,421,114,67,770,487,115,476,23,4,528,227,65,28,6,119,243,488,214,720,552,541,86,474,24,52,350,64,61,7,9,137,11,186,103,536,401,129,745,413,106,58,83,96,920,308,236,13,57,513,123,18,842,464,543,361,245,160,56,59,205,128,655,431,514,358,828,285,171,108,460,55,62,400,27,16,453,40 }, +{ 137,269,141,202,120,450,260,318,494,922,351,291,82,77,5,326,678,352,704,854,128,523,1,817,21,15,64,349,180,342,32,13,475,90,177,947,7,372,61,51,49,23,165,95,403,11,207,115,312,102,4,48,197,237,402,719,203,50,96,308,30,6,2,373,205,86,70,69,67,36,210,241,105,898,859,851,615,208,194,217,901,285,25,453,216,182,163,87,65,46,45,8,0,457,31,307,139,112,58,37,12,3,117,968,158,127,20,730,386,273,199,178,168,147,126,108,60,28,18,16,10,9,954,795,597,275,247,134 }, +{ 16,68,71,24,149,35,191,118,167,212,18,124,101,246,108,399,189,154,140,92,267,9,60,375,65,458,695,302,133,67,398,589,7,0,69,230,114,562,702,1,705,103,55,915,755,283,21,388,602,336,412,48,14,175,273,650,50,345,823,674,411,46,121,146,28,363,236,447,39,10,64,672,22,664,478,796,264,309,330,271,100,520,647,37,95,218,199,12,906,23,565,36,83,32,252,777,88,166,628,126,5,13,125,49,75,2,366,51,96,86,732,486,346,54,815,237,733,429,98,891,759,516,633,818,115,443,723,238 }, +{ 28,109,0,9,67,22,1,55,65,114,103,158,39,49,83,194,168,69,35,420,185,289,36,50,208,24,68,133,2,124,505,251,218,175,86,46,7,389,323,154,95,169,159,346,12,547,160,14,756,101,646,16,570,105,30,5,799,189,533,38,531,96,503,238,596,252,128,64,535,23,54,18,21,344,51,782,272,336,610,419,283,532,345,333,480,13,100,10,37,137,327,115,789,584,149,286,230,361,48,75,285,181,202,29,254,374,164,429,927,141,71,896,143,671,930,577,32,237,140,810,244,484,439,31,131,601,402,310 }, +{ 325,147,427,198,178,142,798,202,259,5,376,20,534,43,465,450,904,318,234,470,858,77,725,455,120,581,329,315,70,97,61,929,105,878,786,113,362,260,58,557,481,403,660,14,639,21,173,0,170,49,159,494,319,269,48,23,344,523,128,107,301,595,1,845,518,416,33,884,817,324,320,13,326,199,22,475,402,158,37,270,132,51,40,38,35,32,7,95,590,121,4,422,239,141,104,66,146,347,112,615,263,230,126,75,28,307,76,207,704,414,360,265,195,9,922,453,356,298,19,17,137,72,342,290,102,87,50,395 }, +{ 28,0,65,109,9,35,55,175,124,67,289,24,39,158,68,114,14,336,570,154,420,1,22,7,185,168,69,133,194,49,16,429,149,101,46,505,83,189,2,103,169,346,50,252,484,36,547,389,610,283,18,756,95,419,159,535,345,251,86,71,105,12,108,398,100,230,30,140,439,333,533,344,584,703,21,208,272,286,671,38,5,327,267,10,64,601,23,254,51,96,118,810,13,48,164,782,265,128,364,236,29,143,160,837,329,374,677,54,577,218,310,637,399,60,37,962,797,92,166,323,793,705,32,238,732,75,6,596 }, +{ 141,180,115,269,13,23,4,1,352,5,202,318,51,317,2,217,21,752,365,77,3,7,165,341,197,32,0,137,11,308,10,6,901,33,15,9,31,22,177,102,403,64,401,12,30,44,498,237,291,48,143,244,93,349,569,40,494,28,8,39,253,125,372,90,221,98,453,304,386,482,873,509,203,120,110,116,18,59,49,457,144,128,95,247,391,864,326,117,16,421,37,153,14,196,475,36,629,134,105,210,260,961,373,160,164,55,719,546,437,216,734,35,468,350,201,17,139,96,89,579,473,72,758,717,111,24,743,275 }, +{ 15,0,1,2,9,23,13,5,7,51,12,6,4,8,901,33,3,180,14,197,10,341,115,77,102,93,120,141,260,22,21,82,457,899,31,64,453,28,165,16,450,18,523,11,351,475,202,36,110,37,203,401,125,30,352,898,44,403,961,730,719,116,128,569,421,365,196,49,40,98,32,217,137,373,269,39,308,237,144,55,854,153,177,318,317,86,326,24,17,117,95,629,48,817,752,59,300,670,498,99,391,494,386,291,134,38,105,90,642,342,922,873,242,143,244,253,393,473,221,50,247,372,57,349,139,65,111,661 }, +{ 6,74,138,66,75,85,25,324,42,380,278,135,26,500,87,226,1,220,97,29,70,222,889,841,52,350,19,606,280,235,294,394,112,571,69,853,21,38,145,335,903,267,582,65,550,309,14,172,792,509,32,2,197,64,749,262,237,174,241,357,122,95,461,486,808,67,337,256,537,96,103,115,774,546,204,63,125,27,391,22,558,462,83,451,7,238,630,5,308,802,24,165,108,734,46,163,140,950,648,641,92,45,13,298,189,416,583,525,150,72,923,86,600,48,114,53,331,221,388,12,620,180,468,426,90,645,746,348 }, +{ 51,23,13,453,12,115,403,4,457,401,165,475,15,0,1,10,11,37,59,5,99,40,3,308,64,197,32,2,33,202,17,9,719,77,629,730,7,14,22,6,961,21,569,523,494,421,386,18,120,141,57,125,177,318,269,102,237,128,90,38,899,341,45,450,111,76,16,180,217,19,36,31,134,117,247,49,670,139,72,28,210,95,291,196,402,153,41,25,24,89,509,216,260,8,93,86,54,221,82,137,65,468,758,26,56,44,27,317,391,352,817,365,304,62,349,123,498,48,34,326,275,152,775,342,114,372,300,757 }, +{ 788,180,319,21,5,83,32,498,314,547,526,17,693,61,817,48,11,4,27,510,33,12,848,77,288,104,24,160,0,814,120,64,3,804,153,134,117,56,519,342,196,102,207,725,326,690,523,450,69,40,403,95,899,306,60,958,90,961,942,801,500,232,174,155,84,43,38,115,945,457,386,595,475,615,247,887,715,671,494,482,365,192,13,312,202,165,10,9,81,51,566,65,71,119,113,861,835,802,770,757,756,746,743,729,692,683,629,587,583,551,550,525,449,426,422,418,414,324,291,260,221,217,214,186,170,125,123,105 }, +{ 15,1,2,13,23,4,5,3,0,11,7,6,341,51,10,9,12,33,77,115,102,40,217,14,197,180,165,141,365,901,569,317,202,64,22,21,8,16,59,32,403,31,17,269,177,318,475,18,196,386,453,352,153,93,401,120,125,117,28,291,457,494,210,110,37,961,629,326,128,391,237,260,139,49,44,349,98,372,116,719,342,36,523,95,57,86,111,137,19,24,203,450,308,752,30,275,38,730,134,90,509,304,373,247,300,144,48,498,27,45,20,758,482,65,143,72,105,55,99,35,670,76,873,402,615,82,29,817 }, +{ 101,520,18,167,9,118,212,604,364,16,60,694,252,0,264,917,24,68,146,55,363,562,35,191,121,166,265,806,329,71,676,100,706,647,411,271,39,907,628,621,925,21,419,848,404,28,682,942,48,1,815,154,777,446,109,132,124,5,821,463,49,857,158,13,199,905,967,23,932,126,88,108,22,346,96,382,354,759,51,575,125,105,98,92,32,522,65,286,333,31,447,812,639,7,553,664,566,727,159,593,30,10,149,150,865,156,375,14,897,936,407,95,638,274,478,175,439,272,67,221,634,302,50,2,12,107,144,44 }, +{ 13,23,51,115,33,217,77,141,64,0,4,102,202,9,2,317,7,269,180,21,291,352,32,16,10,128,5,11,318,6,177,40,341,3,18,22,165,197,137,15,14,153,247,237,125,28,24,12,59,196,365,31,349,117,90,752,49,403,372,98,221,93,308,17,95,44,86,342,48,494,1,304,210,498,30,36,120,475,453,134,401,241,244,386,143,275,19,391,901,72,110,35,39,203,144,326,116,260,164,20,437,457,37,402,509,421,8,482,55,523,105,82,96,316,65,350,450,864,139,216,25,76,285,29,27,579,546,127 }, +{ 66,135,172,74,97,204,278,6,138,324,7,174,87,192,85,448,140,353,29,232,280,620,500,52,802,92,25,226,808,38,568,380,889,42,298,69,426,580,792,314,571,330,2,872,348,95,26,572,622,43,563,32,526,222,893,22,14,65,5,21,81,64,673,24,75,267,950,1,355,885,220,70,357,726,145,104,86,63,888,91,387,189,16,46,289,294,126,71,501,20,107,233,60,19,48,462,335,67,173,28,45,194,49,241,550,235,230,37,90,0,312,83,18,415,61,58,36,262,12,35,112,633,10,72,150,712,246,343 }, +{ 97,24,2,69,66,423,298,6,29,7,267,172,74,52,14,189,67,38,25,607,150,149,83,71,1,36,18,135,733,467,81,0,140,501,426,517,21,33,398,278,160,118,124,809,42,154,26,19,462,85,273,92,20,46,429,302,117,60,336,568,508,204,28,192,715,232,770,705,165,65,16,153,596,173,102,279,50,91,87,175,43,23,448,45,12,861,386,37,13,63,421,104,48,51,324,388,314,197,134,711,138,32,531,526,330,681,712,443,22,451,75,608,185,4,949,697,221,882,636,236,370,196,54,420,5,309,885,458 }, +{ 158,9,0,68,39,333,109,344,49,101,24,16,35,159,124,154,254,272,310,793,252,327,419,65,627,286,71,22,364,455,18,374,105,577,747,28,30,168,912,118,677,55,95,185,709,100,688,149,60,175,671,131,190,346,166,265,518,578,538,329,169,703,424,1,212,21,7,694,962,289,706,439,347,191,108,51,810,48,10,634,23,67,14,616,239,553,170,302,557,98,320,125,31,2,570,857,625,13,5,36,12,128,375,86,137,127,114,37,716,88,44,913,420,92,83,69,96,50,64,224,638,562,242,301,167,890,731,160 }, +{ 15,10,33,77,197,4,180,341,365,115,13,102,23,317,141,117,217,5,1,901,11,40,253,165,134,153,21,752,244,143,32,36,352,51,638,137,2,196,12,55,3,873,569,951,372,82,37,120,291,177,7,59,898,349,6,64,0,509,31,342,269,22,351,498,260,308,160,93,14,139,854,44,202,28,86,48,457,17,482,90,401,450,111,719,72,203,116,125,110,523,128,961,164,57,304,922,9,386,318,38,730,326,49,762,535,275,391,277,629,210,242,373,99,98,148,96,734,817,95,89,237,717,247,30,479,45,758,54 }, +{ 100,382,166,478,265,264,404,274,593,438,88,39,921,724,98,639,682,1,363,411,447,435,905,812,821,9,96,30,897,31,656,23,223,252,254,310,664,410,116,190,51,144,329,691,21,520,393,44,127,101,0,909,48,125,13,625,333,284,557,521,418,286,367,960,772,5,93,77,321,118,105,83,948,616,272,530,33,293,203,795,156,765,676,68,466,102,67,551,131,604,120,242,49,35,16,354,848,421,18,32,553,730,69,158,335,165,759,791,110,731,914,163,613,115,10,386,217,24,36,778,834,65,395,4,578,238,842,364 }, +{ 19,283,436,297,53,26,813,122,42,432,503,27,605,25,736,73,390,235,389,128,630,123,250,529,63,256,80,65,108,445,690,573,269,789,106,444,216,113,381,412,6,14,133,680,200,78,318,650,177,678,17,194,57,114,619,368,4,349,84,472,59,112,85,275,291,56,18,378,714,40,32,396,183,102,11,152,33,416,136,495,341,236,46,403,130,161,90,243,561,255,184,24,129,597,0,742,86,45,469,76,145,862,401,285,249,141,947,665,13,179,51,524,287,50,527,803,233,117,684,12,304,148,205,29,719,23,139,61 }, +{ 202,128,494,141,33,269,137,36,51,0,13,102,180,6,2,1,196,65,4,86,402,95,29,475,403,117,59,40,457,77,450,15,210,177,134,49,22,21,18,291,153,12,3,260,114,90,817,386,318,120,25,16,32,23,11,961,922,576,237,217,194,165,115,14,7,453,342,216,873,373,197,164,64,719,874,854,789,757,751,704,597,558,391,372,326,304,301,300,285,275,208,203,159,133,110,105,99,93,81,74,70,66,52,48,47,42,41,34,28,26,24,10,5,139,76,958,899,801,730,615,551,160,963,901,752,657,584,421 }, +{ 18,60,16,68,167,191,101,118,212,121,35,126,199,146,647,520,55,9,628,806,621,71,24,107,575,346,363,132,446,463,364,0,566,92,562,28,271,411,252,1,727,21,815,48,407,150,604,598,694,279,932,154,608,49,589,493,439,22,5,7,124,109,706,419,10,108,13,354,14,23,640,467,375,96,273,158,848,302,955,535,175,195,39,818,534,105,125,100,221,522,676,264,777,12,51,50,159,329,32,265,65,259,362,917,98,20,826,783,149,37,31,581,95,169,43,67,97,46,223,147,907,166,590,64,246,36,2,967 }, +{ 352,230,531,160,36,748,854,217,93,669,728,137,251,689,871,699,373,228,574,258,202,752,351,717,559,120,144,268,318,260,219,203,269,201,831,533,839,567,539,187,840,213,816,489,679,82,1,317,851,332,44,141,55,295,855,206,30,617,863,418,83,345,926,96,180,443,800,473,116,10,143,326,110,35,406,564,131,224,22,860,276,64,450,28,98,9,21,190,957,466,822,968,244,164,31,434,856,169,384,661,69,898,0,365,730,824,284,125,442,253,128,372,873,498,88,530,922,776,261,165,494,48,237,86,68,940,39,927 }, +{ 15,13,51,23,0,77,8,4,5,1,202,33,10,11,165,180,82,22,12,110,115,9,102,197,40,59,342,403,141,120,351,326,7,453,373,31,386,18,93,457,260,49,2,401,318,475,128,28,901,64,269,291,44,494,36,854,719,21,177,14,30,523,961,16,898,57,3,349,421,125,922,99,341,32,730,98,137,203,56,217,317,450,117,615,76,391,498,275,24,352,569,365,95,6,105,308,144,37,196,899,86,65,153,39,535,90,210,629,116,704,247,83,208,237,48,661,752,638,509,17,758,402,133,551,143,139,817,244 }, +{ 101,9,100,0,88,217,252,68,39,35,352,562,175,30,115,230,752,213,265,419,13,317,197,166,180,154,237,83,212,158,124,64,321,777,382,208,1,336,410,65,194,759,329,694,36,141,826,289,23,365,724,341,429,128,509,69,165,570,345,676,909,96,346,756,553,21,593,372,854,702,498,55,799,264,399,67,86,190,28,468,589,768,51,364,308,144,677,755,689,323,125,722,482,610,547,391,333,137,789,812,189,546,49,32,952,310,247,274,131,72,16,344,98,10,671,351,435,386,251,478,285,244,901,167,160,484,706,164 }, +{ 32,64,95,147,288,21,90,5,519,470,49,61,0,356,22,48,115,362,97,247,312,141,835,387,560,57,56,4,182,128,20,237,178,59,18,11,31,13,107,214,202,28,298,217,44,76,316,7,65,43,259,180,819,874,51,40,23,216,173,330,207,197,150,25,2,86,729,324,120,376,279,140,612,392,595,104,72,66,29,6,352,37,12,210,678,414,172,683,779,490,482,317,291,165,134,102,81,77,58,45,33,26,195,864,795,304,858,87,54,660,427,707,878,465,357,501,232,753,205,177,170,126,117,91,19,597,230,212 }, +{ 24,16,14,35,7,18,69,1,50,46,75,5,2,58,163,67,54,70,0,71,28,502,60,48,38,12,9,21,189,103,155,140,267,223,281,108,37,171,430,92,394,65,68,22,230,513,83,10,23,181,32,55,309,87,45,36,236,51,335,29,220,149,307,99,61,133,112,141,64,13,780,52,6,115,128,227,270,72,89,852,537,328,17,150,474,49,807,114,767,221,552,186,96,290,95,20,246,366,77,443,400,137,202,86,269,486,666,388,237,540,25,278,477,217,4,536,218,765,177,19,125,180,165,126,113,318,251,39 }, +{ 195,18,354,265,252,411,39,9,363,167,101,682,271,132,16,121,60,1,333,203,21,593,35,146,520,156,364,447,639,360,212,5,24,327,23,627,668,310,404,13,48,664,286,100,538,0,777,676,77,98,821,7,68,33,692,446,865,93,158,576,159,116,115,647,966,883,551,407,272,107,51,687,120,591,463,326,137,71,102,857,31,781,421,37,586,30,44,329,379,50,125,374,166,105,92,96,621,709,142,65,36,127,562,475,109,403,14,126,118,70,346,223,479,199,805,450,190,43,20,191,936,905,656,128,254,12,2,202 }, +{ 4,115,13,5,23,141,51,180,2,202,1,217,11,269,318,3,77,341,7,6,317,33,365,0,21,12,352,197,165,9,15,32,102,10,137,40,177,308,752,64,291,31,22,901,349,372,28,8,59,403,90,494,30,237,498,44,120,37,401,125,48,39,14,93,17,244,49,457,569,509,128,153,16,386,98,143,304,36,873,475,196,391,117,482,342,253,210,203,110,453,116,247,373,221,326,24,216,18,144,72,421,260,95,55,134,450,961,576,86,139,719,105,468,35,164,82,57,127,160,89,864,678,523,351,88,275,67,546 }, +{ 7,71,24,14,16,35,140,92,189,149,150,108,60,68,18,230,97,69,66,314,273,267,458,388,336,38,2,65,232,251,175,399,118,46,398,172,67,28,462,246,36,55,375,0,705,1,21,124,154,22,298,302,135,95,451,733,877,126,594,423,345,64,467,101,9,74,517,29,48,86,602,236,6,20,191,83,596,52,330,380,32,357,43,5,10,674,50,12,133,49,429,723,103,711,212,346,104,192,114,107,915,278,167,387,37,443,324,309,121,823,54,125,96,633,566,221,796,484,75,109,547,603,13,23,289,809,575,607 }, +{ 1,22,31,5,36,12,105,44,2,86,21,170,98,180,127,0,55,141,64,23,7,352,28,13,9,128,116,125,164,239,4,301,49,115,6,95,197,37,3,160,242,51,341,752,202,83,498,269,10,96,165,144,48,253,244,285,901,217,320,365,208,569,137,8,338,299,318,395,293,109,654,93,512,143,32,50,237,317,159,402,864,11,15,708,776,873,169,201,14,35,99,67,638,39,954,30,844,531,479,678,77,69,456,740,533,16,403,308,268,120,751,951,33,961,947,457,286,238,401,276,482,203,601,17,506,312,509,18 }, +{ 97,66,192,7,560,52,20,2,135,74,43,173,324,104,580,414,226,107,147,750,204,29,174,500,376,568,825,707,222,0,356,470,77,32,331,194,90,38,729,16,819,298,92,172,355,22,60,64,888,595,357,232,24,18,259,712,202,353,426,81,5,362,262,874,427,526,49,330,14,178,95,885,387,21,10,138,37,861,142,6,33,102,86,28,889,4,359,65,312,36,858,126,59,1,112,792,673,337,58,151,177,91,35,113,319,291,9,115,145,13,636,501,342,448,278,140,12,87,61,71,583,294,751,465,237,246,230,325 }, +{ 101,0,68,9,252,154,124,364,166,35,39,100,24,65,419,16,149,694,71,265,329,28,439,158,346,88,30,289,212,404,55,671,703,562,570,49,274,175,429,21,706,589,18,553,118,375,1,722,67,302,22,109,962,190,677,382,333,108,60,23,967,191,168,95,69,48,344,14,51,336,114,254,676,610,484,13,398,10,83,92,7,520,310,857,818,125,264,593,189,64,133,185,826,438,12,32,159,865,221,103,535,50,194,695,286,105,36,604,96,169,420,230,283,701,167,241,131,140,2,350,656,115,272,5,239,637,812,98 }, +{ 39,100,127,30,737,836,9,254,856,31,166,190,98,395,0,385,88,931,625,131,373,264,863,93,827,28,228,120,44,125,1,219,116,137,110,382,371,55,13,101,731,299,260,144,908,442,21,77,265,23,456,64,203,51,599,242,33,187,49,326,310,22,224,578,202,5,450,36,272,18,276,16,141,795,82,105,916,284,165,274,318,48,95,512,944,35,716,478,24,935,258,201,616,851,32,557,102,96,252,109,68,269,128,351,435,492,83,724,86,67,7,10,704,293,772,59,921,329,846,156,924,286,197,438,717,4,291,244 }, +{ 17,5,45,21,14,2,48,3,32,155,106,227,186,181,38,29,61,209,62,46,328,133,400,80,243,54,56,52,1,51,832,23,19,50,99,255,114,430,6,84,543,536,12,514,401,236,27,37,137,361,552,453,119,136,34,311,58,218,171,221,76,72,4,754,115,281,108,13,285,496,65,454,629,513,41,207,308,540,421,26,290,805,480,541,488,920,657,202,475,11,487,787,128,86,89,569,57,739,151,838,502,36,270,59,403,208,90,10,7,721,474,22,263,745,576,0,457,659,592,663,587,25,161,129,165,148,323,894 }, +{ 131,613,224,856,228,406,716,274,827,30,100,219,190,39,166,863,88,931,924,829,944,31,382,44,625,9,127,1,442,385,187,98,116,731,93,578,258,254,530,816,137,871,160,616,960,96,36,310,265,0,371,203,144,836,410,438,264,435,795,125,242,21,202,120,201,531,276,908,51,921,128,23,101,49,839,846,28,737,48,326,5,83,778,13,110,64,284,105,35,492,272,10,557,33,938,115,299,77,252,158,456,367,268,669,217,260,165,213,32,177,22,800,352,473,86,102,69,197,574,321,318,567,141,935,593,403,55,180 }, +{ 352,217,752,141,954,864,64,372,437,269,180,115,498,177,349,776,579,291,317,247,77,947,873,717,304,318,678,237,179,23,197,128,33,0,35,165,13,275,68,210,457,341,459,1,67,410,32,143,365,65,244,202,102,9,160,140,137,225,569,12,36,18,125,75,51,134,93,751,15,546,509,86,708,482,928,713,330,312,201,164,144,100,10,7,521,268,246,44,24,21,16,558,55,851,682,342,260,245,120,117,101,98,39,28,726,363,116,110,30,189,72,478,83,744,953,841,824,672,563,358,166,114,92,31,5,386,196,69 }, +{ 141,217,317,180,352,365,115,341,5,372,23,13,752,498,253,244,15,1,237,2,51,197,269,0,7,165,21,202,64,349,77,6,137,143,4,318,3,9,901,546,33,177,308,11,32,10,160,12,48,49,482,30,22,125,468,98,373,247,120,102,93,31,864,110,509,260,531,391,28,44,494,437,36,450,569,90,40,490,453,326,221,219,203,16,128,96,82,386,164,72,873,291,251,224,187,117,403,401,210,39,131,116,24,18,473,144,86,37,629,148,105,8,533,951,758,475,421,228,139,170,134,95,65,35,734,704,617,275 }, +{ 5,2,45,17,14,29,48,1,21,58,181,38,50,61,3,133,46,155,171,186,114,52,32,27,281,19,6,218,36,236,227,54,361,151,51,12,754,209,26,400,80,137,514,243,65,106,552,487,13,480,334,23,285,86,412,328,108,4,283,502,311,37,56,99,323,22,745,657,208,202,25,62,72,128,115,838,760,59,430,7,34,536,64,70,454,11,76,10,28,255,119,803,194,787,67,421,0,576,57,859,496,103,84,96,18,532,75,165,89,453,389,223,24,920,401,163,73,113,308,828,402,77,739,112,287,148,457,513 }, +{ 6,25,2,119,790,29,113,76,26,45,483,655,887,42,292,32,19,4,59,128,151,207,1,306,84,17,814,106,240,90,112,209,61,145,14,177,77,64,65,52,833,27,122,179,491,210,70,0,72,311,115,40,255,58,614,74,85,7,214,202,710,22,5,57,469,21,141,11,123,80,476,95,36,396,33,10,24,269,38,137,102,66,425,23,416,49,194,86,275,504,13,216,56,402,318,46,358,18,138,28,460,624,9,148,50,174,129,618,51,205,87,75,16,291,186,12,217,249,222,287,454,20,54,99,243,315,117,114 }, +{ 23,13,51,115,2,4,5,0,141,180,7,11,217,3,33,77,6,1,202,9,317,10,102,197,21,269,40,352,341,32,12,165,16,22,64,318,365,28,128,15,14,18,752,137,59,24,291,308,177,125,31,17,403,498,237,494,372,98,49,117,901,93,196,30,44,153,457,349,8,37,120,134,90,116,247,342,36,482,401,95,35,210,143,221,86,453,260,203,144,475,326,48,244,110,391,386,55,304,873,39,19,569,961,421,105,509,719,546,450,253,864,216,20,402,29,523,72,57,50,139,25,730,373,468,275,65,82,629 }, +{ 23,13,51,202,21,141,115,5,165,318,32,12,403,197,453,1,269,120,15,128,2,180,475,125,308,457,401,7,48,6,386,64,0,730,4,9,719,137,3,10,523,18,33,14,37,421,16,99,494,11,260,450,341,221,17,196,93,77,40,217,22,117,90,95,237,899,31,391,247,352,326,28,24,102,19,153,30,317,98,961,817,134,82,44,25,59,8,241,110,49,365,20,26,291,27,61,177,36,351,498,509,569,402,39,203,758,29,72,57,45,629,350,54,116,316,96,752,50,38,349,67,901,65,46,342,304,285,58 }, +{ 39,9,100,30,31,127,44,88,0,276,98,131,1,385,254,442,166,49,908,116,187,190,935,201,219,284,827,299,28,224,144,829,96,228,36,274,137,141,101,21,265,716,382,48,51,258,202,23,352,22,125,836,93,856,613,128,839,158,371,264,578,395,13,55,16,180,662,244,269,252,217,567,492,110,310,35,64,77,272,83,268,410,931,203,120,326,752,260,68,318,18,489,293,574,625,160,24,33,115,86,159,924,242,373,165,438,5,450,69,102,616,213,197,918,863,321,295,717,291,82,731,177,456,317,406,7,599,737 }, +{ 22,109,49,28,159,185,95,9,105,131,272,327,254,1,67,286,36,39,35,168,86,83,55,169,505,158,224,374,420,127,584,208,98,219,312,578,31,347,535,601,0,69,708,424,44,114,103,30,160,627,346,64,141,194,187,518,175,96,239,345,616,892,10,128,164,143,896,116,137,50,12,5,2,237,228,913,533,13,23,7,21,371,320,597,688,538,751,912,352,323,251,716,165,115,634,202,258,197,498,637,37,531,180,797,874,51,253,768,48,101,890,16,189,201,613,24,752,385,14,170,285,365,406,789,244,218,46,133 }, +{ 5,1,21,2,48,14,12,32,22,36,0,17,54,10,38,3,37,86,50,45,65,28,51,72,281,23,4,6,58,114,89,46,137,13,270,99,430,11,7,208,76,202,181,61,115,403,155,9,133,18,540,64,361,221,29,323,480,285,49,128,24,95,218,401,657,421,290,745,19,576,194,55,308,754,59,453,513,920,148,880,96,341,502,52,16,475,77,67,842,40,283,859,318,197,402,494,171,141,474,244,543,757,165,775,90,541,27,33,180,57,83,227,164,217,428,328,269,108,425,569,514,207,31,143,223,263,102,503 }, +{ 141,352,269,372,351,217,854,82,752,922,318,180,954,260,317,15,349,1,202,64,120,898,717,77,67,35,864,291,69,365,137,851,437,36,22,5,247,86,373,4,457,450,244,165,189,163,140,68,13,237,901,115,128,304,23,21,341,98,125,177,51,93,32,28,961,160,96,494,110,95,10,0,719,253,661,523,326,767,83,730,275,44,386,418,40,12,817,210,19,17,102,59,45,18,7,579,498,482,615,403,144,11,6,3,203,76,822,475,49,48,31,33,293,284,268,228,187,947,899,587,583,485,474,367,342,300,245,100 }, +{ 144,613,203,406,669,418,326,137,228,96,679,494,160,816,1,817,822,36,317,859,840,83,856,876,855,217,251,219,863,831,944,202,576,365,539,93,800,5,345,530,77,128,44,957,748,141,13,839,30,23,21,778,143,341,115,473,617,332,201,64,120,190,492,456,829,531,349,367,716,258,98,48,578,116,180,924,403,187,31,515,966,692,574,442,131,86,931,719,523,450,9,224,351,291,860,752,82,28,10,244,51,371,22,276,39,102,125,730,261,50,851,269,827,335,318,871,704,916,268,110,898,69,67,498,206,177,615,805 }, +{ 15,13,23,51,202,1,21,33,5,269,180,217,2,141,308,12,120,0,352,165,7,221,115,117,48,32,6,318,197,4,153,9,260,82,196,453,134,457,3,40,386,523,730,110,14,719,77,401,31,403,450,137,326,37,102,341,16,351,8,128,752,11,475,93,18,498,317,44,365,391,64,30,98,237,72,10,49,421,22,99,901,494,509,28,24,899,17,125,39,817,569,854,116,203,59,291,177,89,961,95,36,244,629,758,105,247,90,372,241,864,349,546,670,898,96,35,144,86,65,350,373,50,139,304,61,160,922,615 }, +{ 23,115,13,51,77,0,1,4,365,2,141,341,5,33,202,217,11,10,317,9,180,102,3,7,6,15,269,22,318,197,165,64,352,12,40,494,403,21,28,31,128,308,125,32,453,59,177,18,291,16,401,475,901,14,24,752,237,93,342,137,349,457,569,44,8,17,372,30,153,98,120,95,49,210,36,498,196,117,110,509,482,421,116,247,386,873,304,37,391,39,629,244,48,139,90,203,143,134,55,86,523,450,326,468,260,275,57,961,144,719,65,35,402,216,730,221,19,253,373,46,50,734,437,678,576,96,758,551 }, +{ 531,373,728,160,943,559,717,260,93,269,332,206,533,244,352,384,261,535,964,564,120,110,10,253,295,137,365,318,141,55,143,959,180,617,36,851,911,843,197,661,203,873,282,1,752,940,341,699,968,901,82,417,326,21,144,450,22,351,317,434,64,642,498,855,824,574,202,926,473,860,800,896,164,23,28,898,8,51,13,258,15,116,35,816,567,127,187,237,776,9,951,219,601,268,115,811,165,217,201,864,131,98,406,854,77,523,251,902,922,125,48,345,44,31,16,704,96,499,86,83,489,871,367,299,177,72,817,24 }, +{ 1,31,36,170,55,86,22,44,127,5,301,64,98,164,2,116,740,105,299,12,10,242,237,125,169,338,9,0,21,143,7,512,23,28,841,128,141,13,239,51,395,180,654,208,293,685,37,144,870,923,95,6,599,83,197,115,160,456,900,352,67,498,506,253,165,638,49,3,268,492,137,965,4,479,14,393,763,269,244,185,708,202,109,341,96,365,50,762,509,933,276,48,284,951,367,505,864,751,752,546,320,601,597,35,8,569,634,312,323,217,558,201,391,824,317,401,308,901,457,32,837,159,535,93,873,54,114,38 }, +{ 13,23,51,115,32,141,77,177,202,33,64,269,90,4,102,318,128,40,59,21,217,291,137,180,352,210,95,10,48,0,22,5,196,494,15,7,237,14,117,49,18,216,197,125,342,98,31,304,11,9,165,153,403,317,247,86,752,134,28,275,349,16,24,116,365,341,2,6,76,44,453,17,12,20,30,300,221,93,39,143,139,36,1,19,3,402,326,386,312,105,457,65,244,194,8,576,498,901,308,110,99,72,372,120,401,203,50,25,241,144,61,26,208,96,678,450,160,615,421,391,127,114,57,46,37,35,27,947 }, +{ 202,260,120,450,318,51,269,77,23,351,1,326,13,128,82,137,141,21,33,15,494,102,523,817,5,403,110,165,922,64,203,197,854,125,32,180,177,291,48,153,196,93,116,12,342,98,352,373,40,4,115,7,475,144,349,36,217,90,2,453,386,16,0,285,95,44,615,237,59,49,31,457,704,6,898,210,24,58,96,86,30,719,117,70,401,216,8,275,28,22,14,402,17,247,50,39,29,18,421,99,37,20,10,391,304,61,25,752,341,730,678,9,365,859,576,473,139,45,961,692,293,661,498,317,214,132,35,76 }, +{ 899,523,102,730,33,153,196,117,719,23,475,51,817,13,15,403,453,5,4,342,77,494,40,120,21,11,450,202,421,59,457,12,805,165,139,134,26,19,17,2,1,300,386,801,961,57,32,27,7,6,3,880,197,99,361,757,670,128,125,72,58,56,48,45,37,14,318,64,49,770,247,82,576,260,884,775,635,629,509,485,456,402,391,180,177,141,95,89,84,76,70,62,61,54,53,38,29,25,758,401,269,262,583,409,365,341,331,217,52,968,967,966,965,964,963,962,960,959,958,957,956,955,954,953,952,951,950,949 }, +{ 202,494,403,475,523,817,453,450,318,402,120,576,51,13,77,102,342,33,260,128,23,326,5,899,15,4,82,615,210,269,137,351,291,59,196,141,90,730,40,386,285,214,177,21,719,389,49,11,65,61,30,22,48,153,117,457,114,12,3,98,64,44,39,31,1,922,194,216,84,349,165,95,32,28,10,0,757,197,421,474,123,38,961,887,805,690,629,551,401,283,263,207,139,125,118,113,58,848,503,115,41,880,275,24,17,422,319,104,942,854,803,801,704,671,509,416,400,393,372,334,237,227,217,186,180,151,134,96 }, +{ 2,29,52,112,66,87,70,151,135,7,226,58,74,307,186,294,172,287,549,644,334,5,14,97,46,75,45,227,331,113,145,6,25,315,155,337,222,1,61,192,32,243,163,311,64,220,38,400,43,262,171,69,21,37,624,461,20,884,122,849,631,416,26,16,48,86,27,24,42,22,19,278,138,92,353,635,36,609,232,0,128,140,10,500,324,50,17,72,665,59,12,95,76,90,409,209,35,4,396,491,614,65,18,496,415,54,721,568,592,67,632,49,141,137,80,28,89,204,659,869,60,106,426,845,448,177,207,115 }, +{ 1,349,652,5,260,291,77,39,342,102,120,23,100,888,13,269,64,340,264,51,303,698,32,2,202,21,9,296,33,98,70,385,163,638,318,137,327,87,293,58,50,128,48,195,69,774,141,75,121,7,658,850,326,96,371,284,223,931,863,759,132,126,92,71,221,678,203,82,551,961,937,615,575,563,494,105,83,67,55,36,30,27,17,771,418,115,90,31,156,914,687,393,372,12,6,3,622,144,922,898,854,731,691,478,403,367,363,352,351,333,310,286,170,146,0,950,230,93,95,49,919,954,947,865,851,765,751,719 }, +{ 1,5,2,13,4,23,7,3,15,0,6,180,51,115,141,341,11,77,269,352,21,901,217,197,365,33,12,32,177,752,317,202,318,165,40,9,102,10,291,93,8,569,31,22,349,498,120,90,44,110,401,59,37,304,326,48,17,64,372,403,196,117,16,98,14,457,210,453,125,494,28,36,386,629,247,153,475,30,308,260,134,873,116,253,373,450,18,237,244,482,203,49,128,961,275,137,144,216,509,523,421,391,143,342,24,719,105,95,55,72,76,89,39,206,437,139,468,57,579,758,730,864,546,127,221,96,734,19 }, +{ 14,7,16,46,24,2,35,70,92,58,5,38,75,18,140,60,87,171,220,54,1,155,69,307,50,21,163,48,71,32,112,0,37,12,23,278,780,502,126,9,61,52,186,172,135,45,28,64,29,13,67,227,20,107,22,115,97,513,51,10,267,72,68,270,128,230,89,314,666,330,246,141,6,232,189,36,400,177,66,108,290,150,17,309,55,430,767,334,77,474,121,262,103,243,409,223,137,83,43,113,202,592,217,461,49,95,315,571,65,181,394,357,86,281,269,774,294,236,380,852,536,845,76,90,25,102,298,4 }, +{ 226,135,87,2,29,66,74,52,294,278,222,220,75,7,172,145,331,70,324,262,97,6,25,112,138,337,140,42,1,92,461,26,69,38,500,58,357,14,380,5,287,16,46,571,232,620,808,632,267,163,32,24,35,583,853,774,43,314,609,45,171,21,298,353,19,802,95,60,151,415,448,409,64,67,192,22,65,396,85,525,37,174,307,189,872,204,20,71,50,12,330,86,622,61,48,27,36,186,394,764,113,54,335,563,114,108,309,150,950,72,155,17,10,572,122,635,544,103,96,606,28,893,246,18,49,230,550,334 }, +{ 15,33,77,117,134,153,102,4,40,196,1,217,21,11,291,13,32,5,177,202,51,115,3,23,141,2,48,317,180,349,59,137,372,128,17,269,342,210,341,96,57,64,365,120,247,12,216,82,221,139,318,110,6,260,93,90,352,898,450,165,10,36,31,197,275,523,7,37,72,494,203,244,457,56,351,579,125,111,8,237,817,326,403,0,752,98,922,961,901,160,277,22,719,730,144,44,206,14,386,899,86,45,482,437,304,373,143,89,569,9,116,453,475,308,253,300,61,105,76,27,638,164,95,49,490,29,18,94 }, +{ 217,15,317,82,351,141,260,854,13,77,23,120,51,922,115,1,21,180,110,137,365,341,352,372,269,349,898,291,36,202,64,5,32,450,318,373,177,128,752,96,304,523,93,33,48,165,326,197,102,0,10,40,901,9,4,160,498,247,90,244,661,203,22,59,482,2,12,143,86,437,386,83,457,28,473,30,67,253,961,11,35,16,221,24,125,117,391,39,7,811,494,88,37,8,69,719,559,3,817,704,237,216,76,72,61,14,873,403,18,642,31,899,210,164,45,730,717,49,179,134,139,851,475,421,251,223,100,56 }, +{ 190,373,31,30,863,908,120,88,110,127,260,442,856,318,254,326,717,935,131,836,228,93,187,44,39,385,299,100,968,274,219,203,82,166,224,197,116,661,276,77,1,217,98,269,86,450,51,371,36,128,180,829,137,372,341,160,704,141,64,435,202,49,395,144,9,23,918,410,28,22,730,778,244,242,351,55,737,523,827,177,851,625,944,382,272,530,317,115,349,352,96,613,492,291,954,32,931,744,716,125,268,258,284,253,686,48,615,515,367,247,21,33,456,165,321,795,10,567,466,225,83,839,102,578,521,919,817,752 }, +{ 23,13,308,115,401,51,165,9,391,21,629,254,125,159,773,197,743,569,49,468,217,438,656,627,341,89,39,558,221,32,317,386,509,350,28,95,530,228,457,867,109,166,406,876,679,48,669,364,219,158,365,346,168,912,810,101,170,105,72,64,143,30,347,258,967,237,148,90,688,274,131,670,272,185,749,843,33,12,10,187,55,175,141,4,734,758,242,196,190,453,261,518,224,902,747,286,482,164,37,333,241,2,439,102,0,424,420,393,706,613,338,153,67,372,351,68,40,310,120,816,634,332,840,35,320,88,86,289 }, +{ 49,5,165,125,21,173,43,623,104,193,422,102,13,7,91,18,95,22,0,192,141,64,48,197,900,693,558,105,51,23,32,232,391,387,314,98,31,116,20,779,202,81,92,319,408,241,16,126,38,77,494,33,784,643,474,11,221,28,712,138,862,663,595,403,350,879,29,510,27,633,180,140,729,397,172,44,4,858,237,61,718,501,359,71,60,58,511,448,370,356,750,490,482,347,344,316,308,177,93,37,24,498,293,115,158,145,72,65,40,830,246,207,63,85,107,841,569,468,414,352,330,326,269,203,69,14,12,2 }, +{ 4,1,2,5,13,23,77,115,15,3,0,341,7,51,6,11,33,202,102,217,12,180,10,141,9,40,21,317,318,177,365,901,197,269,32,165,352,22,59,8,64,31,291,14,494,403,93,17,401,569,752,16,453,37,342,210,110,153,275,18,475,44,125,196,90,28,308,326,386,98,120,117,116,372,457,128,349,36,95,629,49,421,237,48,139,203,260,244,450,498,137,134,304,30,24,523,144,247,373,719,216,57,391,961,86,482,143,253,39,730,509,111,55,221,817,96,615,19,65,873,351,758,99,670,437,72,50,734 }, +{ 843,295,93,120,160,206,36,943,567,373,384,332,268,137,261,141,201,260,110,10,203,531,144,55,64,617,434,197,258,699,116,244,282,318,559,564,964,269,44,352,911,717,253,860,202,180,31,326,533,1,940,143,473,417,728,661,276,351,959,187,22,341,851,535,219,871,855,28,367,127,82,131,115,450,365,86,901,752,926,317,21,51,98,48,77,165,23,105,224,96,968,662,217,13,8,902,574,489,125,817,349,800,523,515,83,704,49,811,498,164,494,39,5,393,228,32,291,251,128,9,12,898,642,576,69,67,873,839 }, +{ 192,81,43,173,426,879,7,715,172,104,712,91,636,526,232,825,568,97,560,5,95,681,448,66,49,861,32,387,370,74,20,750,33,204,22,707,330,729,718,140,61,0,6,356,397,69,21,117,422,347,135,359,38,92,102,263,348,64,174,4,414,153,888,237,138,319,76,298,40,13,885,52,2,107,86,500,25,196,784,595,77,819,241,180,134,58,207,85,29,42,31,355,65,577,72,18,28,1,343,48,392,23,10,126,89,324,37,189,344,233,314,11,933,71,14,511,16,408,115,673,46,498,45,671,125,60,858,246 }, +{ 475,453,403,51,33,102,494,23,196,13,202,153,117,77,0,318,128,757,421,22,342,730,899,817,18,805,65,15,958,450,134,4,402,24,36,59,269,40,49,210,401,1,28,697,670,64,11,114,291,48,16,576,108,386,523,141,57,177,21,20,86,165,133,95,90,120,365,317,326,260,221,180,137,31,10,115,752,99,498,457,391,361,352,70,50,32,349,113,9,6,3,864,838,770,743,373,351,338,268,242,206,125,116,109,5,283,253,84,17,961,801,791,546,372,341,237,217,214,205,194,163,143,96,72,69,68,30,14 }, +{ 141,269,260,318,352,202,120,351,349,137,854,82,1,851,922,5,180,372,291,64,32,947,21,15,77,752,494,13,48,304,33,7,51,717,23,217,373,177,128,678,450,115,237,326,317,70,898,36,403,704,312,4,160,102,86,90,968,247,95,87,196,49,275,244,197,22,165,67,96,35,288,203,817,735,125,342,144,93,16,216,163,50,44,31,83,954,2,69,597,457,241,59,153,961,221,110,98,39,30,9,8,901,661,551,523,473,442,386,367,284,210,864,117,61,12,0,800,29,24,863,859,730,719,475,453,385,316,293 }, +{ 15,1,2,13,5,4,3,0,23,7,6,115,217,12,180,197,9,51,21,11,352,961,8,10,165,77,457,341,141,317,22,14,901,33,31,117,93,120,102,40,134,752,202,365,260,16,37,269,569,110,32,44,28,318,64,18,17,48,351,719,153,386,177,82,291,36,196,98,873,450,49,125,59,128,498,403,72,326,482,30,523,401,99,854,308,203,24,453,89,137,95,391,509,111,349,86,139,730,372,247,144,55,210,116,342,494,304,475,373,148,922,90,105,237,661,35,579,899,143,221,39,19,629,275,421,758,244,468 }, +{ 166,39,274,404,101,252,190,30,333,9,310,0,100,438,656,158,265,88,68,625,329,530,553,419,344,539,254,455,793,778,21,48,759,228,49,676,1,131,960,709,557,731,520,154,23,35,382,13,124,364,604,677,105,28,272,16,286,406,212,31,51,18,613,219,224,593,840,159,167,125,36,98,65,518,669,865,118,24,44,96,213,748,264,777,115,83,175,22,86,538,957,221,127,55,327,5,10,857,694,688,137,258,795,410,806,627,95,71,577,289,128,116,578,32,50,242,69,724,187,352,562,346,616,67,33,827,846,191 }, +{ 28,0,1,9,22,65,12,83,67,55,109,50,24,5,36,49,39,96,35,238,16,18,2,21,114,124,69,37,7,218,48,23,323,103,158,160,168,54,51,128,285,154,13,68,185,137,14,194,99,141,95,169,181,418,289,420,202,433,86,30,75,480,175,10,505,105,115,32,402,281,223,389,269,208,646,503,745,64,133,46,180,657,159,800,531,547,251,956,101,429,4,318,31,149,163,6,70,346,58,532,822,533,484,757,797,165,335,252,197,735,570,352,283,361,71,98,29,118,3,535,927,766,221,217,38,799,237,308 }, +{ 15,1,2,0,23,5,51,13,7,6,9,180,12,115,3,457,197,8,719,21,730,4,120,901,141,202,14,33,165,341,453,386,82,31,260,351,365,523,308,64,37,22,44,401,450,32,40,16,93,77,110,10,98,961,403,36,102,899,28,217,11,125,352,196,48,318,137,317,475,153,18,269,49,569,116,752,99,326,421,128,24,30,221,95,39,203,117,873,144,817,629,758,177,55,86,35,494,509,898,373,59,237,105,17,65,291,96,89,498,670,482,247,253,134,468,38,143,54,244,72,90,372,160,854,127,210,391,801 }, +{ 9,39,166,49,30,28,0,158,22,131,180,100,219,35,352,190,345,228,1,752,88,498,115,141,274,317,482,109,83,128,930,251,36,217,95,365,230,55,101,160,254,165,224,159,168,23,341,13,105,31,208,187,258,927,310,197,69,137,333,901,864,364,64,185,269,86,344,505,252,202,404,68,286,873,539,372,96,669,438,51,10,164,67,5,868,346,244,637,439,2,7,21,748,323,406,418,318,16,237,44,272,50,840,706,420,265,127,98,946,735,793,768,579,169,125,530,175,148,327,857,702,678,238,116,12,48,533,335 }, +{ 61,311,80,209,45,29,5,58,2,151,454,106,17,6,667,243,255,738,52,592,70,496,287,74,483,1,833,112,549,27,207,119,26,315,32,227,378,19,64,14,138,25,84,263,75,742,186,631,113,21,136,56,48,887,62,46,7,307,469,72,76,145,50,73,66,161,128,495,148,425,814,651,491,4,34,95,869,86,38,87,3,334,240,290,383,396,845,42,53,306,12,171,65,141,163,445,135,155,11,22,54,297,90,331,179,226,655,632,37,614,361,292,663,89,400,13,36,23,10,137,294,666,99,659,250,220,59,51 }, +{ 31,44,299,22,125,599,456,685,116,28,492,393,170,242,144,268,963,301,506,1,95,558,367,36,239,55,489,0,918,109,206,23,105,9,10,434,127,51,384,13,86,286,948,479,98,64,841,5,338,2,93,12,203,498,164,7,512,168,21,143,165,49,903,940,320,401,391,137,8,37,900,417,352,141,115,128,546,253,457,959,237,14,185,197,308,169,202,395,282,421,374,911,180,740,332,293,386,6,24,312,855,538,509,752,244,473,65,928,762,160,638,617,341,269,961,867,949,730,654,403,551,499,965,523,48,719,16,453 }, +{ 187,258,926,839,574,860,93,219,406,228,871,160,531,224,137,902,201,120,116,36,203,144,669,268,318,131,442,567,816,295,434,908,851,533,843,44,384,717,202,800,559,373,489,728,141,332,855,206,261,276,1,260,269,251,617,326,180,317,385,940,110,613,217,959,55,31,450,352,968,365,115,197,64,699,679,244,98,96,83,23,10,840,341,77,492,473,899,856,831,661,143,127,190,918,752,539,21,284,418,13,943,748,662,911,564,530,48,165,291,523,704,128,345,125,822,351,169,954,86,349,367,922,776,535,177,51,824,22 }, +{ 7,107,24,60,349,232,16,51,18,75,9,291,87,23,71,269,92,126,77,141,64,177,307,150,461,35,220,14,330,37,121,0,46,279,115,947,267,132,32,12,172,55,112,309,13,10,448,278,202,21,70,2,372,210,852,678,441,304,28,5,328,217,147,54,48,786,660,259,359,318,155,90,334,181,180,140,872,108,22,163,102,31,409,314,394,352,341,281,171,68,30,622,294,236,20,423,49,626,33,760,186,58,687,415,50,39,407,128,43,771,365,197,237,1,400,929,498,888,590,366,342,270,192,135,100,76,61,675 }, +{ 15,1,2,0,5,7,13,6,3,4,115,23,180,9,12,901,51,8,341,961,365,197,10,22,141,82,33,351,14,11,77,120,31,202,457,165,217,308,134,352,28,64,102,21,269,569,110,18,260,317,40,44,16,37,36,719,93,318,237,137,99,177,450,30,125,128,386,49,752,153,55,498,17,391,98,24,111,403,32,39,196,117,401,116,373,898,730,523,326,291,453,95,854,509,304,247,86,59,372,546,482,349,143,475,899,203,244,494,139,35,48,642,253,811,144,105,210,160,758,421,148,629,221,90,164,65,127,638 }, +{ 23,51,13,202,5,12,115,21,141,165,1,32,2,318,197,15,403,180,453,7,6,3,401,269,4,0,128,308,37,10,99,457,14,11,9,120,64,22,48,341,137,386,494,475,17,77,16,719,18,217,125,31,352,523,421,59,730,90,153,365,391,237,177,317,28,40,450,260,72,221,33,8,569,93,509,961,44,19,89,102,291,98,247,326,498,76,24,49,817,899,758,30,57,629,117,61,36,110,29,139,20,210,402,82,304,196,95,45,351,752,38,285,116,203,134,349,241,96,468,54,216,901,482,576,546,25,275,342 }, +{ 2,1,77,64,141,6,3,7,0,33,102,5,10,13,23,14,269,180,15,217,165,291,352,40,117,197,9,17,115,202,237,4,128,11,22,341,12,153,349,134,196,16,51,86,318,317,177,36,19,125,137,95,342,18,752,8,28,365,31,210,457,143,139,498,59,372,21,164,57,304,82,120,45,27,38,275,24,49,110,391,386,111,93,44,244,901,260,509,56,32,41,450,98,65,99,351,30,961,55,37,403,864,569,494,29,678,48,312,453,326,546,203,20,25,54,401,79,373,402,61,253,26,46,62,719,76,475,523 }, +{ 345,531,332,269,717,260,373,317,728,752,351,180,352,533,10,365,498,82,160,251,244,36,901,143,217,341,93,55,1,141,873,864,898,35,9,564,64,851,951,22,417,137,253,28,617,169,67,69,120,559,854,197,601,482,318,546,115,768,21,96,83,661,261,876,110,372,237,164,144,535,574,203,800,206,16,86,349,31,824,699,50,48,831,902,843,860,434,968,125,221,579,959,700,679,384,926,922,295,7,51,23,291,148,418,230,202,24,943,468,896,201,5,776,77,839,44,258,954,816,13,811,940,844,637,473,868,822,308 }, +{ 92,16,189,7,77,60,388,140,33,153,196,102,35,117,230,134,150,733,314,24,14,71,21,915,246,1,108,594,97,18,32,48,66,126,69,517,121,462,64,22,98,13,399,723,65,5,291,95,67,451,674,267,232,217,653,298,2,23,38,223,104,711,83,0,197,90,36,423,149,46,125,49,167,28,68,195,20,172,120,251,86,12,289,214,508,115,386,633,236,133,10,50,350,458,191,165,330,51,107,31,260,6,43,55,271,841,450,457,273,326,796,146,509,221,603,380,237,702,9,194,4,202,199,103,52,357,29,74 }, +{ 234,142,178,202,639,5,49,450,77,70,786,416,929,48,259,455,21,0,878,147,315,481,198,329,427,318,1,125,105,120,61,113,534,846,58,344,12,132,95,518,465,325,22,31,163,557,494,13,159,32,761,767,128,590,146,37,798,195,269,711,371,291,402,265,50,342,158,362,260,39,98,221,884,687,30,64,279,137,2,167,10,771,165,35,640,626,522,403,293,310,102,23,817,347,170,28,581,99,141,236,127,150,107,51,271,87,763,623,845,212,7,18,423,194,17,523,112,345,663,33,44,376,239,199,121,391,116,75 }, +{ 81,715,192,712,681,636,104,173,750,91,370,0,74,95,718,22,7,825,879,20,49,560,43,64,422,172,397,66,138,207,784,86,500,65,28,18,707,204,414,10,577,174,319,426,32,38,312,888,348,330,4,526,289,52,355,61,511,861,347,33,237,29,102,232,448,31,21,353,835,124,5,6,2,643,36,85,97,117,153,77,306,59,134,819,140,673,671,24,40,120,165,729,568,240,135,280,324,105,125,98,344,519,233,387,194,288,196,693,474,241,214,701,44,107,583,314,260,450,847,287,69,25,872,587,343,84,9,817 }, +{ 23,13,51,15,0,10,9,115,1,453,2,961,4,77,5,457,11,40,33,401,3,7,475,197,102,14,569,165,22,59,12,6,719,32,64,21,99,730,57,17,177,18,37,8,217,386,403,196,28,308,16,31,141,139,111,341,523,120,125,180,153,117,629,391,210,36,45,237,72,899,49,95,202,128,485,247,38,482,24,48,44,509,90,27,260,450,30,19,137,317,365,41,65,291,269,89,134,342,86,304,498,421,474,82,79,148,54,277,758,318,352,46,76,56,326,468,29,670,349,494,275,351,437,300,93,50,546,873 }, +{ 64,297,5,80,445,61,95,311,250,312,472,34,237,86,45,180,738,17,151,58,22,667,869,247,2,14,73,288,194,106,53,21,128,197,352,177,32,29,186,469,833,217,52,165,287,255,3,1,495,391,396,243,176,137,90,546,125,56,161,141,136,592,48,10,209,27,0,231,76,751,62,11,437,315,119,887,115,334,179,23,84,498,651,207,77,4,864,145,13,881,389,304,6,59,49,631,372,65,16,240,164,153,112,378,549,483,584,527,316,26,862,509,409,752,51,7,875,18,933,171,269,196,457,283,241,148,114,19 }, +{ 71,16,24,18,60,35,7,92,118,154,68,149,150,14,175,28,124,55,302,97,0,273,126,108,429,140,230,43,375,2,246,109,20,628,69,336,189,9,101,66,38,298,107,65,439,22,517,346,279,345,1,467,419,21,67,169,399,49,48,46,158,847,420,10,570,185,232,251,6,653,29,252,441,314,12,566,637,191,5,535,51,52,508,423,364,533,722,36,32,398,172,74,882,674,917,168,121,95,39,23,621,83,221,159,105,50,505,356,13,701,96,37,484,694,962,173,608,604,135,267,86,104,64,826,329,103,363,236 }, +{ 195,360,156,591,687,771,163,626,70,883,146,132,586,371,407,379,354,48,846,121,293,13,296,31,761,98,18,767,49,105,385,44,279,522,668,21,1,55,23,125,5,518,271,127,590,878,340,10,608,223,33,807,167,259,77,447,116,75,60,658,102,446,265,929,115,128,35,457,221,87,786,301,284,4,95,51,165,395,39,481,698,541,781,291,178,664,372,150,252,777,557,64,30,24,16,153,120,40,558,535,281,107,465,763,638,783,663,393,101,937,9,467,58,196,217,144,61,401,212,199,117,299,941,32,22,817,260,118 }, +{ 13,77,202,318,23,51,33,269,141,64,137,32,291,0,128,102,21,494,4,10,403,217,177,342,5,196,9,349,117,22,153,134,98,95,115,59,31,120,753,18,16,40,48,28,90,372,317,237,49,450,1,86,65,244,352,475,194,11,180,165,142,100,44,125,76,12,116,93,523,275,127,121,24,20,453,365,341,61,859,401,144,82,402,210,198,178,147,88,37,17,2,351,234,105,7,6,326,197,110,30,203,143,922,854,851,427,325,259,118,107,101,72,55,704,421,260,114,36,208,329,265,38,164,864,752,717,558,498 }, +{ 192,81,172,173,7,426,97,232,861,715,43,879,66,712,104,387,330,568,825,74,526,893,91,298,885,448,636,681,140,92,49,560,6,204,135,779,22,5,95,572,707,64,125,726,750,14,370,563,314,20,324,10,362,29,174,246,713,0,718,356,107,138,25,397,85,63,18,38,71,21,441,98,58,500,230,31,501,32,319,408,69,729,189,13,663,422,24,784,359,241,858,165,16,347,263,77,357,623,673,26,888,2,12,353,900,141,23,52,126,37,33,622,278,830,197,48,233,40,443,355,44,42,45,267,87,19,61,237 }, +{ 14,2,1,67,6,24,69,66,7,29,38,108,36,65,83,124,46,52,150,86,25,484,28,302,74,22,388,18,267,398,458,103,50,273,168,97,12,5,16,0,650,135,26,19,160,75,172,189,21,10,208,32,289,278,380,547,782,95,610,140,51,602,118,37,114,451,429,357,42,71,23,324,505,194,149,420,48,143,92,87,17,13,421,115,60,54,70,35,584,96,756,462,20,238,109,185,27,164,64,45,220,244,253,594,3,154,99,138,43,283,335,701,133,309,128,403,797,49,58,732,550,202,169,646,401,423,218,847 }, +{ 202,77,33,13,102,128,51,318,23,64,494,4,141,196,59,0,115,403,40,22,269,210,177,153,137,117,32,90,10,475,291,21,342,15,11,134,352,95,18,65,49,217,86,16,180,36,197,453,165,275,57,1,402,9,194,48,24,341,719,28,105,6,123,349,317,285,523,125,120,372,216,14,450,365,20,457,2,237,7,82,576,98,3,421,12,5,260,247,110,730,116,44,31,901,752,300,8,208,30,498,351,96,93,139,678,164,46,19,401,386,308,817,615,214,50,35,961,758,859,326,160,17,503,391,293,242,221,203 }, +{ 269,318,141,291,77,202,349,217,947,304,33,177,102,851,372,352,753,260,351,120,5,137,854,752,494,275,403,32,922,22,180,475,21,317,30,10,954,31,64,44,418,365,49,28,48,450,39,23,95,341,661,373,82,11,4,36,93,13,61,128,7,6,3,2,859,51,0,197,800,576,96,59,901,69,165,40,203,144,247,1,86,898,12,76,70,160,498,437,342,237,125,9,433,330,238,103,98,67,453,312,864,367,326,253,87,58,361,221,99,90,888,717,678,579,65,774,241,115,50,45,968,951,704,615,473,277,244,134 }, +{ 6,74,138,85,66,222,226,87,42,280,25,135,26,792,500,294,75,29,220,204,70,174,337,145,235,112,278,853,461,19,52,97,1,32,122,38,808,2,256,172,64,889,69,324,380,774,620,802,609,525,7,95,353,21,571,5,65,580,746,415,22,108,140,96,14,241,24,331,63,45,544,287,67,237,267,125,262,92,394,348,103,86,163,632,426,90,194,606,165,630,550,58,53,36,233,76,91,192,357,28,27,17,141,189,416,72,582,486,81,49,114,16,622,113,78,115,10,928,444,537,872,462,46,605,83,350,335,150 }, +{ 9,0,105,39,101,18,16,68,310,24,333,272,252,127,98,518,846,938,28,371,1,916,35,158,286,737,455,31,301,265,327,100,395,616,49,30,254,7,578,55,23,827,118,512,109,44,329,21,65,890,60,320,242,116,137,709,170,51,385,125,48,761,166,14,5,2,13,71,293,131,520,627,154,159,299,557,344,836,12,553,364,93,202,96,167,88,623,128,36,124,506,64,688,212,604,924,910,931,120,284,50,144,10,419,22,165,219,32,37,95,77,110,121,326,67,403,404,203,442,197,187,6,141,676,276,260,239,33 }, +{ 2,14,1,67,46,24,108,29,83,69,38,103,52,75,133,236,309,36,114,28,50,18,398,135,6,65,458,278,7,238,74,87,160,388,124,220,732,0,267,262,66,149,532,335,283,25,412,71,16,5,96,55,547,154,70,273,602,22,302,418,429,218,516,366,646,150,336,357,86,696,175,26,189,54,12,68,118,226,35,172,324,58,582,19,486,208,9,21,594,109,531,112,45,484,140,596,251,60,95,323,17,10,32,37,194,394,64,650,48,168,163,145,42,571,97,222,23,420,505,27,181,92,389,533,606,171,361,99 }, +{ 22,1,28,105,95,49,55,67,168,159,239,65,14,320,35,0,2,36,114,7,170,109,83,12,169,347,194,50,301,69,9,24,5,424,164,185,103,133,654,46,312,420,16,127,10,175,158,64,584,21,23,51,98,143,31,86,286,13,37,289,6,336,389,48,283,505,96,124,68,38,638,512,160,208,39,141,202,18,115,189,128,395,54,623,874,338,237,713,547,44,272,308,740,137,149,371,125,251,32,30,518,345,844,535,180,3,293,928,756,916,242,29,835,165,538,708,327,323,99,737,484,221,401,218,533,374,253,154 }, +{ 66,7,172,97,232,92,314,568,298,140,192,380,135,330,74,324,387,448,357,14,526,126,38,246,204,16,426,107,572,52,2,808,712,501,359,60,69,278,29,230,32,779,441,500,35,95,550,5,21,22,893,6,43,563,392,104,267,46,24,150,362,64,726,138,189,423,173,65,825,71,356,20,462,279,0,12,802,87,86,174,560,10,81,18,49,37,226,830,633,25,48,28,90,289,58,36,67,75,707,91,508,241,312,1,85,451,220,70,443,199,214,636,50,108,83,61,54,222,121,353,262,125,280,45,888,750,237,42 }, +{ 2,29,52,50,46,14,5,1,6,26,133,114,58,218,366,70,19,108,45,27,112,17,236,137,75,38,262,25,74,13,283,516,53,487,223,151,145,208,96,48,51,412,287,163,23,401,323,285,86,65,171,61,36,220,21,480,594,42,128,80,331,73,103,754,181,115,12,739,113,3,532,4,194,54,602,635,186,99,202,409,675,745,34,308,583,307,357,309,782,396,150,57,361,7,764,165,66,735,324,64,966,457,453,90,24,386,445,11,484,32,389,141,629,59,87,244,155,956,711,670,421,22,545,832,758,334,328,573 }, +{ 6,74,1,25,29,42,75,26,66,2,70,138,52,19,85,220,103,388,38,14,226,87,135,324,67,357,108,112,235,69,238,603,222,65,550,500,96,114,145,594,83,309,133,516,27,36,150,451,218,294,262,532,711,51,58,602,280,13,163,50,380,63,137,97,802,23,122,278,458,64,5,394,86,53,606,696,792,46,891,160,461,267,732,12,7,204,582,113,308,453,24,545,889,386,331,45,21,165,398,486,391,115,32,423,401,95,337,758,632,17,208,3,853,457,256,537,335,78,630,141,307,189,641,37,646,444,670,10 }, +{ 22,28,109,49,9,105,131,95,1,36,159,39,86,185,31,98,272,169,127,55,44,219,83,254,286,208,141,128,35,327,352,160,30,180,116,0,224,202,115,239,13,535,187,137,5,96,12,374,317,269,2,244,837,312,752,67,531,21,533,253,237,197,64,217,51,143,168,158,578,251,318,505,37,258,165,285,365,10,7,23,498,201,538,371,901,320,50,424,347,678,48,69,164,776,708,601,341,597,616,345,228,170,873,238,634,6,947,3,482,93,125,144,518,242,946,913,864,716,4,735,8,627,221,420,100,688,910,323 }, +{ 203,822,77,859,326,576,23,403,39,817,137,100,102,473,494,691,411,291,33,177,704,70,523,217,447,96,367,478,18,373,160,13,363,265,1,658,615,93,966,520,310,144,30,692,800,578,342,182,180,120,90,51,254,296,40,158,682,333,9,354,921,349,273,127,121,101,83,60,59,24,731,264,115,821,364,44,268,260,752,857,810,272,196,166,153,131,118,48,16,457,156,67,506,481,450,415,230,15,0,593,968,914,212,937,829,395,365,351,242,225,224,219,194,187,146,141,132,117,110,87,82,49,36,35,22,905,901,656 }, +{ 15,33,117,77,102,134,153,4,115,196,13,40,217,11,341,1,23,5,317,3,365,2,291,21,32,12,349,569,177,59,51,342,0,6,372,139,7,37,901,210,10,180,17,90,111,629,48,275,82,120,197,244,304,141,14,253,137,57,202,247,401,638,308,457,300,9,719,961,482,437,260,277,351,579,31,44,93,216,165,269,36,125,450,72,523,453,89,38,352,94,730,854,116,752,18,817,143,98,386,64,56,96,318,16,468,55,160,148,61,54,76,22,485,110,403,99,221,922,19,474,79,127,65,105,588,27,490,128 }, +{ 15,13,23,51,0,8,197,180,1,165,9,33,82,5,4,10,12,120,2,102,386,115,260,475,7,351,141,110,77,901,326,14,21,18,11,217,22,457,40,93,898,453,373,36,450,341,16,6,125,31,64,854,352,719,401,117,32,391,28,730,3,291,177,203,24,961,523,202,59,317,403,99,49,44,210,922,615,37,237,111,801,153,128,498,342,629,196,509,30,899,569,421,304,752,48,758,817,276,258,137,269,130,393,98,365,57,116,65,338,144,55,704,134,349,105,206,661,551,308,242,38,95,494,275,86,546,318,56 }, +{ 23,51,1,13,21,141,5,180,15,2,202,120,7,0,197,165,12,9,6,4,115,48,352,269,403,386,33,260,318,93,3,32,457,110,37,137,14,450,475,16,82,128,523,453,102,31,18,326,125,421,8,77,44,221,391,64,308,730,401,341,217,153,11,117,98,719,498,196,30,351,99,40,752,494,24,237,317,39,72,28,36,10,59,203,49,373,365,17,116,817,90,899,96,509,22,569,35,901,144,961,615,342,45,50,291,177,86,89,244,661,55,134,20,54,854,65,873,801,402,160,95,247,38,350,629,127,105,29 }, +{ 15,1,0,2,5,3,7,4,6,8,13,10,341,23,9,180,51,82,120,77,31,110,197,961,115,12,22,93,116,165,569,730,202,217,365,752,457,453,719,102,125,44,351,30,403,141,352,33,11,260,523,317,291,475,28,21,450,318,64,898,401,98,899,386,203,36,210,40,177,269,16,242,638,421,326,153,349,372,18,817,494,854,117,275,342,59,111,196,14,137,629,49,134,55,39,143,70,32,37,139,95,758,244,958,498,801,87,24,922,86,670,253,144,170,208,90,105,615,373,873,391,308,247,482,216,61,393,304 }, +{ 559,661,922,564,373,141,260,533,244,332,269,317,642,143,10,93,110,295,728,752,261,876,531,351,206,843,120,345,203,352,180,811,253,384,36,197,144,434,717,901,959,365,498,55,567,1,943,9,28,535,817,22,160,873,902,341,326,911,35,82,601,860,39,30,679,489,824,704,417,926,217,251,940,699,574,137,617,854,201,816,116,282,898,115,44,372,855,258,237,473,662,509,187,169,864,499,349,284,125,31,468,224,21,669,64,318,164,546,951,395,964,839,450,8,219,170,776,638,268,851,23,131,98,482,367,299,48,730 }, +{ 15,5,1,2,23,0,13,7,6,51,3,180,12,9,115,4,165,719,197,457,21,8,14,33,901,22,37,141,82,341,120,10,730,202,16,110,32,31,386,11,317,153,117,752,260,351,453,217,401,18,352,77,308,93,961,48,28,44,134,569,365,391,49,269,102,523,128,98,196,758,137,99,498,36,40,30,450,64,403,17,318,509,24,89,95,475,629,854,72,125,221,177,86,873,326,247,96,899,817,898,39,38,421,139,116,291,482,55,494,59,105,203,210,144,65,468,29,20,237,54,349,90,148,372,244,734,35,45 }, +{ 198,234,5,0,325,77,416,202,61,32,147,49,639,20,43,21,315,22,450,113,95,455,142,427,48,318,230,207,342,18,494,13,329,904,577,725,64,178,28,10,70,58,344,470,102,403,128,819,269,263,104,137,1,319,112,246,17,23,347,291,7,65,887,798,120,12,241,4,36,858,107,237,66,76,376,817,39,422,316,72,97,33,945,105,2,51,90,141,290,884,557,253,9,518,251,671,11,173,86,31,115,27,159,158,194,3,24,312,289,362,260,259,192,859,414,426,16,14,306,523,37,126,475,712,576,310,453,98 }, +{ 447,411,264,363,676,9,664,682,821,812,759,478,897,166,100,905,354,156,1,382,98,265,404,724,39,18,691,656,668,101,520,195,23,144,223,21,865,271,438,593,639,848,31,96,13,5,51,521,125,586,48,127,604,88,909,30,252,765,393,647,360,77,33,121,167,781,367,44,621,132,93,0,410,274,286,118,203,254,120,272,105,102,293,446,116,83,32,658,68,310,371,284,777,115,364,4,834,16,948,69,333,163,24,212,190,40,340,329,551,914,117,49,110,153,70,165,146,35,296,418,10,67,842,242,883,326,697,238 }, +{ 24,71,35,14,69,149,189,108,267,18,16,68,46,2,7,67,140,388,60,38,236,83,251,1,133,118,309,230,336,52,103,29,458,278,28,65,135,175,150,50,172,92,273,55,0,154,75,443,114,9,705,124,399,66,565,398,412,602,335,366,36,101,823,596,451,74,220,345,375,302,594,330,696,516,87,238,6,891,21,218,5,12,54,262,48,96,86,22,582,357,324,97,191,64,70,232,283,723,95,10,37,160,831,732,346,246,563,380,32,25,109,486,733,167,58,314,212,226,192,13,429,99,547,23,181,126,572,394 }, +{ 35,16,7,20,14,60,18,121,24,43,107,68,109,126,199,326,92,120,77,907,2,147,23,259,265,475,403,260,553,1,13,523,132,252,12,146,71,55,33,0,5,859,191,318,817,38,6,450,82,202,848,402,9,286,51,21,329,159,494,419,351,28,465,327,102,10,158,48,682,374,576,198,178,97,32,421,272,621,269,615,590,279,128,941,22,446,167,142,70,493,4,310,604,581,19,105,640,463,453,407,153,694,64,810,150,108,90,29,534,427,212,346,285,709,638,557,793,137,101,39,37,25,291,165,118,95,58,50 }, +{ 30,131,276,187,613,442,44,228,39,31,190,839,935,224,116,856,219,88,9,406,201,908,574,100,244,127,567,137,36,98,110,144,1,93,202,863,258,141,829,260,28,284,49,120,269,295,318,716,21,827,254,661,166,160,203,373,299,55,385,0,22,662,352,944,13,82,530,77,253,86,268,23,96,717,489,64,180,51,326,274,778,918,48,351,492,5,752,197,83,206,125,128,450,115,217,860,32,242,931,578,293,213,102,924,494,851,95,10,101,836,105,272,143,291,699,371,35,434,165,843,864,367,403,159,177,418,261,68 }, +{ 98,223,1,393,812,834,421,697,48,265,593,791,51,410,100,382,293,284,21,23,125,96,541,213,656,88,801,453,31,321,230,765,730,386,221,13,689,9,264,670,639,163,217,5,909,807,116,144,44,352,137,286,551,30,770,948,39,252,699,466,438,435,201,401,127,93,842,475,203,165,921,478,180,166,949,724,367,963,831,36,128,404,455,805,141,676,854,202,2,317,318,772,840,190,32,418,251,855,105,35,333,77,83,197,102,335,49,443,576,957,719,351,539,308,69,55,82,310,115,0,120,557,752,329,403,269,686,669 }, +{ 98,616,219,127,258,51,293,512,924,395,105,421,272,276,308,201,401,284,763,116,23,301,295,453,327,567,944,31,44,843,261,13,268,860,170,770,115,125,569,900,131,386,144,935,456,55,578,365,320,143,341,662,137,109,28,403,434,242,221,36,203,670,286,141,10,326,22,629,21,943,95,9,743,685,160,384,623,506,180,49,206,949,533,719,734,558,282,299,185,159,244,64,8,0,110,964,911,169,32,4,224,551,202,475,11,187,910,617,492,901,253,841,716,1,489,269,959,940,165,699,615,374,855,332,237,713,86,371 }, +{ 253,951,352,110,811,244,206,141,180,332,854,642,282,10,143,638,417,752,559,533,498,260,55,661,911,499,717,120,351,959,535,93,564,160,873,531,137,341,269,197,922,384,373,36,365,728,261,617,901,8,44,82,116,165,31,317,164,64,203,217,509,824,115,473,968,268,144,326,704,434,295,601,86,15,345,851,864,237,943,251,450,169,1,843,201,762,13,372,22,258,308,125,898,96,98,202,127,855,940,4,33,489,21,28,187,9,40,546,117,83,569,338,964,51,5,32,479,391,276,23,102,318,482,349,219,153,128,817 }, +{ 49,254,272,159,9,158,627,131,327,39,518,688,0,578,28,286,68,105,101,347,424,374,364,344,224,22,333,616,65,219,35,24,124,154,716,890,95,577,16,371,320,109,810,538,228,168,310,793,747,127,30,419,613,829,827,187,385,239,846,170,21,1,98,18,36,71,938,406,910,252,31,55,346,175,23,289,51,190,48,258,86,185,83,912,100,623,301,166,128,149,125,67,118,96,44,137,64,242,13,737,857,160,703,671,694,455,202,442,169,60,856,10,761,924,221,709,116,706,634,114,439,677,194,479,7,570,212,395 }, +{ 105,272,22,131,327,374,286,320,109,224,219,28,239,95,98,578,9,169,127,185,538,159,187,616,55,258,371,36,634,623,64,164,49,713,86,910,716,385,168,654,170,420,424,1,10,312,737,201,35,254,293,284,51,23,143,13,44,761,141,601,160,395,933,31,928,916,276,301,924,208,116,67,346,237,137,347,535,39,194,242,0,442,836,83,762,165,584,338,638,505,892,244,251,175,345,114,740,12,391,944,837,128,158,202,197,479,261,253,908,352,912,125,531,96,308,295,144,24,21,30,7,269,268,2,751,323,228,5 }, +{ 691,478,340,724,658,914,698,1,363,744,772,156,411,447,682,909,303,284,296,264,354,919,335,98,9,21,686,664,225,223,586,410,96,367,382,897,51,13,521,33,848,765,125,144,23,32,120,759,48,69,662,260,44,31,166,40,93,77,5,4,551,668,35,269,30,82,191,167,163,318,351,87,404,371,102,88,812,438,165,70,39,385,293,116,65,64,656,364,101,622,286,948,254,271,393,321,141,75,11,18,854,842,443,433,118,100,418,274,202,421,16,774,67,326,329,905,149,922,110,37,386,201,12,197,127,49,203,907 }, +{ 16,24,71,35,18,108,140,60,92,267,68,189,7,230,191,246,149,14,118,167,388,46,69,236,458,399,674,212,273,9,133,1,126,150,21,309,330,50,101,55,2,48,103,121,67,906,602,5,0,345,723,412,232,172,271,146,565,28,516,696,702,75,38,65,451,32,796,12,37,594,633,154,278,733,375,366,302,199,124,314,36,336,398,443,823,64,695,54,135,114,29,22,95,97,462,915,52,563,582,251,705,575,891,589,175,10,83,566,572,13,220,223,23,467,218,830,163,363,394,66,562,132,107,446,641,517,49,86 }, +{ 9,127,0,395,371,98,39,31,737,49,512,385,272,44,28,293,299,101,836,761,158,252,254,16,242,1,284,159,116,18,518,35,276,310,333,24,187,51,21,599,137,30,301,22,131,68,286,23,219,327,202,125,616,48,442,935,456,578,916,5,109,166,685,55,265,7,65,100,688,128,105,201,36,890,623,96,144,13,908,329,12,2,846,64,37,95,141,344,455,318,403,124,93,492,154,32,404,14,203,269,938,627,67,258,118,224,170,244,326,110,268,165,367,763,86,60,827,221,716,160,924,553,120,419,489,662,10,83 }, +{ 16,18,60,68,35,101,252,0,118,71,9,419,28,24,109,364,604,191,126,167,55,121,329,92,7,158,265,39,212,22,346,14,925,49,107,694,185,169,621,146,439,333,628,124,199,150,942,21,159,48,154,553,706,175,108,575,279,677,10,962,20,105,100,848,917,815,446,363,907,132,5,793,271,375,43,149,23,65,13,566,520,806,286,810,95,166,593,374,302,51,1,97,634,598,404,407,12,31,2,272,493,46,467,727,463,562,589,125,326,327,310,50,967,96,682,168,37,344,140,608,203,98,38,647,821,246,362,67 }, +{ 116,268,203,692,93,206,940,31,551,417,473,959,499,44,202,523,559,8,137,120,450,728,299,494,403,22,51,576,0,326,564,817,10,260,13,23,127,1,899,9,105,421,125,615,318,492,638,98,386,918,141,393,341,269,253,21,791,5,28,2,144,64,37,244,805,762,373,180,128,401,599,55,901,242,352,30,165,197,453,642,730,475,170,873,115,49,569,36,4,859,7,143,391,498,86,48,308,922,752,39,395,719,365,951,285,6,457,456,958,12,110,402,704,384,367,95,512,949,18,24,16,515,479,221,32,948,801,282 }, +{ 225,1,744,919,21,459,914,48,691,284,330,385,141,96,98,335,622,166,5,293,51,32,120,223,948,340,260,443,203,88,286,30,831,372,50,363,351,269,82,64,934,70,658,9,190,127,403,352,13,115,418,682,411,371,87,144,393,909,521,922,776,272,102,90,69,61,839,23,15,4,774,349,327,321,268,244,202,197,100,93,551,75,848,662,523,442,478,373,206,201,180,125,76,59,45,36,33,963,538,410,274,237,163,156,821,303,264,772,724,450,382,367,958,954,899,898,865,864,859,854,765,752,730,668,664,506,494,475 }, +{ 5,1,14,2,36,50,28,0,48,281,21,67,24,54,22,83,218,12,38,18,65,181,58,45,114,133,430,32,17,46,96,10,9,103,37,160,502,61,155,99,270,55,72,7,29,513,16,51,108,487,238,23,543,745,86,3,290,6,540,89,361,115,834,13,52,202,221,433,842,488,480,137,236,76,69,328,223,64,838,514,49,532,35,666,474,128,171,283,766,536,227,124,966,308,75,19,552,95,70,208,775,141,323,27,541,822,697,425,754,765,4,285,207,148,657,109,318,412,243,263,77,592,832,663,741,186,807,576 }, +{ 450,137,704,202,326,120,260,851,318,968,494,269,457,182,403,291,351,349,77,678,141,23,310,373,817,859,576,661,523,890,60,128,82,64,795,110,854,70,515,96,5,159,285,1,961,341,13,717,9,421,922,203,180,95,244,55,379,658,577,347,105,75,49,822,687,115,363,800,557,301,160,36,937,475,411,67,59,237,18,16,354,195,864,771,615,520,424,415,344,83,68,51,28,0,805,447,386,364,268,232,107,101,90,86,7,668,481,342,271,786,735,901,897,846,751,731,719,638,621,586,518,402,296,253,239,208,197,165 }, +{ 15,4,33,77,40,13,102,11,23,5,32,21,110,117,217,51,93,153,59,1,247,134,115,141,64,202,120,2,372,180,3,10,12,31,82,291,177,116,139,125,269,196,8,317,17,22,165,137,98,351,318,36,44,128,203,197,28,0,352,48,260,349,898,144,57,403,450,437,6,719,341,72,304,111,457,523,90,365,494,9,326,49,37,730,7,210,39,86,30,14,475,95,386,453,638,961,854,373,76,401,901,237,277,752,56,342,160,817,244,758,402,308,899,143,89,206,216,569,421,615,61,535,45,18,316,127,164,579 }, +{ 23,13,51,1,15,5,2,7,0,21,180,6,115,12,141,9,165,3,197,457,202,4,14,352,719,48,33,32,16,269,37,217,341,8,11,401,120,318,308,22,386,77,31,18,128,752,40,110,260,10,28,453,730,93,137,498,901,403,391,153,82,317,365,117,44,102,17,523,961,569,64,450,509,72,99,49,134,36,758,59,98,221,24,629,89,30,351,475,196,326,125,177,494,291,90,421,237,29,899,203,35,39,247,864,817,95,372,96,349,20,116,854,65,38,54,160,19,144,57,86,244,304,873,55,342,373,350,316 }, +{ 219,258,127,276,98,944,395,201,567,284,131,293,935,860,116,662,295,224,737,105,578,576,242,403,843,371,137,551,272,456,512,421,51,31,475,716,202,697,261,44,492,187,924,616,268,9,49,326,206,254,144,299,39,385,22,115,916,805,93,699,308,203,943,159,160,761,836,763,125,23,13,0,332,453,401,386,36,120,28,770,141,21,327,615,384,393,282,958,221,318,494,367,365,143,217,128,434,64,692,940,10,244,110,617,301,911,55,964,730,320,5,966,523,86,719,623,457,96,95,1,269,317,24,670,197,859,842,286 }, +{ 16,35,60,18,7,92,20,14,118,0,68,126,71,28,154,24,107,43,158,22,2,109,49,55,677,168,185,1,97,6,121,12,21,175,10,5,159,703,150,202,169,105,191,942,95,38,494,279,37,137,23,13,9,329,230,140,628,48,69,420,32,553,124,326,167,128,403,120,747,101,74,51,108,925,31,65,66,621,246,475,29,46,36,576,344,52,419,25,575,81,104,98,375,173,570,421,346,39,265,199,86,50,671,269,424,362,58,318,54,450,44,149,125,143,817,566,615,302,61,439,260,453,170,165,493,402,67,286 }, +{ 728,531,160,93,373,574,559,717,120,860,533,295,269,260,318,926,851,434,258,36,902,137,251,332,617,141,201,261,699,206,384,940,968,843,816,345,352,244,187,839,564,55,776,661,144,959,871,116,64,219,44,473,489,268,535,203,10,567,31,911,498,143,896,110,679,450,523,224,824,800,197,164,276,601,351,406,662,202,873,752,943,317,365,169,855,228,704,282,131,180,253,326,82,954,1,669,125,854,367,901,98,217,165,417,817,341,86,442,831,8,898,642,284,13,127,876,237,21,947,864,22,83,23,748,418,115,946,868 }, +{ 28,9,0,1,22,109,49,39,83,55,12,158,67,96,69,5,35,30,65,95,168,323,159,128,185,238,21,50,36,105,2,24,160,23,194,208,103,7,68,169,137,218,141,48,37,505,16,420,51,13,202,86,251,285,18,114,269,31,115,531,124,10,289,418,101,402,797,154,433,32,99,175,64,866,735,252,180,646,272,100,286,480,503,54,333,533,244,14,344,131,352,44,318,127,98,327,6,346,217,570,254,197,237,181,657,800,535,745,374,4,335,75,317,165,281,756,143,584,757,419,532,345,956,365,223,831,403,341 }, +{ 23,13,51,5,141,21,1,165,202,2,15,32,12,197,115,180,7,0,48,269,120,9,4,6,453,386,403,318,308,401,37,457,14,33,137,352,64,3,125,128,523,16,31,93,391,260,730,719,475,341,450,237,99,18,82,110,11,10,44,77,326,421,8,217,494,40,28,90,102,59,49,17,117,36,98,30,221,899,247,317,22,365,72,153,509,24,196,351,39,498,569,629,752,89,116,134,177,203,20,373,96,961,901,372,817,241,291,45,86,57,19,61,76,304,38,758,468,65,50,160,105,144,55,402,29,244,216,25 }, +{ 5,21,13,49,23,43,32,20,48,14,7,51,97,107,61,115,38,713,22,24,1,12,70,46,652,955,142,58,16,590,0,626,197,2,640,147,64,279,581,132,350,150,121,303,81,493,340,888,841,104,36,60,87,18,95,345,92,241,296,221,509,98,349,308,622,91,202,195,638,141,125,35,408,407,156,379,269,146,66,28,31,9,786,534,17,128,903,929,518,178,29,354,4,108,105,263,522,687,247,65,259,850,126,44,237,199,54,774,535,271,260,50,347,6,446,318,159,90,10,288,137,783,360,76,223,598,55,586 }, +{ 9,28,0,39,101,30,49,35,68,1,67,166,175,83,22,158,100,252,141,55,88,69,65,109,36,23,180,217,323,115,64,269,345,103,21,124,10,317,13,251,289,238,364,498,154,352,230,5,419,131,190,31,7,51,194,48,50,346,96,128,439,159,160,105,202,24,274,143,952,95,16,168,12,646,341,254,752,86,868,365,637,596,244,127,137,570,433,318,418,114,864,208,44,37,503,404,372,2,32,344,197,333,116,532,218,77,98,187,237,164,125,723,535,443,480,169,265,901,189,310,221,420,336,873,797,403,402,285 }, +{ 260,120,450,351,854,82,269,922,5,32,13,125,33,23,202,291,165,21,197,77,137,1,141,203,457,349,318,51,4,326,177,144,180,753,730,275,386,523,817,237,116,217,373,719,403,98,93,31,372,128,241,115,12,899,704,341,304,196,102,44,40,391,48,2,342,898,954,864,801,494,284,208,110,76,59,365,352,285,207,947,758,663,615,599,558,492,482,456,408,350,263,210,201,160,64,57,49,19,18,16,14,11,10,7,6,961,317,361,37,968,752,661,498,475,453,402,323,300,293,268,244,206,154,127,105,96,95,86 }, +{ 121,16,60,363,35,18,101,20,167,68,621,259,126,191,604,407,107,132,55,364,43,146,199,252,7,14,92,419,590,147,212,71,9,326,5,463,520,21,694,917,465,24,354,446,647,109,13,271,682,0,28,22,120,203,10,97,806,821,48,169,77,279,727,362,2,346,195,581,640,932,178,589,118,115,102,125,23,202,51,439,941,907,848,411,450,33,857,427,634,165,553,154,108,180,39,494,325,185,373,329,142,475,265,818,49,342,158,967,403,260,1,523,374,612,110,962,12,534,955,37,615,376,150,793,692,562,137,638 }, +{ 23,13,51,5,1,12,2,141,15,21,115,0,202,180,7,32,197,3,165,4,6,9,401,37,269,14,308,457,352,11,318,453,341,386,120,403,10,16,33,22,8,719,18,391,40,31,77,48,217,28,137,17,99,365,523,475,569,128,730,44,93,59,260,102,498,450,90,49,509,24,30,317,110,752,421,64,247,125,72,82,237,221,177,629,98,351,961,494,153,36,89,19,117,758,901,373,196,326,57,38,39,29,20,65,546,304,134,116,95,899,817,139,372,76,35,55,316,241,291,468,482,203,144,210,45,402,873,54 }, +{ 201,144,206,443,418,332,203,435,330,96,494,326,473,372,335,269,434,268,187,403,822,817,459,1,88,498,564,384,839,382,617,367,83,264,934,559,295,276,30,717,344,521,141,831,321,274,44,202,576,31,9,686,709,190,100,921,699,812,252,55,230,137,208,450,616,457,284,180,128,93,28,859,410,966,228,265,456,352,69,523,318,244,158,795,961,747,735,662,584,531,421,855,213,168,960,225,478,959,899,716,578,577,489,466,417,291,223,116,36,35,23,13,954,952,237,800,349,285,77,744,866,772,752,346,197,166,98,32 }, +{ 44,276,31,116,201,284,662,567,131,489,144,268,295,434,918,30,9,39,98,137,187,219,299,224,935,367,49,384,385,36,93,22,28,0,244,261,141,127,492,699,203,110,254,1,202,836,160,442,253,258,105,96,64,269,393,51,128,371,125,23,716,55,86,318,326,10,908,120,206,940,855,77,143,190,827,13,21,228,352,217,100,35,159,48,165,115,272,944,373,948,260,617,829,102,197,166,578,737,83,16,332,293,95,717,450,24,523,88,180,403,109,18,177,37,164,5,899,242,959,613,730,285,291,15,7,616,911,473 }, +{ 520,664,478,604,759,264,167,1,724,777,9,647,411,682,48,806,936,363,101,223,265,410,21,68,118,252,100,907,848,447,772,98,96,781,0,212,88,905,16,821,39,925,917,23,329,909,382,18,166,942,125,191,639,221,13,24,51,676,124,932,321,897,621,628,521,5,71,154,69,31,30,815,686,293,541,49,284,271,60,593,765,55,32,812,404,435,335,807,163,562,44,834,553,35,691,65,364,763,105,83,146,28,127,274,10,158,7,190,393,64,238,213,419,67,701,421,354,33,22,254,697,149,116,272,201,115,77,144 }, +{ 70,23,87,21,60,75,163,182,267,92,291,120,115,107,146,379,195,132,446,795,937,246,126,121,98,71,48,18,7,415,931,566,232,133,51,24,125,371,821,668,535,411,401,340,318,308,221,116,77,44,40,32,11,4,281,850,293,563,537,407,273,217,202,199,140,13,5,807,197,64,591,385,33,883,386,626,687,891,823,820,770,766,754,743,670,658,633,627,615,598,551,545,541,458,394,392,372,364,361,349,342,338,333,330,301,284,283,268,264,216,210,105,102,100,95,49,35,31,866,774,597,498,335,244,238,237,160,2 }, +{ 39,9,737,127,0,310,98,827,846,395,100,31,371,916,254,265,385,105,272,101,18,30,836,1,242,166,44,512,16,557,116,252,131,578,938,931,137,93,301,28,125,68,333,24,51,404,23,120,286,616,856,35,299,21,55,13,64,202,593,716,128,96,48,326,329,219,260,158,7,110,264,5,688,456,77,203,165,36,49,373,924,761,442,118,863,639,144,518,318,284,228,88,438,60,327,363,12,450,33,190,82,10,411,731,102,65,293,109,455,95,170,908,599,623,494,115,478,187,141,2,14,22,812,685,276,403,935,197 }, +{ 107,126,279,20,43,356,362,92,7,359,16,598,683,595,246,441,60,392,939,653,399,35,199,319,125,649,97,259,414,71,0,493,121,858,230,150,140,232,191,49,48,14,702,173,575,68,95,298,422,674,18,64,98,590,147,22,612,118,28,24,672,104,819,407,345,146,77,660,695,10,953,375,423,31,945,314,293,33,640,23,115,93,158,44,167,149,132,154,21,783,5,175,81,807,508,376,105,109,59,13,40,391,779,387,237,124,589,470,55,426,4,330,727,729,51,427,169,120,796,223,91,189,446,117,153,541,463,755 }, +{ 206,417,93,959,728,559,499,473,137,120,8,564,141,244,260,253,450,31,44,10,269,352,203,318,373,143,341,202,638,116,752,180,144,951,940,326,268,110,160,851,115,922,127,98,717,642,384,125,434,64,13,36,51,282,615,704,365,661,197,498,23,901,817,30,762,489,276,692,15,873,165,22,968,86,1,854,128,386,299,105,217,811,55,0,242,421,317,351,523,367,237,911,21,170,49,77,9,349,391,28,509,479,187,177,82,201,576,285,164,898,492,401,96,456,291,569,494,800,338,33,32,5,39,372,12,261,295,293 }, +{ 259,465,147,581,534,132,590,687,146,427,199,279,941,195,955,640,786,107,178,522,798,121,929,362,150,5,198,325,626,142,35,21,878,376,407,360,167,48,271,1,423,10,70,20,13,126,77,22,125,98,493,31,163,49,212,202,0,105,43,783,33,14,156,345,883,102,612,767,28,97,660,346,470,221,23,450,60,12,771,92,191,379,120,591,2,467,318,9,32,61,4,535,128,153,117,116,562,95,953,18,115,595,159,494,17,371,44,293,818,58,165,51,7,68,354,246,234,269,87,342,845,196,260,72,6,134,481,93 }, +{ 523,403,817,202,15,899,450,120,51,730,494,421,719,128,457,453,13,23,342,102,401,318,64,196,33,475,141,180,49,5,115,269,308,197,237,221,165,99,4,77,137,95,260,0,757,576,365,316,125,65,48,615,402,326,159,11,671,389,312,289,283,247,210,203,194,148,105,22,21,386,835,12,958,749,743,697,485,351,350,341,300,177,170,158,155,151,136,133,129,127,123,122,119,114,113,112,90,89,86,84,80,72,62,61,59,58,56,45,40,34,27,26,25,19,17,3,901,752,153,134,117,961,922,968,967,966,965,964 }, +{ 141,559,244,10,661,253,564,143,365,533,752,180,55,110,901,160,922,373,341,317,93,535,352,206,260,531,36,197,332,269,82,642,282,964,498,911,717,261,728,873,943,351,137,64,417,854,120,1,811,9,115,217,898,169,28,165,164,86,384,203,22,15,83,21,959,96,617,499,318,35,31,8,482,295,951,251,345,372,902,5,473,601,144,32,546,843,800,237,13,864,44,509,109,824,67,268,450,391,308,349,23,258,77,567,851,291,202,116,949,615,125,926,954,638,551,569,457,51,326,102,59,434,817,418,958,719,629,523 }, +{ 219,258,276,127,284,98,935,860,943,843,567,201,137,295,964,131,261,116,535,662,492,44,160,253,31,224,206,203,615,268,144,332,293,692,924,918,384,244,944,326,36,128,434,395,716,737,367,456,187,55,96,403,551,318,911,617,616,385,699,533,115,940,202,365,10,836,576,966,523,959,77,28,21,93,9,120,489,141,1,260,48,371,531,217,143,282,564,125,110,180,51,704,421,299,39,23,64,363,254,393,442,242,494,417,105,822,473,317,578,269,272,697,22,855,102,805,475,13,948,341,0,373,33,285,82,49,932,574 }, +{ 422,319,0,945,207,887,32,577,693,43,95,20,904,22,344,61,104,804,707,306,426,124,5,725,7,241,153,325,316,49,715,414,113,671,115,239,263,329,173,198,180,102,18,365,117,83,24,33,376,510,942,355,324,140,134,69,21,9,232,77,76,240,237,196,189,177,160,158,36,10,835,292,341,526,334,331,168,92,48,16,330,37,25,204,64,901,595,416,392,347,858,362,244,174,164,149,97,86,60,58,39,31,30,27,790,770,222,65,2,350,40,11,4,814,13,933,424,159,819,397,697,623,610,491,403,387,315,288 }, +{ 1,22,12,5,2,0,36,21,28,49,105,86,95,37,55,9,7,48,23,32,141,83,10,51,31,96,269,202,13,128,50,4,160,239,208,318,14,168,159,6,3,170,44,67,164,54,115,285,99,35,109,98,244,180,64,137,402,65,24,127,16,352,320,18,197,69,323,30,158,11,169,301,708,678,238,312,77,717,597,39,143,165,584,194,125,17,253,217,341,735,281,114,116,218,654,181,403,237,424,103,347,317,185,177,45,401,15,776,242,29,46,72,68,418,498,433,223,33,569,901,480,531,40,657,365,800,851,8 }, +{ 15,13,2,1,5,23,3,0,4,7,6,51,115,9,10,12,197,11,14,77,22,217,269,8,165,31,961,33,457,202,32,180,21,341,40,141,120,102,177,16,569,453,28,318,317,17,260,291,44,365,93,37,117,134,110,30,352,18,403,719,153,196,49,401,59,475,901,36,326,98,64,304,386,125,498,730,349,494,450,137,48,247,95,90,523,308,752,24,128,210,111,99,82,139,372,203,873,57,76,116,237,342,72,629,351,391,482,509,19,421,39,144,373,35,55,216,89,275,437,817,20,86,105,56,899,96,38,65 }, +{ 23,202,77,51,13,120,1,141,15,326,180,269,260,137,318,102,450,5,128,21,110,217,291,165,197,352,115,317,373,2,48,12,7,0,523,33,203,386,403,9,96,64,93,342,6,351,82,32,14,457,177,16,36,817,349,752,494,37,4,475,18,210,901,854,341,285,615,59,275,90,498,50,244,160,391,453,99,308,86,10,365,401,22,719,922,8,221,24,730,28,704,402,421,11,125,83,67,237,661,3,40,898,30,153,35,961,31,196,65,253,39,576,17,44,247,20,569,300,95,49,899,116,509,473,117,143,70,372 }, +{ 15,1,0,2,51,13,23,5,7,180,9,6,12,4,115,33,197,523,21,120,3,8,14,457,901,165,351,141,450,260,202,365,341,82,16,40,730,31,37,308,719,401,77,93,44,18,10,899,64,453,403,32,137,317,386,217,36,48,110,98,475,102,326,28,22,128,269,30,11,116,569,421,352,318,817,752,24,196,961,221,99,39,49,144,153,629,55,89,17,203,373,35,117,59,801,898,291,873,177,509,86,125,494,244,95,160,482,134,498,854,72,372,96,615,349,468,38,143,758,237,90,127,391,54,342,670,734,247 }, +{ 16,24,18,92,35,71,60,7,75,126,140,108,50,132,9,21,68,121,14,246,13,0,146,23,267,1,48,128,220,107,70,230,150,32,12,199,118,5,394,181,87,137,537,46,51,133,269,189,141,54,64,22,167,10,202,156,2,330,281,820,171,77,99,291,774,217,177,349,58,65,39,37,103,69,163,28,95,67,622,318,309,633,86,236,101,360,372,6,563,36,195,304,115,38,641,314,30,149,522,232,20,591,352,354,49,545,55,98,571,271,317,526,649,407,672,278,100,640,586,45,223,114,31,678,430,237,388,328 }, +{ 180,341,901,15,1,365,5,2,0,4,197,7,6,115,3,752,10,13,569,317,873,23,165,8,55,141,9,143,44,93,31,498,217,51,638,253,509,308,352,12,22,401,244,36,116,33,21,11,206,64,144,120,951,391,629,137,16,37,86,372,269,125,734,386,134,110,351,40,18,421,417,260,77,282,117,326,268,499,102,457,164,318,482,373,237,203,170,127,95,35,661,642,82,202,177,559,468,261,201,196,160,221,105,961,32,28,854,551,169,24,349,811,762,728,564,338,14,242,717,291,109,153,139,128,403,312,437,851 }, +{ 9,0,101,175,35,28,39,68,364,67,252,65,124,289,158,336,154,166,83,55,100,114,439,103,419,69,49,194,346,1,30,189,345,570,109,88,22,168,64,251,50,16,547,36,230,96,596,133,389,868,265,238,149,86,429,24,694,21,128,218,637,399,141,703,23,646,51,826,13,671,208,677,159,706,95,137,7,797,505,610,237,12,115,756,10,404,484,131,768,190,2,333,71,164,18,799,329,323,344,967,283,202,274,420,782,930,48,105,286,140,217,702,480,143,212,54,37,962,269,14,857,185,310,532,254,535,197,118 }, +{ 64,115,180,197,237,165,391,247,217,352,386,316,304,32,90,13,21,468,95,72,317,76,498,89,365,291,141,125,22,509,349,288,179,86,546,98,372,23,341,225,437,49,116,569,645,796,923,459,18,411,308,177,48,640,4,586,490,16,5,12,591,312,241,933,117,35,65,134,482,752,672,269,164,77,156,302,71,1,264,873,410,321,118,446,360,271,102,59,24,682,674,246,953,88,149,751,51,521,92,823,447,144,864,37,7,11,695,702,166,781,698,662,647,588,458,403,401,363,283,239,216,194,170,153,57,33,28,17 }, +{ 15,13,1,2,5,23,0,4,7,3,115,6,51,217,9,12,197,10,141,21,11,961,457,180,8,341,77,33,165,22,14,32,31,317,202,120,40,37,177,260,16,102,93,269,901,365,352,28,44,247,318,18,117,110,134,17,386,569,372,719,752,59,48,30,36,498,153,403,196,49,450,291,82,72,125,137,304,128,453,391,730,401,98,873,349,373,523,139,509,24,64,326,39,90,475,111,99,308,899,116,95,89,482,203,351,210,86,922,144,437,629,55,57,421,148,494,342,854,35,76,20,179,817,758,275,105,237,216 }, +{ 132,199,146,121,407,60,493,279,640,598,534,522,195,581,590,955,360,126,259,107,150,783,362,35,5,156,271,49,167,939,18,16,147,612,941,591,467,21,883,465,423,929,0,10,191,92,22,298,441,356,446,13,70,48,7,31,626,28,77,24,32,296,178,97,212,33,354,108,608,786,623,68,345,586,727,660,71,649,687,102,163,125,9,105,115,683,55,4,463,379,75,23,87,98,14,953,293,159,50,44,818,761,376,61,246,40,64,763,713,109,1,120,117,767,359,427,95,101,20,344,58,43,607,221,575,663,142,153 }, +{ 28,1,0,22,9,24,65,55,12,5,67,36,96,83,114,50,18,16,2,14,35,103,21,109,49,48,7,218,160,54,124,69,433,37,281,238,23,10,181,51,223,133,137,39,154,745,68,58,99,480,202,13,95,86,75,128,657,115,283,532,285,46,32,163,323,822,38,141,175,547,30,389,766,108,45,168,646,64,194,429,158,169,185,155,361,505,418,70,420,800,531,105,208,502,269,430,6,101,71,866,318,765,402,289,838,398,149,31,251,221,29,484,757,543,4,3,533,308,180,503,17,403,72,754,171,118,217,89 }, +{ 93,120,957,968,459,77,30,160,352,217,473,110,102,372,202,373,613,291,137,260,190,752,704,141,317,31,318,961,269,177,44,326,203,851,330,863,450,264,321,265,228,224,728,457,304,247,88,924,116,840,800,219,144,365,197,115,28,187,717,49,39,944,559,908,829,406,934,349,213,916,244,131,64,225,36,98,82,9,730,403,342,275,210,180,109,100,86,33,938,855,55,831,521,367,719,10,661,165,922,935,258,839,918,864,669,539,351,274,196,166,83,341,15,959,822,772,617,285,897,531,410,716,686,478,871,251,901,836 }, +{ 15,0,1,13,9,23,2,5,51,7,12,6,120,4,8,10,102,197,523,901,341,180,14,260,115,82,77,141,33,165,3,16,21,18,202,59,450,22,403,457,110,817,93,475,64,351,11,453,137,37,401,898,421,128,28,40,719,31,961,217,36,48,569,365,30,125,269,308,318,373,203,317,210,32,494,98,44,116,730,352,24,86,49,326,386,117,342,854,95,629,17,153,144,55,391,177,922,899,99,291,237,143,196,39,805,134,221,96,576,670,139,752,35,253,244,661,300,50,57,127,402,65,638,349,19,498,206,111 }, +{ 206,417,244,499,141,253,44,8,137,559,269,144,93,10,31,728,116,564,203,143,268,352,717,638,120,260,160,752,951,318,384,341,180,282,373,959,434,127,110,197,202,125,851,64,36,901,642,473,498,326,332,115,165,450,201,98,873,242,922,23,22,1,217,261,276,762,55,13,489,86,661,51,317,365,15,940,898,811,82,855,854,704,9,295,0,21,372,164,351,37,968,187,569,367,911,5,576,28,617,401,237,170,615,128,776,349,7,48,105,421,479,386,16,96,95,299,291,12,258,824,864,308,817,2,30,403,49,692 }, +{ 530,840,254,228,406,829,669,613,827,96,21,48,51,31,23,960,137,224,219,1,166,131,39,98,679,438,310,190,856,116,93,403,274,221,144,127,258,846,36,202,180,938,688,120,318,765,421,385,931,317,475,13,77,816,876,105,44,187,30,115,5,625,203,125,752,442,141,32,367,308,365,284,924,778,341,842,50,28,268,333,242,217,860,160,100,22,616,539,110,88,871,159,37,345,9,165,33,839,332,299,83,574,351,576,68,404,371,10,518,326,82,748,716,863,492,578,401,265,456,102,269,656,128,926,557,531,498,494 }, +{ 15,13,197,457,0,719,23,8,730,1,82,165,120,134,9,10,5,180,2,141,7,12,115,51,260,901,4,899,351,6,341,352,33,3,22,386,450,31,202,11,117,569,523,269,128,93,18,898,44,110,758,28,752,373,365,64,30,961,77,318,498,873,21,854,111,49,102,37,16,40,99,137,125,317,14,391,55,217,24,116,326,98,403,474,36,494,482,817,509,372,35,661,277,139,922,615,38,801,203,143,291,153,475,86,453,253,629,304,148,437,402,237,48,642,954,564,864,431,244,95,242,144,39,401,72,17,196,958 }, +{ 68,0,16,24,35,9,252,71,419,18,28,101,154,158,109,124,118,60,39,55,329,364,333,49,65,677,346,22,7,185,265,149,159,175,169,191,810,302,553,100,14,92,344,108,439,671,703,793,105,168,375,286,272,327,374,21,694,706,1,10,67,126,254,634,310,95,212,289,701,2,48,167,150,455,166,627,577,30,747,420,273,538,46,69,962,36,51,23,424,13,12,64,857,429,593,96,5,570,925,86,917,199,37,125,31,50,83,826,628,912,107,239,604,98,638,114,688,221,967,131,709,137,170,336,140,20,589,128 }, +{ 51,1,23,13,15,180,120,2,5,197,202,141,0,7,21,165,260,326,33,9,4,450,12,102,6,523,48,386,115,403,269,137,457,352,14,318,16,128,110,77,3,40,196,32,18,93,217,82,317,37,341,8,817,96,31,401,453,36,752,342,351,44,719,203,901,28,475,221,421,365,64,730,24,391,153,30,308,373,10,494,22,615,59,11,39,99,98,50,116,899,498,961,177,372,291,35,854,144,509,244,17,49,922,569,86,72,247,65,349,125,160,210,482,127,117,402,20,134,55,873,38,83,898,67,275,88,285,237 }, +{ 535,253,352,564,365,110,82,180,854,341,10,533,873,55,244,898,752,901,143,642,141,559,498,36,317,951,638,160,661,115,197,282,964,137,531,165,634,351,64,308,164,217,169,206,417,811,86,499,482,28,332,125,373,509,15,569,93,546,83,728,762,965,96,22,468,601,260,911,269,717,9,349,922,109,345,800,291,734,31,23,338,170,1,372,538,629,221,943,8,120,261,44,21,318,743,494,401,128,202,13,822,579,403,251,617,959,719,770,67,864,219,185,127,117,48,286,384,299,730,475,453,402,350,69,421,391,98,39 }, +{ 31,125,44,116,338,64,242,55,164,36,299,1,237,86,456,10,22,558,506,144,498,492,13,23,762,170,268,143,206,685,93,870,180,844,599,5,903,546,197,115,2,203,509,169,479,165,141,127,0,352,253,393,752,740,8,137,12,51,28,341,391,638,7,244,9,457,160,367,873,98,128,384,951,963,282,202,918,21,269,37,6,105,569,629,434,365,120,301,4,708,318,3,417,489,923,901,719,317,308,401,386,535,217,14,15,734,95,551,634,499,208,533,332,49,758,83,824,961,730,239,776,601,523,751,948,717,864,654 }, +{ 23,13,51,4,115,202,5,217,77,141,1,11,180,2,317,0,3,7,33,269,318,15,365,341,21,9,102,10,32,6,40,12,352,177,22,197,403,64,165,128,901,59,752,31,494,137,308,291,28,8,18,349,401,16,125,90,30,14,237,498,372,93,37,98,153,49,453,17,36,873,44,475,457,39,342,196,210,24,48,326,569,386,421,247,95,203,120,509,275,116,391,961,117,244,110,143,57,304,144,216,482,719,134,139,468,86,523,55,221,450,67,76,50,253,35,105,260,65,437,373,730,72,859,629,46,692,576,111 }, +{ 39,9,166,364,68,101,158,333,0,154,562,28,404,30,65,124,252,35,175,274,344,310,190,706,49,289,570,100,168,438,694,419,346,703,826,55,16,24,439,21,88,149,254,577,429,810,109,159,962,857,671,212,455,656,22,610,95,194,1,336,747,13,125,67,36,131,530,865,48,71,625,793,10,589,23,64,841,265,484,539,86,224,558,350,69,237,420,51,835,96,272,105,406,677,165,228,83,18,31,141,114,286,557,221,347,115,137,169,722,778,7,391,98,818,816,308,840,634,709,44,185,128,960,777,143,258,669,60 }, +{ 15,341,13,33,23,77,141,4,0,351,1,260,102,51,82,9,40,349,854,11,115,217,269,137,180,202,922,5,901,22,10,117,21,365,318,197,120,352,64,12,7,153,177,59,291,32,128,2,165,196,372,36,403,317,457,28,18,8,16,304,30,14,450,31,898,37,3,752,48,134,139,494,421,6,453,401,719,90,86,569,523,110,24,55,475,210,49,44,386,17,730,95,247,244,961,143,125,308,342,817,629,98,498,93,96,76,39,275,509,326,99,285,373,57,237,35,402,160,111,253,105,391,221,116,899,72,127,661 } diff --git a/extern/skylight/ArHosekSkyModel.c b/extern/skylight/ArHosekSkyModel.c deleted file mode 100644 index 7bfb8375..00000000 --- a/extern/skylight/ArHosekSkyModel.c +++ /dev/null @@ -1,376 +0,0 @@ -/* -This source is published under the following 3-clause BSD license. - -Copyright (c) 2012, Lukas Hosek and Alexander Wilkie -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * None of the names of the contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDERS 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. -*/ - -/* ============================================================================ - -This file is part of a sample implementation of the analytical skylight model -presented in the SIGGRAPH 2012 paper - - - "An Analytic Model for Full Spectral Sky-Dome Radiance" - - by - - Lukas Hosek and Alexander Wilkie - Charles University in Prague, Czech Republic - - - Version: 1.0, May 11th, 2012 - - -Please visit http://cgg.mff.cuni.cz/projects/SkylightModelling/ to check if -an updated version of this code has been published! - -============================================================================ */ - -/* - -All instructions on how to use this code are to be found in the accompanying -header file. - -*/ - -#include "ArHosekSkyModel.h" -#include "ArHosekSkyModelData.h" -#include -#include -#include - -// Some macro definitions that occur elsewhere in ART, and that have to be -// replicated to make this a stand-alone module. - -#ifndef NIL -#define NIL 0 -#endif - -#ifndef MATH_PI -#define MATH_PI 3.141593 -#endif - -#ifndef ALLOC -#define ALLOC(_struct) ((_struct *)malloc(sizeof(_struct))) -#endif - -// internal definitions - -typedef double *ArHosekSkyModel_Dataset; -typedef double *ArHosekSkyModel_Radiance_Dataset; - -// internal functions - -void ArHosekSkyModel_CookConfiguration( - ArHosekSkyModel_Dataset dataset, - ArHosekSkyModelConfiguration config, - double turbidity, - double albedo, - double solar_elevation - ) -{ - double * elev_matrix; - - int int_turbidity = turbidity; - double turbidity_rem = turbidity - (double)int_turbidity; - - solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0)); - - // alb 0 low turb - - elev_matrix = dataset + ( 9 * 6 * (int_turbidity-1) ); - - - for( unsigned int i = 0; i < 9; ++i ) - { - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - config[i] = - (1.0-albedo) * (1.0 - turbidity_rem) - * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i] + - 5.0 * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] + - pow(solar_elevation, 5.0) * elev_matrix[i+45]); - } - - // alb 1 low turb - elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity-1)); - for(unsigned int i = 0; i < 9; ++i) - { - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - config[i] += - (albedo) * (1.0 - turbidity_rem) - * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i] + - 5.0 * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] + - pow(solar_elevation, 5.0) * elev_matrix[i+45]); - } - - if(int_turbidity == 10) - return; - - // alb 0 high turb - elev_matrix = dataset + (9*6*(int_turbidity)); - for(unsigned int i = 0; i < 9; ++i) - { - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - config[i] += - (1.0-albedo) * (turbidity_rem) - * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i] + - 5.0 * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] + - pow(solar_elevation, 5.0) * elev_matrix[i+45]); - } - - // alb 1 high turb - elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity)); - for(unsigned int i = 0; i < 9; ++i) - { - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - config[i] += - (albedo) * (turbidity_rem) - * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i] + - 5.0 * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] + - pow(solar_elevation, 5.0) * elev_matrix[i+45]); - } -} - -double ArHosekSkyModel_CookRadianceConfiguration( - ArHosekSkyModel_Radiance_Dataset dataset, - double turbidity, - double albedo, - double solar_elevation - ) -{ - double* elev_matrix; - - int int_turbidity = turbidity; - double turbidity_rem = turbidity - (double)int_turbidity; - double res; - solar_elevation = pow(solar_elevation / (M_PI / 2.0), (1.0 / 3.0)); - - // alb 0 low turb - elev_matrix = dataset + (6*(int_turbidity-1)); - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - res = (1.0-albedo) * (1.0 - turbidity_rem) * - ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] + - 5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] + - pow(solar_elevation, 5.0) * elev_matrix[5]); - - // alb 1 low turb - elev_matrix = dataset + (6*10 + 6*(int_turbidity-1)); - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - res += (albedo) * (1.0 - turbidity_rem) * - ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] + - 5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] + - pow(solar_elevation, 5.0) * elev_matrix[5]); - if(int_turbidity == 10) - return res; - - // alb 0 high turb - elev_matrix = dataset + (6*(int_turbidity)); - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - res += (1.0-albedo) * (turbidity_rem) * - ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] + - 5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] + - pow(solar_elevation, 5.0) * elev_matrix[5]); - - // alb 1 high turb - elev_matrix = dataset + (6*10 + 6*(int_turbidity)); - //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4; - res += (albedo) * (turbidity_rem) * - ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] + - 5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] + - 10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] + - 10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] + - 5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] + - pow(solar_elevation, 5.0) * elev_matrix[5]); - return res; -} - -double ArHosekSkyModel_GetRadianceInternal( - ArHosekSkyModelConfiguration configuration, - double theta, - double gamma - ) -{ - const double expM = exp(configuration[4] * gamma); - const double rayM = cos(gamma)*cos(gamma); - const double mieM = (1.0 + cos(gamma)*cos(gamma)) / pow((1.0 + configuration[8]*configuration[8] - 2.0*configuration[8]*cos(gamma)), 1.5); - const double zenith = sqrt(cos(theta)); - - return (1.0 + configuration[0] * exp(configuration[1] / (cos(theta) + 0.01))) * - (configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith); -} - -// spectral version - -ArHosekSkyModelState * arhosekskymodelstate_alloc_init( - const double turbidity, - const double albedo, - const double elevation - ) -{ - ArHosekSkyModelState * state = ALLOC(ArHosekSkyModelState); - - for( unsigned int wl = 0; wl < 11; ++wl ) - { - ArHosekSkyModel_CookConfiguration( - datasets[wl], - state->configs[wl], - turbidity, - albedo, - elevation - ); - - state->radiances[wl] = - ArHosekSkyModel_CookRadianceConfiguration( - datasetsRad[wl], - turbidity, - albedo, - elevation - ); - } - - return state; -} - -void arhosekskymodelstate_free( - ArHosekSkyModelState * state - ) -{ - free(state); -} - -double arhosekskymodel_radiance( - ArHosekSkyModelState * state, - double theta, - double gamma, - double wavelength - ) -{ - int low_wl = (wavelength - 320.0 ) / 40.0; - - double interp = fmod((wavelength - 320.0 ) / 40.0, 1.0); - - double val_low = - ArHosekSkyModel_GetRadianceInternal( - state->configs[low_wl], - theta, - gamma - ) - * state->radiances[low_wl]; - - if(interp < 1e-6) - return val_low; - - double result = - (1.0 - interp) - * val_low - + interp - * ArHosekSkyModel_GetRadianceInternal( - state->configs[low_wl+1], - theta, - gamma - ) - * state->radiances[low_wl+1]; - - return result; -} - - -// xyz version - -ArHosekXYZSkyModelState * arhosek_xyz_skymodelstate_alloc_init( - const double turbidity, - const double albedo, - const double elevation - ) -{ - ArHosekXYZSkyModelState * state = ALLOC(ArHosekXYZSkyModelState); - - for( unsigned int channel = 0; channel < 3; ++channel ) - { - ArHosekSkyModel_CookConfiguration( - datasetsXYZ[channel], - state->configs[channel], - turbidity, - albedo, - elevation - ); - - state->radiances[channel] = - ArHosekSkyModel_CookRadianceConfiguration( - datasetsXYZRad[channel], - turbidity, - albedo, - elevation - ); - } - - return state; -} - -void arhosek_xyz_skymodelstate_free( - ArHosekXYZSkyModelState * state - ) -{ - free(state); -} - -double arhosek_xyz_skymodel_radiance( - ArHosekXYZSkyModelState * state, - double theta, - double gamma, - int channel - ) -{ - return - ArHosekSkyModel_GetRadianceInternal( - state->configs[channel], - theta, - gamma - ) - * state->radiances[channel]; -} diff --git a/extern/skylight/ArHosekSkyModel.h b/extern/skylight/ArHosekSkyModel.h deleted file mode 100644 index 5848288a..00000000 --- a/extern/skylight/ArHosekSkyModel.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -This source is published under the following 3-clause BSD license. - -Copyright (c) 2012, Lukas Hosek and Alexander Wilkie -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * None of the names of the contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDERS 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. -*/ - - -/* ============================================================================ - -This file is part of a sample implementation of the analytical skylight model -presented in the SIGGRAPH 2012 paper - - - "An Analytic Model for Full Spectral Sky-Dome Radiance" - - by - - Lukas Hosek and Alexander Wilkie - Charles University in Prague, Czech Republic - - - Version: 1.0, May 11th, 2012 - - -Please visit http://cgg.mff.cuni.cz/projects/SkylightModelling/ to check if -an updated version of this code has been published! - -============================================================================ */ - - -/* - -This code is taken from ART, a rendering research system written in a -mix of C99 / Objective C. Since ART is not a small system and is intended to -be inter-operable with other libraries, and since C does not have namespaces, -the structures and functions in ART all have to have the somewhat wordy -canonical names that begin with Ar.../ar..., like those seen in this example. - -Usage information: -================== - - -Model initialisation --------------------- - -A separate ArHosekSkyModelState has to be maintained for each spectral -band you want to use the model for. So in a renderer with num_channels -bands, you would need something like - - ArHosekSkyModelState * skymodel_state[num_channels]; - -You then have to allocate these states. In the following code snippet, we -assume that "albedo" is defined as - - double albedo[num_channels]; - -with a ground albedo value between [0,1] for each channel. The solar elevation -is given in radians. - - for ( unsigned int i = 0; i < num_channels; i++ ) - skymodel_state[i] = - arhosekskymodelstate_alloc_init( - turbidity, - albedo[i], - solarElevation - ); - - -Using the model to generate skydome samples -------------------------------------------- - -Generating a skydome radiance spectrum "skydome_result" for a given location -on the skydome determined via the angles theta and gamma works as follows: - - double skydome_result[num_channels]; - - for ( unsigned int i = 0; i < num_channels; i++ ) - skydome_result[i] = - arhosekskymodel_radiance( - skymodel_state[i], - theta, - gamma, - channel_center[i] - ); - -The variable "channel_center" is assumed to hold the channel center wavelengths -for each of the num_channels samples of the spectrum we are building. - - -Cleanup after use ------------------ - -After rendering is complete, the content of the sky model states should be -disposed of via - - for ( unsigned int i = 0; i < num_channels; i++ ) - arhosekskymodelstate_free( skymodel_state[i] ); - - -CIE XYZ Version of the Model ----------------------------- - -Usage of the CIE XYZ version of the model is exactly the same, except that -num_channels is of course always 3, and that ArHosekXYZSkyModelState and -arhosek_xyz_skymodel_radiance() have to be used instead of their spectral -counterparts. - -*/ - -typedef double ArHosekSkyModelConfiguration[9]; - - -// Spectral version of the model - - -typedef struct ArHosekSkyModelState -{ - ArHosekSkyModelConfiguration configs[11]; - double radiances[11]; -} -ArHosekSkyModelState; - -ArHosekSkyModelState * arhosekskymodelstate_alloc_init( - const double turbidity, - const double albedo, - const double elevation - ); - -void arhosekskymodelstate_free( - ArHosekSkyModelState * state - ); - -double arhosekskymodel_radiance( - ArHosekSkyModelState * state, - double theta, - double gamma, - double wavelength - ); - - -// CIE XYZ version - - -typedef struct ArHosekXYZSkyModelState -{ - ArHosekSkyModelConfiguration configs[3]; - double radiances[3]; -} -ArHosekXYZSkyModelState; - -ArHosekXYZSkyModelState * arhosek_xyz_skymodelstate_alloc_init( - const double turbidity, - const double albedo, - const double elevation - ); - -void arhosek_xyz_skymodelstate_free( - ArHosekXYZSkyModelState * state - ); - -double arhosek_xyz_skymodel_radiance( - ArHosekXYZSkyModelState * state, - double theta, - double gamma, - int channel - ); \ No newline at end of file diff --git a/extern/skylight/ArHosekSkyModelData.h b/extern/skylight/ArHosekSkyModelData.h deleted file mode 100644 index 75d4abb8..00000000 --- a/extern/skylight/ArHosekSkyModelData.h +++ /dev/null @@ -1,17579 +0,0 @@ -/* -This source is published under the following 3-clause BSD license. - -Copyright (c) 2012, Lukas Hosek and Alexander Wilkie -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * 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. - * None of the names of the contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDERS 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. -*/ - - -/* ============================================================================ - -This file is part of a sample implementation of the analytical skylight model -presented in the SIGGRAPH 2012 paper - - - "An Analytic Model for Full Spectral Sky-Dome Radiance" - - by - - Lukas Hosek and Alexander Wilkie - Charles University in Prague, Czech Republic - - - Version: 1.0, May 11th, 2012 - - -Please visit http://cgg.mff.cuni.cz/projects/SkylightModelling/ to check if -an updated version of this code has been published! - -============================================================================ */ - - -/* - -This file contains the coefficient data for both the spectral and the colour -space version of the model. - -*/ - -double dataset320[] = -{ - // albedo 0, turbidity 1 - -1.341049e+001, - -3.742293e+000, - -5.229614e+000, - 5.307180e+000, - -2.182658e-002, - 1.497676e-001, - -8.561730e-006, - 1.733480e+000, - 8.826913e-001, - -1.426825e+001, - -3.550926e+000, - 5.719350e-002, - 3.165753e-001, - -5.870693e-002, - 1.333896e-001, - 1.779338e-005, - 1.504276e+000, - 9.750357e-001, - -2.239068e+000, - -4.290407e+000, - -7.494879e-001, - 2.864989e-001, - -6.017855e-002, - 1.325901e-001, - -1.661674e-004, - 1.732120e+000, - 6.513374e-001, - -1.336194e+000, - -2.467808e-001, - 3.961139e-001, - -6.723820e-002, - -1.817268e-001, - 1.017581e-002, - 6.096079e-004, - 1.986859e+000, - 1.415296e+000, - -1.554271e+000, - -1.811527e+000, - 7.309756e-001, - 1.766793e-003, - 5.779090e-001, - 6.186216e-001, - -1.755338e-003, - -2.701090e-002, - 2.699530e-001, - -8.449639e-001, - -5.665198e-001, - 5.525823e-001, - -2.838870e-003, - -4.555228e+000, - 2.824945e-001, - 4.002014e-003, - 1.114208e+000, - 6.637074e-001, - // albedo 0, turbidity 2 - -1.298333e+001, - -3.775577e+000, - -5.173531e+000, - 5.316518e+000, - -2.572615e-002, - 1.516601e-001, - -8.297168e-006, - 1.669649e+000, - 9.000495e-001, - -1.402639e+001, - -3.787558e+000, - 7.611941e-002, - 2.521881e-001, - -5.859973e-002, - 1.753711e-001, - 4.670097e-005, - 1.459275e+000, - 8.998629e-001, - -2.190256e+000, - -3.575495e+000, - -4.930996e-001, - 4.826321e-002, - -6.797145e-002, - 3.425922e-002, - -3.512550e-004, - 1.978419e+000, - 8.866517e-001, - -2.415991e+000, - -1.453294e+000, - 2.170671e-001, - 1.341284e-001, - -1.926330e-001, - 1.059103e-001, - 1.360739e-003, - 1.587725e+000, - 9.821154e-001, - -5.254592e-001, - -8.181026e-001, - 7.535702e-001, - -3.323364e-002, - 4.503149e-001, - 5.778285e-001, - -4.089673e-003, - 3.335089e-001, - 6.827164e-001, - -1.280108e+000, - -1.013716e+000, - 5.577676e-001, - 9.539205e-004, - -4.934956e+000, - 2.642883e-001, - 1.005169e-002, - 9.265844e-001, - 4.999698e-001, - // albedo 0, turbidity 3 - -1.292247e+001, - -3.819777e+000, - -4.478733e+000, - 4.582924e+000, - -2.364370e-002, - 1.619828e-001, - -3.053548e-006, - 1.646629e+000, - 5.103371e-001, - -1.433099e+001, - -3.766213e+000, - 4.930150e-001, - -3.081235e-002, - -6.522199e-002, - 1.564198e-001, - 3.455657e-004, - 1.428507e+000, - 4.312273e-001, - -2.539220e+000, - -3.459074e+000, - -3.774393e-001, - -3.628419e-001, - -2.124451e-001, - -1.358132e-002, - -1.812805e-003, - 2.245152e+000, - 7.247429e-001, - -2.393246e+000, - -1.937898e+000, - 1.005834e-001, - 5.867890e-001, - 2.645044e-001, - 1.413695e-001, - 6.378716e-003, - 1.140715e+000, - 1.263014e+000, - -1.185583e-001, - -1.960943e-001, - 7.212723e-001, - -1.763978e-001, - -1.000190e+000, - 6.259726e-001, - -1.783726e-002, - 7.790644e-001, - 3.244710e-001, - -1.550325e+000, - -1.333575e+000, - 5.618137e-001, - 2.563595e-002, - -5.007716e+000, - 6.522985e-002, - 4.262830e-002, - 7.371930e-001, - 5.239972e-001, - // albedo 0, turbidity 4 - -1.234358e+001, - -3.851875e+000, - -3.911206e+000, - 4.011324e+000, - -2.734425e-002, - 1.272306e-001, - -7.628210e-006, - 1.661843e+000, - 8.993903e-001, - -1.349727e+001, - -3.592681e+000, - 1.335192e+000, - -9.426446e-001, - -5.741127e-002, - 9.765267e-002, - 5.518099e-005, - 1.428554e+000, - -4.278471e-001, - -3.399618e+000, - -3.818725e+000, - -8.698171e-001, - 2.723930e-001, - -3.644369e-001, - 1.238759e-001, - -5.189179e-004, - 2.279175e+000, - 1.841076e+000, - -1.925152e+000, - -1.539333e+000, - 2.757771e-001, - -6.435980e-002, - 6.466700e-001, - 3.084382e-002, - 3.114730e-003, - 1.259818e+000, - 5.121617e-001, - -5.706832e-001, - -6.696186e-001, - 6.798158e-001, - 6.920162e-001, - -3.898854e+000, - 5.954021e-001, - -1.196667e-002, - 5.714991e-001, - 6.528481e-001, - -1.371907e+000, - -1.142330e+000, - 5.207805e-001, - -4.480298e-003, - -5.008950e+000, - 1.251549e-001, - 3.531514e-002, - 8.776759e-001, - 4.999465e-001, - // albedo 0, turbidity 5 - -1.459738e+001, - -3.833562e+000, - -4.148717e+000, - 4.203270e+000, - -2.484405e-002, - 1.189704e-001, - 4.166397e-004, - 1.748850e+000, - 4.999721e-001, - -1.223022e+001, - -3.942049e+000, - 1.183072e+000, - -9.018678e-001, - -4.644071e-002, - 1.237476e-001, - -2.359994e-003, - 1.471013e+000, - 5.298845e-001, - -4.078262e+000, - -3.261096e+000, - -5.520001e-001, - 2.174261e-001, - -3.582576e-001, - 2.000597e-002, - 9.890182e-003, - 2.199274e+000, - 2.756320e-001, - -2.499065e+000, - -2.408391e+000, - 3.391663e-002, - -6.167543e-002, - 7.555424e-001, - 2.349252e-001, - -2.443140e-002, - 1.328540e+000, - 1.348906e+000, - 5.456648e-002, - -9.221401e-002, - 7.403428e-001, - 5.565324e-001, - -5.134970e+000, - 3.021763e-001, - 3.638500e-002, - 5.560149e-001, - 1.818210e-001, - -1.590269e+000, - -1.344330e+000, - 4.805789e-001, - 5.038509e-001, - -3.370644e+000, - 3.040357e-001, - 2.418483e-003, - 8.979818e-001, - 7.477974e-001, - // albedo 0, turbidity 6 - -6.775680e+000, - -3.436745e+000, - -2.696730e+000, - 2.740681e+000, - -4.032382e-002, - 1.036486e-001, - 8.133034e-005, - 1.767160e+000, - 5.401354e-001, - -7.800595e+000, - -2.867058e+000, - 1.478909e+000, - -1.380160e+000, - -1.658909e-001, - 1.962673e-001, - -6.512798e-004, - 1.634359e+000, - 4.300704e-001, - -4.392403e+000, - -3.857979e+000, - -1.022020e+000, - 1.449394e+000, - 2.769695e-001, - -3.331834e-001, - 3.513950e-003, - 1.942113e+000, - 3.970742e-001, - -2.469701e+000, - -1.357319e+000, - 2.132600e-001, - -1.918729e+000, - -4.193060e+000, - 8.101579e-001, - -9.605279e-003, - 1.844443e+000, - 1.582310e+000, - -7.759612e-001, - -1.298076e+000, - 7.162377e-001, - 2.906682e+000, - -8.261148e-001, - -2.892123e-001, - 1.491449e-002, - 6.529387e-002, - -4.180287e-002, - -9.962340e-001, - -6.488730e-001, - 3.933344e-001, - -4.752111e-003, - -4.721793e+000, - 6.053196e-001, - 3.453563e-003, - 1.247655e+000, - 8.673379e-001, - // albedo 0, turbidity 7 - -7.552689e+000, - -3.219112e+000, - -2.730242e+000, - 2.755929e+000, - -3.925138e-002, - 8.394617e-002, - 1.514980e-004, - 1.844410e+000, - 5.389194e-001, - -8.494732e+000, - -3.138528e+000, - 1.424739e+000, - -1.269326e+000, - -1.561580e-001, - 1.767060e-001, - -1.175921e-003, - 1.659123e+000, - 3.746132e-001, - -4.672972e+000, - -4.049529e+000, - -1.027600e+000, - 1.072252e+000, - 7.908165e-002, - -2.243835e-001, - 6.190595e-003, - 1.988822e+000, - 6.684758e-001, - -2.256117e+000, - -1.258356e+000, - 2.198377e-001, - -1.296239e+000, - -3.200970e+000, - 6.407291e-001, - -1.527762e-002, - 1.735209e+000, - 1.170530e+000, - -7.790059e-001, - -1.269213e+000, - 6.315194e-001, - 2.368850e+000, - -1.199163e+000, - -1.504024e-001, - 1.733299e-002, - 2.544016e-001, - 2.756763e-001, - -1.046916e+000, - -6.991719e-001, - 3.620624e-001, - 7.364236e-002, - -5.012491e+000, - 4.240417e-001, - 3.580425e-002, - 1.202329e+000, - 6.255804e-001, - // albedo 0, turbidity 8 - -1.886851e+001, - -4.491136e+000, - -3.660440e+000, - 3.704226e+000, - -3.158478e-002, - 1.229909e-001, - 9.233613e-004, - 1.745459e+000, - 5.011929e-001, - -1.986322e+001, - -3.528401e+000, - 1.401749e+000, - -1.191377e+000, - -7.474944e-002, - -2.193835e-002, - -5.138968e-003, - 1.710181e+000, - 5.473672e-001, - 5.355660e-001, - -5.459304e+000, - -8.809226e-001, - 5.959028e-001, - -3.311339e-001, - 3.876731e-001, - 2.126070e-002, - 1.929868e+000, - 1.883429e-001, - -3.136053e+000, - -2.856938e-001, - 1.048390e-001, - -7.708877e-001, - 2.106630e-001, - -1.488471e-001, - -5.172733e-002, - 1.769302e+000, - 1.526253e+000, - 1.496752e-001, - -9.170428e-001, - 5.628226e-001, - 1.733601e+000, - -4.784033e+000, - 3.570330e-001, - 7.396580e-002, - 3.954993e-001, - 1.397727e-003, - -1.839740e+000, - -1.279260e+000, - 3.173503e-001, - 1.096266e+000, - -4.168649e+000, - 2.121881e-001, - 2.150917e-002, - 1.151497e+000, - 7.233585e-001, - // albedo 0, turbidity 9 - -1.841090e+001, - -4.803089e+000, - -4.883823e+000, - 4.962235e+000, - -2.693216e-002, - 1.089917e-001, - -6.338015e-006, - 1.725865e+000, - 8.890717e-001, - -1.947081e+001, - -2.961260e+000, - 1.963002e+000, - -1.942423e+000, - -5.550118e-002, - 7.036456e-002, - -5.990592e-004, - 1.807097e+000, - -8.871814e-003, - 9.588307e-001, - -6.379803e+000, - -1.021090e+000, - 9.560589e-001, - -2.175500e-001, - 8.613517e-002, - 1.362268e-002, - 1.953529e+000, - 7.422482e-001, - -3.609766e+000, - -1.823498e-003, - 2.516424e-002, - -8.909855e-001, - 2.207805e-001, - 1.783064e-001, - -4.293958e-002, - 1.607901e+000, - 1.131559e+000, - 6.087707e-001, - -6.744295e-001, - 4.236310e-001, - 1.505925e+000, - -4.197126e+000, - 2.046561e-001, - 6.445824e-002, - 7.793118e-001, - 3.262213e-001, - -2.148492e+000, - -1.597890e+000, - 3.166858e-001, - 2.414329e+000, - -4.201339e+000, - 1.005902e-001, - 4.687865e-002, - 9.335376e-001, - 5.289661e-001, - // albedo 0, turbidity 10 - -1.787767e+001, - -4.873485e+000, - -5.861224e+000, - 5.866336e+000, - -1.564202e-002, - 6.967640e-002, - 7.574926e-004, - 1.768065e+000, - 5.856596e-001, - -1.932995e+001, - -4.092647e+000, - 2.679531e+000, - -2.555671e+000, - -4.181418e-002, - 1.023654e-001, - -5.964172e-003, - 1.625691e+000, - 4.036808e-001, - 1.788482e+000, - -5.652582e+000, - -1.517519e+000, - 1.251535e+000, - -2.225912e-001, - -1.084716e-001, - 3.272584e-002, - 2.139078e+000, - 3.876645e-001, - -3.363801e+000, - -3.266475e-001, - 1.313912e-001, - -6.889075e-001, - 4.356523e-001, - 3.120297e-001, - -8.700131e-002, - 1.750122e+000, - 1.223546e+000, - 4.668756e-004, - -9.612337e-001, - 3.082344e-001, - 1.298938e+000, - -4.371395e+000, - 8.845524e-002, - 1.303481e-001, - 5.843720e-001, - 2.718863e-001, - -1.759172e+000, - -1.386072e+000, - 2.349661e-001, - 1.592185e+000, - -3.063267e+000, - 1.529736e-001, - 3.429185e-002, - 1.030294e+000, - 6.917018e-001, - // albedo 1, turbidity 1 - -1.341051e+001, - -3.742047e+000, - -5.229556e+000, - 5.307222e+000, - -2.094796e-002, - 1.499787e-001, - -7.023116e-006, - 1.732898e+000, - 8.826861e-001, - -1.426829e+001, - -3.550660e+000, - 5.731266e-002, - 3.166575e-001, - -5.821080e-002, - 1.335860e-001, - 2.003178e-004, - 1.503788e+000, - 9.750310e-001, - -2.239143e+000, - -4.290084e+000, - -7.493158e-001, - 2.865753e-001, - -5.993923e-002, - 1.327393e-001, - -5.399344e-004, - 1.731677e+000, - 6.513329e-001, - -1.336350e+000, - -2.463606e-001, - 3.963632e-001, - -6.721398e-002, - -1.816244e-001, - 1.021503e-002, - 8.081470e-004, - 1.986453e+000, - 1.415292e+000, - -1.554584e+000, - -1.810948e+000, - 7.313475e-001, - 1.703307e-003, - 5.779436e-001, - 6.184790e-001, - -6.832621e-004, - -2.739619e-002, - 2.699443e-001, - -8.456234e-001, - -5.656772e-001, - 5.531782e-001, - -2.975361e-003, - -4.555221e+000, - 2.821035e-001, - 4.007713e-004, - 1.113850e+000, - 6.636719e-001, - // albedo 1, turbidity 2 - -1.263311e+001, - -4.099112e+000, - -5.130792e+000, - 5.526406e+000, - -2.122841e-002, - 1.202556e-001, - -8.060670e-006, - 1.209196e+000, - 8.997967e-001, - -1.361400e+001, - -3.538236e+000, - 1.570583e-001, - 3.445259e-001, - -5.306874e-002, - 2.322893e-001, - 1.572516e-005, - 1.152750e+000, - 9.026902e-001, - -1.477014e+000, - -3.664310e+000, - -1.442116e-001, - -4.293554e-002, - -3.768326e-002, - -1.388530e-001, - -1.687893e-004, - 1.592625e+000, - 8.804841e-001, - -2.050884e+000, - -1.470536e+000, - 3.327590e-001, - 1.976143e-001, - -1.930369e-001, - 2.831960e-001, - 6.940849e-004, - 1.271203e+000, - 9.790242e-001, - -3.704793e-001, - -5.829841e-001, - 1.168589e+000, - -1.387973e-001, - 5.998426e-001, - 3.825096e-001, - -2.188637e-003, - -2.273264e-001, - 7.393514e-001, - -9.877542e-001, - -7.646946e-001, - 8.859003e-001, - 5.263145e-002, - -4.849410e+000, - 1.301905e-001, - 5.464872e-003, - 5.270984e-001, - 5.001226e-001, - // albedo 1, turbidity 3 - -1.294452e+001, - -3.858933e+000, - -4.362969e+000, - 4.657159e+000, - -2.281956e-002, - 1.371565e-001, - 3.552610e-006, - 1.354369e+000, - 5.222053e-001, - -1.425646e+001, - -3.745266e+000, - 6.901454e-001, - -5.345642e-002, - -5.238708e-002, - 1.157055e-001, - -1.961110e-005, - 1.030408e+000, - 4.036292e-001, - -2.236186e+000, - -3.560196e+000, - -1.053059e-001, - -3.002269e-001, - -1.702750e-001, - 3.290753e-002, - -7.253274e-005, - 1.846963e+000, - 6.828000e-001, - -1.991088e+000, - -2.028027e+000, - 2.747056e-001, - 5.076456e-001, - 2.056096e-001, - 1.537040e-001, - 1.010611e-003, - 8.439763e-001, - 1.286657e+000, - -2.733597e-001, - -1.938590e-001, - 1.108079e+000, - -1.668080e-001, - -8.136300e-001, - 3.962292e-001, - -4.757393e-003, - 1.536882e-001, - 4.595467e-001, - -9.782447e-001, - -8.452104e-001, - 9.149995e-001, - 2.750126e-002, - -4.996263e+000, - 1.226836e-001, - 1.533731e-002, - 3.686265e-001, - 5.004484e-001, - // albedo 1, turbidity 4 - -1.234416e+001, - -3.818503e+000, - -3.804408e+000, - 4.093838e+000, - -2.505623e-002, - 1.149315e-001, - -7.610563e-006, - 1.361584e+000, - 8.981571e-001, - -1.349621e+001, - -3.551853e+000, - 1.469377e+000, - -8.971164e-001, - -5.623731e-002, - 1.078524e-001, - 1.491378e-003, - 1.113040e+000, - -4.279059e-001, - -3.391950e+000, - -3.791028e+000, - -6.935352e-001, - 2.998175e-001, - -3.155309e-001, - 1.196041e-001, - -4.708048e-003, - 2.001973e+000, - 1.840166e+000, - -1.915114e+000, - -1.493080e+000, - 4.567342e-001, - -7.334296e-002, - 6.767060e-001, - -4.562689e-003, - 1.016838e-002, - 1.003272e+000, - 5.102018e-001, - -5.674128e-001, - -5.568719e-001, - 9.084369e-001, - 6.684870e-001, - -3.892720e+000, - 5.312866e-001, - -1.768715e-002, - 3.252051e-001, - 6.541029e-001, - -1.343751e+000, - -9.647458e-001, - 7.945561e-001, - 5.127485e-004, - -5.009873e+000, - 6.165389e-002, - 2.642926e-002, - 6.213595e-001, - 5.327376e-001, - // albedo 1, turbidity 5 - -1.450562e+001, - -4.021778e+000, - -4.181517e+000, - 4.509518e+000, - -2.369519e-002, - 6.955582e-002, - 1.149882e-004, - 1.329583e+000, - 5.260857e-001, - -1.297772e+001, - -3.655039e+000, - 2.030636e+000, - -1.537436e+000, - -4.915490e-002, - 1.511047e-001, - -9.053517e-004, - 1.156980e+000, - 4.831690e-001, - -1.991837e+000, - -3.919397e+000, - -8.466357e-001, - 5.319508e-001, - -3.165811e-001, - 1.056172e-001, - 4.836036e-003, - 1.843574e+000, - 3.084513e-001, - -2.052725e+000, - -1.606839e+000, - 5.876624e-001, - -7.464148e-002, - 7.525473e-001, - 1.590947e-003, - -1.261084e-002, - 8.587516e-001, - 1.404076e+000, - -3.737447e-001, - -4.061843e-001, - 8.985804e-001, - 5.700187e-001, - -5.422882e+000, - 4.334301e-001, - 1.759754e-002, - 2.613056e-001, - 2.062463e-001, - -1.002263e+000, - -1.006484e+000, - 9.629219e-001, - 8.528366e-002, - -4.220831e+000, - 7.848806e-002, - 1.254937e-002, - 2.140208e-001, - 6.187813e-001, - // albedo 1, turbidity 6 - -7.175451e+000, - -3.313094e+000, - -2.396914e+000, - 2.657177e+000, - -3.936959e-002, - 1.123476e-001, - 7.315860e-005, - 1.431209e+000, - 5.107145e-001, - -8.058121e+000, - -3.119458e+000, - 1.729776e+000, - -1.435370e+000, - -1.414745e-001, - 2.338787e-001, - -5.865288e-004, - 1.247225e+000, - 5.037743e-001, - -4.387785e+000, - -3.851081e+000, - -7.774273e-001, - 1.405520e+000, - 1.743075e-001, - -4.108912e-001, - 3.058571e-003, - 1.519803e+000, - 2.636805e-001, - -1.807473e+000, - -1.498491e+000, - 3.237723e-001, - -1.626737e+000, - -3.741656e+000, - 8.444519e-001, - -8.297013e-003, - 1.624861e+000, - 1.753817e+000, - -6.242455e-001, - -1.063850e+000, - 1.166897e+000, - 2.283807e+000, - -1.150947e+000, - -3.242997e-001, - 1.279340e-002, - -5.448139e-001, - -8.653106e-002, - -8.143405e-001, - -5.251732e-001, - 7.822692e-001, - -3.764280e-003, - -5.011112e+000, - 3.985065e-001, - 3.652394e-003, - 7.140115e-001, - 7.004910e-001, - // albedo 1, turbidity 7 - -7.579673e+000, - -3.495594e+000, - -2.498830e+000, - 2.771470e+000, - -3.451351e-002, - 8.186886e-002, - 1.272079e-004, - 1.390420e+000, - 5.545117e-001, - -8.524117e+000, - -3.121778e+000, - 1.680395e+000, - -1.329455e+000, - -1.395912e-001, - 1.911589e-001, - -1.027988e-003, - 1.259267e+000, - 3.356989e-001, - -4.579718e+000, - -4.086739e+000, - -8.030175e-001, - 1.103390e+000, - 1.429699e-001, - -2.211841e-001, - 5.620349e-003, - 1.693702e+000, - 7.084432e-001, - -1.946704e+000, - -1.512415e+000, - 3.559506e-001, - -1.318829e+000, - -3.063409e+000, - 6.250046e-001, - -1.490672e-002, - 1.414520e+000, - 1.317647e+000, - -7.123367e-001, - -1.133848e+000, - 1.064800e+000, - 2.217543e+000, - -1.247373e+000, - -2.105594e-001, - 2.261048e-002, - -3.648618e-001, - 1.147223e-001, - -7.979833e-001, - -5.546030e-001, - 7.765850e-001, - -4.676928e-003, - -5.014372e+000, - 3.694816e-001, - 2.373221e-003, - 6.783145e-001, - 7.862971e-001, - // albedo 1, turbidity 8 - -1.886599e+001, - -4.523457e+000, - -3.559445e+000, - 3.748747e+000, - -2.082711e-002, - 1.120505e-001, - 4.908827e-005, - 1.430333e+000, - 4.999603e-001, - -1.985552e+001, - -3.530040e+000, - 1.578922e+000, - -1.170838e+000, - -6.347814e-002, - 2.032158e-003, - -7.291357e-004, - 1.399338e+000, - 5.515394e-001, - 5.631541e-001, - -5.483754e+000, - -6.832337e-001, - 6.170499e-001, - -2.824393e-001, - 3.546810e-001, - 6.248420e-003, - 1.638520e+000, - 2.300717e-001, - -3.083195e+000, - -3.071409e-001, - 2.822360e-001, - -7.871125e-001, - 2.420642e-001, - -1.716096e-001, - -1.936307e-002, - 1.450902e+000, - 1.590291e+000, - 2.003824e-001, - -8.374106e-001, - 8.800366e-001, - 1.702679e+000, - -4.785357e+000, - 3.194078e-001, - 3.028099e-002, - 6.649245e-002, - -4.459174e-003, - -1.738851e+000, - -1.144728e+000, - 6.950894e-001, - 1.073870e+000, - -4.176611e+000, - 9.901497e-002, - 2.719362e-002, - 6.579628e-001, - 6.542088e-001, - // albedo 1, turbidity 9 - -1.842858e+001, - -4.464894e+000, - -4.876181e+000, - 4.999894e+000, - -1.680473e-002, - 9.284371e-002, - 8.631599e-005, - 1.551671e+000, - 8.637202e-001, - -1.946220e+001, - -2.928492e+000, - 1.932796e+000, - -2.009963e+000, - -2.067172e-002, - 2.760643e-001, - -1.316034e-003, - 1.910005e+000, - -2.057018e-002, - 1.012726e+000, - -6.397245e+000, - -8.570688e-001, - 9.466942e-001, - -2.428074e-001, - 4.505376e-002, - 1.159119e-002, - 1.686356e+000, - 7.885028e-001, - -3.502022e+000, - -9.795202e-002, - 3.286657e-001, - -8.318684e-001, - 1.254695e-001, - 9.600123e-002, - -3.501772e-002, - 1.161309e+000, - 1.205342e+000, - 7.024550e-001, - -6.903001e-001, - 7.519618e-001, - 1.501909e+000, - -4.224528e+000, - 1.253867e-001, - 5.829515e-002, - 2.671626e-001, - 3.030079e-001, - -2.056576e+000, - -1.583471e+000, - 7.947031e-001, - 2.224097e+000, - -4.127138e+000, - 1.885249e-001, - 1.729132e-005, - 3.336881e-001, - 5.332061e-001, - // albedo 1, turbidity 10 - -1.825745e+001, - -5.122861e+000, - -5.876715e+000, - 5.970876e+000, - -1.788919e-002, - 1.063934e-001, - 4.770037e-004, - 1.612403e+000, - 5.156506e-001, - -1.981828e+001, - -3.746331e+000, - 2.729783e+000, - -2.477317e+000, - -2.797536e-002, - -5.281985e-002, - -3.739083e-003, - 1.378246e+000, - 5.904024e-001, - 1.346751e+000, - -6.486837e+000, - -1.082622e+000, - 1.125524e+000, - -2.228944e-001, - 3.975587e-001, - 2.035973e-002, - 1.884664e+000, - 1.086023e-003, - -3.996320e+000, - -4.646476e-001, - 3.008639e-002, - -1.193861e+000, - 4.443960e-001, - -2.593178e-001, - -5.378377e-002, - 1.528777e+000, - 1.734923e+000, - 4.789259e-001, - -8.952042e-001, - 8.595191e-001, - 2.353988e+000, - -4.885398e+000, - 4.438339e-001, - 7.931163e-002, - -8.144393e-002, - 1.663921e-002, - -1.772626e+000, - -1.783205e+000, - 7.322534e-001, - 1.529827e+000, - -2.789303e+000, - -1.817210e-001, - 2.737502e-002, - 2.620216e-001, - 6.227585e-001, -}; - -double datasetRad320[] = -{ - // albedo 0, turbidity 1 - 7.512813e-003, - 2.565179e-003, - 4.253480e-002, - -1.185924e-001, - 5.817257e-001, - 4.371426e-001, - // albedo 0, turbidity 2 - 7.414562e-003, - 2.104390e-003, - 4.424958e-002, - -1.216955e-001, - 5.827775e-001, - 4.360785e-001, - // albedo 0, turbidity 3 - 7.404947e-003, - 1.752151e-003, - 4.513723e-002, - -1.244245e-001, - 5.840274e-001, - 4.355152e-001, - // albedo 0, turbidity 4 - 7.357950e-003, - 1.188061e-003, - 4.674957e-002, - -1.293810e-001, - 5.870157e-001, - 4.313968e-001, - // albedo 0, turbidity 5 - 7.205901e-003, - 9.118062e-004, - 4.812589e-002, - -1.334022e-001, - 5.844004e-001, - 4.363489e-001, - // albedo 0, turbidity 6 - 7.191812e-003, - 9.246117e-004, - 4.806915e-002, - -1.350718e-001, - 5.853059e-001, - 4.315313e-001, - // albedo 0, turbidity 7 - 7.021308e-003, - 2.838239e-004, - 4.998992e-002, - -1.401900e-001, - 5.846638e-001, - 4.304544e-001, - // albedo 0, turbidity 8 - 6.900165e-003, - -1.418081e-004, - 5.088191e-002, - -1.440144e-001, - 5.787350e-001, - 4.317369e-001, - // albedo 0, turbidity 9 - 6.663463e-003, - -1.045860e-003, - 5.378644e-002, - -1.526976e-001, - 5.708638e-001, - 4.315470e-001, - // albedo 0, turbidity 10 - 6.208056e-003, - -1.526509e-003, - 5.248712e-002, - -1.499028e-001, - 5.350711e-001, - 4.438774e-001, - // albedo 1, turbidity 1 - 8.947091e-003, - 2.068795e-004, - 6.462783e-002, - -1.742158e-001, - 6.841679e-001, - 7.788551e-001, - // albedo 1, turbidity 2 - 8.995830e-003, - -4.893647e-004, - 6.503652e-002, - -1.727869e-001, - 6.769531e-001, - 7.804054e-001, - // albedo 1, turbidity 3 - 8.932087e-003, - -6.660637e-004, - 6.613318e-002, - -1.772526e-001, - 6.802856e-001, - 7.693223e-001, - // albedo 1, turbidity 4 - 8.702033e-003, - -1.193023e-003, - 6.791705e-002, - -1.825574e-001, - 6.811457e-001, - 7.558930e-001, - // albedo 1, turbidity 5 - 8.389107e-003, - -1.075678e-003, - 6.757016e-002, - -1.826106e-001, - 6.721755e-001, - 7.497970e-001, - // albedo 1, turbidity 6 - 8.436987e-003, - -1.632254e-003, - 6.863361e-002, - -1.858794e-001, - 6.721006e-001, - 7.351320e-001, - // albedo 1, turbidity 7 - 8.209635e-003, - -1.906874e-003, - 6.921140e-002, - -1.888528e-001, - 6.684109e-001, - 7.182233e-001, - // albedo 1, turbidity 8 - 7.837639e-003, - -1.716124e-003, - 6.614409e-002, - -1.800071e-001, - 6.355591e-001, - 7.174486e-001, - // albedo 1, turbidity 9 - 7.397518e-003, - -2.176193e-003, - 6.530836e-002, - -1.800409e-001, - 6.143563e-001, - 6.851424e-001, - // albedo 1, turbidity 10 - 6.845741e-003, - -2.800399e-003, - 6.173213e-002, - -1.673516e-001, - 5.537362e-001, - 6.672731e-001, -}; - -double dataset360[] = -{ - // albedo 0, turbidity 1 - -2.974290e+000, - -1.670904e+000, - -5.183199e+000, - 5.377376e+000, - -2.904124e-002, - 2.486720e-001, - 8.045624e-005, - 1.889212e+000, - 5.188203e-001, - -2.638402e+000, - -1.651876e+000, - -1.229939e+000, - 1.776358e+000, - -6.372414e-002, - 3.767834e-001, - -6.475530e-004, - 1.373589e+000, - 4.349252e-001, - -2.449142e+000, - -1.541788e+000, - 4.629358e-001, - -1.149742e+000, - -7.317185e-002, - -2.422158e-001, - 3.667113e-003, - 3.146429e+000, - 6.725657e-001, - -8.559357e-001, - -5.054959e-001, - 4.334205e-001, - 4.254155e-001, - -2.920605e-001, - 9.303230e-001, - -1.212609e-002, - 4.498482e-001, - 2.117838e-001, - -1.098145e+000, - -5.123514e-001, - 7.773196e-001, - -1.325175e-001, - 4.648396e-001, - 1.386648e-001, - 2.427679e-002, - 1.199386e+000, - 7.988611e-001, - -1.124849e+000, - -5.693597e-001, - 7.315125e-001, - 2.986435e-002, - -4.536788e+000, - 6.650081e-001, - -9.004215e-007, - 1.006380e+000, - 4.999682e-001, - // albedo 0, turbidity 2 - -2.709497e+000, - -1.635812e+000, - -4.594177e+000, - 4.809336e+000, - -3.672907e-002, - 2.383111e-001, - 3.241989e-005, - 1.885505e+000, - 6.619619e-001, - -2.590279e+000, - -1.525236e+000, - -6.846073e-001, - 1.216080e+000, - -8.022814e-002, - 3.040074e-001, - -4.984576e-004, - 1.521429e+000, - 1.746040e-001, - -2.988403e+000, - -1.938687e+000, - 4.954649e-002, - -8.992325e-001, - -7.157111e-002, - -4.370068e-002, - 4.336645e-003, - 2.849496e+000, - 8.892788e-001, - -2.932084e-001, - -1.323910e-001, - 5.535910e-001, - 7.456284e-001, - -2.713400e-001, - 6.989175e-001, - -1.513162e-002, - 6.926848e-001, - 5.719944e-001, - -1.379400e+000, - -6.876864e-001, - 7.224534e-001, - -6.172704e-001, - 1.217500e-001, - 3.074795e-001, - 2.905167e-002, - 1.123563e+000, - 6.837510e-001, - -1.042446e+000, - -5.201193e-001, - 7.107656e-001, - 4.182566e-001, - -4.956238e+000, - 5.315425e-001, - 6.232999e-003, - 1.059015e+000, - 5.116427e-001, - // albedo 0, turbidity 3 - -2.686687e+000, - -1.615137e+000, - -3.811956e+000, - 4.018597e+000, - -3.953418e-002, - 2.171778e-001, - -7.374887e-006, - 1.875745e+000, - 8.996180e-001, - -3.049670e+000, - -1.775802e+000, - 2.577719e-002, - 5.331200e-001, - -9.424429e-002, - 3.852753e-001, - -8.678326e-005, - 1.347053e+000, - -1.078327e-001, - -2.414334e+000, - -1.637863e+000, - -3.948523e-001, - -4.867989e-001, - -1.545516e-001, - -2.045592e-001, - 2.308206e-003, - 3.257409e+000, - 1.029606e+000, - -6.821703e-001, - -3.665215e-001, - 7.496076e-001, - 5.391760e-001, - -2.903450e-001, - 8.498544e-001, - -1.388990e-002, - 2.126622e-001, - 6.857005e-001, - -1.227285e+000, - -5.958479e-001, - 5.828611e-001, - -4.050489e-001, - -2.935835e-001, - 1.410603e-001, - 4.352812e-002, - 1.406076e+000, - 4.955059e-001, - -1.080553e+000, - -5.308084e-001, - 6.980027e-001, - 2.193524e-001, - -5.007206e+000, - 5.895807e-001, - 1.122391e-002, - 1.052433e+000, - 6.643198e-001, - // albedo 0, turbidity 4 - -2.983088e+000, - -1.746025e+000, - -4.564198e+000, - 4.776145e+000, - -3.208607e-002, - 2.008358e-001, - -6.578048e-006, - 1.829880e+000, - 9.001069e-001, - -2.858023e+000, - -1.624623e+000, - 1.859497e+000, - -1.348577e+000, - -7.427284e-002, - 2.943068e-001, - -1.961205e-004, - 1.502334e+000, - -3.183648e-001, - -2.858102e+000, - -2.072804e+000, - -1.205584e+000, - 5.674135e-001, - -3.934144e-001, - -3.736288e-002, - 4.780332e-003, - 2.831298e+000, - 1.553942e+000, - -3.305766e-001, - -8.277591e-003, - 8.561917e-001, - -2.239172e-001, - 5.896697e-001, - 6.229823e-001, - -2.242577e-002, - 7.216263e-001, - 4.295956e-001, - -1.322728e+000, - -7.101315e-001, - 5.645563e-001, - 9.897384e-001, - -6.756374e+000, - 2.491515e-001, - 5.308124e-002, - 1.166258e+000, - 5.472501e-001, - -1.117086e+000, - -5.760006e-001, - 6.388217e-001, - 1.659290e-001, - -4.687099e+000, - 4.544540e-001, - 2.672063e-002, - 1.067777e+000, - 6.419825e-001, - // albedo 0, turbidity 5 - -2.943340e+000, - -1.779161e+000, - -3.715839e+000, - 3.949049e+000, - -4.499824e-002, - 2.234466e-001, - -8.091518e-006, - 1.825217e+000, - 9.000118e-001, - -3.717358e+000, - -1.850324e+000, - 2.277659e+000, - -2.027790e+000, - -1.240730e-001, - 3.029522e-001, - -2.176255e-004, - 1.585933e+000, - -2.794001e-001, - -2.439542e+000, - -2.277701e+000, - -1.702329e+000, - 2.025885e+000, - -1.142291e-001, - -2.011641e-001, - 5.563891e-003, - 2.424957e+000, - 1.399542e+000, - -1.562453e-001, - 5.099893e-001, - 1.026847e+000, - -2.516874e+000, - -2.212969e+000, - 9.252660e-001, - -2.696795e-002, - 1.443711e+000, - 7.450372e-001, - -1.579698e+000, - -1.110703e+000, - 4.743061e-001, - 4.160187e+000, - -4.597085e+000, - -2.112156e-001, - 6.791770e-002, - 6.131169e-001, - 2.291635e-001, - -9.959610e-001, - -4.119588e-001, - 5.707529e-001, - -3.505536e-003, - -4.253949e+000, - 7.498003e-001, - 8.246945e-003, - 1.397857e+000, - 8.021253e-001, - // albedo 0, turbidity 6 - -2.304734e+000, - -1.483605e+000, - -1.531059e+000, - 1.707306e+000, - -1.150367e-001, - 2.153063e-001, - -3.351533e-006, - 2.021261e+000, - 5.742842e-001, - -3.130477e+000, - -1.966839e+000, - 6.058600e-001, - -9.209976e-001, - -1.932901e-001, - 3.242645e-001, - 3.361262e-002, - 1.529938e+000, - 2.851152e-001, - -1.110129e+000, - -1.306323e+000, - -3.235833e-001, - 2.998748e+000, - -1.535927e-002, - -4.001906e-001, - -9.430492e-002, - 2.211086e+000, - 8.632200e-001, - -1.174540e+000, - 7.550161e-002, - -1.849588e-001, - -6.281432e+000, - -6.186665e+000, - 1.173048e+000, - 1.481656e-001, - 2.668578e+000, - 6.145923e-001, - -1.104583e+000, - -8.430389e-001, - 8.668416e-001, - 9.153752e+000, - -7.289540e-001, - -4.346537e-001, - -9.065784e-002, - 2.866983e-001, - 6.920973e-001, - -1.105893e+000, - -4.500399e-001, - 4.286451e-001, - 1.207864e+000, - -5.018291e+000, - 6.988292e-001, - 3.891745e-002, - 1.602324e+000, - 6.269169e-001, - // albedo 0, turbidity 7 - -3.709341e+000, - -2.038242e+000, - -3.127214e+000, - 3.287030e+000, - -4.565671e-002, - 2.427627e-001, - -7.503980e-006, - 1.817881e+000, - 9.000389e-001, - -3.393374e+000, - -1.710497e+000, - 1.661275e+000, - -1.388896e+000, - -1.012293e-001, - 1.676172e-001, - -5.719846e-004, - 1.694199e+000, - -3.140071e-001, - -2.812820e+000, - -2.678401e+000, - -1.170428e+000, - 1.560988e+000, - -4.488218e-001, - 1.088693e-001, - 1.391966e-002, - 2.144426e+000, - 1.525731e+000, - 2.547360e-001, - 8.840167e-001, - 5.469168e-001, - -2.615530e+000, - -1.048663e+000, - 4.823171e-001, - -5.958515e-002, - 1.842479e+000, - 5.322138e-001, - -1.612173e+000, - -1.055541e+000, - 4.733463e-001, - 5.083504e+000, - -5.558403e+000, - 8.029584e-002, - 1.294180e-001, - 7.807964e-001, - 3.949822e-001, - -1.098367e+000, - -5.550631e-001, - 4.221569e-001, - -1.661587e-003, - -4.970027e+000, - 3.479325e-001, - 4.503648e-002, - 1.369224e+000, - 6.753984e-001, - // albedo 0, turbidity 8 - -4.292777e+000, - -2.231300e+000, - -4.359252e+000, - 4.562131e+000, - -3.759725e-002, - 2.170783e-001, - -6.945269e-006, - 1.791630e+000, - 8.996451e-001, - -4.016595e+000, - -1.761175e+000, - 2.616213e+000, - -2.658657e+000, - -8.209207e-002, - 2.736152e-001, - -6.864170e-004, - 1.820262e+000, - -2.712707e-001, - -2.942646e+000, - -3.350329e+000, - -1.645817e+000, - 2.957424e+000, - -1.073783e-001, - -1.920050e-001, - 1.665992e-002, - 1.723144e+000, - 1.394962e+000, - 9.793627e-001, - 1.743715e+000, - 5.396545e-001, - -4.618273e+000, - -2.186669e+000, - 1.012973e+000, - -7.213786e-002, - 2.388103e+000, - 6.712519e-001, - -2.085434e+000, - -1.445755e+000, - 3.384806e-001, - 7.702938e+000, - -3.897179e+000, - -5.947697e-001, - 1.614194e-001, - 7.854754e-001, - 3.291034e-001, - -9.660466e-001, - -5.247410e-001, - 4.199048e-001, - -3.304707e-003, - -5.014144e+000, - 6.733599e-001, - 2.345161e-002, - 1.225739e+000, - 7.256834e-001, - // albedo 0, turbidity 9 - -3.950771e+000, - -2.192673e+000, - -7.263653e+000, - 7.343312e+000, - -1.840332e-002, - 1.893809e-001, - -3.583629e-006, - 1.901172e+000, - 5.902387e-001, - -6.384690e+000, - -2.515788e+000, - 3.874778e+000, - -3.776079e+000, - -3.484710e-002, - 3.311078e-001, - 8.248395e-003, - 1.612712e+000, - 3.123684e-001, - -6.207616e-001, - -2.681061e+000, - -2.005212e+000, - 2.445498e+000, - -1.935675e-001, - -1.988856e-001, - -1.553754e-002, - 2.210740e+000, - 6.507040e-001, - -1.241493e+000, - 5.908170e-001, - 3.899777e-001, - -2.344038e+000, - -1.820327e-001, - 7.889592e-001, - -1.468064e-002, - 1.586758e+000, - 1.007885e+000, - -4.395130e-001, - -3.700611e-001, - 2.452754e-001, - 3.602006e+000, - -4.692896e+000, - -8.620746e-002, - 1.418548e-001, - 1.521301e+000, - 3.989756e-001, - -1.794977e+000, - -1.190586e+000, - 3.928989e-001, - 1.946953e+000, - -1.874118e+000, - -3.292602e-002, - 2.983309e-002, - 6.737092e-001, - 7.322706e-001, - // albedo 0, turbidity 10 - -8.896186e+000, - -3.278330e+000, - -7.998349e+000, - 8.023312e+000, - -1.357555e-002, - 1.947910e-001, - -5.390226e-006, - 1.798414e+000, - 7.881395e-001, - -8.040403e+000, - -2.528514e+000, - 3.774303e+000, - -3.590457e+000, - -3.551313e-002, - 3.650761e-001, - -4.401382e-004, - 1.701545e+000, - -6.992899e-003, - -4.150010e-001, - -3.539507e+000, - -1.527733e+000, - 1.415242e+000, - -1.831476e-001, - -3.009746e-001, - 1.211955e-002, - 2.365976e+000, - 9.928240e-001, - -2.090923e+000, - 1.673638e-001, - -2.183495e-001, - -8.374584e-001, - 2.774184e-002, - 7.912769e-001, - -6.650609e-002, - 1.154446e+000, - 7.863979e-001, - 5.115239e-001, - 2.415831e-001, - 4.022318e-001, - 2.292950e+000, - -4.061496e+000, - 7.453182e-002, - 1.902451e-001, - 1.587339e+000, - 5.207620e-001, - -2.334879e+000, - -1.642495e+000, - 2.384458e-001, - 3.068363e+000, - -1.699588e+000, - -3.936924e-001, - 3.028660e-002, - 4.715374e-001, - 7.091893e-001, - // albedo 1, turbidity 1 - -2.375941e+000, - -1.508643e+000, - -5.070151e+000, - 5.509378e+000, - -2.915769e-002, - 2.122471e-001, - 8.584007e-005, - 1.517285e+000, - 5.163253e-001, - -2.605398e+000, - -1.589160e+000, - -1.137560e+000, - 1.827729e+000, - -4.939637e-002, - 3.243952e-001, - -6.464612e-004, - 1.008816e+000, - 4.568463e-001, - -2.176260e+000, - -1.601522e+000, - 7.060324e-001, - -1.060717e+000, - -5.144614e-002, - -1.938031e-001, - 3.449257e-003, - 2.641594e+000, - 5.976852e-001, - -7.365744e-001, - -3.720296e-001, - 7.315328e-001, - 3.156067e-001, - -2.739385e-001, - 8.252942e-001, - -1.055013e-002, - 7.327610e-002, - 3.218251e-001, - -1.017537e+000, - -4.631811e-001, - 1.093174e+000, - -7.215941e-002, - 5.408457e-001, - -1.848322e-002, - 1.942990e-002, - 6.882763e-001, - 7.268524e-001, - -1.025215e+000, - -3.712574e-001, - 9.661278e-001, - 7.791398e-003, - -4.508617e+000, - 4.371074e-001, - -1.241898e-006, - 1.152655e+000, - 5.008240e-001, - // albedo 1, turbidity 2 - -2.621793e+000, - -1.611544e+000, - -4.494730e+000, - 4.902741e+000, - -2.935751e-002, - 1.930048e-001, - 1.821579e-005, - 1.522018e+000, - 6.563013e-001, - -2.473330e+000, - -1.495083e+000, - -5.536781e-001, - 1.305457e+000, - -7.261347e-002, - 2.967738e-001, - -2.858526e-004, - 1.132650e+000, - 1.737068e-001, - -2.843519e+000, - -1.913751e+000, - 2.006296e-001, - -8.580922e-001, - -5.273753e-002, - -7.800250e-002, - 2.395781e-003, - 2.505017e+000, - 9.023934e-001, - -1.805184e-001, - -3.670063e-002, - 7.583717e-001, - 7.594739e-001, - -2.092951e-001, - 6.278666e-001, - -8.086828e-003, - 4.136002e-001, - 6.026937e-001, - -1.274753e+000, - -5.831501e-001, - 9.711756e-001, - -6.209175e-001, - 1.488633e-001, - 2.117108e-001, - 1.531499e-002, - 9.306008e-001, - 7.201852e-001, - -9.224434e-001, - -3.344822e-001, - 9.964647e-001, - 3.991735e-001, - -4.951439e+000, - 4.332347e-001, - -1.082832e-005, - 9.570977e-001, - 5.221054e-001, - // albedo 1, turbidity 3 - -2.648100e+000, - -1.587720e+000, - -3.738681e+000, - 4.084015e+000, - -3.301163e-002, - 1.736140e-001, - -5.598265e-006, - 1.628176e+000, - 8.967917e-001, - -3.004556e+000, - -1.702983e+000, - 1.060112e-001, - 5.816666e-001, - -8.140777e-002, - 3.584557e-001, - -7.793874e-005, - 1.090228e+000, - -1.079451e-001, - -2.337937e+000, - -1.584523e+000, - -2.912486e-001, - -4.467895e-001, - -9.195281e-002, - -2.355753e-001, - 1.887118e-003, - 3.053238e+000, - 1.043382e+000, - -5.985994e-001, - -2.846782e-001, - 8.903642e-001, - 5.578845e-001, - -2.510042e-001, - 8.033778e-001, - -9.920460e-003, - 7.388584e-002, - 7.097127e-001, - -1.155357e+000, - -4.638306e-001, - 8.041892e-001, - -4.051351e-001, - -2.819435e-001, - 8.505708e-002, - 2.749222e-002, - 1.334820e+000, - 5.216620e-001, - -1.010658e+000, - -3.816787e-001, - 9.644918e-001, - 2.144477e-001, - -5.005667e+000, - 5.475125e-001, - 3.758162e-005, - 1.033427e+000, - 6.866266e-001, - // albedo 1, turbidity 4 - -2.686681e+000, - -1.694114e+000, - -4.346908e+000, - 4.745876e+000, - -2.879846e-002, - 2.237339e-001, - -6.438656e-006, - 1.456353e+000, - 9.000340e-001, - -2.684912e+000, - -1.616888e+000, - 2.447798e+000, - -1.626883e+000, - -7.346183e-002, - 2.641722e-001, - -1.001518e-004, - 1.045501e+000, - -2.314856e-001, - -2.587652e+000, - -1.999748e+000, - -1.325810e+000, - 7.561102e-001, - -4.182131e-001, - -4.285017e-002, - 2.719759e-003, - 2.420598e+000, - 1.281981e+000, - -2.679506e-001, - 5.139740e-002, - 1.276587e+000, - -2.286956e-001, - 7.388924e-001, - 5.606395e-001, - -1.472508e-002, - 5.105614e-001, - 7.670396e-001, - -1.267160e+000, - -7.441021e-001, - 9.154665e-001, - 8.190436e-001, - -6.805266e+000, - 1.013064e-001, - 4.140297e-002, - 3.378301e-001, - 3.128860e-001, - -9.570978e-001, - -3.478847e-001, - 9.709923e-001, - -3.444499e-003, - -4.677921e+000, - 3.551546e-001, - 6.241534e-003, - 1.052060e+000, - 7.543152e-001, - // albedo 1, turbidity 5 - -3.093830e+000, - -1.859478e+000, - -4.003711e+000, - 4.391665e+000, - -3.051581e-002, - 2.180265e-001, - -7.401285e-006, - 1.448366e+000, - 9.000549e-001, - -3.121106e+000, - -1.664385e+000, - 2.868256e+000, - -2.280292e+000, - -8.456847e-002, - 2.227469e-001, - -1.681252e-004, - 1.176332e+000, - -2.605895e-001, - -2.166025e+000, - -2.172663e+000, - -1.705862e+000, - 1.960864e+000, - -2.185020e-001, - 1.891067e-002, - 4.423413e-003, - 2.071931e+000, - 1.297661e+000, - -5.263078e-001, - 2.296403e-001, - 1.342025e+000, - -2.034590e+000, - -1.024013e+000, - 4.873264e-001, - -1.982506e-002, - 9.818474e-001, - 1.040041e+000, - -1.138361e+000, - -8.186096e-001, - 8.845700e-001, - 3.291911e+000, - -5.915866e+000, - 1.125846e-001, - 4.477952e-002, - 9.195132e-002, - -1.138939e-002, - -1.013651e+000, - -3.811416e-001, - 9.420266e-001, - -3.599378e-003, - -4.895655e+000, - 2.864445e-001, - 1.940262e-002, - 1.026648e+000, - 7.421204e-001, - // albedo 1, turbidity 6 - -2.379373e+000, - -1.540348e+000, - -1.318467e+000, - 1.724703e+000, - -1.017147e-001, - 1.811106e-001, - -3.047951e-006, - 1.598808e+000, - 5.796580e-001, - -3.200327e+000, - -2.016985e+000, - 9.935187e-001, - -9.970906e-001, - -2.159523e-001, - 3.183812e-001, - 1.575987e-002, - 1.180131e+000, - 2.839510e-001, - -1.107956e+000, - -1.330969e+000, - -1.627216e-001, - 2.985435e+000, - -2.198633e-002, - -4.401148e-001, - -5.433064e-002, - 1.701087e+000, - 8.289746e-001, - -9.423359e-001, - 4.619106e-002, - 3.116348e-002, - -6.353122e+000, - -6.192769e+000, - 1.175886e+000, - 1.020452e-001, - 2.180417e+000, - 7.076018e-001, - -1.037343e+000, - -5.711080e-001, - 1.282899e+000, - 8.808032e+000, - -8.741903e-001, - -6.097972e-001, - -5.996612e-002, - 1.533313e-001, - 5.842877e-001, - -1.002208e+000, - -3.271512e-001, - 7.288675e-001, - 7.950560e-001, - -5.029931e+000, - 4.493639e-001, - 2.389923e-002, - 1.568465e+000, - 5.653910e-001, - // albedo 1, turbidity 7 - -3.584221e+000, - -2.140498e+000, - -5.324613e+000, - 5.753381e+000, - -2.662581e-002, - 2.099272e-001, - -6.879519e-006, - 1.362229e+000, - 9.000467e-001, - -3.579609e+000, - -1.804420e+000, - 3.448490e+000, - -2.929179e+000, - -6.009529e-002, - 2.821561e-001, - -6.203809e-004, - 1.312035e+000, - -3.013934e-001, - -2.053811e+000, - -2.420850e+000, - -1.795999e+000, - 1.835004e+000, - -3.451800e-001, - -1.042135e-001, - 1.511574e-002, - 1.751304e+000, - 1.491704e+000, - -2.602659e-001, - 5.963320e-001, - 1.059632e+000, - -1.214076e+000, - 6.424455e-001, - 6.890202e-001, - -6.544341e-002, - 1.457883e+000, - 5.321707e-001, - -1.266632e+000, - -8.504227e-001, - 8.680693e-001, - 1.899473e+000, - -8.680238e+000, - -1.798563e-001, - 1.477665e-001, - 2.430031e-001, - 4.229871e-001, - -1.021321e+000, - -5.129049e-001, - 9.006232e-001, - 1.534018e+000, - -3.672948e+000, - 2.301115e-001, - 5.151145e-003, - 7.460819e-001, - 5.418252e-001, - // albedo 1, turbidity 8 - -4.095186e+000, - -2.274183e+000, - -4.115160e+000, - 4.514741e+000, - -3.131440e-002, - 1.475658e-001, - -5.329133e-006, - 1.411833e+000, - 8.893477e-001, - -3.691554e+000, - -1.654418e+000, - 3.158573e+000, - -2.961366e+000, - -7.834161e-002, - 3.035141e-001, - -4.241191e-004, - 1.485200e+000, - -1.689443e-001, - -2.697067e+000, - -3.473351e+000, - -1.707297e+000, - 3.138823e+000, - -8.323430e-002, - -1.605972e-001, - 1.025052e-002, - 1.132282e+000, - 1.093318e+000, - 7.049827e-001, - 1.769870e+000, - 8.659868e-001, - -4.445404e+000, - -2.256134e+000, - 7.768538e-001, - -4.741793e-002, - 2.212406e+000, - 1.109562e+000, - -1.771411e+000, - -1.358270e+000, - 7.604506e-001, - 7.191590e+000, - -4.358366e+000, - -3.375251e-001, - 1.136852e-001, - 1.844576e-001, - -1.208189e-003, - -9.623648e-001, - -5.518470e-001, - 9.623684e-001, - -5.697517e-003, - -5.015884e+000, - 2.811964e-001, - 2.100168e-002, - 4.434131e-001, - 7.212648e-001, - // albedo 1, turbidity 9 - -5.131552e+000, - -2.558716e+000, - -8.066753e+000, - 8.403192e+000, - -1.450692e-002, - 1.494495e-001, - -2.898774e-006, - 1.427512e+000, - 5.020826e-001, - -6.192910e+000, - -2.261479e+000, - 5.059205e+000, - -4.892079e+000, - -2.703716e-002, - 3.381259e-001, - 2.231257e-002, - 1.490697e+000, - 5.441761e-001, - -6.741018e-001, - -3.356237e+000, - -2.207329e+000, - 3.300094e+000, - -1.801120e-001, - -2.560242e-001, - -6.216731e-002, - 1.180699e+000, - 2.241782e-001, - -8.312435e-001, - 1.325391e+000, - 5.324159e-001, - -2.912438e+000, - -8.384977e-002, - 7.600872e-001, - 7.749519e-002, - 2.129188e+000, - 1.328287e+000, - -7.455272e-001, - -8.504579e-001, - 9.021474e-001, - 3.426594e+000, - -4.607412e+000, - -1.706127e-001, - 4.792024e-002, - 2.354077e-001, - 2.718195e-001, - -1.448374e+000, - -9.739004e-001, - 8.801628e-001, - 1.705262e+000, - -2.420298e+000, - -1.077392e-002, - 2.691713e-002, - 1.854876e-001, - 7.097466e-001, - // albedo 1, turbidity 10 - -8.672396e+000, - -3.339107e+000, - -7.666257e+000, - 7.916291e+000, - -1.396976e-002, - 1.676538e-001, - -5.816416e-006, - 1.448247e+000, - 8.178892e-001, - -7.852799e+000, - -2.606120e+000, - 4.231840e+000, - -3.774406e+000, - -3.540722e-002, - 2.178494e-001, - 6.198617e-005, - 1.295236e+000, - 1.130678e-001, - -1.374103e-001, - -3.570476e+000, - -1.588768e+000, - 1.538806e+000, - -1.923629e-001, - -1.793545e-002, - 3.373950e-003, - 2.008581e+000, - 6.041668e-001, - -2.211224e+000, - 1.190704e-001, - 6.700025e-002, - -8.972445e-001, - 2.133056e-001, - 4.471730e-001, - -3.148150e-002, - 9.759721e-001, - 1.166537e+000, - 5.932825e-001, - 2.482606e-001, - 9.239617e-001, - 2.382787e+000, - -4.611846e+000, - 1.608983e-001, - 1.385590e-001, - 7.641781e-001, - 3.076032e-001, - -2.098394e+000, - -1.561705e+000, - 7.602298e-001, - 1.783879e+000, - -1.486238e+000, - -4.025919e-001, - 2.965074e-002, - -8.717180e-002, - 7.279518e-001, -}; - -double datasetRad360[] = -{ - // albedo 0, turbidity 1 - 2.018734e-002, - 2.878447e-002, - 2.400602e-003, - 2.195955e-002, - 1.081208e+000, - 6.713020e-001, - // albedo 0, turbidity 2 - 2.002136e-002, - 2.847494e-002, - 3.587591e-003, - 1.419700e-002, - 1.094719e+000, - 6.680584e-001, - // albedo 0, turbidity 3 - 2.011594e-002, - 2.839101e-002, - 3.428003e-003, - 9.071270e-003, - 1.101399e+000, - 6.741060e-001, - // albedo 0, turbidity 4 - 1.959942e-002, - 2.653676e-002, - 1.129384e-002, - -1.580946e-002, - 1.127469e+000, - 6.780204e-001, - // albedo 0, turbidity 5 - 1.945450e-002, - 2.520872e-002, - 1.800661e-002, - -4.294016e-002, - 1.162101e+000, - 6.730305e-001, - // albedo 0, turbidity 6 - 1.903655e-002, - 2.359634e-002, - 2.573237e-002, - -6.716183e-002, - 1.191096e+000, - 6.637348e-001, - // albedo 0, turbidity 7 - 1.900294e-002, - 2.235101e-002, - 2.971978e-002, - -8.191387e-002, - 1.197978e+000, - 6.798375e-001, - // albedo 0, turbidity 8 - 1.858572e-002, - 1.959071e-002, - 4.133418e-002, - -1.226605e-001, - 1.235477e+000, - 6.843139e-001, - // albedo 0, turbidity 9 - 1.775300e-002, - 1.478736e-002, - 6.156524e-002, - -1.871793e-001, - 1.285714e+000, - 6.918133e-001, - // albedo 0, turbidity 10 - 1.649168e-002, - 7.620909e-003, - 8.938806e-002, - -2.710168e-001, - 1.325702e+000, - 7.116526e-001, - // albedo 1, turbidity 1 - 2.477596e-002, - 1.721452e-002, - 9.168552e-002, - -2.257278e-001, - 1.577194e+000, - 1.309986e+000, - // albedo 1, turbidity 2 - 2.466371e-002, - 1.743042e-002, - 9.040406e-002, - -2.274583e-001, - 1.578315e+000, - 1.306446e+000, - // albedo 1, turbidity 3 - 2.459685e-002, - 1.660564e-002, - 9.153715e-002, - -2.315701e-001, - 1.571815e+000, - 1.309528e+000, - // albedo 1, turbidity 4 - 2.398256e-002, - 1.512880e-002, - 9.624211e-002, - -2.499972e-001, - 1.588498e+000, - 1.289531e+000, - // albedo 1, turbidity 5 - 2.362570e-002, - 1.397231e-002, - 1.012384e-001, - -2.701754e-001, - 1.597686e+000, - 1.277024e+000, - // albedo 1, turbidity 6 - 2.311217e-002, - 1.333246e-002, - 1.016992e-001, - -2.741844e-001, - 1.590760e+000, - 1.271949e+000, - // albedo 1, turbidity 7 - 2.286898e-002, - 1.138458e-002, - 1.081702e-001, - -2.975024e-001, - 1.604279e+000, - 1.243052e+000, - // albedo 1, turbidity 8 - 2.167905e-002, - 8.977041e-003, - 1.158610e-001, - -3.247192e-001, - 1.602017e+000, - 1.222336e+000, - // albedo 1, turbidity 9 - 2.068610e-002, - 5.054490e-003, - 1.264696e-001, - -3.615436e-001, - 1.593307e+000, - 1.183658e+000, - // albedo 1, turbidity 10 - 1.880968e-002, - 1.052745e-003, - 1.346693e-001, - -3.906154e-001, - 1.528992e+000, - 1.155257e+000, -}; - -double dataset400[] = -{ - // albedo 0, turbidity 1 - -1.869600e+000, - -9.575785e-001, - -6.993871e+000, - 7.306207e+000, - -3.240320e-002, - 3.834949e-001, - 4.369976e-005, - 2.254773e+000, - 5.025988e-001, - -1.746138e+000, - -1.001117e+000, - -1.758295e+000, - 2.492931e+000, - -6.202861e-002, - 4.442043e-001, - -3.779550e-004, - 1.411622e+000, - 4.890101e-001, - -1.536453e+000, - -5.330479e-001, - 1.126830e+000, - -2.452367e+000, - -6.694842e-002, - -2.983825e-002, - 2.320196e-003, - 5.488905e+000, - 5.403856e-001, - -1.069780e+000, - -5.815078e-001, - 8.612956e-001, - 1.301347e+000, - -4.089489e-001, - 1.269432e+000, - -9.018004e-003, - -2.283572e+000, - 3.760374e-001, - -1.060384e+000, - -2.207518e-001, - 6.362691e-001, - -5.757237e-001, - 4.275177e-001, - 8.443714e-002, - 2.082596e-002, - 3.125040e+000, - 7.891611e-001, - -1.077246e+000, - -2.993040e-001, - 8.167430e-001, - 2.203982e-001, - -3.984213e+000, - 1.123699e+000, - 1.313138e-002, - 1.750491e+000, - 4.999653e-001, - // albedo 0, turbidity 2 - -1.752499e+000, - -9.053927e-001, - -1.080943e+001, - 1.110516e+001, - -2.092090e-002, - 3.348109e-001, - -8.432141e-006, - 2.326824e+000, - 9.000500e-001, - -1.888565e+000, - -1.067725e+000, - 1.491851e+000, - -7.934014e-001, - -4.853718e-002, - 5.346693e-001, - 9.170370e-005, - 1.397595e+000, - -3.635730e-001, - -1.471013e+000, - -5.497976e-001, - -4.310423e-001, - -8.787275e-001, - -9.206447e-002, - -1.490862e-001, - -4.078054e-005, - 5.442983e+000, - 1.757010e+000, - -1.061905e+000, - -5.429222e-001, - 1.412232e+000, - 8.460977e-001, - -2.973654e-001, - 1.357299e+000, - -5.347332e-003, - -2.444304e+000, - -3.363016e-002, - -1.071200e+000, - -2.263246e-001, - 3.639469e-001, - -6.109244e-001, - -2.484665e-001, - -7.097027e-002, - 4.735641e-002, - 3.445733e+000, - 8.486491e-001, - -1.081645e+000, - -3.128264e-001, - 8.436471e-001, - 3.884148e-001, - -5.004662e+000, - 1.137000e+000, - 1.500838e-002, - 1.585647e+000, - 5.832608e-001, - // albedo 0, turbidity 3 - -1.774187e+000, - -9.327599e-001, - -9.130103e+000, - 9.413272e+000, - -2.448089e-002, - 3.487996e-001, - -3.033497e-006, - 2.291071e+000, - 6.408360e-001, - -1.849342e+000, - -1.038735e+000, - 2.863013e+000, - -2.260302e+000, - -5.040252e-002, - 4.583723e-001, - 1.008690e-002, - 1.502617e+000, - 7.223351e-002, - -1.624679e+000, - -7.257060e-001, - -1.493033e+000, - 5.658415e-001, - -2.079847e-001, - -4.651180e-002, - -3.701743e-002, - 4.858534e+000, - 1.342775e+000, - -8.692395e-001, - -3.025565e-001, - 1.630221e+000, - -4.624355e-002, - 8.408669e-002, - 1.091981e+000, - 6.506253e-002, - -1.403006e+000, - 2.076066e-001, - -1.169258e+000, - -3.711802e-001, - 3.440155e-001, - -1.044556e-001, - -3.304858e+000, - 1.185883e-001, - 1.489352e-002, - 2.642598e+000, - 8.151882e-001, - -1.058391e+000, - -2.657785e-001, - 6.984363e-001, - 9.737578e-002, - -1.903943e+000, - 8.963329e-001, - 6.480860e-002, - 2.034024e+000, - 5.870424e-001, - // albedo 0, turbidity 4 - -1.898858e+000, - -1.031814e+000, - -9.726056e+000, - 1.000989e+001, - -2.125268e-002, - 3.569897e-001, - -2.706653e-006, - 2.147646e+000, - 5.982401e-001, - -2.136007e+000, - -1.206456e+000, - 3.801172e+000, - -3.254852e+000, - -4.516490e-002, - 4.001123e-001, - 2.151890e-002, - 1.481457e+000, - 1.444904e-001, - -1.355343e+000, - -6.736369e-001, - -2.052620e+000, - 1.298239e+000, - -1.986869e-001, - 6.321488e-002, - -6.792635e-002, - 4.482593e+000, - 1.322565e+000, - -9.063816e-001, - -1.873797e-001, - 1.559544e+000, - -2.631298e-001, - 5.988684e-002, - 9.375378e-001, - 9.681349e-002, - -6.480890e-001, - 2.362949e-001, - -1.170470e+000, - -3.968082e-001, - 2.266604e-001, - -2.018118e-001, - -3.768512e+000, - 9.706445e-002, - 6.046660e-002, - 2.723200e+000, - 7.968878e-001, - -1.085813e+000, - -3.519543e-001, - 7.537557e-001, - 3.003522e-001, - -1.811803e+000, - 7.945754e-001, - 5.293207e-002, - 1.335214e+000, - 6.385980e-001, - // albedo 0, turbidity 5 - -1.743240e+000, - -9.391727e-001, - -8.905876e+000, - 9.139326e+000, - -2.333803e-002, - 3.093783e-001, - -2.051734e-006, - 2.320564e+000, - 5.474845e-001, - -2.624196e+000, - -1.516703e+000, - 5.053093e+000, - -4.599198e+000, - -4.248730e-002, - 4.820250e-001, - 1.829762e-002, - 1.216991e+000, - 2.739806e-001, - -1.040612e+000, - -6.103044e-001, - -3.190021e+000, - 3.216574e+000, - -3.285978e-001, - -1.982489e-001, - -5.367025e-002, - 3.984414e+000, - 1.158312e+000, - -9.537244e-001, - -6.895800e-003, - 1.788307e+000, - -2.659655e+000, - 6.473584e-001, - 1.333544e+000, - 5.529579e-002, - 8.049825e-001, - 4.930209e-001, - -1.163791e+000, - -5.095388e-001, - 1.215079e-001, - 3.427998e+000, - -9.243257e+000, - -5.059496e-001, - 1.412681e-001, - 1.829389e+000, - 5.544610e-001, - -1.118058e+000, - -3.706501e-001, - 6.885180e-001, - -1.596776e-003, - -3.279613e+000, - 1.068229e+000, - 3.010797e-002, - 1.479756e+000, - 7.483765e-001, - // albedo 0, turbidity 6 - -1.811701e+000, - -1.002650e+000, - -9.194183e+000, - 9.469966e+000, - -2.224886e-002, - 3.237441e-001, - -2.632967e-006, - 2.168879e+000, - 5.952956e-001, - -2.746180e+000, - -1.592055e+000, - 4.225172e+000, - -3.929912e+000, - -3.866297e-002, - 3.982440e-001, - 3.812089e-002, - 1.390284e+000, - 1.922369e-001, - -9.558770e-001, - -6.401790e-001, - -2.117905e+000, - 2.293799e+000, - -2.226591e-001, - 6.151477e-002, - -1.223358e-001, - 3.475975e+000, - 1.124575e+000, - -9.065351e-001, - 1.443765e-001, - 7.871576e-001, - -1.631026e+000, - 1.537369e-001, - 8.353048e-001, - 1.849704e-001, - 1.650615e+000, - 4.473559e-001, - -1.180081e+000, - -5.441674e-001, - 3.963103e-001, - 1.375519e+000, - -4.882926e+000, - -9.391794e-004, - 6.455569e-002, - 1.774670e+000, - 6.989373e-001, - -1.128755e+000, - -3.892532e-001, - 5.327884e-001, - 1.825253e+000, - -2.335719e+000, - 5.863162e-001, - 5.535626e-002, - 1.452293e+000, - 6.920090e-001, - // albedo 0, turbidity 7 - -2.042064e+000, - -1.144943e+000, - -5.152625e+000, - 5.384535e+000, - -3.519943e-002, - 3.025845e-001, - -2.994849e-006, - 2.113418e+000, - 6.000255e-001, - -2.700541e+000, - -1.485611e+000, - 2.159154e+000, - -2.188608e+000, - -5.879735e-002, - 3.921779e-001, - 5.020849e-002, - 1.869923e+000, - 2.118398e-001, - -1.187417e+000, - -1.102630e+000, - -9.404690e-001, - 2.427532e+000, - -2.948903e-001, - -3.437257e-002, - -1.636446e-001, - 1.894926e+000, - 1.001327e+000, - -5.639857e-001, - 7.170770e-001, - -1.146502e-001, - -3.487513e+000, - -7.711076e-001, - 1.046031e+000, - 2.606854e-001, - 3.873520e+000, - 5.637980e-001, - -1.363103e+000, - -8.396317e-001, - 5.750351e-001, - 4.317766e+000, - -2.364722e+000, - -4.135433e-001, - 2.669162e-002, - 5.768700e-001, - 6.649078e-001, - -1.102449e+000, - -3.685043e-001, - 4.622549e-001, - -2.018634e-003, - -3.947538e+000, - 8.449276e-001, - 8.837036e-002, - 1.601304e+000, - 7.026980e-001, - // albedo 0, turbidity 8 - -2.314053e+000, - -1.314766e+000, - -7.125646e+000, - 7.357344e+000, - -2.585710e-002, - 2.863908e-001, - -2.425744e-006, - 2.039404e+000, - 5.594003e-001, - -2.630411e+000, - -1.404258e+000, - 3.675058e+000, - -3.804226e+000, - -4.249037e-002, - 3.486414e-001, - 5.675141e-002, - 1.944935e+000, - 2.880711e-001, - -1.884599e+000, - -1.657069e+000, - -1.731916e+000, - 3.034605e+000, - -1.746846e-001, - -1.559184e-002, - -1.600465e-001, - 1.915108e+000, - 9.460232e-001, - 6.351036e-002, - 1.061776e+000, - 1.195544e-002, - -3.018584e+000, - -5.618808e-001, - 1.008146e+000, - 2.013783e-001, - 3.212273e+000, - 6.523624e-001, - -1.672505e+000, - -9.752710e-001, - 5.282860e-001, - 3.776331e+000, - -4.325128e+000, - -4.384279e-001, - 1.352387e-001, - 8.847662e-001, - 5.717158e-001, - -1.007695e+000, - -3.840375e-001, - 3.463543e-001, - 2.848366e+000, - -2.105699e+000, - 4.636429e-001, - 2.800131e-002, - 1.306056e+000, - 7.618236e-001, - // albedo 0, turbidity 9 - -2.865406e+000, - -1.637174e+000, - -7.429613e+000, - 7.592861e+000, - -2.196505e-002, - 2.800873e-001, - -3.908530e-006, - 1.962505e+000, - 5.891464e-001, - -3.196334e+000, - -1.512711e+000, - 3.947880e+000, - -4.029796e+000, - -3.699620e-002, - 1.461452e-001, - 5.921432e-002, - 1.806132e+000, - 2.331816e-001, - -2.335492e+000, - -2.353032e+000, - -1.764665e+000, - 2.841986e+000, - -7.331326e-002, - 4.537047e-001, - -1.668000e-001, - 2.156269e+000, - 9.812486e-001, - 3.278911e-001, - 1.315177e+000, - -1.438189e-001, - -2.859630e+000, - -8.436262e-001, - 2.645711e-001, - 2.154409e-001, - 2.264493e+000, - 5.975203e-001, - -1.738015e+000, - -1.091057e+000, - 5.425696e-001, - 4.650166e+000, - -3.975190e+000, - 2.066035e-001, - 1.017332e-001, - 9.321625e-001, - 6.517783e-001, - -1.006457e+000, - -4.243112e-001, - 1.934952e-001, - 2.795030e+000, - -1.680697e+000, - -9.428375e-002, - 7.158314e-002, - 1.082383e+000, - 7.234775e-001, - // albedo 0, turbidity 10 - -4.195701e+000, - -2.171135e+000, - -5.278016e+000, - 5.393085e+000, - -2.419182e-002, - 2.050075e-001, - -3.797795e-006, - 1.853402e+000, - 6.912927e-001, - -4.119053e+000, - -1.648023e+000, - 2.332552e+000, - -2.173813e+000, - -6.442977e-002, - 2.188945e-001, - 3.548565e-002, - 1.792598e+000, - 4.162082e-002, - -4.016823e+000, - -3.599323e+000, - -6.179057e-001, - 6.454998e-001, - -9.913704e-002, - 2.770986e-001, - -9.265471e-002, - 2.227501e+000, - 1.179216e+000, - 1.066227e+000, - 1.392783e+000, - -9.653695e-001, - -5.471637e-001, - -8.500569e-001, - 4.678476e-001, - 8.760324e-002, - 1.564314e+000, - 4.885251e-001, - -1.855594e+000, - -1.029300e+000, - 8.521013e-001, - 3.975027e+000, - -3.806819e+000, - -2.044703e-002, - 1.757298e-001, - 7.790123e-001, - 6.918921e-001, - -1.014961e+000, - -6.014045e-001, - 1.926619e-002, - 2.357335e+000, - -1.312911e+000, - -8.783609e-002, - 7.739369e-002, - 7.356770e-001, - 7.042591e-001, - // albedo 1, turbidity 1 - -1.467874e+000, - -7.636581e-001, - -7.251111e+000, - 7.726558e+000, - -2.759341e-002, - 3.527534e-001, - 5.340629e-005, - 2.007747e+000, - 5.447487e-001, - -1.863242e+000, - -1.048209e+000, - -1.580541e+000, - 2.558030e+000, - -5.622126e-002, - 3.053960e-001, - -4.657733e-004, - 9.956390e-001, - 3.409087e-001, - -1.384101e+000, - -5.553588e-001, - 1.191974e+000, - -2.157512e+000, - -3.567589e-002, - 1.020018e-001, - 2.940191e-003, - 4.555372e+000, - 8.736043e-001, - -9.828878e-001, - -4.220161e-001, - 1.184916e+000, - 9.230716e-001, - -4.062756e-001, - 1.064980e+000, - -1.060088e-002, - -1.764815e+000, - 2.932808e-001, - -1.057001e+000, - -2.727017e-001, - 1.000018e+000, - -3.108668e-001, - 6.848382e-001, - -1.682596e-001, - 2.301218e-002, - 2.075821e+000, - 7.647327e-001, - -1.058165e+000, - -2.436130e-001, - 1.074414e+000, - 8.554434e-002, - -3.846431e+000, - 7.595465e-001, - 9.729528e-006, - 1.915942e+000, - 4.999612e-001, - // albedo 1, turbidity 2 - -1.610179e+000, - -8.336019e-001, - -1.443356e+001, - 1.492556e+001, - -1.381931e-002, - 2.902743e-001, - -7.665717e-006, - 1.981513e+000, - 9.000423e-001, - -2.004083e+000, - -1.148388e+000, - 3.747156e+000, - -2.808560e+000, - -3.298677e-002, - 4.224754e-001, - 4.166438e-004, - 8.792110e-001, - -2.321793e-001, - -1.178554e+000, - -5.064839e-001, - -1.117126e+000, - 2.815740e-001, - -7.068438e-002, - -3.031589e-002, - -3.468069e-003, - 4.539093e+000, - 1.385612e+000, - -1.091191e+000, - -4.200919e-001, - 1.826508e+000, - 7.131992e-002, - -1.883417e-001, - 1.061437e+000, - 1.311913e-002, - -1.972550e+000, - 2.511246e-001, - -9.987232e-001, - -2.073656e-001, - 7.443384e-001, - -7.245157e-002, - -5.588818e-001, - -1.364188e-001, - 2.023795e-002, - 2.829822e+000, - 7.230021e-001, - -1.075477e+000, - -2.556973e-001, - 1.051690e+000, - 3.075960e-002, - -1.895492e+000, - 6.408333e-001, - 2.109454e-002, - 1.891240e+000, - 5.652527e-001, - // albedo 1, turbidity 3 - -1.531711e+000, - -8.266123e-001, - -9.324763e+000, - 9.811491e+000, - -1.988560e-002, - 3.404598e-001, - -2.068369e-006, - 1.869307e+000, - 5.860842e-001, - -2.113444e+000, - -1.209106e+000, - 3.526508e+000, - -2.628730e+000, - -4.634065e-002, - 3.182739e-001, - 9.500212e-003, - 1.004871e+000, - 2.109968e-001, - -1.196720e+000, - -5.485073e-001, - -1.667136e+000, - 9.920197e-001, - -1.622954e-001, - 6.951315e-002, - -3.482877e-002, - 4.214632e+000, - 1.108967e+000, - -1.003096e+000, - -3.200944e-001, - 2.042427e+000, - -4.417822e-001, - -1.404599e-001, - 9.288535e-001, - 6.077264e-002, - -1.386737e+000, - 4.557129e-001, - -1.061048e+000, - -2.908451e-001, - 6.390633e-001, - 1.406786e-001, - -1.834706e+000, - -1.432145e-001, - 1.914080e-002, - 2.284516e+000, - 5.965839e-001, - -1.054623e+000, - -2.267971e-001, - 1.028491e+000, - -3.197518e-003, - -1.705329e+000, - 6.747358e-001, - 2.072713e-002, - 2.140509e+000, - 7.205824e-001, - // albedo 1, turbidity 4 - -1.610001e+000, - -8.622601e-001, - -1.060181e+001, - 1.106133e+001, - -1.648296e-002, - 2.590559e-001, - -1.904522e-006, - 1.930415e+000, - 6.006964e-001, - -2.308577e+000, - -1.440194e+000, - 2.937335e+000, - -2.093599e+000, - -3.430217e-002, - 3.427774e-001, - 2.590705e-002, - 5.673750e-001, - 1.250422e-001, - -9.441254e-001, - -3.064812e-001, - -8.895068e-001, - 2.815271e-001, - -8.036228e-002, - 1.867017e-001, - -7.809247e-002, - 4.774631e+000, - 1.391904e+000, - -1.214397e+000, - -5.423074e-001, - 1.361001e+000, - 1.782273e-001, - -3.648675e-001, - 7.181838e-001, - 1.135547e-001, - -1.935982e+000, - 1.820361e-001, - -9.377631e-001, - -1.533211e-001, - 8.439993e-001, - -3.893771e-001, - -2.564779e-001, - -6.742272e-002, - 2.255856e-002, - 2.780601e+000, - 7.972008e-001, - -1.101428e+000, - -3.069552e-001, - 9.687591e-001, - 4.500576e-001, - -4.912444e+000, - 5.398387e-001, - 3.638172e-002, - 1.582999e+000, - 6.425950e-001, - // albedo 1, turbidity 5 - -1.687541e+000, - -9.378170e-001, - -8.475686e+000, - 8.929279e+000, - -2.132746e-002, - 2.917650e-001, - -2.177239e-006, - 1.863407e+000, - 5.908179e-001, - -2.278432e+000, - -1.387936e+000, - 5.425292e+000, - -4.725025e+000, - -3.892912e-002, - 4.084727e-001, - 1.842665e-002, - 8.461986e-001, - 1.673366e-001, - -1.302702e+000, - -7.200083e-001, - -3.084331e+000, - 3.191487e+000, - -3.222828e-001, - -1.493849e-001, - -5.641672e-002, - 3.624218e+000, - 1.256086e+000, - -7.886965e-001, - -3.966453e-002, - 2.110076e+000, - -2.232935e+000, - 7.269719e-001, - 1.163410e+000, - 7.133744e-002, - -1.660119e-001, - 4.329084e-001, - -1.157760e+000, - -4.084596e-001, - 5.689088e-001, - 2.379590e+000, - -9.687743e+000, - -5.598487e-001, - 9.191895e-002, - 1.923047e+000, - 5.802927e-001, - -1.047250e+000, - -2.873072e-001, - 1.046858e+000, - 6.890046e-001, - -2.947892e+000, - 7.245997e-001, - 1.125227e-002, - 1.352625e+000, - 7.193979e-001, - // albedo 1, turbidity 6 - -1.643764e+000, - -9.086683e-001, - -8.750078e+000, - 9.165653e+000, - -2.025728e-002, - 2.737848e-001, - -2.240987e-006, - 1.943471e+000, - 5.731722e-001, - -2.473069e+000, - -1.505194e+000, - 5.448737e+000, - -4.863726e+000, - -3.662439e-002, - 1.938729e-001, - 4.741355e-002, - 8.586572e-001, - 2.284408e-001, - -1.232599e+000, - -7.896777e-001, - -3.056911e+000, - 3.546334e+000, - -1.948820e-001, - 3.344216e-001, - -1.376967e-001, - 3.029469e+000, - 1.120573e+000, - -6.095289e-001, - 2.745468e-001, - 1.809782e+000, - -2.593032e+000, - -1.710009e-002, - 5.537278e-001, - 1.935506e-001, - 1.259882e+000, - 4.970103e-001, - -1.324655e+000, - -6.255071e-001, - 6.240868e-001, - 2.021182e+000, - -5.876050e+000, - -1.507819e-001, - 3.301250e-002, - 1.142019e+000, - 5.986671e-001, - -9.888131e-001, - -2.584852e-001, - 1.052160e+000, - 7.264224e-001, - -2.563426e+000, - 5.494058e-001, - 1.821983e-002, - 1.277896e+000, - 7.557967e-001, - // albedo 1, turbidity 7 - -2.100689e+000, - -1.204431e+000, - -7.573121e+000, - 8.039632e+000, - -2.300526e-002, - 2.839214e-001, - -2.346958e-006, - 1.678847e+000, - 5.536303e-001, - -2.610610e+000, - -1.587799e+000, - 5.460928e+000, - -5.158708e+000, - -4.505650e-002, - 3.876929e-001, - 3.852459e-002, - 1.172854e+000, - 3.104745e-001, - -8.340903e-001, - -7.487965e-001, - -3.154774e+000, - 4.600448e+000, - -1.818975e-001, - -1.871764e-001, - -1.222094e-001, - 2.067197e+000, - 8.802127e-001, - -9.180308e-001, - 3.752197e-001, - 1.471125e+000, - -4.691789e+000, - -5.128294e-001, - 1.164707e+000, - 1.831224e-001, - 2.900937e+000, - 7.718397e-001, - -1.126819e+000, - -6.652330e-001, - 7.386065e-001, - 5.362044e+000, - -6.196453e+000, - -7.280092e-001, - 6.312604e-002, - 2.874666e-001, - 4.225580e-001, - -1.091610e+000, - -3.433417e-001, - 1.042206e+000, - 1.075776e-001, - -4.443940e+000, - 7.469895e-001, - 3.166247e-002, - 1.019495e+000, - 7.523771e-001, - // albedo 1, turbidity 8 - -2.234623e+000, - -1.310221e+000, - -8.525764e+000, - 8.932373e+000, - -1.814945e-002, - 2.615153e-001, - -2.992344e-006, - 1.672403e+000, - 5.897681e-001, - -2.566352e+000, - -1.472664e+000, - 5.894182e+000, - -5.619094e+000, - -3.204346e-002, - 2.993298e-001, - 4.281047e-002, - 1.303481e+000, - 2.453403e-001, - -1.577477e+000, - -1.491725e+000, - -3.065840e+000, - 4.446634e+000, - -1.689128e-001, - 9.559287e-002, - -1.384724e-001, - 1.778589e+000, - 9.159045e-001, - -2.747774e-001, - 8.787060e-001, - 1.071723e+000, - -4.169230e+000, - -3.029966e-001, - 6.326611e-001, - 2.145395e-001, - 2.611218e+000, - 7.082708e-001, - -1.433045e+000, - -8.939972e-001, - 8.538090e-001, - 4.481475e+000, - -5.978961e+000, - -1.608369e-001, - 5.335732e-002, - 3.510751e-001, - 5.421327e-001, - -9.961738e-001, - -3.023960e-001, - 9.152994e-001, - 2.936173e+000, - -2.311060e+000, - 1.216642e-001, - 2.844950e-002, - 9.492671e-001, - 6.929460e-001, - // albedo 1, turbidity 9 - -2.428587e+000, - -1.538689e+000, - -9.076712e+000, - 9.464050e+000, - -1.503392e-002, - 2.373401e-001, - -2.770103e-006, - 1.537508e+000, - 5.959289e-001, - -3.240872e+000, - -1.646067e+000, - 6.091797e+000, - -5.738481e+000, - -3.098072e-002, - 2.698026e-001, - 3.864212e-002, - 1.286514e+000, - 2.461153e-001, - -1.970987e+000, - -2.124015e+000, - -2.894000e+000, - 3.858260e+000, - -1.449222e-001, - 1.903898e-001, - -1.194017e-001, - 1.882566e+000, - 8.764452e-001, - 3.562238e-002, - 1.092427e+000, - 6.291668e-001, - -3.337396e+000, - -2.817141e-001, - 4.799828e-001, - 1.674350e-001, - 1.943489e+000, - 7.728749e-001, - -1.501790e+000, - -9.408520e-001, - 1.000954e+000, - 4.599103e+000, - -5.295662e+000, - -1.111397e-001, - 1.040124e-001, - 3.185557e-001, - 4.959400e-001, - -9.859417e-001, - -3.827367e-001, - 8.040930e-001, - 2.980678e+000, - -2.015582e+000, - -8.947514e-003, - 1.696367e-002, - 6.489501e-001, - 7.555598e-001, - // albedo 1, turbidity 10 - -3.758956e+000, - -2.159015e+000, - -7.207163e+000, - 7.516659e+000, - -1.643521e-002, - 2.465725e-001, - -4.045068e-006, - 1.471688e+000, - 6.687943e-001, - -4.635664e+000, - -1.766046e+000, - 4.282669e+000, - -4.058908e+000, - -2.908998e-002, - 1.202684e-001, - 3.167305e-002, - 1.450927e+000, - 8.171815e-002, - -3.458011e+000, - -3.657280e+000, - -1.484743e+000, - 2.264533e+000, - -1.033120e-001, - 4.282323e-001, - -8.387881e-002, - 1.687334e+000, - 1.130604e+000, - 9.673527e-001, - 1.500425e+000, - -3.604932e-001, - -2.050346e+000, - -3.778381e-001, - 2.416298e-001, - 8.439313e-002, - 1.458583e+000, - 5.816071e-001, - -1.808078e+000, - -1.089975e+000, - 1.291838e+000, - 5.144631e+000, - -5.047822e+000, - 4.301183e-002, - 1.426941e-001, - 1.187472e-001, - 6.145551e-001, - -8.399253e-001, - -3.832885e-001, - 6.306417e-001, - 2.179775e+000, - -1.492762e+000, - -1.682763e-001, - 4.109851e-002, - 4.221724e-001, - 7.086504e-001, -}; - -double datasetRad400[] = -{ - // albedo 0, turbidity 1 - 4.668300e-002, - 9.868960e-002, - -1.771333e-001, - 6.687440e-001, - 1.392029e+000, - 9.986235e-001, - // albedo 0, turbidity 2 - 4.582776e-002, - 1.018614e-001, - -1.881307e-001, - 6.776592e-001, - 1.401047e+000, - 1.016435e+000, - // albedo 0, turbidity 3 - 4.568248e-002, - 1.010922e-001, - -1.851341e-001, - 6.474660e-001, - 1.469330e+000, - 1.014158e+000, - // albedo 0, turbidity 4 - 4.434795e-002, - 9.838154e-002, - -1.718009e-001, - 5.819163e-001, - 1.588451e+000, - 1.008220e+000, - // albedo 0, turbidity 5 - 4.359376e-002, - 9.611603e-002, - -1.639761e-001, - 5.344035e-001, - 1.673271e+000, - 1.023811e+000, - // albedo 0, turbidity 6 - 4.305955e-002, - 9.393132e-002, - -1.541275e-001, - 4.880885e-001, - 1.746925e+000, - 1.020812e+000, - // albedo 0, turbidity 7 - 4.192088e-002, - 9.112506e-002, - -1.382965e-001, - 4.137111e-001, - 1.849490e+000, - 1.034616e+000, - // albedo 0, turbidity 8 - 4.042670e-002, - 8.299413e-002, - -1.015609e-001, - 2.776178e-001, - 2.015643e+000, - 1.054391e+000, - // albedo 0, turbidity 9 - 3.852343e-002, - 6.641196e-002, - -2.627537e-002, - 3.164681e-002, - 2.282128e+000, - 1.070368e+000, - // albedo 0, turbidity 10 - 3.571325e-002, - 3.974297e-002, - 8.424870e-002, - -2.935775e-001, - 2.547312e+000, - 1.140705e+000, - // albedo 1, turbidity 1 - 5.679224e-002, - 7.929513e-002, - -7.951369e-003, - 1.881214e-001, - 2.456521e+000, - 2.083260e+000, - // albedo 1, turbidity 2 - 5.653144e-002, - 7.757465e-002, - -4.812390e-003, - 1.668414e-001, - 2.501044e+000, - 2.061822e+000, - // albedo 1, turbidity 3 - 5.556607e-002, - 7.722316e-002, - -2.680467e-003, - 1.397415e-001, - 2.547245e+000, - 2.055499e+000, - // albedo 1, turbidity 4 - 5.423907e-002, - 7.569948e-002, - 2.746208e-003, - 9.388053e-002, - 2.613087e+000, - 2.047858e+000, - // albedo 1, turbidity 5 - 5.272135e-002, - 7.182013e-002, - 1.893595e-002, - 2.280844e-002, - 2.704394e+000, - 2.020504e+000, - // albedo 1, turbidity 6 - 5.184846e-002, - 6.852665e-002, - 2.963929e-002, - -2.465402e-002, - 2.763538e+000, - 1.994612e+000, - // albedo 1, turbidity 7 - 5.035161e-002, - 6.473107e-002, - 4.822041e-002, - -1.054530e-001, - 2.851784e+000, - 1.957751e+000, - // albedo 1, turbidity 8 - 4.785788e-002, - 5.525476e-002, - 8.163098e-002, - -2.243489e-001, - 2.946524e+000, - 1.931700e+000, - // albedo 1, turbidity 9 - 4.492922e-002, - 4.174088e-002, - 1.344967e-001, - -4.105780e-001, - 3.081372e+000, - 1.874144e+000, - // albedo 1, turbidity 10 - 4.055971e-002, - 2.134172e-002, - 2.023388e-001, - -6.132472e-001, - 3.098515e+000, - 1.884364e+000, -}; - -double dataset440[] = -{ - // albedo 0, turbidity 1 - -1.397312e+000, - -5.327311e-001, - -5.456059e+000, - 5.777674e+000, - -5.111575e-002, - 4.730804e-001, - 7.375500e-003, - 3.032806e+000, - 5.181890e-001, - -1.561639e+000, - -7.024946e-001, - -2.140322e+000, - 2.841761e+000, - -8.846023e-002, - 5.529005e-001, - 6.219344e-003, - 2.004212e+000, - 3.701256e-001, - -1.047473e+000, - -1.152734e-001, - 2.275873e+000, - -3.020347e+000, - -1.739218e-001, - 2.250142e-001, - -2.731776e-002, - 6.659723e+000, - 1.067495e+000, - -1.298483e+000, - -5.788209e-001, - 4.906412e-001, - 1.522576e+000, - -5.650061e-001, - 1.544707e+000, - 4.638003e-002, - -3.742019e+000, - 2.485397e-001, - -9.485899e-001, - -7.383610e-002, - 1.039247e+000, - -4.744931e-001, - -1.822357e-001, - 2.284415e-001, - -4.796962e-002, - 4.363935e+000, - 8.217971e-001, - -1.099082e+000, - -2.001688e-001, - 7.365077e-001, - 1.068489e-001, - -5.005434e+000, - 1.508145e+000, - 8.181497e-002, - 3.226865e+000, - 4.999418e-001, - // albedo 0, turbidity 2 - -1.416143e+000, - -5.515006e-001, - -7.045898e+000, - 7.448161e+000, - -4.504075e-002, - 5.055437e-001, - -1.378949e-006, - 2.955475e+000, - 6.184716e-001, - -1.698183e+000, - -8.272914e-001, - 9.984388e-001, - -2.511235e-001, - -9.262675e-002, - 5.681534e-001, - 5.377123e-003, - 1.631048e+000, - 1.137691e-001, - -9.234085e-001, - -2.165404e-002, - 6.483039e-002, - -8.535145e-001, - -2.497457e-001, - 1.695057e-001, - -3.410225e-002, - 6.726925e+000, - 1.331197e+000, - -1.265077e+000, - -5.034231e-001, - 1.196547e+000, - 3.666463e-001, - -3.960044e-001, - 1.404008e+000, - 1.129300e-001, - -2.644439e+000, - 1.103356e-001, - -1.008210e+000, - -1.455232e-001, - 7.347739e-001, - 2.462433e-002, - -2.534587e+000, - 3.088590e-001, - -6.687136e-002, - 3.786007e+000, - 9.578369e-001, - -1.076840e+000, - -1.851501e-001, - 7.341818e-001, - -2.658571e-003, - -5.001762e+000, - 1.275390e+000, - 1.277410e-001, - 3.223315e+000, - 5.147659e-001, - // albedo 0, turbidity 3 - -1.449526e+000, - -5.738159e-001, - -8.976383e+000, - 9.275142e+000, - -3.157845e-002, - 5.011970e-001, - -1.218363e-006, - 3.001006e+000, - 5.662190e-001, - -1.748840e+000, - -9.338946e-001, - 5.557460e-002, - 9.451626e-001, - -6.929558e-002, - 5.458365e-001, - 5.505399e-003, - 8.818793e-001, - 2.135274e-001, - -8.369988e-001, - 1.127967e-001, - 8.846958e-001, - -2.467908e+000, - -8.394011e-002, - 1.684067e-001, - -3.352743e-002, - 7.957386e+000, - 1.297777e+000, - -1.284515e+000, - -5.332365e-001, - 5.511261e-001, - 1.702784e+000, - -6.616281e-001, - 1.349449e+000, - 1.269152e-001, - -3.247373e+000, - 2.115827e-001, - -9.889637e-001, - -9.962819e-002, - 6.096776e-001, - -8.472749e-001, - 7.672924e-001, - 7.425160e-002, - 2.113714e-002, - 4.990637e+000, - 8.274585e-001, - -1.093910e+000, - -2.211349e-001, - 6.959659e-001, - 3.423174e-001, - -5.004213e+000, - 1.347201e+000, - 1.198192e-001, - 2.547517e+000, - 6.329489e-001, - // albedo 0, turbidity 4 - -1.394462e+000, - -5.287733e-001, - -8.095187e+000, - 8.076613e+000, - -1.275227e-002, - 1.916790e-001, - 4.741296e-002, - 3.145140e+000, - 5.071760e-001, - -2.234192e+000, - -1.437079e+000, - -5.734544e-001, - 1.248687e+000, - -4.136344e-002, - 7.671749e-001, - -1.273584e-002, - 4.751894e-001, - 4.116995e-001, - -4.063889e-001, - 4.920785e-001, - 3.865520e-001, - 2.254008e-001, - -1.618861e-001, - 1.950875e-001, - -8.622479e-002, - 3.836900e+000, - 1.108189e+000, - -1.366924e+000, - -4.557853e-001, - -6.731417e-001, - -3.011452e-001, - 2.413069e-001, - 1.404821e+000, - 1.920278e-001, - 6.394529e+000, - 4.219713e-001, - -9.128947e-001, - 1.980978e-002, - 5.119874e-001, - 8.027541e-002, - -3.680159e+000, - 6.597416e-001, - 3.853339e-002, - 3.969131e+000, - 8.351942e-001, - -1.162856e+000, - -3.606511e-001, - 7.055795e-001, - -2.702137e-003, - 4.777294e-001, - -7.722331e-001, - 3.446509e-001, - 1.186834e+000, - 5.118539e-001, - // albedo 0, turbidity 5 - -1.563353e+000, - -6.916347e-001, - -4.154766e+001, - 4.181703e+001, - -5.673370e-003, - 4.344900e-001, - 1.839829e-003, - 2.669278e+000, - 5.021266e-001, - -1.948172e+000, - -1.080669e+000, - 1.082552e+001, - -1.034262e+001, - -1.196421e-002, - 3.895739e-001, - 5.621831e-002, - 1.347130e+000, - 4.561106e-001, - -9.155219e-001, - -1.456265e-001, - -2.177275e+000, - 2.079788e+000, - -2.154465e-002, - 7.743816e-001, - -2.181642e-001, - 4.897704e+000, - 1.035464e+000, - -1.010898e+000, - -4.425431e-002, - 3.067880e-001, - -6.899235e-001, - -1.891895e-001, - 3.015686e-001, - 4.236422e-001, - 1.901582e+000, - 3.916662e-001, - -1.159005e+000, - -4.048136e-001, - 5.385745e-001, - 3.423651e-001, - 1.474365e-001, - 3.516065e-001, - 2.564260e-003, - 1.815518e+000, - 7.634079e-001, - -1.081675e+000, - -2.556981e-001, - 6.544471e-001, - 4.093649e-001, - -3.215201e+000, - 9.116400e-001, - 1.406660e-001, - 1.869407e+000, - 6.968119e-001, - // albedo 0, turbidity 6 - -1.561484e+000, - -7.153039e-001, - -1.623772e+001, - 1.650713e+001, - -1.394913e-002, - 4.467465e-001, - 9.613464e-004, - 2.564429e+000, - 5.363746e-001, - -2.308050e+000, - -1.314851e+000, - -1.484346e+000, - 1.928705e+000, - -2.164130e-002, - 2.817711e-001, - 7.177671e-002, - 1.146387e+000, - 3.025595e-001, - -4.886429e-001, - 8.279799e-002, - 2.432876e+000, - -2.276257e+000, - -4.799742e-002, - 9.362010e-001, - -2.753669e-001, - 4.784291e+000, - 1.180593e+000, - -1.306115e+000, - -1.759650e-001, - -1.392008e+000, - 3.119302e-001, - -2.268673e-001, - 8.336951e-002, - 5.250725e-001, - 2.534962e+000, - 2.800244e-001, - -1.016608e+000, - -3.429911e-001, - 5.659470e-001, - 9.044333e-001, - 7.387499e-002, - 4.267609e-001, - -4.165623e-002, - 1.452779e+000, - 8.409560e-001, - -1.127637e+000, - -2.854231e-001, - 4.933964e-001, - -3.379287e-003, - -1.181893e+000, - 8.164171e-001, - 1.910509e-001, - 1.979338e+000, - 6.658885e-001, - // albedo 0, turbidity 7 - -1.675310e+000, - -8.020443e-001, - -1.136130e+001, - 1.159861e+001, - -1.871156e-002, - 4.151400e-001, - -1.940992e-006, - 2.486322e+000, - 5.256426e-001, - -2.071301e+000, - -1.175325e+000, - 1.789426e+000, - -1.455233e+000, - -2.855906e-002, - 3.218745e-001, - 7.776969e-002, - 1.431615e+000, - 3.478887e-001, - -1.093503e+000, - -4.120496e-001, - -8.598647e-002, - 4.564844e-001, - -1.231980e-001, - 7.992132e-001, - -2.910745e-001, - 3.881502e+000, - 1.064658e+000, - -7.736128e-001, - 2.385498e-001, - -7.867818e-001, - -6.009723e-001, - -1.808566e-001, - -8.796429e-003, - 5.412620e-001, - 2.991552e+000, - 4.008143e-001, - -1.259083e+000, - -5.300975e-001, - 5.418031e-001, - 1.150966e+000, - -7.553821e-001, - 5.991000e-001, - -2.344718e-003, - 1.097939e+000, - 7.756612e-001, - -1.094148e+000, - -3.178958e-001, - 4.126954e-001, - 3.591106e-001, - -1.415744e+000, - 3.908399e-001, - 1.806147e-001, - 1.584959e+000, - 6.862009e-001, - // albedo 0, turbidity 8 - -1.815485e+000, - -9.306778e-001, - -1.249527e+001, - 1.271288e+001, - -1.497209e-002, - 3.576353e-001, - -2.464284e-006, - 2.326460e+000, - 5.655414e-001, - -2.225570e+000, - -1.213627e+000, - 6.082472e+000, - -5.907562e+000, - -2.446452e-002, - 2.113558e-001, - 7.708802e-002, - 1.647556e+000, - 2.416155e-001, - -1.439532e+000, - -8.666475e-001, - -2.734807e+000, - 3.355265e+000, - -1.311068e-001, - 1.048703e+000, - -2.887025e-001, - 3.419973e+000, - 1.146322e+000, - -5.599890e-001, - 4.437236e-001, - 1.582320e-001, - -2.000110e+000, - -2.859304e-001, - -5.600631e-001, - 5.382793e-001, - 1.986387e+000, - 3.455121e-001, - -1.319304e+000, - -6.466246e-001, - 5.684685e-001, - 2.050330e+000, - -2.796053e+000, - 1.001659e+000, - -1.161356e-002, - 9.737235e-001, - 8.101246e-001, - -1.097281e+000, - -3.336023e-001, - 1.781708e-001, - 1.733079e+000, - -1.378806e+000, - -1.870394e-001, - 1.997578e-001, - 1.456148e+000, - 6.791796e-001, - // albedo 0, turbidity 9 - -2.208666e+000, - -1.219745e+000, - -7.548669e+000, - 7.680830e+000, - -2.012473e-002, - 3.627866e-001, - -2.906182e-006, - 2.147138e+000, - 6.340095e-001, - -1.967348e+000, - -9.528057e-001, - 4.171590e+000, - -4.002838e+000, - -5.074552e-002, - 1.581866e-001, - 5.920106e-002, - 1.981564e+000, - 1.023257e-001, - -3.150304e+000, - -2.193706e+000, - -2.016165e+000, - 2.374337e+000, - -6.793058e-002, - 9.623811e-001, - -2.195022e-001, - 2.736885e+000, - 1.252161e+000, - 4.737094e-001, - 1.067875e+000, - -1.003861e-001, - -1.566752e+000, - -1.217264e+000, - -4.270598e-001, - 3.968055e-001, - 1.234108e+000, - 3.105789e-001, - -1.706975e+000, - -9.607442e-001, - 7.140098e-001, - 3.981202e+000, - -3.521433e+000, - 6.308820e-001, - 5.140937e-002, - 7.435120e-001, - 8.074305e-001, - -1.012042e+000, - -3.372525e-001, - 2.589450e-002, - 1.768224e+000, - -1.059990e+000, - -1.299077e-001, - 1.790337e-001, - 1.091012e+000, - 6.873854e-001, - // albedo 0, turbidity 10 - -2.912541e+000, - -1.677524e+000, - -3.843452e+000, - 3.954207e+000, - -3.414327e-002, - 2.945890e-001, - -4.245832e-006, - 1.934337e+000, - 7.258748e-001, - -1.567383e+000, - -8.279686e-001, - 1.690940e+000, - -1.413268e+000, - -1.216792e-001, - 7.332798e-002, - 4.862765e-002, - 2.034766e+000, - -5.041561e-002, - -6.058613e+000, - -3.509207e+000, - -6.312870e-001, - -4.558316e-002, - 6.168891e-002, - 8.153413e-001, - -1.686845e-001, - 2.670227e+000, - 1.362906e+000, - 1.347177e+000, - 9.821888e-001, - -9.242155e-001, - 5.851576e-001, - -1.897421e+000, - -2.729487e-002, - 2.866724e-001, - 7.306238e-001, - 2.792136e-001, - -1.810783e+000, - -1.027512e+000, - 1.216071e+000, - 5.270108e+000, - -3.887149e+000, - 6.193256e-002, - 2.774610e-002, - 1.484756e-001, - 8.033249e-001, - -9.801965e-001, - -3.375841e-001, - -3.004804e-001, - 1.385754e+000, - -6.834540e-001, - 5.827734e-002, - 2.268309e-001, - 1.028696e+000, - 6.797371e-001, - // albedo 1, turbidity 1 - -1.345260e+000, - -5.085528e-001, - -6.052009e+000, - 6.604590e+000, - -4.300752e-002, - 4.745234e-001, - 6.591457e-003, - 2.595142e+000, - 5.013653e-001, - -1.573525e+000, - -7.133524e-001, - -1.671346e+000, - 2.693205e+000, - -7.828763e-002, - 2.915699e-001, - 1.795879e-002, - 1.469445e+000, - 4.927472e-001, - -1.013665e+000, - -1.731419e-001, - 2.043423e+000, - -2.919634e+000, - -1.020807e-001, - 5.467619e-001, - -4.041481e-002, - 5.853992e+000, - 5.272064e-001, - -1.173191e+000, - -3.964683e-001, - 1.097258e+000, - 1.509973e+000, - -5.675641e-001, - 9.815927e-001, - 6.962319e-002, - -3.358210e+000, - 4.263117e-001, - -1.003507e+000, - -1.124908e-001, - 1.030642e+000, - -5.357088e-001, - 6.114201e-001, - 1.628414e-001, - -5.701497e-002, - 4.541126e+000, - 8.084996e-001, - -1.071959e+000, - -1.567262e-001, - 9.923029e-001, - 1.457160e-001, - -4.742907e+000, - 7.280970e-001, - 6.770360e-002, - 3.919300e+000, - 4.999529e-001, - // albedo 1, turbidity 2 - -1.399982e+000, - -5.538549e-001, - -6.983148e+000, - 7.513966e+000, - -3.358417e-002, - 3.667027e-001, - 1.158837e-002, - 2.499680e+000, - 5.598537e-001, - -1.602839e+000, - -7.835806e-001, - 1.200264e+000, - -1.454290e-001, - -7.431927e-002, - 5.374263e-001, - 9.505505e-004, - 1.096167e+000, - 2.185838e-001, - -9.587294e-001, - -6.134134e-002, - 2.234030e-001, - -8.115395e-001, - -2.344054e-001, - 2.018782e-001, - -4.192332e-002, - 6.331499e+000, - 1.353587e+000, - -1.166832e+000, - -4.057833e-001, - 1.461335e+000, - 3.165401e-001, - -3.245858e-001, - 1.199323e+000, - 1.100274e-001, - -2.727373e+000, - 5.329788e-002, - -1.023178e+000, - -1.351631e-001, - 9.944251e-001, - 2.103341e-002, - -2.460318e+000, - 5.136074e-003, - -5.267951e-002, - 4.097235e+000, - 9.388837e-001, - -1.071426e+000, - -1.726491e-001, - 1.048949e+000, - -2.624840e-003, - -4.993124e+000, - 6.621513e-001, - 7.801931e-002, - 3.227750e+000, - 5.363265e-001, - // albedo 1, turbidity 3 - -1.362723e+000, - -5.257224e-001, - -1.325130e+001, - 1.374641e+001, - -1.971887e-002, - 4.480379e-001, - -9.588735e-007, - 2.679516e+000, - 5.628531e-001, - -1.824466e+000, - -9.877790e-001, - 4.631069e+000, - -3.630521e+000, - -4.340325e-002, - 3.913450e-001, - 3.415899e-002, - 4.746800e-001, - 2.022772e-001, - -6.435267e-001, - 1.629762e-001, - -1.452097e+000, - 8.028761e-001, - -9.611017e-002, - 4.267105e-001, - -1.023573e-001, - 6.652106e+000, - 1.406057e+000, - -1.400277e+000, - -5.150235e-001, - 1.752017e+000, - -1.699743e-001, - -3.411643e-001, - 8.465596e-001, - 2.127075e-001, - -2.235971e+000, - 4.728189e-002, - -9.044866e-001, - -7.979493e-002, - 8.298122e-001, - -5.604698e-002, - -1.433761e+000, - 1.011757e-001, - -7.175544e-002, - 4.243075e+000, - 9.588179e-001, - -1.115618e+000, - -2.148000e-001, - 1.109081e+000, - 2.661209e-001, - -5.008111e+000, - 6.333048e-001, - 9.274718e-002, - 2.494529e+000, - 5.890657e-001, - // albedo 1, turbidity 4 - -1.389611e+000, - -5.579886e-001, - -1.045229e+001, - 1.092342e+001, - -2.282772e-002, - 4.054079e-001, - 2.781558e-003, - 2.578484e+000, - 5.372706e-001, - -1.893851e+000, - -1.116122e+000, - 2.111553e+000, - -8.775468e-001, - -5.640158e-002, - 5.399894e-001, - 1.929352e-002, - -5.585557e-002, - 2.870402e-001, - -7.015617e-001, - 1.884526e-001, - -1.660273e-001, - -8.785899e-001, - -5.471987e-002, - 1.787856e-001, - -9.958870e-002, - 7.207213e+000, - 1.277933e+000, - -1.279075e+000, - -4.794032e-001, - 9.037342e-001, - 6.225399e-001, - -6.592270e-001, - 9.474313e-001, - 2.524811e-001, - -2.485658e+000, - 2.050401e-001, - -9.744212e-001, - -9.899254e-002, - 9.474600e-001, - -2.536639e-001, - 5.390432e-001, - -8.465488e-002, - -3.140532e-002, - 4.512343e+000, - 8.530654e-001, - -1.093264e+000, - -2.115594e-001, - 9.876876e-001, - 7.531309e-002, - -5.003648e+000, - 6.719560e-001, - 1.111699e-001, - 2.412349e+000, - 6.482966e-001, - // albedo 1, turbidity 5 - -1.410458e+000, - -5.905263e-001, - -4.146328e+001, - 4.190254e+001, - -5.607421e-003, - 4.437719e-001, - -1.948391e-006, - 2.496743e+000, - 5.031933e-001, - -1.817258e+000, - -9.848495e-001, - 1.089217e+001, - -1.028029e+001, - -1.221684e-002, - 3.317008e-001, - 5.060062e-002, - 1.198443e+000, - 4.449482e-001, - -8.920534e-001, - -8.835804e-002, - -2.111594e+000, - 2.083599e+000, - -1.507800e-002, - 6.993567e-001, - -1.987686e-001, - 4.793539e+000, - 1.072586e+000, - -1.048633e+000, - -1.110825e-001, - 5.438710e-001, - -6.707296e-001, - -1.825365e-001, - 2.307221e-001, - 4.056218e-001, - 1.886912e+000, - 3.579576e-001, - -1.094223e+000, - -3.084727e-001, - 9.739595e-001, - 3.972140e-001, - 1.511647e-001, - 2.788218e-001, - -6.279180e-002, - 1.866444e+000, - 7.995203e-001, - -1.078162e+000, - -2.176197e-001, - 1.088756e+000, - 4.329413e-001, - -3.209490e+000, - 8.364785e-001, - 7.689785e-002, - 1.943182e+000, - 7.150615e-001, - // albedo 1, turbidity 6 - -1.455846e+000, - -6.322333e-001, - -1.618289e+001, - 1.656258e+001, - -1.280603e-002, - 4.130359e-001, - -9.061644e-007, - 2.461391e+000, - 5.315915e-001, - -2.222251e+000, - -1.233356e+000, - -1.454954e+000, - 1.957432e+000, - -1.730555e-002, - 2.418496e-001, - 7.240262e-002, - 1.061939e+000, - 3.148474e-001, - -4.536196e-001, - 1.457295e-001, - 2.483934e+000, - -2.244550e+000, - -4.593767e-002, - 8.967621e-001, - -2.712877e-001, - 4.732142e+000, - 1.188839e+000, - -1.277343e+000, - -2.046024e-001, - -1.229720e+000, - 3.977256e-001, - -2.209195e-001, - 6.033235e-002, - 5.267707e-001, - 2.536445e+000, - 2.759606e-001, - -1.029833e+000, - -2.979843e-001, - 8.742883e-001, - 1.037710e+000, - 1.350257e-001, - 4.066094e-001, - -1.376375e-001, - 1.500753e+000, - 8.676699e-001, - -1.095935e+000, - -2.211775e-001, - 9.320585e-001, - 8.955212e-002, - -1.113388e+000, - 7.909911e-001, - 1.393848e-001, - 2.057146e+000, - 6.699739e-001, - // albedo 1, turbidity 7 - -1.571831e+000, - -7.466353e-001, - -1.226063e+001, - 1.265995e+001, - -1.514083e-002, - 3.639653e-001, - -2.504287e-006, - 2.204454e+000, - 5.468861e-001, - -2.235398e+000, - -1.371434e+000, - 1.787996e+000, - -1.073965e+000, - -2.503530e-002, - 2.143584e-001, - 7.703453e-002, - 5.207181e-001, - 2.714312e-001, - -6.944677e-001, - -7.243136e-002, - -6.193104e-001, - 9.567440e-001, - -6.317194e-002, - 8.881508e-001, - -2.783301e-001, - 4.224532e+000, - 1.192802e+000, - -1.133391e+000, - -9.811942e-002, - 2.312721e-001, - -1.100585e+000, - -3.655097e-001, - 2.268787e-003, - 5.074358e-001, - 1.512457e+000, - 3.165593e-001, - -1.057051e+000, - -3.424797e-001, - 9.536822e-001, - 1.034064e+000, - 6.413292e-001, - 1.165363e-001, - -4.248128e-002, - 1.592803e+000, - 7.875911e-001, - -1.096695e+000, - -2.745143e-001, - 1.077920e+000, - -8.435082e-004, - -3.715956e+000, - 5.197900e-001, - 1.171467e-001, - 1.236912e+000, - 6.915287e-001, - // albedo 1, turbidity 8 - -1.711623e+000, - -9.023881e-001, - -9.799257e+000, - 1.022040e+001, - -1.708447e-002, - 3.309925e-001, - -3.241111e-006, - 1.932295e+000, - 5.844205e-001, - -2.351937e+000, - -1.340391e+000, - 6.329976e+000, - -6.054139e+000, - -2.843868e-002, - 2.298301e-001, - 7.698142e-002, - 1.109800e+000, - 1.863187e-001, - -1.141314e+000, - -6.670322e-001, - -3.262632e+000, - 4.551521e+000, - -8.614941e-002, - 8.058038e-001, - -2.791051e-001, - 3.084281e+000, - 1.236638e+000, - -7.950557e-001, - 2.489854e-001, - 9.966347e-001, - -3.391737e+000, - -7.235716e-001, - -2.155609e-001, - 5.126659e-001, - 1.452322e+000, - 2.882812e-001, - -1.182289e+000, - -5.192524e-001, - 9.672941e-001, - 3.091448e+000, - -4.193043e+000, - 4.051469e-001, - -5.708309e-002, - 9.386723e-001, - 8.208828e-001, - -1.080579e+000, - -2.918654e-001, - 9.499317e-001, - 2.856082e+000, - -2.256007e+000, - 1.377750e-002, - 1.012914e-001, - 9.716489e-001, - 6.832750e-001, - // albedo 1, turbidity 9 - -1.964781e+000, - -1.162652e+000, - -6.074737e+000, - 6.497797e+000, - -2.595660e-002, - 3.222936e-001, - -3.220871e-006, - 1.685891e+000, - 6.501551e-001, - -2.352213e+000, - -1.199539e+000, - 4.248376e+000, - -3.876965e+000, - -6.837923e-002, - 1.764412e-001, - 5.514810e-002, - 1.442736e+000, - 6.979575e-002, - -2.560247e+000, - -1.883591e+000, - -1.916723e+000, - 2.598994e+000, - -2.372381e-002, - 8.442578e-001, - -2.063113e-001, - 2.359942e+000, - 1.287838e+000, - 7.281064e-002, - 7.835433e-001, - 1.380748e-001, - -2.065580e+000, - -1.696648e+000, - -4.575316e-001, - 3.840004e-001, - 9.397056e-001, - 3.103904e-001, - -1.444446e+000, - -7.662151e-001, - 1.364103e+000, - 4.930232e+000, - -4.455564e+000, - 6.735458e-001, - -4.052978e-003, - 3.194173e-001, - 7.842959e-001, - -1.039666e+000, - -3.171617e-001, - 7.295920e-001, - 2.813846e+000, - -1.561230e+000, - -4.128303e-001, - 1.004149e-001, - 6.653613e-001, - 6.980277e-001, - // albedo 1, turbidity 10 - -2.999915e+000, - -1.721740e+000, - -4.796494e+000, - 5.021888e+000, - -2.163250e-002, - 3.309183e-001, - -4.051804e-006, - 1.645464e+000, - 7.145890e-001, - -1.673162e+000, - -1.056666e+000, - 3.209766e+000, - -2.559187e+000, - -7.456364e-002, - 6.215063e-002, - 4.469425e-002, - 1.242757e+000, - -1.580590e-002, - -5.775475e+000, - -3.239700e+000, - -1.356432e+000, - 1.099950e+000, - -9.497509e-002, - 7.121875e-001, - -1.656838e-001, - 2.553396e+000, - 1.286227e+000, - 1.241869e+000, - 6.671222e-001, - -4.156007e-001, - -8.167921e-001, - -1.037816e+000, - 5.950065e-002, - 3.114868e-001, - 6.414114e-001, - 3.677503e-001, - -1.580126e+000, - -7.852349e-001, - 1.749569e+000, - 5.987990e+000, - -5.075133e+000, - -4.693815e-002, - -5.106759e-002, - -9.755925e-001, - 7.440092e-001, - -9.732917e-001, - -1.939297e-001, - 2.709367e-001, - 1.352990e+000, - -9.040352e-001, - 5.181217e-003, - 2.302437e-001, - 1.506500e+000, - 6.840186e-001, -}; - -double datasetRad440[] = -{ - // albedo 0, turbidity 1 - 7.613884e-002, - 1.581858e-001, - -3.252313e-001, - 1.408388e+000, - 1.093508e+000, - 1.105128e+000, - // albedo 0, turbidity 2 - 7.451325e-002, - 1.653037e-001, - -3.543027e-001, - 1.446460e+000, - 1.123936e+000, - 1.120306e+000, - // albedo 0, turbidity 3 - 7.325740e-002, - 1.688718e-001, - -3.766044e-001, - 1.452725e+000, - 1.233697e+000, - 1.114182e+000, - // albedo 0, turbidity 4 - 7.006396e-002, - 1.789290e-001, - -4.219204e-001, - 1.486303e+000, - 1.346055e+000, - 1.149056e+000, - // albedo 0, turbidity 5 - 6.762868e-002, - 1.817070e-001, - -4.365127e-001, - 1.447243e+000, - 1.512287e+000, - 1.169631e+000, - // albedo 0, turbidity 6 - 6.626986e-002, - 1.809348e-001, - -4.282658e-001, - 1.370862e+000, - 1.678637e+000, - 1.152996e+000, - // albedo 0, turbidity 7 - 6.401686e-002, - 1.780154e-001, - -4.181312e-001, - 1.277002e+000, - 1.859575e+000, - 1.188609e+000, - // albedo 0, turbidity 8 - 6.135668e-002, - 1.657981e-001, - -3.619501e-001, - 1.033618e+000, - 2.215815e+000, - 1.212149e+000, - // albedo 0, turbidity 9 - 5.748273e-002, - 1.355812e-001, - -2.235179e-001, - 5.729304e-001, - 2.749632e+000, - 1.260376e+000, - // albedo 0, turbidity 10 - 5.281658e-002, - 8.825729e-002, - -1.614986e-002, - -6.617688e-002, - 3.338203e+000, - 1.388015e+000, - // albedo 1, turbidity 1 - 8.998056e-002, - 1.443958e-001, - -1.578024e-001, - 9.105446e-001, - 2.422784e+000, - 2.318869e+000, - // albedo 1, turbidity 2 - 8.900756e-002, - 1.464687e-001, - -1.698990e-001, - 9.161196e-001, - 2.474653e+000, - 2.320503e+000, - // albedo 1, turbidity 3 - 8.660660e-002, - 1.471943e-001, - -1.748207e-001, - 8.777832e-001, - 2.613680e+000, - 2.294963e+000, - // albedo 1, turbidity 4 - 8.354844e-002, - 1.514437e-001, - -1.998722e-001, - 8.658343e-001, - 2.736118e+000, - 2.318493e+000, - // albedo 1, turbidity 5 - 8.008078e-002, - 1.493295e-001, - -1.908957e-001, - 7.640320e-001, - 2.948273e+000, - 2.290225e+000, - // albedo 1, turbidity 6 - 7.810981e-002, - 1.519283e-001, - -2.057773e-001, - 7.437529e-001, - 3.011442e+000, - 2.311845e+000, - // albedo 1, turbidity 7 - 7.545684e-002, - 1.465048e-001, - -1.818352e-001, - 6.105517e-001, - 3.203786e+000, - 2.300408e+000, - // albedo 1, turbidity 8 - 7.157199e-002, - 1.298467e-001, - -1.131010e-001, - 3.426176e-001, - 3.527560e+000, - 2.258120e+000, - // albedo 1, turbidity 9 - 6.612079e-002, - 1.024330e-001, - 3.299415e-003, - -6.376105e-002, - 3.909414e+000, - 2.240796e+000, - // albedo 1, turbidity 10 - 5.976123e-002, - 5.941061e-002, - 1.695098e-001, - -5.778192e-001, - 4.222691e+000, - 2.269388e+000, -}; - -double dataset480[] = -{ - // albedo 0, turbidity 1 - -1.397312e+000, - -5.327311e-001, - -5.456059e+000, - 5.777674e+000, - -5.111575e-002, - 4.730804e-001, - 7.375500e-003, - 3.032806e+000, - 5.181890e-001, - -1.561639e+000, - -7.024946e-001, - -2.140322e+000, - 2.841761e+000, - -8.846023e-002, - 5.529005e-001, - 6.219344e-003, - 2.004212e+000, - 3.701256e-001, - -1.047473e+000, - -1.152734e-001, - 2.275873e+000, - -3.020347e+000, - -1.739218e-001, - 2.250142e-001, - -2.731776e-002, - 6.659723e+000, - 1.067495e+000, - -1.298483e+000, - -5.788209e-001, - 4.906412e-001, - 1.522576e+000, - -5.650061e-001, - 1.544707e+000, - 4.638003e-002, - -3.742019e+000, - 2.485397e-001, - -9.485899e-001, - -7.383610e-002, - 1.039247e+000, - -4.744931e-001, - -1.822357e-001, - 2.284415e-001, - -4.796962e-002, - 4.363935e+000, - 8.217971e-001, - -1.099082e+000, - -2.001688e-001, - 7.365077e-001, - 1.068489e-001, - -5.005434e+000, - 1.508145e+000, - 8.181497e-002, - 3.226865e+000, - 4.999418e-001, - // albedo 0, turbidity 2 - -1.416143e+000, - -5.515006e-001, - -7.045898e+000, - 7.448161e+000, - -4.504075e-002, - 5.055437e-001, - -1.378949e-006, - 2.955475e+000, - 6.184716e-001, - -1.698183e+000, - -8.272914e-001, - 9.984388e-001, - -2.511235e-001, - -9.262675e-002, - 5.681534e-001, - 5.377123e-003, - 1.631048e+000, - 1.137691e-001, - -9.234085e-001, - -2.165404e-002, - 6.483039e-002, - -8.535145e-001, - -2.497457e-001, - 1.695057e-001, - -3.410225e-002, - 6.726925e+000, - 1.331197e+000, - -1.265077e+000, - -5.034231e-001, - 1.196547e+000, - 3.666463e-001, - -3.960044e-001, - 1.404008e+000, - 1.129300e-001, - -2.644439e+000, - 1.103356e-001, - -1.008210e+000, - -1.455232e-001, - 7.347739e-001, - 2.462433e-002, - -2.534587e+000, - 3.088590e-001, - -6.687136e-002, - 3.786007e+000, - 9.578369e-001, - -1.076840e+000, - -1.851501e-001, - 7.341818e-001, - -2.658571e-003, - -5.001762e+000, - 1.275390e+000, - 1.277410e-001, - 3.223315e+000, - 5.147659e-001, - // albedo 0, turbidity 3 - -1.449526e+000, - -5.738159e-001, - -8.976383e+000, - 9.275142e+000, - -3.157845e-002, - 5.011970e-001, - -1.218363e-006, - 3.001006e+000, - 5.662190e-001, - -1.748840e+000, - -9.338946e-001, - 5.557460e-002, - 9.451626e-001, - -6.929558e-002, - 5.458365e-001, - 5.505399e-003, - 8.818793e-001, - 2.135274e-001, - -8.369988e-001, - 1.127967e-001, - 8.846958e-001, - -2.467908e+000, - -8.394011e-002, - 1.684067e-001, - -3.352743e-002, - 7.957386e+000, - 1.297777e+000, - -1.284515e+000, - -5.332365e-001, - 5.511261e-001, - 1.702784e+000, - -6.616281e-001, - 1.349449e+000, - 1.269152e-001, - -3.247373e+000, - 2.115827e-001, - -9.889637e-001, - -9.962819e-002, - 6.096776e-001, - -8.472749e-001, - 7.672924e-001, - 7.425160e-002, - 2.113714e-002, - 4.990637e+000, - 8.274585e-001, - -1.093910e+000, - -2.211349e-001, - 6.959659e-001, - 3.423174e-001, - -5.004213e+000, - 1.347201e+000, - 1.198192e-001, - 2.547517e+000, - 6.329489e-001, - // albedo 0, turbidity 4 - -1.394462e+000, - -5.287733e-001, - -8.095187e+000, - 8.076613e+000, - -1.275227e-002, - 1.916790e-001, - 4.741296e-002, - 3.145140e+000, - 5.071760e-001, - -2.234192e+000, - -1.437079e+000, - -5.734544e-001, - 1.248687e+000, - -4.136344e-002, - 7.671749e-001, - -1.273584e-002, - 4.751894e-001, - 4.116995e-001, - -4.063889e-001, - 4.920785e-001, - 3.865520e-001, - 2.254008e-001, - -1.618861e-001, - 1.950875e-001, - -8.622479e-002, - 3.836900e+000, - 1.108189e+000, - -1.366924e+000, - -4.557853e-001, - -6.731417e-001, - -3.011452e-001, - 2.413069e-001, - 1.404821e+000, - 1.920278e-001, - 6.394529e+000, - 4.219713e-001, - -9.128947e-001, - 1.980978e-002, - 5.119874e-001, - 8.027541e-002, - -3.680159e+000, - 6.597416e-001, - 3.853339e-002, - 3.969131e+000, - 8.351942e-001, - -1.162856e+000, - -3.606511e-001, - 7.055795e-001, - -2.702137e-003, - 4.777294e-001, - -7.722331e-001, - 3.446509e-001, - 1.186834e+000, - 5.118539e-001, - // albedo 0, turbidity 5 - -1.563353e+000, - -6.916347e-001, - -4.154766e+001, - 4.181703e+001, - -5.673370e-003, - 4.344900e-001, - 1.839829e-003, - 2.669278e+000, - 5.021266e-001, - -1.948172e+000, - -1.080669e+000, - 1.082552e+001, - -1.034262e+001, - -1.196421e-002, - 3.895739e-001, - 5.621831e-002, - 1.347130e+000, - 4.561106e-001, - -9.155219e-001, - -1.456265e-001, - -2.177275e+000, - 2.079788e+000, - -2.154465e-002, - 7.743816e-001, - -2.181642e-001, - 4.897704e+000, - 1.035464e+000, - -1.010898e+000, - -4.425431e-002, - 3.067880e-001, - -6.899235e-001, - -1.891895e-001, - 3.015686e-001, - 4.236422e-001, - 1.901582e+000, - 3.916662e-001, - -1.159005e+000, - -4.048136e-001, - 5.385745e-001, - 3.423651e-001, - 1.474365e-001, - 3.516065e-001, - 2.564260e-003, - 1.815518e+000, - 7.634079e-001, - -1.081675e+000, - -2.556981e-001, - 6.544471e-001, - 4.093649e-001, - -3.215201e+000, - 9.116400e-001, - 1.406660e-001, - 1.869407e+000, - 6.968119e-001, - // albedo 0, turbidity 6 - -1.561484e+000, - -7.153039e-001, - -1.623772e+001, - 1.650713e+001, - -1.394913e-002, - 4.467465e-001, - 9.613464e-004, - 2.564429e+000, - 5.363746e-001, - -2.308050e+000, - -1.314851e+000, - -1.484346e+000, - 1.928705e+000, - -2.164130e-002, - 2.817711e-001, - 7.177671e-002, - 1.146387e+000, - 3.025595e-001, - -4.886429e-001, - 8.279799e-002, - 2.432876e+000, - -2.276257e+000, - -4.799742e-002, - 9.362010e-001, - -2.753669e-001, - 4.784291e+000, - 1.180593e+000, - -1.306115e+000, - -1.759650e-001, - -1.392008e+000, - 3.119302e-001, - -2.268673e-001, - 8.336951e-002, - 5.250725e-001, - 2.534962e+000, - 2.800244e-001, - -1.016608e+000, - -3.429911e-001, - 5.659470e-001, - 9.044333e-001, - 7.387499e-002, - 4.267609e-001, - -4.165623e-002, - 1.452779e+000, - 8.409560e-001, - -1.127637e+000, - -2.854231e-001, - 4.933964e-001, - -3.379287e-003, - -1.181893e+000, - 8.164171e-001, - 1.910509e-001, - 1.979338e+000, - 6.658885e-001, - // albedo 0, turbidity 7 - -1.675310e+000, - -8.020443e-001, - -1.136130e+001, - 1.159861e+001, - -1.871156e-002, - 4.151400e-001, - -1.940992e-006, - 2.486322e+000, - 5.256426e-001, - -2.071301e+000, - -1.175325e+000, - 1.789426e+000, - -1.455233e+000, - -2.855906e-002, - 3.218745e-001, - 7.776969e-002, - 1.431615e+000, - 3.478887e-001, - -1.093503e+000, - -4.120496e-001, - -8.598647e-002, - 4.564844e-001, - -1.231980e-001, - 7.992132e-001, - -2.910745e-001, - 3.881502e+000, - 1.064658e+000, - -7.736128e-001, - 2.385498e-001, - -7.867818e-001, - -6.009723e-001, - -1.808566e-001, - -8.796429e-003, - 5.412620e-001, - 2.991552e+000, - 4.008143e-001, - -1.259083e+000, - -5.300975e-001, - 5.418031e-001, - 1.150966e+000, - -7.553821e-001, - 5.991000e-001, - -2.344718e-003, - 1.097939e+000, - 7.756612e-001, - -1.094148e+000, - -3.178958e-001, - 4.126954e-001, - 3.591106e-001, - -1.415744e+000, - 3.908399e-001, - 1.806147e-001, - 1.584959e+000, - 6.862009e-001, - // albedo 0, turbidity 8 - -1.815485e+000, - -9.306778e-001, - -1.249527e+001, - 1.271288e+001, - -1.497209e-002, - 3.576353e-001, - -2.464284e-006, - 2.326460e+000, - 5.655414e-001, - -2.225570e+000, - -1.213627e+000, - 6.082472e+000, - -5.907562e+000, - -2.446452e-002, - 2.113558e-001, - 7.708802e-002, - 1.647556e+000, - 2.416155e-001, - -1.439532e+000, - -8.666475e-001, - -2.734807e+000, - 3.355265e+000, - -1.311068e-001, - 1.048703e+000, - -2.887025e-001, - 3.419973e+000, - 1.146322e+000, - -5.599890e-001, - 4.437236e-001, - 1.582320e-001, - -2.000110e+000, - -2.859304e-001, - -5.600631e-001, - 5.382793e-001, - 1.986387e+000, - 3.455121e-001, - -1.319304e+000, - -6.466246e-001, - 5.684685e-001, - 2.050330e+000, - -2.796053e+000, - 1.001659e+000, - -1.161356e-002, - 9.737235e-001, - 8.101246e-001, - -1.097281e+000, - -3.336023e-001, - 1.781708e-001, - 1.733079e+000, - -1.378806e+000, - -1.870394e-001, - 1.997578e-001, - 1.456148e+000, - 6.791796e-001, - // albedo 0, turbidity 9 - -2.208666e+000, - -1.219745e+000, - -7.548669e+000, - 7.680830e+000, - -2.012473e-002, - 3.627866e-001, - -2.906182e-006, - 2.147138e+000, - 6.340095e-001, - -1.967348e+000, - -9.528057e-001, - 4.171590e+000, - -4.002838e+000, - -5.074552e-002, - 1.581866e-001, - 5.920106e-002, - 1.981564e+000, - 1.023257e-001, - -3.150304e+000, - -2.193706e+000, - -2.016165e+000, - 2.374337e+000, - -6.793058e-002, - 9.623811e-001, - -2.195022e-001, - 2.736885e+000, - 1.252161e+000, - 4.737094e-001, - 1.067875e+000, - -1.003861e-001, - -1.566752e+000, - -1.217264e+000, - -4.270598e-001, - 3.968055e-001, - 1.234108e+000, - 3.105789e-001, - -1.706975e+000, - -9.607442e-001, - 7.140098e-001, - 3.981202e+000, - -3.521433e+000, - 6.308820e-001, - 5.140937e-002, - 7.435120e-001, - 8.074305e-001, - -1.012042e+000, - -3.372525e-001, - 2.589450e-002, - 1.768224e+000, - -1.059990e+000, - -1.299077e-001, - 1.790337e-001, - 1.091012e+000, - 6.873854e-001, - // albedo 0, turbidity 10 - -2.912541e+000, - -1.677524e+000, - -3.843452e+000, - 3.954207e+000, - -3.414327e-002, - 2.945890e-001, - -4.245832e-006, - 1.934337e+000, - 7.258748e-001, - -1.567383e+000, - -8.279686e-001, - 1.690940e+000, - -1.413268e+000, - -1.216792e-001, - 7.332798e-002, - 4.862765e-002, - 2.034766e+000, - -5.041561e-002, - -6.058613e+000, - -3.509207e+000, - -6.312870e-001, - -4.558316e-002, - 6.168891e-002, - 8.153413e-001, - -1.686845e-001, - 2.670227e+000, - 1.362906e+000, - 1.347177e+000, - 9.821888e-001, - -9.242155e-001, - 5.851576e-001, - -1.897421e+000, - -2.729487e-002, - 2.866724e-001, - 7.306238e-001, - 2.792136e-001, - -1.810783e+000, - -1.027512e+000, - 1.216071e+000, - 5.270108e+000, - -3.887149e+000, - 6.193256e-002, - 2.774610e-002, - 1.484756e-001, - 8.033249e-001, - -9.801965e-001, - -3.375841e-001, - -3.004804e-001, - 1.385754e+000, - -6.834540e-001, - 5.827734e-002, - 2.268309e-001, - 1.028696e+000, - 6.797371e-001, - // albedo 1, turbidity 1 - -1.345260e+000, - -5.085528e-001, - -6.052009e+000, - 6.604590e+000, - -4.300752e-002, - 4.745234e-001, - 6.591457e-003, - 2.595142e+000, - 5.013653e-001, - -1.573525e+000, - -7.133524e-001, - -1.671346e+000, - 2.693205e+000, - -7.828763e-002, - 2.915699e-001, - 1.795879e-002, - 1.469445e+000, - 4.927472e-001, - -1.013665e+000, - -1.731419e-001, - 2.043423e+000, - -2.919634e+000, - -1.020807e-001, - 5.467619e-001, - -4.041481e-002, - 5.853992e+000, - 5.272064e-001, - -1.173191e+000, - -3.964683e-001, - 1.097258e+000, - 1.509973e+000, - -5.675641e-001, - 9.815927e-001, - 6.962319e-002, - -3.358210e+000, - 4.263117e-001, - -1.003507e+000, - -1.124908e-001, - 1.030642e+000, - -5.357088e-001, - 6.114201e-001, - 1.628414e-001, - -5.701497e-002, - 4.541126e+000, - 8.084996e-001, - -1.071959e+000, - -1.567262e-001, - 9.923029e-001, - 1.457160e-001, - -4.742907e+000, - 7.280970e-001, - 6.770360e-002, - 3.919300e+000, - 4.999529e-001, - // albedo 1, turbidity 2 - -1.399982e+000, - -5.538549e-001, - -6.983148e+000, - 7.513966e+000, - -3.358417e-002, - 3.667027e-001, - 1.158837e-002, - 2.499680e+000, - 5.598537e-001, - -1.602839e+000, - -7.835806e-001, - 1.200264e+000, - -1.454290e-001, - -7.431927e-002, - 5.374263e-001, - 9.505505e-004, - 1.096167e+000, - 2.185838e-001, - -9.587294e-001, - -6.134134e-002, - 2.234030e-001, - -8.115395e-001, - -2.344054e-001, - 2.018782e-001, - -4.192332e-002, - 6.331499e+000, - 1.353587e+000, - -1.166832e+000, - -4.057833e-001, - 1.461335e+000, - 3.165401e-001, - -3.245858e-001, - 1.199323e+000, - 1.100274e-001, - -2.727373e+000, - 5.329788e-002, - -1.023178e+000, - -1.351631e-001, - 9.944251e-001, - 2.103341e-002, - -2.460318e+000, - 5.136074e-003, - -5.267951e-002, - 4.097235e+000, - 9.388837e-001, - -1.071426e+000, - -1.726491e-001, - 1.048949e+000, - -2.624840e-003, - -4.993124e+000, - 6.621513e-001, - 7.801931e-002, - 3.227750e+000, - 5.363265e-001, - // albedo 1, turbidity 3 - -1.362723e+000, - -5.257224e-001, - -1.325130e+001, - 1.374641e+001, - -1.971887e-002, - 4.480379e-001, - -9.588735e-007, - 2.679516e+000, - 5.628531e-001, - -1.824466e+000, - -9.877790e-001, - 4.631069e+000, - -3.630521e+000, - -4.340325e-002, - 3.913450e-001, - 3.415899e-002, - 4.746800e-001, - 2.022772e-001, - -6.435267e-001, - 1.629762e-001, - -1.452097e+000, - 8.028761e-001, - -9.611017e-002, - 4.267105e-001, - -1.023573e-001, - 6.652106e+000, - 1.406057e+000, - -1.400277e+000, - -5.150235e-001, - 1.752017e+000, - -1.699743e-001, - -3.411643e-001, - 8.465596e-001, - 2.127075e-001, - -2.235971e+000, - 4.728189e-002, - -9.044866e-001, - -7.979493e-002, - 8.298122e-001, - -5.604698e-002, - -1.433761e+000, - 1.011757e-001, - -7.175544e-002, - 4.243075e+000, - 9.588179e-001, - -1.115618e+000, - -2.148000e-001, - 1.109081e+000, - 2.661209e-001, - -5.008111e+000, - 6.333048e-001, - 9.274718e-002, - 2.494529e+000, - 5.890657e-001, - // albedo 1, turbidity 4 - -1.389611e+000, - -5.579886e-001, - -1.045229e+001, - 1.092342e+001, - -2.282772e-002, - 4.054079e-001, - 2.781558e-003, - 2.578484e+000, - 5.372706e-001, - -1.893851e+000, - -1.116122e+000, - 2.111553e+000, - -8.775468e-001, - -5.640158e-002, - 5.399894e-001, - 1.929352e-002, - -5.585557e-002, - 2.870402e-001, - -7.015617e-001, - 1.884526e-001, - -1.660273e-001, - -8.785899e-001, - -5.471987e-002, - 1.787856e-001, - -9.958870e-002, - 7.207213e+000, - 1.277933e+000, - -1.279075e+000, - -4.794032e-001, - 9.037342e-001, - 6.225399e-001, - -6.592270e-001, - 9.474313e-001, - 2.524811e-001, - -2.485658e+000, - 2.050401e-001, - -9.744212e-001, - -9.899254e-002, - 9.474600e-001, - -2.536639e-001, - 5.390432e-001, - -8.465488e-002, - -3.140532e-002, - 4.512343e+000, - 8.530654e-001, - -1.093264e+000, - -2.115594e-001, - 9.876876e-001, - 7.531309e-002, - -5.003648e+000, - 6.719560e-001, - 1.111699e-001, - 2.412349e+000, - 6.482966e-001, - // albedo 1, turbidity 5 - -1.410458e+000, - -5.905263e-001, - -4.146328e+001, - 4.190254e+001, - -5.607421e-003, - 4.437719e-001, - -1.948391e-006, - 2.496743e+000, - 5.031933e-001, - -1.817258e+000, - -9.848495e-001, - 1.089217e+001, - -1.028029e+001, - -1.221684e-002, - 3.317008e-001, - 5.060062e-002, - 1.198443e+000, - 4.449482e-001, - -8.920534e-001, - -8.835804e-002, - -2.111594e+000, - 2.083599e+000, - -1.507800e-002, - 6.993567e-001, - -1.987686e-001, - 4.793539e+000, - 1.072586e+000, - -1.048633e+000, - -1.110825e-001, - 5.438710e-001, - -6.707296e-001, - -1.825365e-001, - 2.307221e-001, - 4.056218e-001, - 1.886912e+000, - 3.579576e-001, - -1.094223e+000, - -3.084727e-001, - 9.739595e-001, - 3.972140e-001, - 1.511647e-001, - 2.788218e-001, - -6.279180e-002, - 1.866444e+000, - 7.995203e-001, - -1.078162e+000, - -2.176197e-001, - 1.088756e+000, - 4.329413e-001, - -3.209490e+000, - 8.364785e-001, - 7.689785e-002, - 1.943182e+000, - 7.150615e-001, - // albedo 1, turbidity 6 - -1.455846e+000, - -6.322333e-001, - -1.618289e+001, - 1.656258e+001, - -1.280603e-002, - 4.130359e-001, - -9.061644e-007, - 2.461391e+000, - 5.315915e-001, - -2.222251e+000, - -1.233356e+000, - -1.454954e+000, - 1.957432e+000, - -1.730555e-002, - 2.418496e-001, - 7.240262e-002, - 1.061939e+000, - 3.148474e-001, - -4.536196e-001, - 1.457295e-001, - 2.483934e+000, - -2.244550e+000, - -4.593767e-002, - 8.967621e-001, - -2.712877e-001, - 4.732142e+000, - 1.188839e+000, - -1.277343e+000, - -2.046024e-001, - -1.229720e+000, - 3.977256e-001, - -2.209195e-001, - 6.033235e-002, - 5.267707e-001, - 2.536445e+000, - 2.759606e-001, - -1.029833e+000, - -2.979843e-001, - 8.742883e-001, - 1.037710e+000, - 1.350257e-001, - 4.066094e-001, - -1.376375e-001, - 1.500753e+000, - 8.676699e-001, - -1.095935e+000, - -2.211775e-001, - 9.320585e-001, - 8.955212e-002, - -1.113388e+000, - 7.909911e-001, - 1.393848e-001, - 2.057146e+000, - 6.699739e-001, - // albedo 1, turbidity 7 - -1.571831e+000, - -7.466353e-001, - -1.226063e+001, - 1.265995e+001, - -1.514083e-002, - 3.639653e-001, - -2.504287e-006, - 2.204454e+000, - 5.468861e-001, - -2.235398e+000, - -1.371434e+000, - 1.787996e+000, - -1.073965e+000, - -2.503530e-002, - 2.143584e-001, - 7.703453e-002, - 5.207181e-001, - 2.714312e-001, - -6.944677e-001, - -7.243136e-002, - -6.193104e-001, - 9.567440e-001, - -6.317194e-002, - 8.881508e-001, - -2.783301e-001, - 4.224532e+000, - 1.192802e+000, - -1.133391e+000, - -9.811942e-002, - 2.312721e-001, - -1.100585e+000, - -3.655097e-001, - 2.268787e-003, - 5.074358e-001, - 1.512457e+000, - 3.165593e-001, - -1.057051e+000, - -3.424797e-001, - 9.536822e-001, - 1.034064e+000, - 6.413292e-001, - 1.165363e-001, - -4.248128e-002, - 1.592803e+000, - 7.875911e-001, - -1.096695e+000, - -2.745143e-001, - 1.077920e+000, - -8.435082e-004, - -3.715956e+000, - 5.197900e-001, - 1.171467e-001, - 1.236912e+000, - 6.915287e-001, - // albedo 1, turbidity 8 - -1.711623e+000, - -9.023881e-001, - -9.799257e+000, - 1.022040e+001, - -1.708447e-002, - 3.309925e-001, - -3.241111e-006, - 1.932295e+000, - 5.844205e-001, - -2.351937e+000, - -1.340391e+000, - 6.329976e+000, - -6.054139e+000, - -2.843868e-002, - 2.298301e-001, - 7.698142e-002, - 1.109800e+000, - 1.863187e-001, - -1.141314e+000, - -6.670322e-001, - -3.262632e+000, - 4.551521e+000, - -8.614941e-002, - 8.058038e-001, - -2.791051e-001, - 3.084281e+000, - 1.236638e+000, - -7.950557e-001, - 2.489854e-001, - 9.966347e-001, - -3.391737e+000, - -7.235716e-001, - -2.155609e-001, - 5.126659e-001, - 1.452322e+000, - 2.882812e-001, - -1.182289e+000, - -5.192524e-001, - 9.672941e-001, - 3.091448e+000, - -4.193043e+000, - 4.051469e-001, - -5.708309e-002, - 9.386723e-001, - 8.208828e-001, - -1.080579e+000, - -2.918654e-001, - 9.499317e-001, - 2.856082e+000, - -2.256007e+000, - 1.377750e-002, - 1.012914e-001, - 9.716489e-001, - 6.832750e-001, - // albedo 1, turbidity 9 - -1.964781e+000, - -1.162652e+000, - -6.074737e+000, - 6.497797e+000, - -2.595660e-002, - 3.222936e-001, - -3.220871e-006, - 1.685891e+000, - 6.501551e-001, - -2.352213e+000, - -1.199539e+000, - 4.248376e+000, - -3.876965e+000, - -6.837923e-002, - 1.764412e-001, - 5.514810e-002, - 1.442736e+000, - 6.979575e-002, - -2.560247e+000, - -1.883591e+000, - -1.916723e+000, - 2.598994e+000, - -2.372381e-002, - 8.442578e-001, - -2.063113e-001, - 2.359942e+000, - 1.287838e+000, - 7.281064e-002, - 7.835433e-001, - 1.380748e-001, - -2.065580e+000, - -1.696648e+000, - -4.575316e-001, - 3.840004e-001, - 9.397056e-001, - 3.103904e-001, - -1.444446e+000, - -7.662151e-001, - 1.364103e+000, - 4.930232e+000, - -4.455564e+000, - 6.735458e-001, - -4.052978e-003, - 3.194173e-001, - 7.842959e-001, - -1.039666e+000, - -3.171617e-001, - 7.295920e-001, - 2.813846e+000, - -1.561230e+000, - -4.128303e-001, - 1.004149e-001, - 6.653613e-001, - 6.980277e-001, - // albedo 1, turbidity 10 - -2.999915e+000, - -1.721740e+000, - -4.796494e+000, - 5.021888e+000, - -2.163250e-002, - 3.309183e-001, - -4.051804e-006, - 1.645464e+000, - 7.145890e-001, - -1.673162e+000, - -1.056666e+000, - 3.209766e+000, - -2.559187e+000, - -7.456364e-002, - 6.215063e-002, - 4.469425e-002, - 1.242757e+000, - -1.580590e-002, - -5.775475e+000, - -3.239700e+000, - -1.356432e+000, - 1.099950e+000, - -9.497509e-002, - 7.121875e-001, - -1.656838e-001, - 2.553396e+000, - 1.286227e+000, - 1.241869e+000, - 6.671222e-001, - -4.156007e-001, - -8.167921e-001, - -1.037816e+000, - 5.950065e-002, - 3.114868e-001, - 6.414114e-001, - 3.677503e-001, - -1.580126e+000, - -7.852349e-001, - 1.749569e+000, - 5.987990e+000, - -5.075133e+000, - -4.693815e-002, - -5.106759e-002, - -9.755925e-001, - 7.440092e-001, - -9.732917e-001, - -1.939297e-001, - 2.709367e-001, - 1.352990e+000, - -9.040352e-001, - 5.181217e-003, - 2.302437e-001, - 1.506500e+000, - 6.840186e-001, -}; - -double datasetRad480[] = -{ - // albedo 0, turbidity 1 - 1.106836e-001, - 1.617557e-001, - -2.223712e-001, - 1.629241e+000, - 8.626553e-001, - 1.011117e+000, - // albedo 0, turbidity 2 - 1.068095e-001, - 1.807606e-001, - -3.107154e-001, - 1.794334e+000, - 8.357312e-001, - 1.058704e+000, - // albedo 0, turbidity 3 - 1.023979e-001, - 1.935925e-001, - -3.821700e-001, - 1.903843e+000, - 9.506144e-001, - 1.055374e+000, - // albedo 0, turbidity 4 - 9.750983e-002, - 2.221893e-001, - -5.210713e-001, - 2.109239e+000, - 1.050698e+000, - 1.115763e+000, - // albedo 0, turbidity 5 - 9.111285e-002, - 2.453301e-001, - -6.358660e-001, - 2.264126e+000, - 1.142400e+000, - 1.203246e+000, - // albedo 0, turbidity 6 - 8.801765e-002, - 2.536783e-001, - -6.724997e-001, - 2.260727e+000, - 1.303234e+000, - 1.215945e+000, - // albedo 0, turbidity 7 - 8.383362e-002, - 2.570991e-001, - -6.868821e-001, - 2.164623e+000, - 1.598177e+000, - 1.240969e+000, - // albedo 0, turbidity 8 - 7.810199e-002, - 2.499359e-001, - -6.529595e-001, - 1.904702e+000, - 2.066657e+000, - 1.302165e+000, - // albedo 0, turbidity 9 - 7.178799e-002, - 2.126681e-001, - -4.768538e-001, - 1.271237e+000, - 2.836735e+000, - 1.395516e+000, - // albedo 0, turbidity 10 - 6.560434e-002, - 1.422030e-001, - -1.620349e-001, - 2.862457e-001, - 3.797996e+000, - 1.559196e+000, - // albedo 1, turbidity 1 - 1.239585e-001, - 1.691730e-001, - -1.347675e-001, - 1.316695e+000, - 2.106735e+000, - 2.217214e+000, - // albedo 1, turbidity 2 - 1.214136e-001, - 1.827941e-001, - -2.037588e-001, - 1.440769e+000, - 2.108289e+000, - 2.269001e+000, - // albedo 1, turbidity 3 - 1.162070e-001, - 2.002146e-001, - -2.955303e-001, - 1.591777e+000, - 2.141568e+000, - 2.342411e+000, - // albedo 1, turbidity 4 - 1.107892e-001, - 2.106751e-001, - -3.612057e-001, - 1.626070e+000, - 2.411162e+000, - 2.325309e+000, - // albedo 1, turbidity 5 - 1.050623e-001, - 2.192739e-001, - -4.115423e-001, - 1.626936e+000, - 2.636868e+000, - 2.361264e+000, - // albedo 1, turbidity 6 - 1.025933e-001, - 2.228143e-001, - -4.341956e-001, - 1.588611e+000, - 2.810589e+000, - 2.370193e+000, - // albedo 1, turbidity 7 - 9.714317e-002, - 2.251753e-001, - -4.411182e-001, - 1.471839e+000, - 3.071992e+000, - 2.407635e+000, - // albedo 1, turbidity 8 - 9.030970e-002, - 2.107053e-001, - -3.728364e-001, - 1.119804e+000, - 3.583579e+000, - 2.403320e+000, - // albedo 1, turbidity 9 - 8.372172e-002, - 1.708661e-001, - -2.025603e-001, - 5.031154e-001, - 4.251905e+000, - 2.428124e+000, - // albedo 1, turbidity 10 - 7.503295e-002, - 1.014131e-001, - 8.782860e-002, - -4.050759e-001, - 4.993351e+000, - 2.471109e+000, -}; - -double dataset520[] = -{ - // albedo 0, turbidity 1 - -1.171338e+000, - -2.379456e-001, - -6.515446e+000, - 7.133235e+000, - -5.382867e-002, - 6.889982e-001, - 4.250983e-002, - 4.471437e+000, - 5.087463e-001, - -1.193029e+000, - -2.445141e-001, - -4.311723e-001, - 1.019354e+000, - -1.281643e-001, - 7.837279e-001, - 2.609613e-002, - 5.965800e+000, - 4.381607e-001, - -1.165299e+000, - -2.503239e-001, - 3.829843e+000, - -2.234083e+000, - -4.693988e-001, - 1.045109e+000, - -6.241707e-002, - 2.623310e-001, - 7.500398e-001, - -1.077288e+000, - -2.659342e-001, - -7.565678e-002, - 1.145086e+000, - -2.316655e-002, - 1.564941e+000, - 9.375322e-002, - -7.476929e-001, - 6.076913e-001, - -1.075530e+000, - -1.232648e-001, - 1.877081e+000, - -1.186427e-001, - -2.748628e+000, - 1.249377e+000, - -1.085780e-001, - 3.838331e+000, - 8.601227e-001, - -1.067002e+000, - -1.572453e-001, - 1.350156e+000, - 3.140948e-003, - -3.277283e+000, - 1.488404e+000, - 1.127058e-001, - 2.655730e+000, - 4.999138e-001, - // albedo 0, turbidity 2 - -1.175145e+000, - -2.454528e-001, - -8.173280e+000, - 8.622722e+000, - -3.895019e-002, - 6.739096e-001, - 6.622835e-002, - 4.450872e+000, - 5.061382e-001, - -1.226543e+000, - -2.979950e-001, - 3.102814e+000, - -2.662701e+000, - -1.012309e-001, - 5.142095e-001, - 4.939276e-002, - 5.007851e+000, - 4.179865e-001, - -1.075743e+000, - -1.267529e-001, - 1.017884e-001, - 4.839556e-001, - -4.025119e-001, - 1.120466e+000, - -5.059103e-002, - 3.601070e+000, - 1.104232e+000, - -1.104008e+000, - -2.079352e-001, - 1.094572e+000, - 1.147058e+000, - -1.516726e-001, - 1.526097e+000, - 1.922554e-001, - 4.060614e-001, - 2.975787e-001, - -1.080135e+000, - -1.942481e-001, - 1.409056e+000, - -3.800384e+000, - -7.125701e+000, - 9.731220e-001, - -7.312793e-002, - 2.377810e+000, - 9.223131e-001, - -1.066280e+000, - -1.421591e-001, - 1.272936e+000, - 7.891881e+000, - -3.626975e+000, - 1.294678e+000, - 1.331475e-001, - 2.986127e+000, - 5.316962e-001, - // albedo 0, turbidity 3 - -1.210057e+000, - -2.827640e-001, - -5.179186e+000, - 5.514430e+000, - -5.638504e-002, - 6.656727e-001, - 5.417868e-002, - 4.216550e+000, - 5.495231e-001, - -1.311087e+000, - -3.921139e-001, - 1.436554e+000, - -7.051260e-001, - -1.462714e-001, - 2.604620e-001, - 5.771570e-002, - 3.493766e+000, - 5.041164e-001, - -9.705912e-001, - -4.316197e-002, - 5.357225e-001, - -1.399982e+000, - -3.407923e-001, - 1.585242e+000, - -6.423039e-002, - 5.338193e+000, - 9.835385e-001, - -1.177697e+000, - -1.893604e-001, - -5.207247e-002, - 4.572666e+000, - -5.523178e-001, - 2.677765e-001, - 3.872768e-001, - 1.978123e+000, - 4.095974e-001, - -1.029420e+000, - -2.105096e-001, - 1.657176e+000, - -1.028655e+001, - -7.725428e+000, - 1.707122e+000, - -7.681108e-002, - 1.074660e+000, - 8.312794e-001, - -1.082084e+000, - -1.321893e-001, - 8.487219e-001, - 1.858290e+001, - -3.172656e+000, - 6.915801e-001, - 1.905927e-001, - 3.901473e+000, - 6.144141e-001, - // albedo 0, turbidity 4 - -1.259854e+000, - -3.329630e-001, - -2.270176e+000, - 2.357599e+000, - -9.019414e-002, - 5.779792e-001, - 7.706039e-002, - 3.971905e+000, - 4.999172e-001, - -1.413220e+000, - -5.430979e-001, - -1.715627e-001, - 1.151561e+000, - -2.318489e-001, - 2.791441e-001, - 1.306646e-002, - 1.794583e+000, - 6.167457e-001, - -9.926840e-001, - 2.303697e-002, - 7.306051e-001, - -2.124879e+000, - -2.221853e-001, - 1.635982e+000, - -8.684297e-002, - 7.621636e+000, - 9.443863e-001, - -1.113409e+000, - -2.409045e-001, - -1.979662e-001, - 5.089736e+000, - -2.071840e+000, - -6.954891e-001, - 5.966469e-001, - -1.346819e+000, - 3.752080e-001, - -1.055595e+000, - -1.703680e-001, - 1.089771e+000, - -1.041463e+001, - -4.687545e+000, - 2.149733e+000, - -1.118987e-001, - 3.558810e+000, - 8.741214e-001, - -1.070779e+000, - -1.445161e-001, - 6.385947e-001, - 1.695445e+001, - -3.724275e+000, - -3.465499e-002, - 3.645376e-001, - 3.232410e+000, - 6.285788e-001, - // albedo 0, turbidity 5 - -1.297812e+000, - -3.805039e-001, - -1.474455e+000, - 1.558382e+000, - -1.292485e-001, - 5.206238e-001, - 7.166147e-002, - 3.651150e+000, - 4.998781e-001, - -1.680599e+000, - -8.036751e-001, - 8.267015e-001, - -2.109200e-001, - -4.326451e-001, - 3.843930e-001, - 5.207142e-002, - 6.938520e-001, - 4.752346e-001, - -8.467684e-001, - 1.620743e-001, - -5.520307e-001, - 8.293798e-001, - 8.728132e-001, - 9.075147e-001, - -1.734859e-001, - 7.815672e+000, - 1.126843e+000, - -1.182658e+000, - -3.290773e-001, - 1.442907e-001, - -1.705529e+000, - -1.186174e+001, - -1.903040e-001, - 7.826049e-001, - -1.497409e+000, - 2.238945e-001, - -1.032316e+000, - -1.590425e-001, - 9.289968e-001, - 1.217091e+001, - 1.274690e+000, - 1.400296e+000, - -3.047612e-001, - 2.805729e+000, - 9.198989e-001, - -1.073060e+000, - -1.623303e-001, - 3.798836e-001, - 2.223272e+000, - -4.660805e+000, - -1.172357e-001, - 5.306455e-001, - 3.105520e+000, - 6.420864e-001, - // albedo 0, turbidity 6 - -1.374072e+000, - -4.453408e-001, - -1.081601e+000, - 1.104314e+000, - -1.730612e-001, - 5.074812e-001, - 5.784588e-002, - 3.488150e+000, - 5.037112e-001, - -1.704606e+000, - -8.629255e-001, - -3.905040e-001, - 2.152742e+000, - -6.716606e-001, - 5.638527e-001, - -5.967161e-003, - 4.886292e-001, - 4.385432e-001, - -9.651511e-001, - 1.186522e-001, - 3.421397e-001, - -4.626814e+000, - 9.716770e-001, - 7.579588e-001, - -1.064476e-002, - 8.154392e+000, - 1.103676e+000, - -1.067172e+000, - -3.214506e-001, - -3.934660e-001, - 9.254630e+000, - -3.599603e+000, - -1.624031e-001, - 5.478446e-001, - -2.781628e+000, - 2.905848e-001, - -1.063218e+000, - -1.412572e-001, - 8.153795e-001, - -1.467486e+001, - -2.020170e+000, - 1.094685e+000, - 7.786265e-002, - 3.719129e+000, - 8.826899e-001, - -1.070058e+000, - -1.684172e-001, - 2.225147e-001, - 2.345795e+001, - -4.342429e+000, - -4.661816e-002, - 3.545794e-001, - 3.051769e+000, - 6.567686e-001, - // albedo 0, turbidity 7 - -1.397244e+000, - -4.874379e-001, - -2.217129e+000, - 2.415780e+000, - -1.039290e-001, - 5.444596e-001, - 2.296795e-002, - 3.242776e+000, - 5.575920e-001, - -1.943117e+000, - -1.042293e+000, - 1.936194e+000, - -7.807718e-001, - -4.753317e-001, - 6.351817e-001, - 3.357824e-002, - 3.221570e-001, - 2.277390e-001, - -1.007469e+000, - 4.283560e-002, - -1.830583e+000, - -1.613949e-001, - 5.103059e-001, - 1.830881e-001, - -6.111472e-002, - 7.698471e+000, - 1.322151e+000, - -9.885823e-001, - -2.796329e-001, - 9.017585e-001, - 9.500529e-001, - -8.751757e+000, - 5.198673e-001, - 6.111910e-001, - -3.165369e+000, - 1.193651e-001, - -1.105054e+000, - -1.835801e-001, - 2.099263e-001, - 3.626436e+000, - 4.241807e-001, - 2.861915e-002, - -3.245808e-002, - 3.560209e+000, - 9.581069e-001, - -1.061783e+000, - -1.955111e-001, - 3.405765e-001, - 1.682185e+001, - -4.868111e+000, - 3.591669e-001, - 3.518670e-001, - 2.163473e+000, - 6.425305e-001, - // albedo 0, turbidity 8 - -1.452178e+000, - -5.662818e-001, - -1.492883e+000, - 1.742373e+000, - -1.894966e-001, - 6.129524e-001, - 2.370115e-006, - 3.042560e+000, - 7.988979e-001, - -2.146318e+000, - -1.176122e+000, - 1.480664e+000, - 1.846814e-001, - -9.003192e-001, - 2.819986e-001, - -6.858291e-003, - 5.447940e-001, - -2.109028e-001, - -1.465359e+000, - -3.055025e-001, - -1.747423e+000, - -2.538335e+000, - 6.082904e-001, - 6.523133e-001, - 1.426957e-001, - 6.921276e+000, - 1.637843e+000, - -7.135462e-001, - -2.351046e-001, - 1.111445e+000, - 2.259275e+000, - -7.853810e+000, - -3.006083e-001, - 3.100486e-001, - -4.047366e+000, - -3.732308e-002, - -1.188030e+000, - -2.177467e-001, - 8.022451e-002, - 8.746107e+000, - -6.824017e-001, - 5.968181e-001, - 7.024883e-002, - 3.164998e+000, - 9.909158e-001, - -1.038065e+000, - -1.989059e-001, - 1.630845e-001, - 1.261969e+001, - -4.006594e+000, - -3.213161e-001, - 3.948313e-001, - 2.040063e+000, - 6.364874e-001, - // albedo 0, turbidity 9 - -1.789980e+000, - -8.450140e-001, - -2.591234e+000, - 2.769295e+000, - -8.338896e-002, - 5.620741e-001, - -8.271253e-006, - 2.531602e+000, - 9.001159e-001, - -1.468080e+000, - -7.426812e-001, - 2.369441e+000, - -1.635443e+000, - -3.560365e-001, - 2.130482e-001, - -2.124886e-003, - 1.863478e+000, - -3.426455e-001, - -3.911974e+000, - -1.873182e+000, - -2.428294e+000, - 1.019786e+000, - 2.178584e-001, - 9.599962e-001, - 3.763471e-002, - 4.121844e+000, - 1.708236e+000, - 5.986629e-001, - 4.160930e-001, - 1.499968e+000, - -4.234635e+000, - -7.153272e+000, - -8.777277e-001, - 4.276508e-001, - -2.268730e+000, - -9.278595e-002, - -1.581111e+000, - -5.414559e-001, - 3.449756e-002, - 2.095624e+001, - -1.717086e+000, - 6.913385e-001, - -1.227380e-001, - 1.401315e+000, - 9.723511e-001, - -9.931334e-001, - -2.191364e-001, - 1.647201e-001, - 2.954460e+000, - -2.889774e+000, - -4.261816e-001, - 4.166838e-001, - 1.370273e+000, - 6.561021e-001, - // albedo 0, turbidity 10 - -2.368520e+000, - -1.245557e+000, - -3.473878e+000, - 3.511922e+000, - -4.076311e-002, - 4.228576e-001, - -8.136079e-006, - 2.268992e+000, - 9.001266e-001, - -1.498984e+000, - -9.483364e-001, - 2.970418e+000, - -2.003511e+000, - -3.005171e-001, - 3.242320e-001, - 6.724107e-003, - 1.693927e+000, - -2.648941e-001, - -6.258071e+000, - -2.616781e+000, - -3.186408e+000, - -3.570416e-002, - 5.972101e-001, - 5.638927e-001, - -8.227073e-002, - 3.805214e+000, - 1.486701e+000, - 7.183470e-001, - -1.332710e-001, - 1.495243e+000, - 3.859652e+000, - -5.605361e+000, - 3.808435e-001, - 4.998100e-001, - -1.207866e+000, - 1.082917e-001, - -1.422091e+000, - -5.984032e-001, - 2.297508e-001, - 1.726780e+000, - -6.684454e-001, - -1.024912e+000, - -1.967199e-001, - -3.214571e-001, - 8.922300e-001, - -1.018798e+000, - -2.003211e-001, - 5.344788e-002, - 1.474717e+001, - -4.025558e+000, - 9.010150e-001, - 3.605184e-001, - 1.504726e+000, - 6.720300e-001, - // albedo 1, turbidity 1 - -1.150179e+000, - -2.233430e-001, - -6.725138e+000, - 7.601675e+000, - -6.176639e-002, - 7.963802e-001, - 2.476816e-002, - 4.311811e+000, - 5.070506e-001, - -1.184017e+000, - -2.330060e-001, - 1.903877e-001, - 4.425206e-001, - -1.173330e-001, - 2.459899e-001, - 6.799957e-002, - 5.710763e+000, - 4.639162e-001, - -1.129855e+000, - -2.313999e-001, - 3.299978e+000, - -1.861830e+000, - -3.626476e-001, - 1.858194e+000, - -9.845844e-002, - 6.523143e-001, - 6.278178e-001, - -1.090030e+000, - -2.445577e-001, - 4.546659e-001, - 9.848860e-001, - -4.044981e-001, - 3.532740e-001, - 1.409977e-001, - -7.724273e-001, - 2.901711e-001, - -1.048192e+000, - -1.048720e-001, - 2.079951e+000, - -7.519850e-002, - -1.451911e+000, - 1.354243e+000, - -1.508252e-001, - 4.159135e+000, - 8.685415e-001, - -1.081709e+000, - -1.496534e-001, - 1.433416e+000, - -8.415186e-005, - -3.147387e+000, - 6.964893e-002, - 1.345400e-001, - 3.372381e+000, - 5.369835e-001, - // albedo 1, turbidity 2 - -1.163329e+000, - -2.341078e-001, - -8.084459e+000, - 8.765664e+000, - -4.227908e-002, - 6.476384e-001, - 5.575993e-002, - 4.291594e+000, - 5.023286e-001, - -1.234281e+000, - -3.038288e-001, - 3.304120e+000, - -2.565467e+000, - -1.080261e-001, - 5.183037e-001, - 2.633070e-002, - 4.459108e+000, - 4.526356e-001, - -1.015235e+000, - -1.003890e-001, - 2.834337e-001, - 4.230399e-001, - -4.060874e-001, - 1.119918e+000, - -2.357803e-002, - 3.215664e+000, - 1.089777e+000, - -1.171497e+000, - -2.465867e-001, - 1.219344e+000, - 1.184120e+000, - -6.451707e-002, - 1.087554e+000, - 1.687897e-001, - 4.111776e-001, - 2.471485e-001, - -1.010262e+000, - -1.337460e-001, - 1.953577e+000, - -3.761183e+000, - -7.089300e+000, - 5.963565e-001, - -8.297304e-002, - 2.741114e+000, - 9.771003e-001, - -1.102719e+000, - -1.647974e-001, - 1.510508e+000, - 7.573412e+000, - -3.431528e+000, - 3.953995e-001, - 6.793657e-002, - 2.744717e+000, - 5.018037e-001, - // albedo 1, turbidity 3 - -1.186728e+000, - -2.648685e-001, - -7.540497e+000, - 8.152868e+000, - -4.363040e-002, - 6.836829e-001, - 3.221451e-002, - 4.013046e+000, - 6.004295e-001, - -1.302626e+000, - -3.904258e-001, - 3.431819e+000, - -2.975541e+000, - -7.666020e-002, - 2.464561e-002, - 1.054528e-001, - 3.161765e+000, - 3.544185e-001, - -9.615438e-001, - -4.842098e-002, - -4.756207e-001, - 9.408081e-001, - -3.108222e-001, - 1.708814e+000, - -1.241215e-001, - 4.416567e+000, - 1.207369e+000, - -1.178731e+000, - -1.824314e-001, - 8.266664e-001, - 1.001614e+000, - 3.024332e-001, - 3.291998e-002, - 4.178949e-001, - 2.532397e+000, - 2.014902e-001, - -1.018913e+000, - -2.016682e-001, - 2.132865e+000, - -3.323938e+000, - -8.751654e+000, - 1.240780e+000, - -1.801214e-001, - 6.145479e-001, - 9.457932e-001, - -1.101603e+000, - -1.521834e-001, - 1.348807e+000, - 5.640453e+000, - -2.695953e+000, - -7.496627e-002, - 1.719606e-001, - 3.175091e+000, - 5.968939e-001, - // albedo 1, turbidity 4 - -1.229694e+000, - -3.167126e-001, - -3.548352e+000, - 3.846155e+000, - -5.028022e-002, - 5.061677e-001, - 7.498335e-002, - 3.626295e+000, - 4.999424e-001, - -1.436439e+000, - -5.562909e-001, - 8.010070e-001, - 3.290243e-001, - -1.385772e-001, - 4.556269e-002, - 2.571935e-002, - 1.623385e+000, - 5.222220e-001, - -8.876360e-001, - 5.717281e-002, - 4.713905e-001, - -1.668970e+000, - -3.199243e-001, - 2.050582e+000, - -7.783980e-002, - 6.117601e+000, - 1.070445e+000, - -1.235363e+000, - -2.778190e-001, - 1.577638e-001, - 3.982457e+000, - -2.266885e-002, - -1.411004e+000, - 5.570462e-001, - 1.740426e-001, - 2.747952e-001, - -9.785264e-001, - -1.458813e-001, - 1.996989e+000, - -7.517409e+000, - -6.602487e+000, - 2.387711e+000, - -1.996484e-001, - 2.112759e+000, - 9.289256e-001, - -1.117781e+000, - -1.699302e-001, - 1.214480e+000, - 1.141083e+001, - -3.253445e+000, - -8.156284e-001, - 2.248021e-001, - 2.860500e+000, - 6.151694e-001, - // albedo 1, turbidity 5 - -1.290523e+000, - -3.813116e-001, - -6.728796e-001, - 1.007366e+000, - -2.068030e-001, - 4.422499e-001, - 6.016254e-002, - 3.218056e+000, - 5.068822e-001, - -1.614452e+000, - -7.953309e-001, - 5.977485e-001, - 1.056365e+000, - -8.402403e-001, - 3.713919e-001, - 3.164720e-002, - -2.526630e-001, - 4.072481e-001, - -8.377211e-001, - 2.276878e-001, - -3.232539e-001, - -2.390300e+000, - 2.127070e+000, - 7.169058e-001, - -4.032313e-002, - 9.072383e+000, - 1.188019e+000, - -1.226600e+000, - -4.426177e-001, - 6.370202e-001, - 3.846913e+000, - -1.128719e+001, - 3.667721e-002, - 5.000027e-001, - -4.192432e+000, - 2.376054e-001, - -9.852235e-001, - -5.890324e-002, - 1.529937e+000, - 4.301220e+000, - -1.839775e+000, - 8.993504e-001, - -1.040866e-001, - 4.636528e+000, - 8.466710e-001, - -1.118112e+000, - -2.040213e-001, - 1.203227e+000, - 7.252102e+000, - -4.515955e+000, - -2.398231e-001, - 2.375855e-001, - 1.923160e+000, - 6.645269e-001, - // albedo 1, turbidity 6 - -1.330626e+000, - -4.272516e-001, - -1.317682e+000, - 1.650847e+000, - -1.192771e-001, - 4.904191e-001, - 4.074827e-002, - 3.015846e+000, - 5.271835e-001, - -1.711989e+000, - -8.644776e-001, - 4.057135e-001, - 9.037139e-001, - -3.100084e-001, - 6.317697e-002, - 1.065625e-001, - 9.226240e-002, - 3.022474e-001, - -8.465894e-001, - 1.652715e-001, - -2.532361e-001, - -2.422693e+000, - 3.144841e-001, - 1.839347e+000, - -2.818162e-001, - 7.856667e+000, - 1.387977e+000, - -1.192114e+000, - -3.830569e-001, - 5.124751e-001, - 7.280034e+000, - -2.610477e+000, - -1.832768e+000, - 9.101904e-001, - -3.349116e+000, - -7.313079e-002, - -1.011026e+000, - -1.061217e-001, - 1.357854e+000, - -1.496195e+001, - -2.180975e+000, - 2.484329e+000, - -3.239225e-001, - 3.899425e+000, - 1.179264e+000, - -1.106228e+000, - -1.927917e-001, - 1.179701e+000, - 2.379834e+001, - -4.870211e+000, - -1.290713e+000, - 2.854422e-001, - 2.078973e+000, - 5.128625e-001, - // albedo 1, turbidity 7 - -1.342815e+000, - -4.571984e-001, - -1.803521e+000, - 2.229578e+000, - -1.196587e-001, - 5.694038e-001, - 1.194687e-002, - 2.950110e+000, - 5.961719e-001, - -1.937297e+000, - -1.078823e+000, - 2.178495e+000, - -1.251900e+000, - -3.577875e-001, - 2.553915e-001, - 8.081142e-002, - -4.723152e-001, - 1.174551e-001, - -9.292675e-001, - 1.125551e-001, - -1.708569e+000, - 1.832840e+000, - 5.150525e-001, - 9.287322e-001, - -1.746780e-001, - 7.793815e+000, - 1.498832e+000, - -1.058850e+000, - -3.495292e-001, - 1.135259e+000, - -4.069374e+000, - -9.727412e+000, - -7.670653e-001, - 7.550431e-001, - -4.105064e+000, - -5.149354e-002, - -1.079472e+000, - -1.399984e-001, - 1.058148e+000, - 1.392667e+001, - -6.245343e-001, - 1.192083e+000, - -2.578858e-001, - 4.030723e+000, - 1.025069e+000, - -1.093159e+000, - -2.150433e-001, - 1.210946e+000, - 3.349246e+000, - -4.030345e+000, - -5.362971e-001, - 2.886842e-001, - 1.192375e+000, - 6.363049e-001, - // albedo 1, turbidity 8 - -1.408172e+000, - -5.491538e-001, - -1.360219e+000, - 1.738150e+000, - -1.505117e-001, - 6.030014e-001, - -6.866289e-006, - 2.656101e+000, - 9.001849e-001, - -2.171702e+000, - -1.231851e+000, - 1.860400e+000, - 3.613146e-002, - -7.300078e-001, - 1.974371e-001, - -5.351202e-003, - -1.443434e-001, - -3.779605e-001, - -1.284657e+000, - -1.935945e-001, - -1.494185e+000, - -2.070689e+000, - 2.974020e-001, - 8.048383e-001, - 1.097715e-001, - 6.907960e+000, - 1.819367e+000, - -8.288598e-001, - -3.374917e-001, - 1.029011e+000, - 1.347088e+000, - -7.655126e+000, - -8.232335e-001, - 3.722934e-001, - -4.847675e+000, - -1.864913e-001, - -1.146031e+000, - -1.480097e-001, - 1.051391e+000, - 8.396865e+000, - -1.407010e+000, - 1.240651e+000, - -3.942068e-002, - 3.291458e+000, - 1.060212e+000, - -1.069599e+000, - -2.047532e-001, - 9.437765e-001, - 1.189879e+001, - -4.026750e+000, - -9.372092e-001, - 2.463501e-001, - 1.782902e+000, - 6.235027e-001, - // albedo 1, turbidity 9 - -1.793508e+000, - -8.986075e-001, - -2.346395e+000, - 2.775625e+000, - -7.052213e-002, - 5.349215e-001, - -7.457456e-006, - 1.901248e+000, - 9.001358e-001, - -1.629402e+000, - -8.273410e-001, - 2.270930e+000, - -1.125114e+000, - -3.562854e-001, - 1.948044e-001, - 1.703882e-003, - 1.426305e+000, - -3.737234e-001, - -3.443431e+000, - -1.686429e+000, - -1.515036e+000, - -6.941862e-001, - 4.976814e-001, - 1.144483e+000, - -4.277285e-002, - 3.662107e+000, - 1.819972e+000, - 3.138150e-001, - 2.426714e-001, - 7.717995e-001, - 2.759520e+000, - -7.216077e+000, - -1.389093e+000, - 5.332838e-001, - -2.316313e+000, - -2.636593e-001, - -1.449802e+000, - -4.017798e-001, - 1.133688e+000, - 2.114337e+000, - 6.227965e-002, - 1.378688e+000, - -1.759313e-001, - 9.446579e-001, - 1.165017e+000, - -1.049420e+000, - -2.614006e-001, - 9.473363e-001, - 1.531288e+001, - -4.714989e+000, - -8.992715e-001, - 2.423509e-001, - 9.148027e-001, - 5.650972e-001, - // albedo 1, turbidity 10 - -2.382332e+000, - -1.290760e+000, - -3.316114e+000, - 3.587059e+000, - -3.748522e-002, - 4.468493e-001, - -7.212198e-006, - 1.789208e+000, - 9.001267e-001, - -1.333339e+000, - -9.355999e-001, - 3.281313e+000, - -2.263103e+000, - -2.499164e-001, - 1.591742e-001, - 8.117981e-003, - 1.345396e+000, - -2.689053e-001, - -6.612658e+000, - -2.809230e+000, - -2.744061e+000, - 1.005261e+000, - 4.216309e-001, - 1.055067e+000, - -9.021558e-002, - 2.940833e+000, - 1.495270e+000, - 1.251113e+000, - 5.915517e-002, - 1.142846e+000, - -2.807371e-001, - -5.335452e+000, - -6.967012e-001, - 5.129558e-001, - -5.264483e-001, - 1.137786e-001, - -1.517768e+000, - -5.807447e-001, - 1.179477e+000, - 1.252252e+001, - -2.305973e+000, - 2.184822e-001, - -3.092917e-001, - -1.524373e+000, - 8.724218e-001, - -1.037889e+000, - -2.065780e-001, - 6.479897e-001, - 4.786848e-002, - -2.348244e+000, - -3.053490e-002, - 4.059549e-001, - 1.313102e+000, - 6.713422e-001, -}; - -double datasetRad520[] = -{ - // albedo 0, turbidity 1 - 1.181575e-001, - 1.246023e-001, - -1.496294e-002, - 1.265571e+000, - 5.482287e-001, - 7.505452e-001, - // albedo 0, turbidity 2 - 1.160347e-001, - 1.329016e-001, - -8.180703e-002, - 1.418742e+000, - 5.748010e-001, - 7.627669e-001, - // albedo 0, turbidity 3 - 1.101719e-001, - 1.655258e-001, - -2.430655e-001, - 1.733940e+000, - 5.362119e-001, - 8.264630e-001, - // albedo 0, turbidity 4 - 1.022463e-001, - 1.983788e-001, - -4.272497e-001, - 2.067266e+000, - 6.024013e-001, - 8.848645e-001, - // albedo 0, turbidity 5 - 9.401543e-002, - 2.296749e-001, - -5.842591e-001, - 2.315439e+000, - 6.927636e-001, - 9.577504e-001, - // albedo 0, turbidity 6 - 8.955011e-002, - 2.492320e-001, - -6.780498e-001, - 2.434256e+000, - 7.757295e-001, - 1.006068e+000, - // albedo 0, turbidity 7 - 8.389384e-002, - 2.633396e-001, - -7.506875e-001, - 2.457562e+000, - 1.011233e+000, - 1.057894e+000, - // albedo 0, turbidity 8 - 7.664395e-002, - 2.660639e-001, - -7.551246e-001, - 2.244514e+000, - 1.510373e+000, - 1.106036e+000, - // albedo 0, turbidity 9 - 6.960593e-002, - 2.348760e-001, - -6.096824e-001, - 1.645028e+000, - 2.296756e+000, - 1.213901e+000, - // albedo 0, turbidity 10 - 6.281555e-002, - 1.600404e-001, - -2.694273e-001, - 5.733989e-001, - 3.363154e+000, - 1.382931e+000, - // albedo 1, turbidity 1 - 1.293373e-001, - 1.448979e-001, - -1.489032e-002, - 1.190124e+000, - 1.374518e+000, - 1.715324e+000, - // albedo 1, turbidity 2 - 1.257474e-001, - 1.593917e-001, - -9.494839e-002, - 1.358060e+000, - 1.387390e+000, - 1.759057e+000, - // albedo 1, turbidity 3 - 1.205675e-001, - 1.785796e-001, - -2.085014e-001, - 1.577640e+000, - 1.442267e+000, - 1.810434e+000, - // albedo 1, turbidity 4 - 1.120654e-001, - 2.046914e-001, - -3.577105e-001, - 1.820708e+000, - 1.593538e+000, - 1.871408e+000, - // albedo 1, turbidity 5 - 1.051588e-001, - 2.239942e-001, - -4.688978e-001, - 1.950392e+000, - 1.793172e+000, - 1.930285e+000, - // albedo 1, turbidity 6 - 1.008210e-001, - 2.326341e-001, - -5.167178e-001, - 1.966038e+000, - 1.965523e+000, - 1.957849e+000, - // albedo 1, turbidity 7 - 9.476285e-002, - 2.429074e-001, - -5.647231e-001, - 1.916956e+000, - 2.246725e+000, - 2.009022e+000, - // albedo 1, turbidity 8 - 8.751265e-002, - 2.310627e-001, - -5.147987e-001, - 1.576738e+000, - 2.834201e+000, - 2.015610e+000, - // albedo 1, turbidity 9 - 8.015871e-002, - 1.955507e-001, - -3.514813e-001, - 9.234911e-001, - 3.616998e+000, - 2.073327e+000, - // albedo 1, turbidity 10 - 7.117381e-002, - 1.228804e-001, - -3.803469e-002, - -7.371653e-002, - 4.495822e+000, - 2.179633e+000, -}; - -double dataset560[] = -{ - // albedo 0, turbidity 1 - -1.121223e+000, - -1.710187e-001, - -1.383038e+001, - 1.475343e+001, - -3.137953e-002, - 1.035662e+000, - 4.060064e-002, - 5.222551e+000, - 5.001051e-001, - -1.172565e+000, - -1.880874e-001, - 7.283594e+000, - -5.774643e+000, - -9.051333e-002, - 9.108126e-001, - -1.565410e-002, - 6.194404e+000, - 4.688599e-001, - -1.124108e+000, - -3.082835e-001, - -2.179926e-001, - 1.330167e+000, - -4.502254e-001, - 1.470140e+000, - 4.202392e-004, - -4.724308e+000, - 1.134678e+000, - -1.079809e+000, - -9.226814e-002, - 1.465364e+000, - 1.348856e+000, - 4.357794e-001, - 1.771543e+000, - 8.121383e-003, - 6.057395e+000, - 2.462141e-001, - -1.086667e+000, - -2.709889e-001, - 2.249152e+000, - -3.177505e+000, - -7.138130e+000, - 1.112553e+000, - -9.718434e-003, - -2.392239e+000, - 9.352768e-001, - -1.071154e+000, - -1.272150e-001, - 1.644374e+000, - 4.326598e+000, - -2.244682e+000, - 1.611051e+000, - 7.835546e-003, - 3.213282e+000, - 6.580432e-001, - // albedo 0, turbidity 2 - -1.133883e+000, - -1.835049e-001, - -1.232301e+001, - 1.307796e+001, - -3.760123e-002, - 1.051162e+000, - 3.392954e-002, - 5.319376e+000, - 6.501601e-001, - -1.116119e+000, - -1.457114e-001, - 5.436576e+000, - -5.114276e+000, - -7.178414e-002, - 2.658168e-001, - 1.603756e-001, - 7.619379e+000, - 3.112698e-001, - -1.215552e+000, - -3.391607e-001, - 4.502377e-001, - 1.281602e+000, - -4.095778e-001, - 2.374058e+000, - -1.988430e-001, - -3.809377e+000, - 1.254846e+000, - -9.657094e-001, - 3.858547e-002, - 3.324554e-001, - 1.541740e+000, - 6.029572e-001, - 2.346414e-001, - 3.902458e-001, - 7.263050e+000, - 1.353991e-001, - -1.152042e+000, - -3.155103e-001, - 2.163244e+000, - -5.230832e+000, - -7.443608e+000, - 2.247834e+000, - -1.632216e-001, - -1.725315e+000, - 1.034709e+000, - -1.051862e+000, - -1.310458e-001, - 1.554942e+000, - 1.063510e+001, - -3.558989e+000, - 6.764257e-001, - 1.428912e-001, - 2.541641e+000, - 5.000389e-001, - // albedo 0, turbidity 3 - -1.156925e+000, - -2.104634e-001, - -1.793090e+001, - 1.817524e+001, - -1.225514e-002, - 6.518753e-001, - 1.085708e-001, - 4.947239e+000, - 5.635117e-001, - -1.183783e+000, - -2.187288e-001, - 5.860654e+000, - -5.643960e+000, - -4.453459e-002, - 6.724995e-001, - 1.698133e-002, - 6.742131e+000, - 6.353553e-001, - -1.143101e+000, - -2.644541e-001, - 9.354577e-001, - 9.256854e-001, - -1.074845e-001, - 1.663131e+000, - 4.998918e-002, - -2.049721e+000, - 8.150826e-001, - -1.021102e+000, - 2.478746e-002, - -1.367363e+000, - -9.011684e-002, - -5.001730e-001, - 4.316685e-002, - 3.952231e-001, - 8.084754e+000, - 5.380131e-001, - -1.101145e+000, - -2.731481e-001, - 2.483816e+000, - 3.581780e-001, - 4.249615e-001, - 2.284087e+000, - -5.836688e-002, - -1.651434e+000, - 7.685430e-001, - -1.073863e+000, - -1.705854e-001, - 1.169673e+000, - -2.183705e-003, - -5.007439e+000, - 2.318154e-001, - 2.738714e-001, - 2.187327e+000, - 6.676882e-001, - // albedo 0, turbidity 4 - -1.207581e+000, - -2.653224e-001, - -9.004497e+000, - 8.985720e+000, - -9.024461e-003, - 4.273132e-001, - 1.378091e-001, - 4.307648e+000, - 5.309421e-001, - -1.278614e+000, - -3.516334e-001, - 2.489304e+000, - -1.840089e+000, - -6.293646e-002, - 8.426903e-001, - -7.266949e-002, - 4.434869e+000, - 7.077739e-001, - -1.150333e+000, - -2.033123e-001, - 8.150312e-001, - -7.926382e-001, - -3.230951e-001, - 1.291679e+000, - 1.822329e-001, - 1.619133e+000, - 7.522432e-001, - -1.002248e+000, - -3.092969e-002, - -1.092273e+000, - 2.820671e+000, - 4.504455e-001, - -5.121048e-001, - 4.229688e-001, - 4.037073e+000, - 5.843543e-001, - -1.087962e+000, - -2.434172e-001, - 1.817322e+000, - -6.031774e+000, - -4.873903e+000, - 2.094606e+000, - 1.184743e-001, - 2.293346e-001, - 7.283940e-001, - -1.072272e+000, - -1.614715e-001, - 8.337136e-001, - 1.086866e+001, - -3.373042e+000, - 2.260332e-002, - 2.622468e-001, - 2.470766e+000, - 7.078601e-001, - // albedo 0, turbidity 5 - -1.263850e+000, - -3.278851e-001, - -5.336400e+000, - 5.102832e+000, - 2.070020e-003, - 3.605369e-001, - 1.633426e-001, - 3.790121e+000, - 4.999503e-001, - -1.507623e+000, - -6.465694e-001, - -2.983753e+000, - 4.212027e+000, - -5.868795e-002, - 3.852488e-001, - -7.222995e-002, - 1.042808e+000, - 6.632120e-001, - -1.041397e+000, - 6.326589e-002, - 3.860471e+000, - -5.579882e+000, - -1.730201e-001, - 2.303753e+000, - 6.102393e-002, - 7.287763e+000, - 8.916057e-001, - -1.049861e+000, - -2.836044e-001, - -2.302537e+000, - 6.724969e+000, - 4.373598e-001, - -2.422514e+000, - 6.952438e-001, - -2.633600e+000, - 4.070954e-001, - -1.054117e+000, - -1.206625e-001, - 1.764625e+000, - -9.467716e+000, - -3.436987e+000, - 3.394707e+000, - -8.149683e-002, - 3.485918e+000, - 8.515716e-001, - -1.072517e+000, - -1.574135e-001, - 2.214599e-001, - 1.331766e+001, - -3.915381e+000, - -1.229973e+000, - 6.267275e-001, - 2.923262e+000, - 6.516824e-001, - // albedo 0, turbidity 6 - -1.293503e+000, - -3.676147e-001, - -1.323095e+001, - 1.301713e+001, - -3.471894e-004, - 3.957986e-001, - 1.317480e-001, - 3.616827e+000, - 4.998510e-001, - -1.757697e+000, - -8.202513e-001, - 2.560133e+000, - -1.337734e+000, - -3.413795e-002, - 5.633043e-001, - -4.355758e-002, - 7.324869e-001, - 5.728008e-001, - -8.814599e-001, - 9.828960e-002, - -2.701428e-001, - -1.298657e+000, - -6.721423e-002, - 1.581675e+000, - 4.095024e-002, - 6.548913e+000, - 9.726866e-001, - -1.125663e+000, - -2.625873e-001, - -2.797592e-001, - 2.848739e+000, - -3.363778e-002, - -1.672768e+000, - 7.349952e-001, - -1.708628e+000, - 3.557813e-001, - -1.044841e+000, - -1.712889e-001, - 7.091708e-001, - -4.275119e+000, - -7.565130e-001, - 2.483873e+000, - -7.781321e-002, - 2.667776e+000, - 8.709126e-001, - -1.067360e+000, - -1.543712e-001, - 3.884866e-001, - 6.915851e+000, - -4.250734e+000, - -6.525729e-001, - 6.368377e-001, - 2.671865e+000, - 6.566986e-001, - // albedo 0, turbidity 7 - -1.360356e+000, - -4.336026e-001, - -1.442967e+001, - 1.428579e+001, - -3.990325e-003, - 4.600126e-001, - 1.023159e-001, - 3.367805e+000, - 4.999150e-001, - -2.054147e+000, - -1.064745e+000, - -7.857491e-001, - 2.214734e+000, - -3.764113e-002, - 8.504761e-001, - -4.222958e-002, - 1.091377e-001, - 4.732161e-001, - -8.953952e-001, - 1.048085e-001, - 1.481293e+000, - -4.223012e+000, - -4.164160e-002, - 5.999023e-001, - 6.310005e-002, - 7.156883e+000, - 1.066682e+000, - -1.030251e+000, - -2.777709e-001, - -8.361086e-001, - 5.611154e+000, - 1.861240e-001, - -5.823197e-001, - 6.716210e-001, - -3.269717e+000, - 2.922029e-001, - -1.095631e+000, - -1.966849e-001, - 6.300566e-001, - -7.129591e+000, - -7.351951e-001, - 1.400340e+000, - -6.997516e-003, - 2.879018e+000, - 8.879337e-001, - -1.052935e+000, - -1.551958e-001, - 2.334578e-001, - 1.040948e+001, - -4.426381e+000, - -3.477323e-001, - 6.257070e-001, - 2.451148e+000, - 6.570737e-001, - // albedo 0, turbidity 8 - -1.382656e+000, - -4.830539e-001, - -1.107403e+001, - 1.127854e+001, - -2.723641e-002, - 8.478005e-001, - 2.907652e-003, - 3.290364e+000, - 7.398950e-001, - -2.230895e+000, - -1.163446e+000, - -1.001991e+001, - 1.125340e+001, - -3.233871e-002, - 3.041577e-001, - 3.870458e-003, - 3.463879e-001, - -8.829082e-002, - -1.489234e+000, - -3.402035e-001, - 2.948409e+000, - -8.098077e+000, - 9.078299e-002, - -3.179835e-001, - 4.730321e-001, - 6.765707e+000, - 1.440217e+000, - -6.206234e-001, - -1.701007e-001, - -7.346357e-002, - 9.350033e+000, - 1.548964e-001, - 1.313206e+000, - -1.479143e-001, - -5.119165e+000, - 1.854277e-001, - -1.226372e+000, - -2.128299e-001, - -1.643093e-001, - -9.382334e+000, - -4.857784e-001, - -1.374948e-001, - 5.877245e-001, - 3.862307e+000, - 8.700125e-001, - -1.030598e+000, - -1.931668e-001, - 3.691403e-001, - 1.066393e+001, - -4.244968e+000, - -5.872571e-002, - 4.193140e-001, - 1.461878e+000, - 6.699478e-001, - // albedo 0, turbidity 9 - -1.606656e+000, - -7.140209e-001, - -1.149565e+001, - 1.168427e+001, - -2.245577e-002, - 7.718953e-001, - -8.349882e-006, - 2.654449e+000, - 9.001224e-001, - -2.100494e+000, - -1.013602e+000, - -1.638934e+001, - 1.729185e+001, - -1.580924e-002, - 5.038208e-002, - -1.628735e-002, - 1.762584e+000, - -3.121794e-001, - -3.228292e+000, - -1.459508e+000, - 7.424519e+000, - -1.194272e+001, - 4.931054e-002, - 6.493074e-001, - 3.590561e-001, - 4.068321e+000, - 1.613039e+000, - 1.278814e-001, - 4.010913e-002, - -2.185675e+000, - 1.164548e+001, - 2.706306e-002, - 1.632886e-001, - -1.090111e-002, - -3.342580e+000, - 1.916992e-002, - -1.400278e+000, - -2.825658e-001, - 4.168149e-001, - -1.195909e+001, - -1.122968e-002, - 1.863328e-001, - 4.263033e-001, - 2.270053e+000, - 9.748449e-001, - -1.017511e+000, - -2.884028e-001, - 3.544996e-001, - 1.535118e+001, - -5.009184e+000, - 1.511064e-001, - 2.916578e-001, - 7.889658e-001, - 6.294910e-001, - // albedo 0, turbidity 10 - -2.031136e+000, - -1.076357e+000, - -8.660773e+000, - 8.800317e+000, - -2.370842e-002, - 5.736027e-001, - -8.441313e-006, - 2.248669e+000, - 9.001280e-001, - -1.270967e+000, - -7.828844e-001, - -1.198232e+001, - 1.262753e+001, - -1.509989e-002, - 1.663438e-001, - 2.440939e-004, - 2.068640e+000, - -2.521574e-001, - -6.600872e+000, - -2.689874e+000, - 6.453928e+000, - -9.592747e+000, - -3.551170e-002, - 1.325662e+000, - -1.894375e-002, - 3.506163e+000, - 1.469724e+000, - 7.961323e-001, - -1.989144e-001, - -2.685238e+000, - 1.034230e+001, - 2.076702e-001, - -7.692350e-001, - 6.184894e-001, - -1.969413e+000, - 3.842922e-002, - -1.459073e+000, - -4.964034e-001, - 1.060127e+000, - -1.277712e+001, - -9.634553e-001, - 5.610879e-001, - -2.034286e-001, - 3.525910e-001, - 1.003048e+000, - -1.021565e+000, - -2.553022e-001, - 6.367571e-002, - 2.028825e+001, - -4.623219e+000, - -2.400428e-002, - 4.251423e-001, - 9.640897e-001, - 6.080298e-001, - // albedo 1, turbidity 1 - -1.121224e+000, - -1.710171e-001, - -1.383038e+001, - 1.475343e+001, - -3.137812e-002, - 1.035662e+000, - 4.060006e-002, - 5.222551e+000, - 5.001051e-001, - -1.172565e+000, - -1.880857e-001, - 7.283595e+000, - -5.774643e+000, - -9.051285e-002, - 9.108124e-001, - -1.565627e-002, - 6.194404e+000, - 4.688599e-001, - -1.124109e+000, - -3.082816e-001, - -2.179926e-001, - 1.330167e+000, - -4.502252e-001, - 1.470140e+000, - 4.158616e-004, - -4.724308e+000, - 1.134678e+000, - -1.079810e+000, - -9.226583e-002, - 1.465364e+000, - 1.348856e+000, - 4.357794e-001, - 1.771543e+000, - 8.115381e-003, - 6.057395e+000, - 2.462140e-001, - -1.086668e+000, - -2.709863e-001, - 2.249153e+000, - -3.177505e+000, - -7.138130e+000, - 1.112553e+000, - -9.724210e-003, - -2.392239e+000, - 9.352768e-001, - -1.071158e+000, - -1.272123e-001, - 1.644374e+000, - 4.326598e+000, - -2.244682e+000, - 1.611051e+000, - 7.831866e-003, - 3.213282e+000, - 6.580432e-001, - // albedo 1, turbidity 2 - -1.125449e+000, - -1.733403e-001, - -1.228038e+001, - 1.311695e+001, - -3.541409e-002, - 1.005494e+000, - 4.147852e-002, - 5.316886e+000, - 6.051699e-001, - -1.101273e+000, - -1.422106e-001, - 5.484715e+000, - -5.089835e+000, - -6.655928e-002, - 2.076815e-001, - 1.633101e-001, - 7.624535e+000, - 3.044941e-001, - -1.213425e+000, - -3.085010e-001, - 5.550585e-001, - 1.302798e+000, - -3.946488e-001, - 2.285152e+000, - -1.925101e-001, - -3.790065e+000, - 1.263207e+000, - -9.610579e-001, - 9.458093e-003, - 5.293256e-001, - 1.553214e+000, - 6.053752e-001, - 1.172267e-001, - 3.674690e-001, - 7.305350e+000, - 1.509544e-001, - -1.119731e+000, - -2.765693e-001, - 2.433951e+000, - -5.229810e+000, - -7.449777e+000, - 2.123304e+000, - -2.242917e-001, - -1.669115e+000, - 1.041008e+000, - -1.094324e+000, - -1.418743e-001, - 1.836224e+000, - 1.063054e+001, - -3.561209e+000, - 5.916534e-001, - 9.296571e-002, - 2.600060e+000, - 4.999316e-001, - // albedo 1, turbidity 3 - -1.155818e+000, - -2.162981e-001, - -2.560068e+001, - 2.636088e+001, - -1.382944e-002, - 8.101983e-001, - 4.709210e-002, - 4.301909e+000, - 6.416958e-001, - -1.171460e+000, - -1.866443e-001, - 8.497645e+000, - -8.396229e+000, - -3.345417e-002, - 2.960022e-001, - 7.985279e-002, - 7.420544e+000, - 5.552152e-001, - -1.114385e+000, - -2.963805e-001, - 5.955009e-002, - 2.320529e+000, - -7.649266e-002, - 2.277940e+000, - -5.942479e-002, - -4.040964e+000, - 9.588558e-001, - -1.070647e+000, - 4.194546e-002, - -5.701942e-001, - -1.001278e+000, - -3.389615e-001, - -8.559533e-001, - 5.070784e-001, - 9.805560e+000, - 3.529747e-001, - -1.057912e+000, - -2.733753e-001, - 3.080618e+000, - 7.477366e-001, - 3.484876e-001, - 2.214994e+000, - -2.597625e-001, - -2.842961e+000, - 9.178917e-001, - -1.105636e+000, - -1.815423e-001, - 1.651373e+000, - -2.553941e-003, - -5.008441e+000, - -6.378055e-001, - 2.370503e-001, - 1.890656e+000, - 6.018255e-001, - // albedo 1, turbidity 4 - -1.194221e+000, - -2.570801e-001, - -8.919095e+000, - 9.380192e+000, - -2.650470e-002, - 6.233645e-001, - 6.663964e-002, - 4.027438e+000, - 6.125383e-001, - -1.308216e+000, - -3.781794e-001, - 2.369107e+000, - -1.977066e+000, - -4.079773e-002, - 1.443960e-001, - 8.206719e-002, - 3.465933e+000, - 5.442867e-001, - -1.048459e+000, - -1.617720e-001, - 1.015136e+000, - -2.989579e-001, - -2.764989e-001, - 2.427990e+000, - -1.147612e-001, - 1.522921e+000, - 1.041410e+000, - -1.105796e+000, - -4.826962e-002, - -8.419705e-001, - 3.285981e+000, - 7.975109e-001, - -1.954456e+000, - 7.424696e-001, - 4.604902e+000, - 2.602059e-001, - -1.033856e+000, - -2.507382e-001, - 2.882633e+000, - -8.250912e+000, - -6.878129e+000, - 2.948966e+000, - -2.850302e-001, - -8.253849e-001, - 9.844934e-001, - -1.125219e+000, - -1.879003e-001, - 1.474838e+000, - 1.453266e+001, - -3.271910e+000, - -1.231579e+000, - 2.397524e-001, - 1.654932e+000, - 5.625696e-001, - // albedo 1, turbidity 5 - -1.246640e+000, - -3.202274e-001, - -6.355032e+000, - 6.364143e+000, - 9.028376e-004, - 3.146975e-001, - 1.550718e-001, - 3.413749e+000, - 4.999065e-001, - -1.477471e+000, - -5.819223e-001, - 1.329471e+000, - -2.694229e-001, - -4.575905e-002, - 5.087866e-001, - -6.857139e-002, - 1.810092e+000, - 6.318693e-001, - -1.046136e+000, - -6.763679e-002, - 6.725076e-001, - -1.036786e+000, - -3.192799e-001, - 1.724205e+000, - 6.468388e-002, - 3.953855e+000, - 9.417528e-001, - -1.033910e+000, - -1.295544e-001, - -4.551294e-001, - 2.659205e+000, - 8.887235e-001, - -1.733153e+000, - 6.540117e-001, - 8.046523e-001, - 3.597443e-001, - -1.094530e+000, - -2.282012e-001, - 2.298267e+000, - -5.184881e+000, - -6.122309e+000, - 2.590799e+000, - -1.618707e-001, - 1.116033e+000, - 8.867666e-001, - -1.095556e+000, - -1.807112e-001, - 1.406193e+000, - 8.120385e+000, - -3.058239e+000, - -1.121150e+000, - 2.933606e-001, - 1.488339e+000, - 6.374827e-001, - // albedo 1, turbidity 6 - -1.270123e+000, - -3.552595e-001, - -8.975893e+000, - 9.110080e+000, - -3.388207e-003, - 3.559109e-001, - 1.201097e-001, - 3.109904e+000, - 4.998957e-001, - -1.663376e+000, - -7.846840e-001, - 6.951405e-001, - 3.139107e-001, - -2.448004e-002, - 3.572505e-001, - 1.453572e-002, - 6.307761e-001, - 5.142914e-001, - -9.518772e-001, - 7.764573e-002, - 1.247094e+000, - -2.224855e+000, - -1.195310e-001, - 1.709581e+000, - -8.836329e-002, - 5.688916e+000, - 1.113629e+000, - -1.087154e+000, - -2.665646e-001, - -8.624251e-001, - 4.536060e+000, - 4.180650e-001, - -1.629798e+000, - 8.479560e-001, - -1.293696e+000, - 1.869693e-001, - -1.064826e+000, - -1.599892e-001, - 2.285337e+000, - -8.584887e+000, - -3.074560e+000, - 2.139459e+000, - -2.592372e-001, - 1.937577e+000, - 9.957954e-001, - -1.099622e+000, - -1.849797e-001, - 1.193609e+000, - 1.416481e+001, - -5.009527e+000, - -8.592493e-001, - 3.485606e-001, - 1.884203e+000, - 6.097274e-001, - // albedo 1, turbidity 7 - -1.344841e+000, - -4.339942e-001, - -9.193112e+000, - 9.385864e+000, - -9.742818e-003, - 4.812040e-001, - 7.690647e-002, - 2.843801e+000, - 5.228047e-001, - -1.975928e+000, - -1.042040e+000, - 9.695714e-001, - 3.718000e-001, - -3.334078e-002, - 1.333620e-001, - 8.180282e-002, - -1.652429e-001, - 3.267010e-001, - -8.651864e-001, - 1.288722e-001, - 6.811456e-001, - -3.282787e+000, - -9.074685e-002, - 1.894059e+000, - -1.849744e-001, - 6.610614e+000, - 1.322978e+000, - -1.103780e+000, - -3.279618e-001, - -4.193802e-001, - 7.331165e+000, - 6.529659e-001, - -2.227297e+000, - 9.625482e-001, - -3.348971e+000, - -7.261722e-003, - -1.055963e+000, - -1.527328e-001, - 1.786114e+000, - -1.367578e+001, - -3.450729e+000, - 2.641691e+000, - -3.229222e-001, - 2.800131e+000, - 1.129409e+000, - -1.111541e+000, - -2.123518e-001, - 1.286159e+000, - 2.297563e+001, - -4.591526e+000, - -1.374672e+000, - 3.462811e-001, - 1.071127e+000, - 5.498514e-001, - // albedo 1, turbidity 8 - -1.387544e+000, - -4.964558e-001, - -9.744778e+000, - 1.014533e+001, - -2.463089e-002, - 7.188705e-001, - 3.919951e-003, - 2.760792e+000, - 7.369418e-001, - -2.206536e+000, - -1.191342e+000, - -2.244384e+000, - 3.629413e+000, - -3.601610e-002, - 7.725349e-002, - 5.357588e-002, - -2.692147e-001, - -1.142476e-001, - -1.358286e+000, - -2.268740e-001, - 9.805731e-001, - -5.163195e+000, - -8.589000e-003, - 7.697565e-001, - 2.198750e-001, - 7.029301e+000, - 1.567170e+000, - -7.167767e-001, - -2.969978e-001, - 2.300987e-001, - 7.956088e+000, - 6.339728e-001, - -6.195374e-001, - 2.502844e-001, - -6.307569e+000, - -2.208822e-002, - -1.210525e+000, - -1.245541e-001, - 9.742409e-001, - -9.705683e+000, - -1.658899e+000, - 1.365829e+000, - 2.003500e-001, - 4.400174e+000, - 1.042345e+000, - -1.061524e+000, - -2.323500e-001, - 1.284880e+000, - 1.294836e+001, - -5.011732e+000, - -9.141086e-001, - 2.723804e-001, - 6.225528e-001, - 6.030977e-001, - // albedo 1, turbidity 9 - -1.548946e+000, - -6.802676e-001, - -1.274231e+001, - 1.312954e+001, - -1.834225e-002, - 7.051580e-001, - -8.330446e-006, - 2.320435e+000, - 9.001244e-001, - -1.867128e+000, - -9.670210e-001, - -6.847422e+000, - 7.952765e+000, - -1.985986e-002, - 1.690548e-002, - -1.176902e-002, - 8.988469e-001, - -3.242269e-001, - -3.470633e+000, - -1.555121e+000, - 2.684966e+000, - -5.964736e+000, - -5.524158e-003, - 1.187089e+000, - 2.552534e-001, - 4.394076e+000, - 1.656399e+000, - 4.095837e-001, - 1.440005e-001, - -5.602190e-001, - 7.110869e+000, - 2.313366e-001, - -1.373206e+000, - 1.973962e-001, - -4.112998e+000, - -5.877027e-002, - -1.540633e+000, - -3.264234e-001, - 1.072405e+000, - -7.205546e+000, - -5.125251e-001, - 2.009905e+000, - 1.531985e-001, - 2.113439e+000, - 1.042547e+000, - -1.013330e+000, - -2.663837e-001, - 1.168934e+000, - 9.315778e+000, - -4.320502e+000, - -1.303393e+000, - 2.825872e-001, - 2.365015e-001, - 5.993344e-001, - // albedo 1, turbidity 10 - -2.055426e+000, - -1.093229e+000, - -3.487182e+000, - 3.753855e+000, - -4.639837e-002, - 5.797714e-001, - -8.056992e-006, - 1.916262e+000, - 9.001298e-001, - -1.643864e+000, - -9.676934e-001, - -1.147133e+001, - 1.253880e+001, - 2.347351e-002, - -1.602964e-002, - 4.481579e-003, - 1.373645e+000, - -2.884929e-001, - -6.156336e+000, - -2.568735e+000, - 6.499533e+000, - -9.136753e+000, - -1.751599e-001, - 1.876960e+000, - -7.959051e-002, - 3.074951e+000, - 1.579874e+000, - 7.378485e-001, - -2.614544e-001, - -2.861777e+000, - 9.518947e+000, - 5.033808e-001, - -1.844722e+000, - 6.855962e-001, - -1.497263e+000, - -9.081643e-002, - -1.341940e+000, - -3.847183e-001, - 2.045437e+000, - -1.179073e+001, - -1.532773e+000, - 1.639939e+000, - -2.668175e-001, - -8.401827e-001, - 1.083722e+000, - -1.086126e+000, - -2.811402e-001, - 7.554239e-001, - 1.862181e+001, - -4.343385e+000, - -8.611011e-001, - 3.146558e-001, - 7.022438e-001, - 5.872694e-001, -}; - -double datasetRad560[] = -{ - // albedo 0, turbidity 1 - 1.229100e-001, - 9.521889e-002, - 1.405396e-001, - 8.787112e-001, - 3.988783e-001, - 5.495204e-001, - // albedo 0, turbidity 2 - 1.199581e-001, - 1.081049e-001, - 6.220570e-002, - 1.081857e+000, - 3.919610e-001, - 5.733490e-001, - // albedo 0, turbidity 3 - 1.138362e-001, - 1.298987e-001, - -7.284771e-002, - 1.405046e+000, - 3.664093e-001, - 6.266856e-001, - // albedo 0, turbidity 4 - 1.049109e-001, - 1.679341e-001, - -2.972688e-001, - 1.869885e+000, - 3.458361e-001, - 7.128497e-001, - // albedo 0, turbidity 5 - 9.598094e-002, - 2.070366e-001, - -5.051216e-001, - 2.239049e+000, - 3.816016e-001, - 7.939503e-001, - // albedo 0, turbidity 6 - 8.963794e-002, - 2.286618e-001, - -6.166284e-001, - 2.410878e+000, - 4.394852e-001, - 8.454492e-001, - // albedo 0, turbidity 7 - 8.340284e-002, - 2.476914e-001, - -7.170190e-001, - 2.486806e+000, - 6.858305e-001, - 8.717659e-001, - // albedo 0, turbidity 8 - 7.444609e-002, - 2.646252e-001, - -7.920395e-001, - 2.426535e+000, - 1.075172e+000, - 9.650954e-001, - // albedo 0, turbidity 9 - 6.629833e-002, - 2.459655e-001, - -6.980154e-001, - 1.912425e+000, - 1.829164e+000, - 1.077596e+000, - // albedo 0, turbidity 10 - 5.889089e-002, - 1.723101e-001, - -3.613857e-001, - 8.275448e-001, - 2.946694e+000, - 1.231617e+000, - // albedo 1, turbidity 1 - 1.314133e-001, - 1.122331e-001, - 1.449363e-001, - 8.093475e-001, - 1.079774e+000, - 1.233568e+000, - // albedo 1, turbidity 2 - 1.279124e-001, - 1.290274e-001, - 4.690773e-002, - 1.061743e+000, - 1.017150e+000, - 1.317400e+000, - // albedo 1, turbidity 3 - 1.220803e-001, - 1.528616e-001, - -9.605511e-002, - 1.391437e+000, - 1.000174e+000, - 1.408238e+000, - // albedo 1, turbidity 4 - 1.121360e-001, - 1.811889e-001, - -2.743886e-001, - 1.744983e+000, - 1.106066e+000, - 1.489542e+000, - // albedo 1, turbidity 5 - 1.043672e-001, - 2.082413e-001, - -4.376278e-001, - 2.008634e+000, - 1.246195e+000, - 1.572920e+000, - // albedo 1, turbidity 6 - 9.950913e-002, - 2.198237e-001, - -5.028179e-001, - 2.058564e+000, - 1.441221e+000, - 1.587471e+000, - // albedo 1, turbidity 7 - 9.246215e-002, - 2.370164e-001, - -5.865610e-001, - 2.082736e+000, - 1.718826e+000, - 1.643687e+000, - // albedo 1, turbidity 8 - 8.343644e-002, - 2.411559e-001, - -6.125797e-001, - 1.909744e+000, - 2.180259e+000, - 1.747309e+000, - // albedo 1, turbidity 9 - 7.492090e-002, - 2.122543e-001, - -4.784322e-001, - 1.297338e+000, - 2.978259e+000, - 1.846305e+000, - // albedo 1, turbidity 10 - 6.653290e-002, - 1.376844e-001, - -1.431215e-001, - 2.099180e-001, - 4.028552e+000, - 1.938106e+000, -}; - -double dataset600[] = -{ - // albedo 0, turbidity 1 - -1.120756e+000, - -1.756050e-001, - -3.557732e+000, - 5.117996e+000, - -1.042966e-001, - 1.269364e+000, - 1.318863e-002, - 3.718263e+000, - 5.393663e-001, - -1.170564e+000, - -1.845108e-001, - 1.081952e+000, - 1.330153e+000, - -2.486698e-001, - 7.864551e-001, - 3.710973e-003, - 4.567181e+000, - 4.998408e-001, - -1.036563e+000, - -2.605284e-001, - 3.803752e+000, - -3.585400e+000, - -9.070196e-001, - 2.380958e+000, - -1.320680e-002, - -4.210738e+000, - 1.085121e+000, - -1.193752e+000, - -1.236757e-001, - -2.036484e-001, - 4.137855e+000, - 1.566414e+000, - 8.510547e-001, - 1.653213e-002, - 5.488784e+000, - 2.335910e-001, - -9.950781e-001, - -2.103974e-001, - 2.992004e+000, - -4.050491e+000, - -6.354208e+000, - 2.250652e+000, - -1.548511e-002, - -1.876535e+000, - 9.733518e-001, - -1.106820e+000, - -1.804412e-001, - 1.960315e+000, - 3.667064e+000, - -2.460232e+000, - 9.553453e-001, - 1.238019e-002, - 1.307691e+000, - 5.564710e-001, - // albedo 0, turbidity 2 - -1.112834e+000, - -1.534956e-001, - -4.968015e+000, - 6.079068e+000, - -8.917942e-002, - 1.167545e+000, - 5.945633e-002, - 5.295468e+000, - 6.272123e-001, - -1.160910e+000, - -1.640745e-001, - 7.416807e-001, - -2.894668e-001, - -8.983936e-002, - 3.778575e-002, - 2.133300e-001, - 6.390765e+000, - 3.592393e-001, - -1.054872e+000, - -2.642844e-001, - 4.375802e+000, - -1.434824e+000, - -7.521504e-001, - 3.669027e+000, - -2.992879e-001, - -5.159653e+000, - 1.284643e+000, - -1.147542e+000, - 1.011446e-002, - -2.308529e+000, - 1.587994e+000, - 1.226957e+000, - -1.328837e+000, - 5.996235e-001, - 1.004278e+001, - 5.212352e-002, - -1.023945e+000, - -2.867193e-001, - 3.733660e+000, - -2.572157e+000, - -7.749675e+000, - 3.927326e+000, - -3.230666e-001, - -4.260418e+000, - 1.091761e+000, - -1.100815e+000, - -1.590204e-001, - 1.413330e+000, - 6.546557e+000, - -2.407235e+000, - -2.678587e-001, - 2.367155e-001, - 2.242596e+000, - 5.273419e-001, - // albedo 0, turbidity 3 - -1.137271e+000, - -1.838447e-001, - -2.268731e+000, - 3.013967e+000, - -1.471213e-001, - 9.047947e-001, - 8.086373e-002, - 4.834215e+000, - 6.545047e-001, - -1.136415e+000, - -1.536696e-001, - -1.821062e+000, - 1.756804e+000, - -9.313635e-002, - 2.208938e-001, - 2.021774e-001, - 7.289664e+000, - 4.997813e-001, - -1.173214e+000, - -3.202233e-001, - 4.868221e+000, - -2.485467e+000, - -7.693969e-001, - 3.027854e+000, - -1.745243e-001, - -4.896365e+000, - 1.014186e+000, - -1.021346e+000, - 7.262425e-002, - -2.940205e+000, - 3.357462e+000, - 1.150486e+000, - -1.710207e+000, - 7.381637e-001, - 9.857427e+000, - 3.036725e-001, - -1.082107e+000, - -2.721172e-001, - 3.071962e+000, - -7.058088e+000, - -5.103538e+000, - 3.852302e+000, - -2.281911e-001, - -2.565665e+000, - 9.669584e-001, - -1.076296e+000, - -1.655466e-001, - 1.323765e+000, - 1.496892e+001, - -3.773928e+000, - -5.211752e-001, - 2.583009e-001, - 1.797906e+000, - 5.888323e-001, - // albedo 0, turbidity 4 - -1.180432e+000, - -2.327942e-001, - -7.152650e-001, - 1.078120e+000, - -2.935788e-001, - 6.977295e-001, - 1.118530e-001, - 4.270574e+000, - 6.241267e-001, - -1.260549e+000, - -2.865438e-001, - -2.736770e+000, - 2.720969e+000, - 1.291231e-001, - 4.072562e-001, - 4.510932e-002, - 5.412464e+000, - 6.781695e-001, - -1.119712e+000, - -2.521160e-001, - 4.860527e+000, - -1.950603e+000, - -1.598805e+000, - 2.556718e+000, - 2.462723e-002, - -2.059404e+000, - 8.000995e-001, - -1.056386e+000, - 2.018258e-002, - -3.728955e+000, - 1.022270e+000, - 1.722210e+000, - -2.691554e+000, - 8.329883e-001, - 6.982450e+000, - 4.746778e-001, - -1.044811e+000, - -2.531291e-001, - 3.102204e+000, - -3.662632e+000, - -5.609358e+000, - 4.574385e+000, - -2.173600e-001, - -1.646110e+000, - 8.593305e-001, - -1.090027e+000, - -1.699462e-001, - 7.118896e-001, - 1.287572e+001, - -2.747429e+000, - -1.706223e+000, - 4.483382e-001, - 2.029605e+000, - 6.366599e-001, - // albedo 0, turbidity 5 - -1.232266e+000, - -2.905676e-001, - -4.158347e-001, - 5.285264e-001, - -3.064312e-001, - 5.569478e-001, - 1.195289e-001, - 3.788091e+000, - 5.970680e-001, - -1.451205e+000, - -5.169964e-001, - -2.018331e-001, - 1.499655e+000, - -1.575963e+000, - 2.761459e-001, - 5.184923e-002, - 2.301119e+000, - 6.177771e-001, - -1.059832e+000, - -7.658003e-002, - 6.456894e-001, - -4.398594e+000, - 5.369604e+000, - 2.121235e+000, - 3.210869e-002, - 3.542794e+000, - 9.114953e-001, - -1.040966e+000, - -1.269405e-001, - -3.751056e-001, - 1.229395e+001, - -1.977090e+001, - -2.458488e+000, - 7.711932e-001, - 8.079227e-001, - 3.865305e-001, - -1.061923e+000, - -1.981907e-001, - 1.089854e+000, - -3.414507e+000, - 8.032592e+000, - 3.459965e+000, - -1.253984e-001, - 1.188198e+000, - 8.639277e-001, - -1.070607e+000, - -1.627049e-001, - 7.012071e-001, - 2.138780e+000, - -5.006595e+000, - -1.096698e+000, - 6.658771e-001, - 1.999430e+000, - 6.557122e-001, - // albedo 0, turbidity 6 - -1.280090e+000, - -3.357179e-001, - -9.337154e-002, - -5.075553e-003, - -3.096112e+000, - 4.001499e-001, - 1.489818e-001, - 3.515349e+000, - 5.571477e-001, - -1.648190e+000, - -7.024227e-001, - -2.925797e-002, - 1.658094e+000, - 4.229924e+000, - 3.502683e-001, - 3.180108e-002, - 1.430955e+000, - 5.739552e-001, - -9.589189e-001, - 2.559557e-002, - 2.192186e-001, - -5.276316e+000, - -4.153922e+000, - 1.855574e+000, - 3.052317e-002, - 4.323694e+000, - 9.839497e-001, - -1.076589e+000, - -1.936109e-001, - -4.162615e-001, - 1.202609e+001, - -9.327314e+000, - -2.326508e+000, - 7.983253e-001, - 2.100845e-001, - 3.135170e-001, - -1.049437e+000, - -1.694738e-001, - 1.062110e+000, - 5.575299e+000, - 4.846701e-001, - 3.089474e+000, - -1.584214e-001, - 1.369457e+000, - 8.995377e-001, - -1.069986e+000, - -1.830827e-001, - 5.006422e-001, - -3.063835e-003, - -2.768514e+000, - -1.258027e+000, - 6.679955e-001, - 1.840288e+000, - 6.498676e-001, - // albedo 0, turbidity 7 - -1.328971e+000, - -3.853230e-001, - -2.343098e-001, - -6.505414e-003, - -4.859294e+000, - 3.752993e-001, - 1.670718e-001, - 3.474961e+000, - 4.998573e-001, - -2.023062e+000, - -1.023840e+000, - 4.308501e-001, - 1.473146e+000, - 6.112105e+000, - 5.767265e-001, - -3.107377e-002, - 7.748759e-002, - 5.016978e-001, - -8.575747e-001, - 1.580212e-001, - -7.365004e-001, - -4.007773e+000, - -4.051657e+000, - 8.889282e-001, - 1.978413e-001, - 6.282132e+000, - 1.063928e+000, - -1.073428e+000, - -3.228761e-001, - 4.793085e-001, - 5.455778e+000, - -7.830559e+000, - -9.794478e-001, - 5.370543e-001, - -3.022750e+000, - 2.818600e-001, - -1.057120e+000, - -1.266841e-001, - 4.555368e-001, - 1.201278e+001, - -9.293773e-001, - 1.439595e+000, - 3.262182e-002, - 2.890364e+000, - 8.821540e-001, - -1.060079e+000, - -1.816680e-001, - 3.541107e-001, - -2.642196e-003, - -2.588317e+000, - -5.640010e-001, - 6.643994e-001, - 1.673077e+000, - 6.658333e-001, - // albedo 0, turbidity 8 - -1.395409e+000, - -4.658947e-001, - -4.370597e-001, - 1.342039e+000, - -1.108674e+000, - 6.439316e-001, - 1.355229e-002, - 3.241153e+000, - 6.696079e-001, - -2.418167e+000, - -1.266061e+000, - 3.287382e-001, - -1.486721e+000, - -6.770180e-001, - 2.439008e-001, - 1.703788e-001, - 1.664559e-002, - -6.330217e-003, - -1.221212e+000, - -1.072571e-001, - -1.655914e+000, - 2.659047e+000, - 6.830770e+000, - 4.984792e-001, - 2.538158e-001, - 6.500660e+000, - 1.486576e+000, - -7.182331e-001, - -2.519055e-001, - 1.641261e+000, - -5.500375e+000, - -1.253143e+001, - -1.542672e-001, - 1.741161e-001, - -4.907497e+000, - 7.968864e-002, - -1.207117e+000, - -1.635739e-001, - -3.256308e-001, - 1.409033e+001, - 1.107883e+000, - 7.217342e-001, - 3.158860e-001, - 3.537550e+000, - 9.389751e-001, - -1.015927e+000, - -1.890895e-001, - 4.180376e-001, - 9.528535e+000, - -4.073979e+000, - -8.713087e-001, - 4.899379e-001, - 1.277831e+000, - 6.519818e-001, - // albedo 0, turbidity 9 - -1.551242e+000, - -6.400568e-001, - -3.673011e-001, - 1.623228e+000, - -1.482572e+000, - 5.625944e-001, - -1.130924e-005, - 2.792007e+000, - 9.000924e-001, - -1.971409e+000, - -9.004995e-001, - -2.337582e-001, - -1.511905e+000, - 6.645432e-002, - 6.149087e-001, - -3.184094e-002, - 2.026210e+000, - -2.799058e-001, - -3.464015e+000, - -1.604654e+000, - -1.514516e+000, - 2.768075e+000, - 4.084166e+000, - -4.287171e-001, - 7.112107e-001, - 2.896460e+000, - 1.502031e+000, - 4.069978e-001, - 2.775394e-001, - 1.525761e+000, - -5.264056e+000, - -7.108445e+000, - 1.134996e+000, - -4.122625e-001, - -2.558151e+000, - 2.009854e-001, - -1.504217e+000, - -3.618442e-001, - -2.305374e-001, - 1.434481e+001, - -1.713254e+000, - -5.670708e-001, - 5.206848e-001, - 1.704009e+000, - 8.447497e-001, - -9.753124e-001, - -2.080868e-001, - 2.450141e-001, - -3.535206e-003, - -2.121317e+000, - -1.425634e-001, - 4.670084e-001, - 1.027875e+000, - 6.735543e-001, - // albedo 0, turbidity 10 - -2.027207e+000, - -1.003600e+000, - -3.813114e-001, - 9.357907e-001, - -1.031886e+000, - 5.523389e-001, - -8.883940e-006, - 2.339379e+000, - 9.001659e-001, - -1.506235e+000, - -7.795241e-001, - -4.313309e-001, - 9.124054e-001, - -7.484352e-001, - -8.417756e-002, - -1.426561e-002, - 2.571178e+000, - -2.504298e-001, - -6.482777e+000, - -2.700075e+000, - -1.556622e+000, - -2.978497e+000, - 4.623255e+000, - 1.953868e+000, - 3.113178e-001, - 2.311303e+000, - 1.451021e+000, - 9.357272e-001, - -1.066566e-001, - 1.476763e+000, - 6.889797e+000, - -1.038036e+001, - -2.094856e+000, - 1.330069e-001, - -1.446404e+000, - 1.121890e-001, - -1.398229e+000, - -3.167573e-001, - -1.276866e-001, - 1.239440e+000, - 1.816678e+000, - 1.586775e+000, - 8.043533e-002, - 3.219192e-001, - 9.200620e-001, - -1.070734e+000, - -3.636167e-001, - 2.426490e-001, - 8.282765e+000, - -3.588710e+000, - -9.105402e-001, - 3.760276e-001, - 5.756358e-001, - 6.508161e-001, - // albedo 1, turbidity 1 - -1.120757e+000, - -1.756034e-001, - -3.557732e+000, - 5.117996e+000, - -1.042960e-001, - 1.269364e+000, - 1.318834e-002, - 3.718263e+000, - 5.393663e-001, - -1.170565e+000, - -1.845093e-001, - 1.081952e+000, - 1.330153e+000, - -2.486697e-001, - 7.864550e-001, - 3.709405e-003, - 4.567181e+000, - 4.998408e-001, - -1.036564e+000, - -2.605265e-001, - 3.803752e+000, - -3.585400e+000, - -9.070196e-001, - 2.380958e+000, - -1.320996e-002, - -4.210738e+000, - 1.085121e+000, - -1.193753e+000, - -1.236733e-001, - -2.036483e-001, - 4.137855e+000, - 1.566414e+000, - 8.510543e-001, - 1.652749e-002, - 5.488784e+000, - 2.335910e-001, - -9.950796e-001, - -2.103948e-001, - 2.992004e+000, - -4.050491e+000, - -6.354208e+000, - 2.250652e+000, - -1.548996e-002, - -1.876535e+000, - 9.733518e-001, - -1.106823e+000, - -1.804388e-001, - 1.960315e+000, - 3.667064e+000, - -2.460232e+000, - 9.553451e-001, - 1.237721e-002, - 1.307692e+000, - 5.564710e-001, - // albedo 1, turbidity 2 - -1.113356e+000, - -1.560185e-001, - -7.788803e+000, - 8.963658e+000, - -5.322872e-002, - 1.116670e+000, - 7.024842e-002, - 4.886694e+000, - 5.931909e-001, - -1.134232e+000, - -1.667475e-001, - 4.176259e+000, - -3.242194e+000, - -7.889230e-002, - 8.254326e-002, - 1.400333e-001, - 5.395289e+000, - 4.862375e-001, - -1.105040e+000, - -2.389195e-001, - 9.866260e-001, - 1.271557e+000, - -6.066849e-001, - 3.599900e+000, - -1.681445e-001, - -2.812867e+000, - 1.053791e+000, - -1.078302e+000, - -2.258635e-002, - 7.407482e-001, - 1.805864e-001, - 9.070580e-001, - -1.720820e+000, - 4.256187e-001, - 6.982502e+000, - 3.350778e-001, - -1.070883e+000, - -2.752054e-001, - 2.937203e+000, - -2.246366e+000, - -9.847865e+000, - 3.104714e+000, - -2.573859e-001, - -2.816401e+000, - 8.478900e-001, - -1.090880e+000, - -1.453755e-001, - 2.046382e+000, - 5.595795e+000, - -2.809181e+000, - -9.239576e-001, - 1.783176e-001, - 2.051350e+000, - 5.815062e-001, - // albedo 1, turbidity 3 - -1.136641e+000, - -1.825277e-001, - -3.464338e+000, - 4.413974e+000, - -1.123917e-001, - 1.009115e+000, - 5.542918e-002, - 4.702599e+000, - 6.799974e-001, - -1.146478e+000, - -1.593833e-001, - -9.055790e-001, - 8.991902e-001, - -4.711416e-002, - -3.813573e-001, - 2.290428e-001, - 6.961903e+000, - 4.206011e-001, - -1.136317e+000, - -3.103198e-001, - 4.219694e+000, - -2.031887e+000, - -7.184952e-001, - 3.795646e+000, - -1.650547e-001, - -5.402471e+000, - 1.118561e+000, - -1.044973e+000, - 7.826651e-002, - -2.043684e+000, - 3.410720e+000, - 1.974969e+000, - -2.736513e+000, - 6.828176e-001, - 1.049084e+001, - 1.894241e-001, - -1.076125e+000, - -2.930526e-001, - 3.722784e+000, - -7.364061e+000, - -7.399428e+000, - 4.034307e+000, - -3.489831e-001, - -3.438955e+000, - 1.077145e+000, - -1.100551e+000, - -1.533449e-001, - 1.767589e+000, - 1.479022e+001, - -2.910058e+000, - -1.732923e+000, - 2.193598e-001, - 1.880974e+000, - 4.999331e-001, - // albedo 1, turbidity 4 - -1.175282e+000, - -2.274651e-001, - -8.788053e-001, - 1.446934e+000, - -2.568124e-001, - 7.201567e-001, - 1.054963e-001, - 4.149007e+000, - 6.084060e-001, - -1.224868e+000, - -2.528005e-001, - -2.861303e+000, - 3.033667e+000, - 1.405049e-001, - 2.481768e-001, - 6.435189e-002, - 5.409907e+000, - 6.372238e-001, - -1.144647e+000, - -3.063749e-001, - 4.347579e+000, - -2.473291e+000, - -1.180139e+000, - 2.550631e+000, - 3.833967e-002, - -3.231444e+000, - 8.737219e-001, - -1.028428e+000, - 8.888974e-002, - -2.431225e+000, - 2.811511e+000, - 2.400771e+000, - -2.380403e+000, - 7.114868e-001, - 8.190106e+000, - 4.166861e-001, - -1.076730e+000, - -3.129260e-001, - 3.582560e+000, - -5.902417e+000, - -6.959342e+000, - 3.528030e+000, - -2.613596e-001, - -2.993803e+000, - 8.934226e-001, - -1.107957e+000, - -1.728652e-001, - 1.679540e+000, - 1.238391e+001, - -2.945620e+000, - -1.568811e+000, - 2.418421e-001, - 1.360652e+000, - 6.182405e-001, - // albedo 1, turbidity 5 - -1.215034e+000, - -2.755459e-001, - -1.477751e-001, - 4.448730e-001, - -4.027817e-001, - 4.787013e-001, - 1.200617e-001, - 3.613995e+000, - 5.999756e-001, - -1.443500e+000, - -5.194350e-001, - 1.588243e-001, - 1.429114e+000, - -2.310655e+000, - 3.033213e-001, - 2.308566e-002, - 1.894189e+000, - 6.066576e-001, - -1.051421e+000, - -9.990731e-002, - 5.187710e-001, - -3.890856e+000, - 7.794599e+000, - 1.810628e+000, - 6.532073e-002, - 2.564480e+000, - 9.334916e-001, - -1.034548e+000, - -6.777012e-002, - -2.587520e-002, - 1.062675e+001, - -2.266196e+001, - -2.002081e+000, - 7.508804e-001, - 2.022771e+000, - 3.517577e-001, - -1.090576e+000, - -2.542157e-001, - 2.213560e+000, - -3.563890e+000, - 9.180955e+000, - 2.780121e+000, - -2.656654e-001, - -5.012514e-002, - 8.968751e-001, - -1.104356e+000, - -1.955634e-001, - 1.782217e+000, - 1.085584e+000, - -5.011522e+000, - -1.075140e+000, - 3.828238e-001, - 6.133363e-001, - 6.448312e-001, - // albedo 1, turbidity 6 - -1.261147e+000, - -3.271435e-001, - 1.136430e-001, - -3.464762e-003, - -3.025565e+000, - 3.660675e-001, - 1.337332e-001, - 3.190374e+000, - 5.655627e-001, - -1.611753e+000, - -6.914768e-001, - 2.911405e-001, - 1.806475e+000, - 2.823240e+000, - 3.320241e-001, - 2.606391e-002, - 9.946717e-001, - 5.581393e-001, - -9.491151e-001, - 9.848038e-003, - 2.711804e-001, - -5.319331e+000, - 1.135835e-001, - 1.669815e+000, - 3.604115e-002, - 3.506230e+000, - 1.008650e+000, - -1.109597e+000, - -1.650703e-001, - -3.529912e-001, - 1.209251e+001, - -1.435008e+001, - -2.085063e+000, - 7.955493e-001, - 1.240407e+000, - 2.856509e-001, - -1.035803e+000, - -1.963707e-001, - 2.407913e+000, - -1.564693e+000, - 4.483717e+000, - 2.795295e+000, - -2.799711e-001, - 6.851892e-002, - 9.312311e-001, - -1.132687e+000, - -2.383551e-001, - 1.590132e+000, - 1.025733e+000, - -4.837236e+000, - -1.334195e+000, - 4.022060e-001, - 4.281273e-001, - 6.334802e-001, - // albedo 1, turbidity 7 - -1.310240e+000, - -3.819813e-001, - 2.469845e-002, - -7.043983e-003, - -5.009925e+000, - 3.560980e-001, - 1.582176e-001, - 2.966421e+000, - 4.998910e-001, - -1.993638e+000, - -1.029241e+000, - 7.780588e-001, - 1.080741e+000, - 7.179598e+000, - 2.478857e-001, - 1.935012e-002, - -3.434240e-001, - 4.813586e-001, - -8.209344e-001, - 1.728853e-001, - -7.045676e-001, - -3.384688e+000, - -4.855111e+000, - 1.661563e+000, - 4.252574e-002, - 5.701648e+000, - 1.110774e+000, - -1.130678e+000, - -3.273624e-001, - 5.555549e-001, - 5.800793e+000, - -8.817085e+000, - -2.344445e+000, - 7.532869e-001, - -2.418368e+000, - 2.201826e-001, - -1.032417e+000, - -1.335568e-001, - 1.707051e+000, - 8.168228e+000, - -5.151972e-003, - 2.785504e+000, - -2.123703e-001, - 1.770173e+000, - 9.064082e-001, - -1.125604e+000, - -2.328530e-001, - 1.537245e+000, - 4.347312e+000, - -4.368526e+000, - -1.527321e+000, - 3.574251e-001, - 5.982159e-001, - 6.705880e-001, - // albedo 1, turbidity 8 - -1.381743e+000, - -4.607543e-001, - -2.754732e-001, - 9.134243e-001, - -7.581174e-001, - 6.220814e-001, - 2.353878e-002, - 2.891536e+000, - 6.426078e-001, - -2.362341e+000, - -1.306326e+000, - 6.909936e-001, - -7.196658e-001, - -4.501812e-001, - -5.219928e-002, - 2.111683e-001, - -9.499603e-001, - 3.301774e-002, - -1.218829e+000, - -6.834768e-002, - -1.241760e+000, - 1.122890e+000, - 5.750762e+000, - 1.231058e+000, - 6.884716e-003, - 6.801032e+000, - 1.512485e+000, - -6.781560e-001, - -2.446588e-001, - 1.302166e+000, - -2.334650e+000, - -1.218960e+001, - -1.257952e+000, - 5.387955e-001, - -5.559859e+000, - -1.209718e-002, - -1.270037e+000, - -1.870204e-001, - 9.650201e-001, - 9.976613e+000, - 1.444014e+000, - 1.523442e+000, - -2.753646e-002, - 3.415790e+000, - 1.017645e+000, - -1.046712e+000, - -2.173979e-001, - 1.473981e+000, - 4.368847e+000, - -4.642506e+000, - -1.049951e+000, - 3.511771e-001, - 2.379457e-001, - 6.307946e-001, - // albedo 1, turbidity 9 - -1.532302e+000, - -6.390752e-001, - -1.369123e-001, - 1.480171e+000, - -1.313391e+000, - 5.210118e-001, - -1.053608e-005, - 2.352090e+000, - 9.000581e-001, - -2.042866e+000, - -1.015386e+000, - 1.750126e-001, - -9.921800e-001, - -9.449241e-002, - 4.791921e-001, - -2.744712e-002, - 9.337925e-001, - -2.902902e-001, - -3.413474e+000, - -1.485380e+000, - -1.301300e+000, - 1.266203e+000, - 3.869657e+000, - -1.405606e-002, - 6.109944e-001, - 3.883967e+000, - 1.540321e+000, - 5.838664e-001, - 2.370098e-001, - 1.420200e+000, - -1.803001e+000, - -6.672775e+000, - 2.866921e-001, - -2.599250e-001, - -4.162164e+000, - 1.296901e-001, - -1.654226e+000, - -3.296843e-001, - 6.245723e-001, - 7.899655e+000, - -1.079857e+000, - 3.145485e-001, - 4.085894e-001, - 2.258895e+000, - 9.071309e-001, - -9.748612e-001, - -2.545963e-001, - 1.374064e+000, - -2.816107e-003, - -2.589259e+000, - -5.960628e-001, - 2.656787e-001, - -1.458520e-001, - 6.529731e-001, - // albedo 1, turbidity 10 - -1.944006e+000, - -9.776516e-001, - -2.425412e-001, - 8.187180e-001, - -6.620102e-001, - 5.676187e-001, - -7.857556e-006, - 1.944153e+000, - 9.001463e-001, - -1.294455e+000, - -7.294996e-001, - -1.718682e-002, - 1.261264e+000, - -1.170104e+000, - -2.029198e-001, - -1.306023e-002, - 1.821821e+000, - -2.533820e-001, - -6.849943e+000, - -2.937611e+000, - -1.107710e+000, - -3.923478e+000, - 5.018293e+000, - 2.040419e+000, - 2.845113e-001, - 2.080902e+000, - 1.460328e+000, - 1.445166e+000, - 1.641979e-001, - 9.591325e-001, - 8.676572e+000, - -1.098801e+001, - -2.274573e+000, - 1.340040e-001, - -1.166380e+000, - 1.014270e-001, - -1.596800e+000, - -4.130457e-001, - 9.250919e-001, - -1.406592e+000, - 2.474727e+000, - 1.748285e+000, - 9.929937e-002, - -6.705073e-001, - 9.210646e-001, - -1.035617e+000, - -3.537996e-001, - 1.073337e+000, - 6.090616e+000, - -3.710420e+000, - -9.390485e-001, - 2.233788e-001, - -3.213961e-004, - 6.545784e-001, -}; - -double datasetRad600[] = -{ - // albedo 0, turbidity 1 - 1.299197e-001, - 8.321511e-002, - 2.387451e-001, - 5.880940e-001, - 3.729916e-001, - 4.103205e-001, - // albedo 0, turbidity 2 - 1.270323e-001, - 9.637820e-002, - 1.615812e-001, - 8.452533e-001, - 3.032088e-001, - 4.665419e-001, - // albedo 0, turbidity 3 - 1.219961e-001, - 1.092933e-001, - 5.901632e-002, - 1.159891e+000, - 2.934228e-001, - 5.092212e-001, - // albedo 0, turbidity 4 - 1.119541e-001, - 1.351827e-001, - -1.275865e-001, - 1.613767e+000, - 3.106034e-001, - 5.716776e-001, - // albedo 0, turbidity 5 - 1.014757e-001, - 1.830462e-001, - -3.923527e-001, - 2.142187e+000, - 2.311117e-001, - 6.935246e-001, - // albedo 0, turbidity 6 - 9.547231e-002, - 2.061450e-001, - -5.263613e-001, - 2.366722e+000, - 2.846338e-001, - 7.366447e-001, - // albedo 0, turbidity 7 - 8.667068e-002, - 2.433017e-001, - -7.117469e-001, - 2.634726e+000, - 3.869484e-001, - 8.214510e-001, - // albedo 0, turbidity 8 - 7.662515e-002, - 2.696023e-001, - -8.324986e-001, - 2.658131e+000, - 7.772588e-001, - 8.929431e-001, - // albedo 0, turbidity 9 - 6.629504e-002, - 2.629460e-001, - -7.999192e-001, - 2.265017e+000, - 1.480991e+000, - 1.022526e+000, - // albedo 0, turbidity 10 - 5.848320e-002, - 1.969638e-001, - -4.880301e-001, - 1.188948e+000, - 2.656831e+000, - 1.166634e+000, - // albedo 1, turbidity 1 - 1.356710e-001, - 1.027510e-001, - 2.164597e-001, - 5.973954e-001, - 8.682036e-001, - 9.805911e-001, - // albedo 1, turbidity 2 - 1.334939e-001, - 1.170363e-001, - 1.345563e-001, - 8.550149e-001, - 8.116863e-001, - 1.066240e+000, - // albedo 1, turbidity 3 - 1.276963e-001, - 1.324982e-001, - 2.283428e-002, - 1.185916e+000, - 8.070938e-001, - 1.153223e+000, - // albedo 1, turbidity 4 - 1.189040e-001, - 1.594238e-001, - -1.704000e-001, - 1.638298e+000, - 8.601982e-001, - 1.260336e+000, - // albedo 1, turbidity 5 - 1.084167e-001, - 1.944743e-001, - -3.780871e-001, - 2.038365e+000, - 9.194507e-001, - 1.384964e+000, - // albedo 1, turbidity 6 - 1.031451e-001, - 2.143658e-001, - -4.911574e-001, - 2.201644e+000, - 1.040176e+000, - 1.437725e+000, - // albedo 1, turbidity 7 - 9.432700e-002, - 2.394741e-001, - -6.269994e-001, - 2.357064e+000, - 1.243691e+000, - 1.534951e+000, - // albedo 1, turbidity 8 - 8.488675e-002, - 2.521587e-001, - -6.920513e-001, - 2.241994e+000, - 1.759223e+000, - 1.611551e+000, - // albedo 1, turbidity 9 - 7.537831e-002, - 2.332452e-001, - -5.979287e-001, - 1.683393e+000, - 2.607738e+000, - 1.716448e+000, - // albedo 1, turbidity 10 - 6.598016e-002, - 1.617505e-001, - -2.684133e-001, - 5.631708e-001, - 3.767336e+000, - 1.829865e+000, -}; - -double dataset640[] = -{ - // albedo 0, turbidity 1 - -1.113346e+000, - -1.715076e-001, - -2.657094e+000, - 4.632520e+000, - -1.092310e-001, - 1.421516e+000, - 3.230348e-003, - 2.697889e+000, - 6.262031e-001, - -1.193355e+000, - -2.074379e-001, - 1.431777e+000, - 8.245570e-001, - -1.936967e-001, - 9.392137e-001, - 1.972523e-002, - 3.001209e+000, - 4.415825e-001, - -9.337792e-001, - -2.037239e-001, - 3.943675e+000, - -2.487730e+000, - -9.876315e-001, - 2.772411e+000, - -4.919462e-002, - -4.176827e+000, - 1.026227e+000, - -1.297623e+000, - -1.296758e-001, - -3.144502e-001, - 2.454199e+000, - 2.433614e+000, - 5.298928e-001, - 7.814939e-002, - 6.564581e+000, - 5.587597e-001, - -9.325270e-001, - -1.997966e-001, - 3.363315e+000, - -1.887198e+000, - -8.905212e+000, - 2.808597e+000, - -9.537165e-002, - -3.059702e+000, - 5.403718e-001, - -1.125650e+000, - -1.904795e-001, - 2.099998e+000, - 1.251930e+000, - -1.899312e+000, - 5.255919e-001, - 9.848260e-002, - 9.627433e-001, - 6.251236e-001, - // albedo 0, turbidity 2 - -1.104956e+000, - -1.372068e-001, - -2.996624e+000, - 4.260021e+000, - -1.263137e-001, - 1.327775e+000, - 7.595887e-002, - 5.301229e+000, - 6.478109e-001, - -1.158426e+000, - -1.921879e-001, - 3.371987e-001, - 8.543727e-001, - -1.195421e-001, - 2.178871e-001, - 1.573997e-001, - 3.059646e+000, - 5.355391e-001, - -1.012076e+000, - -1.456275e-001, - 3.857821e+000, - -1.137640e+000, - -7.400821e-001, - 4.132381e+000, - -2.101470e-001, - -1.704290e-001, - 1.094519e+000, - -1.200085e+000, - -9.008631e-002, - -1.764929e+000, - 4.584027e-001, - 8.033799e-001, - -1.730728e+000, - 5.892683e-001, - 6.438112e+000, - 2.141131e-001, - -9.836248e-001, - -1.983419e-001, - 3.519957e+000, - -9.777763e-001, - -5.727911e+000, - 4.397457e+000, - -2.864495e-001, - -2.511187e+000, - 9.881415e-001, - -1.111842e+000, - -1.992363e-001, - 1.746814e+000, - 5.036170e+000, - -2.993753e+000, - -5.348114e-001, - 2.332738e-001, - 8.970344e-001, - 5.806194e-001, - // albedo 0, turbidity 3 - -1.120087e+000, - -1.577355e-001, - -1.165606e+000, - 1.782016e+000, - -1.771264e-001, - 8.928578e-001, - 1.613110e-001, - 4.975693e+000, - 6.258796e-001, - -1.182069e+000, - -2.047357e-001, - -4.041517e-001, - 1.732659e+000, - -4.322749e-001, - 6.549554e-001, - 5.392767e-002, - 4.838218e+000, - 6.441461e-001, - -1.071518e+000, - -2.057500e-001, - 2.808685e+000, - -1.990080e+000, - -8.491815e-001, - 2.193915e+000, - 2.411077e-001, - -3.251587e+000, - 7.470978e-001, - -1.113379e+000, - -6.708322e-003, - -2.181109e+000, - 2.107674e+000, - 2.216970e+000, - -6.233552e-001, - 3.558080e-001, - 9.251876e+000, - 6.319555e-001, - -1.026698e+000, - -2.260748e-001, - 3.031659e+000, - -1.615765e+000, - -1.323341e+000, - 2.835147e+000, - 1.186568e-001, - -3.366247e+000, - 6.850407e-001, - -1.088223e+000, - -1.817555e-001, - 1.435855e+000, - 1.845164e+000, - -3.488539e+000, - 2.554837e-001, - 2.144895e-001, - 1.558895e+000, - 7.315398e-001, - // albedo 0, turbidity 4 - -1.164089e+000, - -2.003003e-001, - -2.998423e-001, - 2.713689e-001, - -1.828861e-001, - 5.800779e-001, - 1.968402e-001, - 4.650130e+000, - 6.156174e-001, - -1.209796e+000, - -2.733887e-001, - -9.360003e-001, - 2.769100e+000, - -1.870929e+000, - 7.049322e-001, - -8.477045e-002, - 4.120960e+000, - 7.444509e-001, - -1.232839e+000, - -2.622151e-001, - 2.857050e+000, - -2.866256e+000, - 3.128232e+000, - 1.897877e+000, - 4.581244e-001, - -2.112943e+000, - 6.384882e-001, - -9.291113e-001, - 4.110508e-002, - -2.235781e+000, - 2.969741e+000, - -9.758544e+000, - -1.941571e+000, - 3.426656e-001, - 6.907158e+000, - 6.945892e-001, - -1.103614e+000, - -2.279953e-001, - 2.314490e+000, - -6.307971e-001, - 3.369674e+000, - 3.787928e+000, - 2.456513e-001, - -1.776073e+000, - 6.864316e-001, - -1.072160e+000, - -1.984678e-001, - 1.092192e+000, - 8.472734e-001, - -3.126637e+000, - -1.076607e+000, - 3.908469e-001, - 1.205671e+000, - 7.035925e-001, - // albedo 0, turbidity 5 - -1.222416e+000, - -2.654298e-001, - -1.149975e-001, - -6.277756e-003, - -1.369463e+000, - 4.402179e-001, - 1.881320e-001, - 3.896722e+000, - 6.037946e-001, - -1.407746e+000, - -4.603243e-001, - -3.071475e-001, - 2.937390e+000, - -9.164938e-001, - 6.696693e-001, - -6.608327e-002, - 2.444782e+000, - 6.905594e-001, - -1.120454e+000, - -1.466269e-001, - 7.829076e-001, - -7.009271e+000, - 5.364470e+000, - 1.294280e+000, - 4.109552e-001, - 1.525889e+000, - 7.709564e-001, - -9.792886e-001, - -4.325464e-002, - -4.059461e-001, - 1.522559e+001, - -1.867598e+001, - -1.169367e+000, - 3.589556e-001, - 2.368951e+000, - 5.526839e-001, - -1.091118e+000, - -2.286983e-001, - 9.896666e-001, - -6.655971e+000, - 8.168041e+000, - 1.923773e+000, - 3.116805e-001, - 1.852611e-001, - 7.524175e-001, - -1.053081e+000, - -1.598496e-001, - 9.684194e-001, - 3.620674e+000, - -5.015769e+000, - 8.125082e-002, - 4.669502e-001, - 1.415221e+000, - 7.044272e-001, - // albedo 0, turbidity 6 - -1.267172e+000, - -3.101221e-001, - -8.556526e-002, - -3.602153e-003, - -4.988229e+000, - 4.099753e-001, - 1.555248e-001, - 3.585489e+000, - 6.128833e-001, - -1.613116e+000, - -6.560485e-001, - 9.250270e-002, - 2.119268e+000, - 8.031058e+000, - 4.019483e-001, - 4.526662e-002, - 1.362051e+000, - 5.999628e-001, - -1.012405e+000, - -2.251592e-002, - 2.836289e-001, - -7.904006e+000, - -9.544755e+000, - 1.754891e+000, - 1.283266e-001, - 3.042478e+000, - 9.234755e-001, - -1.022835e+000, - -1.361070e-001, - -4.207218e-001, - 1.947050e+001, - -5.511234e+000, - -2.417169e+000, - 7.837822e-001, - 8.288902e-001, - 3.509734e-001, - -1.068370e+000, - -1.806143e-001, - 1.059217e+000, - 7.087518e-001, - -1.671865e+000, - 3.098645e+000, - -9.859822e-002, - 9.336021e-001, - 8.929147e-001, - -1.065467e+000, - -1.928982e-001, - 6.159162e-001, - -4.157538e-003, - -9.397621e-001, - -1.193139e+000, - 6.979501e-001, - 1.118894e+000, - 6.467115e-001, - // albedo 0, turbidity 7 - -1.345697e+000, - -3.906019e-001, - -1.921159e-001, - -7.410201e-003, - -4.683006e+000, - 4.591917e-001, - 1.919817e-001, - 3.158844e+000, - 5.319014e-001, - -2.096314e+000, - -1.056514e+000, - 7.665515e-001, - 1.602483e+000, - 6.290779e+000, - 4.693208e-001, - -6.258855e-002, - -3.745685e-001, - 5.853677e-001, - -7.573573e-001, - 2.265213e-001, - -1.283398e+000, - -4.696984e+000, - -4.261986e+000, - 1.197826e+000, - 3.444468e-001, - 6.004387e+000, - 9.413954e-001, - -1.140929e+000, - -3.489820e-001, - 1.095429e+000, - 7.531589e+000, - -8.153320e+000, - -1.722207e+000, - 4.427477e-001, - -3.072440e+000, - 3.874398e-001, - -1.009003e+000, - -9.087616e-002, - 4.181128e-002, - 1.154023e+001, - -5.092155e-001, - 2.166116e+000, - 1.620893e-001, - 2.824826e+000, - 8.289491e-001, - -1.080842e+000, - -2.166745e-001, - 6.939662e-001, - -2.316636e-003, - -2.616711e+000, - -1.012238e+000, - 6.132021e-001, - 7.579828e-001, - 6.813755e-001, - // albedo 0, turbidity 8 - -1.394668e+000, - -4.508268e-001, - -2.615024e-001, - -7.412740e-003, - -4.811648e+000, - 4.235635e-001, - 1.627041e-001, - 3.134174e+000, - 5.225016e-001, - -2.715734e+000, - -1.409574e+000, - 6.485110e-001, - 6.307101e-001, - 8.120123e+000, - 3.677567e-001, - 6.430919e-002, - -3.729191e-001, - 3.463130e-001, - -8.973624e-001, - 2.859206e-002, - -1.610007e+000, - -1.483136e+000, - -5.613288e+000, - 7.093329e-001, - 2.936945e-001, - 5.541210e+000, - 1.143952e+000, - -8.450858e-001, - -1.969825e-001, - 1.399585e+000, - 1.418708e-001, - -4.532026e+000, - -7.432040e-001, - 3.410858e-001, - -3.386293e+000, - 2.885614e-001, - -1.180533e+000, - -2.469972e-001, - -2.694505e-002, - 1.635998e+001, - -2.378676e+000, - 9.477733e-001, - 1.105776e-001, - 1.954485e+000, - 8.559872e-001, - -1.022908e+000, - -1.650807e-001, - 3.812483e-001, - -2.139201e-003, - -2.300711e+000, - -5.917998e-001, - 6.793527e-001, - 1.248273e+000, - 6.747565e-001, - // albedo 0, turbidity 9 - -1.557922e+000, - -6.294681e-001, - -2.355549e-001, - -8.743568e-003, - -5.017111e+000, - 4.034446e-001, - 1.005643e-001, - 2.735289e+000, - 5.667004e-001, - -3.061673e+000, - -1.398157e+000, - 1.597008e-001, - 1.066059e+000, - 8.207018e+000, - 4.785780e-001, - 4.629487e-002, - 1.324020e+000, - 2.540204e-001, - -2.371583e+000, - -1.100187e+000, - -1.279309e+000, - -3.340819e+000, - -6.556706e+000, - 2.636750e-001, - 4.298705e-001, - 2.649782e+000, - 1.060950e+000, - -5.315727e-002, - 2.306821e-001, - 1.091037e+000, - 5.297610e+000, - -2.412315e+000, - -7.083157e-002, - 7.256586e-002, - -1.330891e+000, - 4.168205e-001, - -1.375983e+000, - -4.677570e-001, - 2.271650e-001, - 8.771601e+000, - -2.511780e+000, - 1.487082e-001, - 8.542210e-002, - 5.509707e-003, - 7.821447e-001, - -1.006483e+000, - -1.435513e-001, - 5.802646e-002, - -3.181899e-003, - -2.010861e+000, - -1.746922e-001, - 7.487809e-001, - 1.623209e+000, - 6.848148e-001, - // albedo 0, turbidity 10 - -1.919035e+000, - -9.396362e-001, - -3.059418e-001, - 1.542398e+000, - -1.488273e+000, - 5.133825e-001, - -7.992185e-006, - 2.276361e+000, - 8.334381e-001, - -2.470138e+000, - -1.108577e+000, - -5.521438e-001, - -9.047033e-001, - 6.905739e-001, - 3.774300e-001, - -2.801883e-002, - 2.413470e+000, - -8.986266e-002, - -5.532450e+000, - -2.346497e+000, - -1.734654e+000, - 1.461689e+000, - 1.765938e+000, - 4.969811e-001, - 6.205943e-001, - 2.112232e+000, - 1.159488e+000, - 4.159150e-001, - -2.306809e-001, - 1.540502e+000, - -1.006923e+000, - -5.275092e+000, - -2.776202e-002, - -1.632884e-001, - -1.467491e+000, - 4.177919e-001, - -1.248112e+000, - -3.080519e-001, - -1.229235e-001, - 8.972757e+000, - -1.532948e+000, - -8.283794e-002, - 1.561573e-001, - 1.856113e-001, - 7.696948e-001, - -1.054499e+000, - -2.660558e-001, - 1.307025e-001, - -2.167883e-003, - -1.531056e+000, - 1.525856e-001, - 5.356892e-001, - 7.181428e-001, - 6.837654e-001, - // albedo 1, turbidity 1 - -1.113347e+000, - -1.715068e-001, - -2.657094e+000, - 4.632520e+000, - -1.092308e-001, - 1.421516e+000, - 3.229759e-003, - 2.697889e+000, - 6.262031e-001, - -1.193355e+000, - -2.074367e-001, - 1.431777e+000, - 8.245569e-001, - -1.936966e-001, - 9.392136e-001, - 1.972263e-002, - 3.001209e+000, - 4.415825e-001, - -9.337795e-001, - -2.037221e-001, - 3.943675e+000, - -2.487730e+000, - -9.876315e-001, - 2.772410e+000, - -4.919872e-002, - -4.176827e+000, - 1.026227e+000, - -1.297624e+000, - -1.296733e-001, - -3.144502e-001, - 2.454199e+000, - 2.433614e+000, - 5.298925e-001, - 7.814503e-002, - 6.564581e+000, - 5.587597e-001, - -9.325285e-001, - -1.997939e-001, - 3.363316e+000, - -1.887198e+000, - -8.905212e+000, - 2.808596e+000, - -9.537523e-002, - -3.059702e+000, - 5.403717e-001, - -1.125653e+000, - -1.904767e-001, - 2.099998e+000, - 1.251930e+000, - -1.899312e+000, - 5.255917e-001, - 9.848033e-002, - 9.627434e-001, - 6.251233e-001, - // albedo 1, turbidity 2 - -1.115892e+000, - -1.571450e-001, - -5.361081e+000, - 6.833528e+000, - -6.891479e-002, - 1.309709e+000, - 6.046362e-002, - 3.972373e+000, - 6.651606e-001, - -1.147479e+000, - -1.855896e-001, - 2.239259e+000, - -5.937930e-001, - -1.005125e-001, - 2.773971e-001, - 1.337105e-001, - 3.136906e+000, - 5.194230e-001, - -1.030450e+000, - -1.533626e-001, - 2.268967e+000, - -4.886576e-001, - -6.336865e-001, - 3.911080e+000, - -1.602643e-001, - 1.513730e-001, - 1.130153e+000, - -1.159297e+000, - -5.818314e-002, - -1.488690e-001, - 1.358829e+000, - 1.208889e+000, - -1.827456e+000, - 4.867277e-001, - 6.185880e+000, - 1.951064e-001, - -1.023581e+000, - -2.517540e-001, - 3.635148e+000, - -2.375150e+000, - -9.409992e+000, - 3.209554e+000, - -3.006489e-001, - -3.235953e+000, - 9.969505e-001, - -1.102864e+000, - -1.644399e-001, - 2.160645e+000, - 5.685422e+000, - -2.867248e+000, - -1.020916e+000, - 2.064591e-001, - 1.192668e+000, - 5.029621e-001, - // albedo 1, turbidity 3 - -1.120417e+000, - -1.543428e-001, - -2.173869e+000, - 2.965267e+000, - -1.062190e-001, - 8.112859e-001, - 1.448682e-001, - 4.993622e+000, - 6.373394e-001, - -1.168618e+000, - -1.948508e-001, - -6.247560e-001, - 2.203402e+000, - -2.724794e-001, - 8.364691e-001, - 5.608377e-002, - 4.262497e+000, - 6.310098e-001, - -1.080229e+000, - -2.282841e-001, - 2.194035e+000, - -1.203336e+000, - -3.861545e-001, - 2.234045e+000, - 1.553866e-001, - -3.266039e+000, - 8.246847e-001, - -1.101698e+000, - 2.182410e-002, - -1.179116e+000, - 8.533844e-001, - 8.777171e-001, - -1.222988e+000, - 5.021882e-001, - 9.364642e+000, - 4.790363e-001, - -1.047144e+000, - -2.539571e-001, - 3.684827e+000, - 9.827861e-002, - -2.297266e-001, - 3.038327e+000, - -2.609445e-001, - -3.685112e+000, - 8.596057e-001, - -1.103227e+000, - -1.861499e-001, - 2.098952e+000, - 1.030900e-001, - -4.268311e+000, - -1.120060e+000, - 2.879792e-001, - 7.160893e-001, - 6.213207e-001, - // albedo 1, turbidity 4 - -1.155288e+000, - -2.006105e-001, - -5.822630e-002, - 3.970794e-001, - -2.828885e-001, - 5.093569e-001, - 1.631119e-001, - 4.152479e+000, - 6.357376e-001, - -1.241627e+000, - -2.673712e-001, - -6.444494e-001, - 2.257014e+000, - -1.630843e+000, - 5.967071e-001, - 9.888683e-003, - 4.308732e+000, - 6.751366e-001, - -1.136812e+000, - -2.811418e-001, - 2.220215e+000, - -1.535870e+000, - 2.354743e+000, - 2.041362e+000, - 2.387976e-001, - -3.453756e+000, - 7.672245e-001, - -1.028322e+000, - 9.134962e-002, - -1.151053e+000, - 6.511620e-001, - -5.683098e+000, - -2.001006e+000, - 6.430642e-001, - 8.523367e+000, - 5.422240e-001, - -1.076830e+000, - -3.101207e-001, - 3.052794e+000, - 3.177593e-001, - 3.054756e+000, - 3.386727e+000, - -2.312489e-001, - -3.908802e+000, - 7.978614e-001, - -1.107083e+000, - -1.880372e-001, - 2.001810e+000, - -3.352202e-003, - -1.526356e+000, - -1.480550e+000, - 3.486524e-001, - 7.220325e-001, - 6.581821e-001, - // albedo 1, turbidity 5 - -1.214879e+000, - -2.719222e-001, - 2.247747e-001, - 1.509740e-002, - -5.438281e-001, - 3.728351e-001, - 1.749880e-001, - 3.132220e+000, - 6.001432e-001, - -1.424202e+000, - -4.768943e-001, - -6.396040e-001, - 2.060101e+000, - -1.113780e+000, - 6.993089e-001, - -2.098291e-002, - 2.504826e+000, - 6.757213e-001, - -1.048548e+000, - -1.173837e-001, - 1.885902e+000, - -3.700301e+000, - 4.667326e+000, - 1.344798e+000, - 2.140261e-001, - 1.525414e-001, - 8.450168e-001, - -1.056271e+000, - -5.272364e-002, - -1.391708e+000, - 9.711492e+000, - -1.742761e+001, - -1.677628e+000, - 6.906304e-001, - 4.107662e+000, - 4.268005e-001, - -1.072328e+000, - -2.450563e-001, - 3.125155e+000, - -2.470389e+000, - 6.794968e+000, - 2.678049e+000, - -2.092059e-001, - -1.651858e+000, - 8.708740e-001, - -1.107628e+000, - -2.089585e-001, - 1.799168e+000, - 4.621596e-001, - -5.008181e+000, - -1.121127e+000, - 3.917217e-001, - 2.703209e-001, - 6.449597e-001, - // albedo 1, turbidity 6 - -1.249741e+000, - -3.073987e-001, - 1.398829e-001, - -2.878563e-003, - -5.008845e+000, - 4.535605e-001, - 1.447766e-001, - 3.091173e+000, - 6.138128e-001, - -1.577209e+000, - -6.213162e-001, - 2.895282e-001, - 1.670732e+000, - 8.708786e+000, - 2.480283e-001, - 7.326386e-002, - 1.395638e+000, - 5.814691e-001, - -1.015394e+000, - -9.306378e-002, - 4.870291e-001, - -6.558243e+000, - -1.073347e+001, - 1.842159e+000, - 2.135043e-002, - 1.655269e+000, - 9.750505e-001, - -1.030222e+000, - -3.712071e-002, - -4.565649e-001, - 1.827249e+001, - -4.505703e+000, - -2.635230e+000, - 9.447498e-001, - 2.450865e+000, - 2.757082e-001, - -1.086063e+000, - -2.709359e-001, - 2.527868e+000, - -1.786375e+000, - -2.329338e+000, - 3.367729e+000, - -4.201670e-001, - -9.372873e-001, - 9.570917e-001, - -1.113156e+000, - -2.162986e-001, - 1.815038e+000, - 1.036606e-001, - -1.106537e+000, - -1.657558e+000, - 4.923976e-001, - -1.768985e-002, - 6.218745e-001, - // albedo 1, turbidity 7 - -1.345662e+000, - -4.038158e-001, - 1.601105e-001, - -6.892546e-003, - -5.010308e+000, - 3.903794e-001, - 1.543535e-001, - 2.538245e+000, - 5.555141e-001, - -1.998866e+000, - -9.786972e-001, - 5.763250e-001, - 1.007104e+000, - 8.983795e+000, - 3.752110e-001, - 7.375525e-002, - 1.792659e-001, - 4.969463e-001, - -7.854213e-001, - 1.186171e-001, - -1.925047e-001, - -3.567464e+000, - -8.901606e+000, - 1.181923e+000, - 4.049067e-002, - 3.603602e+000, - 1.081550e+000, - -1.113558e+000, - -1.964692e-001, - -6.175963e-002, - 7.345047e+000, - -5.293662e+000, - -1.720046e+000, - 8.863695e-001, - -1.699694e-001, - 2.184709e-001, - -1.077319e+000, - -2.429937e-001, - 2.226652e+000, - 8.082352e+000, - -5.647382e-001, - 2.187018e+000, - -3.571678e-001, - -2.370890e-001, - 9.528157e-001, - -1.101702e+000, - -2.020333e-001, - 1.637670e+000, - 5.276716e-001, - -4.006007e+000, - -1.066501e+000, - 4.548015e-001, - 4.055769e-001, - 6.485706e-001, - // albedo 1, turbidity 8 - -1.411469e+000, - -4.870956e-001, - 1.017578e-001, - -8.806763e-003, - -5.014847e+000, - 4.306981e-001, - 1.278033e-001, - 2.361142e+000, - 5.472925e-001, - -2.735007e+000, - -1.453253e+000, - 5.783189e-001, - 5.673243e-001, - 9.968637e+000, - 2.236397e-001, - 1.860109e-001, - -3.781953e-001, - 2.505082e-001, - -7.371503e-001, - 1.290592e-001, - -5.349577e-001, - -1.885854e+000, - -8.623054e+000, - 1.078614e+000, - -5.694996e-002, - 4.526279e+000, - 1.347569e+000, - -9.678370e-001, - -2.562830e-001, - 2.961987e-001, - 2.461144e+000, - -4.753928e+000, - -1.657373e+000, - 8.388825e-001, - -2.440974e+000, - 1.816225e-002, - -1.148918e+000, - -2.271366e-001, - 1.817890e+000, - 1.097345e+001, - -1.126160e+000, - 1.993895e+000, - -2.870862e-001, - 7.269217e-001, - 1.032783e+000, - -1.090291e+000, - -2.315314e-001, - 1.491197e+000, - 9.632479e+000, - -4.323932e+000, - -1.326631e+000, - 3.604933e-001, - 1.905995e-001, - 6.312241e-001, - // albedo 1, turbidity 9 - -1.552618e+000, - -6.336918e-001, - 4.605315e-002, - -8.452985e-003, - -4.979015e+000, - 3.484674e-001, - 8.791637e-002, - 2.297399e+000, - 5.705230e-001, - -2.770597e+000, - -1.302036e+000, - 3.421676e-001, - 1.220769e+000, - 7.584372e+000, - 4.050789e-001, - 4.478808e-002, - 9.435710e-001, - 2.393878e-001, - -2.631791e+000, - -1.247576e+000, - -8.423940e-001, - -3.955998e+000, - -5.341100e+000, - 6.385142e-001, - 3.872948e-001, - 2.279807e+000, - 1.101259e+000, - 1.875824e-001, - 3.564184e-001, - 7.973268e-001, - 7.159160e+000, - -3.857340e+000, - -9.227702e-001, - 8.283793e-002, - -1.444145e+000, - 3.654244e-001, - -1.489693e+000, - -4.947623e-001, - 1.253918e+000, - 3.949282e+000, - -1.320903e+000, - 1.088652e+000, - 1.489763e-001, - -3.855853e-001, - 8.130960e-001, - -1.042349e+000, - -2.134514e-001, - 1.289359e+000, - -3.129206e-003, - -2.385397e+000, - -7.642278e-001, - 3.772293e-001, - 3.683001e-001, - 6.811674e-001, - // albedo 1, turbidity 10 - -1.924886e+000, - -9.354584e-001, - -1.879067e-001, - 1.267892e+000, - -1.174622e+000, - 5.570232e-001, - -1.060836e-005, - 2.002481e+000, - 9.001398e-001, - -1.556107e+000, - -8.200410e-001, - -1.065249e-001, - -3.241942e-001, - 1.552504e-001, - 7.662815e-002, - -2.568474e-002, - 1.738474e+000, - -2.100942e-001, - -7.169297e+000, - -2.972878e+000, - -1.324108e+000, - 7.276378e-003, - 2.638975e+000, - 1.186150e+000, - 5.695709e-001, - 2.027718e+000, - 1.328077e+000, - 1.889259e+000, - 2.600110e-001, - 1.309033e+000, - 1.187864e+000, - -6.905754e+000, - -1.163025e+000, - -1.642758e-001, - -1.774036e+000, - 2.566466e-001, - -1.816439e+000, - -3.601966e-001, - 6.367922e-001, - 6.798160e+000, - -6.431562e-001, - 9.014269e-001, - 2.490693e-001, - -6.685128e-003, - 8.542883e-001, - -9.684886e-001, - -3.866519e-001, - 1.268224e+000, - -4.187273e-003, - -1.833316e+000, - -4.626197e-001, - 2.263859e-001, - -5.583963e-001, - 6.650112e-001, -}; - -double datasetRad640[] = -{ - // albedo 0, turbidity 1 - 1.197895e-001, - 7.750667e-002, - 2.407021e-001, - 3.903099e-001, - 2.932408e-001, - 3.006399e-001, - // albedo 0, turbidity 2 - 1.209424e-001, - 8.265434e-002, - 2.083945e-001, - 5.853826e-001, - 2.663490e-001, - 3.373078e-001, - // albedo 0, turbidity 3 - 1.161191e-001, - 9.288397e-002, - 1.219496e-001, - 9.247264e-001, - 2.049420e-001, - 4.043150e-001, - // albedo 0, turbidity 4 - 1.073493e-001, - 1.169092e-001, - -6.161409e-002, - 1.431414e+000, - 1.494847e-001, - 4.931987e-001, - // albedo 0, turbidity 5 - 9.794193e-002, - 1.457214e-001, - -2.558067e-001, - 1.850120e+000, - 1.802584e-001, - 5.523752e-001, - // albedo 0, turbidity 6 - 9.153358e-002, - 1.740591e-001, - -4.147944e-001, - 2.143293e+000, - 1.718393e-001, - 6.142311e-001, - // albedo 0, turbidity 7 - 8.281154e-002, - 2.131901e-001, - -6.172447e-001, - 2.462224e+000, - 2.434283e-001, - 6.958915e-001, - // albedo 0, turbidity 8 - 7.214826e-002, - 2.499471e-001, - -8.009912e-001, - 2.650458e+000, - 4.904950e-001, - 8.061404e-001, - // albedo 0, turbidity 9 - 6.109653e-002, - 2.500028e-001, - -7.962813e-001, - 2.317194e+000, - 1.174011e+000, - 9.080407e-001, - // albedo 0, turbidity 10 - 5.281779e-002, - 1.966643e-001, - -5.387787e-001, - 1.359134e+000, - 2.260367e+000, - 1.063031e+000, - // albedo 1, turbidity 1 - 1.241851e-001, - 9.705702e-002, - 2.016387e-001, - 4.445551e-001, - 6.215866e-001, - 7.528173e-001, - // albedo 1, turbidity 2 - 1.248417e-001, - 1.001877e-001, - 1.809281e-001, - 6.156329e-001, - 6.384930e-001, - 8.001681e-001, - // albedo 1, turbidity 3 - 1.215185e-001, - 1.116381e-001, - 9.409322e-002, - 9.385153e-001, - 6.300761e-001, - 8.884105e-001, - // albedo 1, turbidity 4 - 1.132146e-001, - 1.313387e-001, - -7.312012e-002, - 1.408822e+000, - 6.509308e-001, - 1.009256e+000, - // albedo 1, turbidity 5 - 1.032816e-001, - 1.663390e-001, - -2.911491e-001, - 1.869933e+000, - 6.563583e-001, - 1.150412e+000, - // albedo 1, turbidity 6 - 9.701537e-002, - 1.883206e-001, - -4.243771e-001, - 2.104057e+000, - 7.155674e-001, - 1.228579e+000, - // albedo 1, turbidity 7 - 8.841369e-002, - 2.160578e-001, - -5.725878e-001, - 2.290829e+000, - 9.251758e-001, - 1.303580e+000, - // albedo 1, turbidity 8 - 7.850642e-002, - 2.390426e-001, - -6.946719e-001, - 2.320692e+000, - 1.325887e+000, - 1.424719e+000, - // albedo 1, turbidity 9 - 6.825538e-002, - 2.253718e-001, - -6.265067e-001, - 1.821317e+000, - 2.158738e+000, - 1.529418e+000, - // albedo 1, turbidity 10 - 5.985528e-002, - 1.644544e-001, - -3.362673e-001, - 7.751736e-001, - 3.306230e+000, - 1.654105e+000, -}; - -double dataset680[] = -{ - // albedo 0, turbidity 1 - -1.112655e+000, - -1.844098e-001, - -3.170582e+000, - 5.334685e+000, - -6.690891e-002, - 1.561122e+000, - -2.792088e-006, - 1.400688e+000, - 6.639418e-001, - -1.138469e+000, - -1.797086e-001, - 1.271179e+000, - 1.158372e+000, - -1.687824e-001, - 1.414051e+000, - 4.258569e-003, - 2.135675e+000, - 5.322718e-001, - -1.026337e+000, - -1.861539e-001, - 2.119648e+000, - -6.753200e-001, - -1.972700e-001, - 2.384659e+000, - -1.304972e-002, - -1.804518e+000, - 1.207802e+000, - -1.198321e+000, - -1.585305e-001, - 1.339219e+000, - 5.796904e-001, - -5.143433e-002, - 1.107455e+000, - 2.551349e-002, - 3.346946e+000, - -3.387602e-002, - -9.935091e-001, - -1.747698e-001, - 2.816779e+000, - -3.496148e-001, - 1.832218e+000, - 2.324658e+000, - -3.408305e-002, - -1.618451e+000, - 1.189512e+000, - -1.092682e+000, - -1.840784e-001, - 2.455887e+000, - 1.441429e-001, - -4.002347e+000, - 1.186375e+000, - 3.634755e-002, - 3.070963e-001, - 5.512501e-001, - // albedo 0, turbidity 2 - -1.104975e+000, - -1.425541e-001, - -1.889148e+000, - 3.408593e+000, - -1.252648e-001, - 1.396095e+000, - 8.358812e-002, - 3.814297e+000, - 6.848154e-001, - -1.131570e+000, - -1.500053e-001, - -1.048539e+000, - 3.133642e+000, - -2.651219e-001, - 1.193999e+000, - 7.013543e-002, - 4.592749e+000, - 6.857750e-001, - -1.030016e+000, - -1.667752e-001, - 6.179600e+000, - -5.163198e+000, - -4.084328e-001, - 2.617798e+000, - 1.966627e-003, - -2.417731e+000, - 8.402310e-001, - -1.167563e+000, - -3.644294e-002, - -4.501893e+000, - 4.471663e+000, - -5.377956e-001, - 4.971351e-002, - 4.621337e-001, - 1.014187e+001, - 4.411276e-001, - -1.018402e+000, - -2.068288e-001, - 4.710566e+000, - -1.425858e+000, - 1.287815e-001, - 3.605281e+000, - -2.164599e-001, - -4.336932e+000, - 9.051639e-001, - -1.078985e+000, - -1.995548e-001, - 1.678948e+000, - 3.074167e-001, - -1.642830e+000, - -1.235470e-001, - 2.735898e-001, - 6.360197e-001, - 5.870665e-001, - // albedo 0, turbidity 3 - -1.132881e+000, - -1.676238e-001, - -1.179974e+000, - 1.902080e+000, - -7.980402e-002, - 8.946611e-001, - 1.939671e-001, - 3.793414e+000, - 6.357246e-001, - -1.138356e+000, - -1.681053e-001, - 1.548320e+000, - -6.001024e-001, - -4.138892e-001, - 2.586807e-001, - 2.126762e-001, - 4.742849e+000, - 5.910253e-001, - -1.093982e+000, - -1.847904e-001, - 1.234133e+000, - -4.707125e-001, - 1.076579e+000, - 3.355751e+000, - 5.394600e-002, - -2.314910e+000, - 8.900752e-001, - -1.117812e+000, - -6.182272e-002, - -4.681118e-001, - 5.075227e+000, - -1.561122e+001, - -2.343845e+000, - 5.618788e-001, - 7.005713e+000, - 4.622191e-001, - -1.013135e+000, - -1.529086e-001, - 1.960772e+000, - -3.022528e+000, - 8.938126e+000, - 4.411437e+000, - 3.156643e-002, - -1.449180e+000, - 8.181914e-001, - -1.087086e+000, - -2.231900e-001, - 1.871061e+000, - 1.830836e+000, - -4.397140e+000, - -5.441402e-001, - 2.728682e-001, - -5.607736e-002, - 6.741811e-001, - // albedo 0, turbidity 4 - -1.176035e+000, - -2.099056e-001, - -8.221907e-001, - 1.520994e+000, - -2.507738e-001, - 9.100863e-001, - 1.507234e-001, - 3.661138e+000, - 6.726424e-001, - -1.140180e+000, - -1.918480e-001, - 2.844393e-001, - -3.842927e-001, - -5.520764e-001, - -1.868484e-001, - 2.247948e-001, - 5.381202e+000, - 6.059726e-001, - -1.282085e+000, - -3.059464e-001, - 1.619956e+000, - -1.362117e+000, - 2.324649e+000, - 3.350678e+000, - 2.102082e-001, - -4.028753e+000, - 8.172091e-001, - -9.092985e-001, - 4.843416e-002, - -1.076741e+000, - 8.143038e+000, - -1.618418e+001, - -3.681285e+000, - 5.217800e-001, - 7.307672e+000, - 5.312006e-001, - -1.110248e+000, - -2.047143e-001, - 1.565253e+000, - -4.575474e+000, - 8.737741e+000, - 5.023419e+000, - 2.469230e-001, - -1.716906e+000, - 7.856742e-001, - -1.054900e+000, - -2.018466e-001, - 1.352034e+000, - 2.656066e+000, - -4.403444e+000, - -1.479998e+000, - 3.939305e-001, - 6.455032e-001, - 6.775162e-001, - // albedo 0, turbidity 5 - -1.237521e+000, - -2.734963e-001, - -4.554763e-001, - 3.417711e-001, - 2.054204e-001, - 3.954470e-001, - 2.366979e-001, - 3.239693e+000, - 6.083737e-001, - -1.354583e+000, - -4.251172e-001, - -3.241668e-001, - 2.077967e+000, - -1.910410e+000, - 8.755633e-001, - -8.365829e-002, - 2.443727e+000, - 7.260119e-001, - -1.152500e+000, - -1.277879e-001, - 1.089367e+000, - -4.497520e+000, - 5.636501e+000, - 1.249272e+000, - 5.829396e-001, - 9.198423e-001, - 7.039872e-001, - -9.782313e-001, - -8.253891e-002, - -5.673470e-001, - 1.098032e+001, - -1.689550e+001, - -1.619205e+000, - 2.125660e-001, - 2.080566e+000, - 6.315535e-001, - -1.064286e+000, - -1.710957e-001, - 9.336921e-001, - -5.525059e+000, - 8.053084e+000, - 2.664602e+000, - 4.815015e-001, - 4.884965e-001, - 7.093015e-001, - -1.067798e+000, - -1.817268e-001, - 1.095720e+000, - 3.551145e+000, - -5.009504e+000, - -4.802047e-001, - 4.854159e-001, - 8.021585e-001, - 7.133339e-001, - // albedo 0, turbidity 6 - -1.251896e+000, - -2.936510e-001, - -3.090944e-002, - -5.488869e-003, - -6.577788e-001, - 4.577691e-001, - 1.780002e-001, - 3.335561e+000, - 6.394482e-001, - -1.615603e+000, - -6.405318e-001, - -4.651954e-001, - 2.332689e+000, - -1.893131e-001, - 3.391170e-001, - 3.495888e-002, - 1.058634e+000, - 6.310524e-001, - -9.703572e-001, - 1.437971e-002, - 6.532383e-001, - -6.450045e+000, - 4.026380e+000, - 2.198628e+000, - 2.684967e-001, - 2.873804e+000, - 8.626816e-001, - -1.053437e+000, - -1.577255e-001, - -2.354526e-001, - 1.753047e+001, - -1.802766e+001, - -3.193379e+000, - 6.264380e-001, - 3.733714e-001, - 4.466776e-001, - -1.051388e+000, - -1.690749e-001, - 6.925698e-001, - -7.450365e+000, - 7.747780e+000, - 3.681960e+000, - 1.688173e-001, - 9.054528e-001, - 8.229209e-001, - -1.060369e+000, - -1.751603e-001, - 8.678290e-001, - 5.136962e+000, - -5.014566e+000, - -1.283438e+000, - 6.547844e-001, - 9.420523e-001, - 6.738511e-001, - // albedo 0, turbidity 7 - -1.358251e+000, - -3.909003e-001, - -7.590093e-002, - -8.010253e-003, - -2.417641e-001, - 5.031789e-001, - 1.882499e-001, - 2.807060e+000, - 5.884485e-001, - -2.043506e+000, - -9.923881e-001, - -4.530797e-001, - 1.750575e+000, - -4.362236e-001, - 2.997323e-001, - 2.328504e-002, - 1.626543e-001, - 5.806819e-001, - -7.280672e-001, - 2.228069e-001, - 2.169765e-001, - -3.681736e+000, - 4.308793e+000, - 1.308622e+000, - 3.451835e-001, - 4.037459e+000, - 9.113772e-001, - -1.155299e+000, - -3.079453e-001, - -1.640569e-001, - 7.663297e+000, - -1.327817e+001, - -1.431157e+000, - 4.096359e-001, - -9.185502e-001, - 4.578034e-001, - -1.006427e+000, - -1.250087e-001, - 7.477012e-001, - 2.612704e+000, - 2.531799e+000, - 1.565371e+000, - 3.452604e-001, - 9.129266e-001, - 7.684386e-001, - -1.068759e+000, - -1.729191e-001, - 5.265652e-001, - 7.074812e+000, - -4.259958e+000, - -4.833255e-001, - 6.043380e-001, - 1.489203e+000, - 7.089074e-001, - // albedo 0, turbidity 8 - -1.398983e+000, - -4.500153e-001, - -5.189309e-001, - 1.546325e-001, - 4.187327e-001, - 2.811516e-001, - 2.379667e-001, - 2.801040e+000, - 5.198375e-001, - -2.970455e+000, - -1.529948e+000, - 1.094532e-001, - 7.382263e-001, - -1.024683e+000, - 2.074091e-001, - 1.397605e-001, - -6.743828e-001, - 3.496944e-001, - -3.942086e-001, - 3.424842e-001, - -1.253259e+000, - -9.268654e-001, - 5.636065e+000, - 8.224289e-001, - 2.452235e-001, - 5.864258e+000, - 1.202820e+000, - -1.181174e+000, - -4.197175e-001, - 1.429102e+000, - -7.894317e-003, - -1.239152e+001, - -5.753431e-001, - 3.552180e-001, - -4.495555e+000, - 2.141883e-001, - -1.060281e+000, - -1.080598e-001, - -3.276480e-001, - 1.369250e+001, - 1.504389e+000, - 6.401191e-001, - 2.437501e-001, - 3.212918e+000, - 9.172133e-001, - -1.037564e+000, - -2.018083e-001, - 6.250668e-001, - -2.525843e-003, - -3.269998e+000, - -2.649814e-001, - 6.600589e-001, - 3.337508e-001, - 6.516131e-001, - // albedo 0, turbidity 9 - -1.610481e+000, - -6.353902e-001, - -5.968977e-001, - 1.414037e+000, - -7.941453e-001, - 7.888684e-001, - 2.209045e-002, - 2.615106e+000, - 6.870260e-001, - -3.073343e+000, - -1.365905e+000, - -2.651943e-001, - -1.685310e+000, - 4.755874e-001, - -1.110669e-001, - 2.561961e-001, - 1.222045e+000, - 3.362780e-002, - -2.207768e+000, - -1.009608e+000, - -1.329601e+000, - 3.393091e+000, - 3.419104e+000, - -4.733375e-002, - 5.989185e-001, - 2.814641e+000, - 1.245189e+000, - -1.981173e-002, - 2.018414e-001, - 1.457765e+000, - -6.316169e+000, - -6.640569e+000, - 7.150646e-001, - -2.993748e-001, - -2.703376e+000, - 3.218596e-001, - -1.435873e+000, - -3.390505e-001, - -3.859047e-001, - 1.457464e+001, - -1.121591e+000, - -6.089868e-002, - 5.319220e-001, - 1.852395e+000, - 8.379521e-001, - -9.812568e-001, - -2.273751e-001, - 5.108069e-001, - -3.735693e-003, - -2.547988e+000, - -4.492561e-001, - 5.069199e-001, - 2.977910e-001, - 6.639273e-001, - // albedo 0, turbidity 10 - -2.056405e+000, - -9.703512e-001, - -3.731953e-001, - 2.052022e+000, - -1.445283e+000, - 6.103743e-001, - -9.389644e-006, - 2.198652e+000, - 8.567335e-001, - -2.105651e+000, - -8.924283e-001, - -6.868702e-001, - -1.665838e+000, - 4.795702e-001, - 5.228080e-001, - -4.272483e-002, - 2.661317e+000, - -1.154062e-001, - -6.179767e+000, - -2.651580e+000, - -1.527652e+000, - 2.692054e+000, - 2.293427e+000, - -1.005611e-001, - 9.545323e-001, - 1.367438e+000, - 1.169193e+000, - 1.240848e+000, - 1.126706e-001, - 1.620422e+000, - -3.384604e+000, - -5.545532e+000, - 4.928203e-001, - -5.999585e-001, - -1.407078e+000, - 4.193816e-001, - -1.539149e+000, - -2.081890e-001, - -4.552234e-001, - 1.056410e+001, - -1.048637e+000, - -2.780921e-001, - 5.682296e-001, - 6.785092e-001, - 7.729892e-001, - -1.036841e+000, - -4.359099e-001, - 4.767834e-001, - -3.794262e-003, - -1.980492e+000, - 9.954067e-002, - 3.037557e-001, - 2.156592e-002, - 6.845201e-001, - // albedo 1, turbidity 1 - -1.110980e+000, - -1.799491e-001, - -3.168600e+000, - 5.336662e+000, - -6.318131e-002, - 1.559251e+000, - 3.204341e-003, - 1.401140e+000, - 6.638144e-001, - -1.132332e+000, - -1.786787e-001, - 1.272954e+000, - 1.160211e+000, - -1.685885e-001, - 1.409550e+000, - 7.140682e-003, - 2.136473e+000, - 5.320908e-001, - -1.015776e+000, - -1.825058e-001, - 2.122848e+000, - -6.725506e-001, - -1.976294e-001, - 2.376807e+000, - -1.859856e-002, - -1.803033e+000, - 1.207528e+000, - -1.189845e+000, - -1.509036e-001, - 1.345709e+000, - 5.832609e-001, - -5.130839e-002, - 1.097035e+000, - 2.686911e-002, - 3.349361e+000, - -3.431297e-002, - -1.000281e+000, - -1.696328e-001, - 2.829408e+000, - -3.466041e-001, - 1.832532e+000, - 2.314637e+000, - -2.721994e-002, - -1.614939e+000, - 1.188720e+000, - -1.120411e+000, - -1.974172e-001, - 2.474172e+000, - 1.453506e-001, - -4.002206e+000, - 1.180333e+000, - 2.229171e-002, - 3.112615e-001, - 5.505539e-001, - // albedo 1, turbidity 2 - -1.112667e+000, - -1.574855e-001, - -2.284814e+000, - 4.255050e+000, - -1.386097e-001, - 1.459506e+000, - 4.508931e-002, - 2.944474e+000, - 7.339984e-001, - -1.113577e+000, - -1.331062e-001, - -1.828757e+000, - 3.910596e+000, - -2.095519e-001, - 1.159335e+000, - 9.311608e-002, - 4.517295e+000, - 6.365313e-001, - -1.061651e+000, - -2.007134e-001, - 5.907472e+000, - -4.808769e+000, - -2.120206e-001, - 2.727568e+000, - -4.222666e-002, - -2.599674e+000, - 9.265659e-001, - -1.136633e+000, - -4.281875e-003, - -3.407541e+000, - 4.132332e+000, - -3.866153e-001, - -5.082717e-001, - 4.828348e-001, - 9.797167e+000, - 3.325034e-001, - -1.027909e+000, - -2.334388e-001, - 4.972147e+000, - -1.499736e+000, - 9.598438e-002, - 2.744895e+000, - -3.558702e-001, - -4.288054e+000, - 1.000138e+000, - -1.102843e+000, - -1.875642e-001, - 2.087760e+000, - 3.692600e-001, - -6.520835e-001, - -9.598766e-001, - 2.984231e-001, - 4.045786e-001, - 5.091931e-001, - // albedo 1, turbidity 3 - -1.117485e+000, - -1.492968e-001, - -2.639425e+000, - 3.672106e+000, - -1.058342e-001, - 1.098101e+000, - 1.544782e-001, - 4.496691e+000, - 6.582312e-001, - -1.123872e+000, - -1.467158e-001, - 3.049045e+000, - -2.607634e+000, - -2.505495e-001, - -8.310458e-002, - 3.333822e-001, - 4.631418e+000, - 5.120491e-001, - -1.118262e+000, - -2.462050e-001, - -8.333919e-002, - 2.438788e+000, - 6.143236e-001, - 3.745903e+000, - -2.043295e-001, - -3.451983e+000, - 1.056003e+000, - -1.095394e+000, - 2.009680e-002, - 8.468659e-001, - 1.230624e-002, - -8.638525e+000, - -2.989487e+000, - 8.735734e-001, - 8.533740e+000, - 2.548062e-001, - -1.035035e+000, - -2.296018e-001, - 2.722309e+000, - 1.849369e-001, - 3.440975e+000, - 4.372083e+000, - -4.747494e-001, - -2.984092e+000, - 1.009737e+000, - -1.113497e+000, - -1.931400e-001, - 2.288509e+000, - 4.973129e-002, - -1.353292e-001, - -1.587772e+000, - 4.073801e-001, - -8.180513e-003, - 5.682569e-001, - // albedo 1, turbidity 4 - -1.172242e+000, - -2.084847e-001, - -1.212027e+000, - 1.991627e+000, - -1.403495e-001, - 7.684996e-001, - 1.582914e-001, - 3.407597e+000, - 6.659386e-001, - -1.167834e+000, - -2.117291e-001, - 1.196578e+000, - -1.438719e+000, - -3.137939e-001, - -4.537552e-002, - 2.260096e-001, - 4.659389e+000, - 5.776369e-001, - -1.222298e+000, - -2.893306e-001, - 9.080116e-001, - 1.413518e+000, - 1.709237e+000, - 2.915962e+000, - 8.464584e-002, - -3.867076e+000, - 9.110543e-001, - -9.554071e-001, - 6.610246e-002, - -3.323811e-001, - 2.702543e+000, - -1.345592e+001, - -3.119309e+000, - 7.740473e-001, - 7.452516e+000, - 3.929172e-001, - -1.119763e+000, - -2.579942e-001, - 2.830634e+000, - -1.333418e+000, - 6.825773e+000, - 4.230596e+000, - -2.654108e-001, - -2.669457e+000, - 9.126183e-001, - -1.084261e+000, - -2.086570e-001, - 2.248616e+000, - 6.993871e-001, - -2.391760e+000, - -1.738827e+000, - 3.674794e-001, - -5.324741e-001, - 6.183292e-001, - // albedo 1, turbidity 5 - -1.226325e+000, - -2.688667e-001, - -1.462040e-001, - 4.749868e-001, - -8.718681e-002, - 4.956704e-001, - 1.752427e-001, - 2.933911e+000, - 6.470198e-001, - -1.359737e+000, - -3.985716e-001, - -1.570034e-001, - 1.277905e+000, - -1.314322e+000, - 4.320873e-001, - 8.532731e-002, - 2.774395e+000, - 6.318556e-001, - -1.088212e+000, - -1.688766e-001, - 1.399098e+000, - -3.254950e+000, - 4.733557e+000, - 2.079183e+000, - 1.907990e-001, - -9.540048e-001, - 8.714774e-001, - -1.034524e+000, - -1.050729e-002, - -8.054376e-001, - 1.166351e+001, - -1.879498e+001, - -3.021428e+000, - 7.755251e-001, - 4.516574e+000, - 4.092690e-001, - -1.076150e+000, - -2.551781e-001, - 2.797790e+000, - -5.437950e+000, - 9.156159e+000, - 3.988462e+000, - -2.324172e-001, - -2.124766e+000, - 8.863276e-001, - -1.103432e+000, - -2.058047e-001, - 2.117130e+000, - 2.401558e+000, - -5.015370e+000, - -1.829480e+000, - 4.046378e-001, - -2.078794e-001, - 6.449045e-001, - // albedo 1, turbidity 6 - -1.263516e+000, - -3.133966e-001, - 3.174560e-001, - -4.989246e-003, - -2.317630e+000, - 3.963746e-001, - 1.677262e-001, - 2.563898e+000, - 6.335899e-001, - -1.577927e+000, - -5.893907e-001, - -2.991531e-001, - 1.783728e+000, - 3.693827e+000, - 5.704918e-001, - 6.768069e-002, - 2.215180e+000, - 6.196162e-001, - -9.191335e-001, - -4.529201e-002, - 1.577262e+000, - -6.455191e+000, - -4.020064e+000, - 1.309911e+000, - 1.373281e-001, - -7.178508e-001, - 9.243738e-001, - -1.144508e+000, - -9.289247e-002, - -1.606387e+000, - 2.061805e+001, - -1.051527e+001, - -2.077164e+000, - 8.328239e-001, - 4.729795e+000, - 3.298487e-001, - -1.018834e+000, - -2.186851e-001, - 3.321767e+000, - -7.887012e+000, - 3.374834e+000, - 3.005232e+000, - -2.515037e-001, - -2.656610e+000, - 9.316017e-001, - -1.125230e+000, - -2.422532e-001, - 1.850916e+000, - 6.213105e+000, - -5.017914e+000, - -1.644457e+000, - 3.811828e-001, - -1.772362e-001, - 6.297360e-001, - // albedo 1, turbidity 7 - -1.365631e+000, - -4.017085e-001, - 1.942501e-001, - -7.073927e-003, - -1.461125e-001, - 4.898017e-001, - 1.623346e-001, - 2.330174e+000, - 5.983242e-001, - -1.957177e+000, - -9.640834e-001, - -2.217521e-001, - 1.316645e+000, - -1.907085e-001, - 1.134191e-002, - 9.704476e-002, - 3.828565e-002, - 5.538419e-001, - -7.832629e-001, - 1.949904e-001, - 6.232354e-001, - -2.947737e+000, - 3.702377e+000, - 2.212239e+000, - 9.128296e-002, - 3.131504e+000, - 9.923939e-001, - -1.121562e+000, - -2.704893e-001, - -5.161748e-001, - 8.115427e+000, - -1.443497e+001, - -3.292676e+000, - 8.232212e-001, - -1.548451e-002, - 3.199244e-001, - -1.059207e+000, - -1.613941e-001, - 2.375866e+000, - -9.517705e-002, - 4.514722e+000, - 3.755824e+000, - -1.696953e-001, - -2.539157e-001, - 8.992553e-001, - -1.108877e+000, - -2.404852e-001, - 1.830175e+000, - 2.808956e+000, - -4.932362e+000, - -2.042775e+000, - 4.168739e-001, - -2.534590e-001, - 6.533212e-001, - // albedo 1, turbidity 8 - -1.405398e+000, - -4.540068e-001, - -4.766512e-001, - 1.871207e-001, - 5.535070e-001, - -4.467365e-002, - 2.846366e-001, - 2.443422e+000, - 5.035706e-001, - -2.843953e+000, - -1.562366e+000, - 8.527921e-001, - 5.991182e-001, - -9.984088e-001, - 7.599314e-001, - -2.025184e-002, - -1.515050e+000, - 4.397429e-001, - -5.156586e-001, - 3.789775e-001, - -1.194407e+000, - -7.591558e-001, - 4.515532e+000, - 4.795814e-001, - 3.163186e-001, - 5.993132e+000, - 1.096327e+000, - -1.070353e+000, - -4.037269e-001, - 1.108932e+000, - 1.269159e+000, - -1.099135e+001, - -1.049849e+000, - 4.644725e-001, - -4.387074e+000, - 2.704008e-001, - -1.136211e+000, - -1.473182e-001, - 1.235769e+000, - 5.725364e+000, - 1.712036e+000, - 1.630777e+000, - 3.656685e-002, - 2.082798e+000, - 9.036801e-001, - -1.083101e+000, - -2.468910e-001, - 1.894919e+000, - 6.574012e+000, - -4.949098e+000, - -1.132033e+000, - 3.336584e-001, - -7.321133e-001, - 6.606587e-001, - // albedo 1, turbidity 9 - -1.609910e+000, - -6.550380e-001, - -5.773346e-001, - 1.426156e+000, - -5.000686e-001, - 8.257866e-001, - 1.839148e-002, - 2.106656e+000, - 6.957214e-001, - -3.047283e+000, - -1.421592e+000, - -4.003615e-001, - -6.531692e-001, - 5.643821e-001, - -2.693762e-001, - 2.295553e-001, - 5.533910e-001, - 2.751822e-002, - -2.160824e+000, - -9.212504e-001, - -8.438420e-001, - 1.466021e+000, - 1.124686e+000, - -6.848173e-002, - 6.224893e-001, - 3.137662e+000, - 1.224147e+000, - 1.444817e-002, - 1.418426e-001, - 7.055176e-001, - -1.787432e+000, - -1.625625e+000, - 7.638401e-001, - -3.309940e-001, - -3.414755e+000, - 3.580691e-001, - -1.480512e+000, - -3.141638e-001, - 1.193403e+000, - 6.152773e+000, - -3.314867e+000, - 1.345353e-001, - 5.359935e-001, - 1.409582e+000, - 8.072343e-001, - -1.016066e+000, - -2.346375e-001, - 1.457587e+000, - -2.761458e-003, - -2.546952e+000, - -6.058542e-001, - 3.134230e-001, - -2.232281e-001, - 6.760089e-001, - // albedo 1, turbidity 10 - -2.019395e+000, - -9.550942e-001, - -1.187885e-001, - 1.995372e+000, - -1.604228e+000, - 4.995785e-001, - -9.647137e-006, - 1.929333e+000, - 8.659254e-001, - -2.071307e+000, - -9.485438e-001, - -3.817151e-001, - -1.657017e+000, - 9.488626e-001, - 5.816145e-001, - -3.856514e-002, - 1.677756e+000, - -1.262572e-001, - -6.388445e+000, - -2.738739e+000, - -9.872469e-001, - 2.450058e+000, - 1.075999e+000, - 2.305434e-002, - 8.598771e-001, - 1.853582e+000, - 1.180017e+000, - 1.742851e+000, - 2.950102e-001, - 1.015937e+000, - -2.511194e+000, - -3.829361e+000, - -1.126698e-001, - -4.564605e-001, - -2.097128e+000, - 4.012648e-001, - -1.845177e+000, - -3.242819e-001, - 7.060963e-001, - 7.747868e+000, - -1.721532e+000, - 6.057347e-001, - 4.266212e-001, - 3.153697e-001, - 7.958222e-001, - -9.599955e-001, - -3.732025e-001, - 1.381129e+000, - -3.983023e-003, - -1.941446e+000, - -5.943490e-001, - 2.269207e-001, - -7.249738e-001, - 6.710888e-001, -}; - -double datasetRad680[] = -{ - // albedo 0, turbidity 1 - 1.069136e-001, - 7.429652e-002, - 2.056544e-001, - 2.763020e-001, - 2.214969e-001, - 2.265690e-001, - // albedo 0, turbidity 2 - 1.104352e-001, - 7.802008e-002, - 1.987620e-001, - 4.426471e-001, - 1.961324e-001, - 2.622675e-001, - // albedo 0, turbidity 3 - 1.098059e-001, - 7.983873e-002, - 1.632683e-001, - 7.073005e-001, - 1.731280e-001, - 3.099027e-001, - // albedo 0, turbidity 4 - 1.031706e-001, - 8.474020e-002, - 5.727517e-002, - 1.115427e+000, - 1.666019e-001, - 3.729170e-001, - // albedo 0, turbidity 5 - 9.321128e-002, - 1.157084e-001, - -1.460692e-001, - 1.597840e+000, - 1.062877e-001, - 4.640498e-001, - // albedo 0, turbidity 6 - 8.816825e-002, - 1.391452e-001, - -2.899934e-001, - 1.874267e+000, - 1.135532e-001, - 5.090668e-001, - // albedo 0, turbidity 7 - 7.855885e-002, - 1.795611e-001, - -5.035302e-001, - 2.242952e+000, - 1.336585e-001, - 5.946044e-001, - // albedo 0, turbidity 8 - 6.763602e-002, - 2.205196e-001, - -7.151851e-001, - 2.508741e+000, - 3.330016e-001, - 6.895142e-001, - // albedo 0, turbidity 9 - 5.687157e-002, - 2.382926e-001, - -7.951639e-001, - 2.380214e+000, - 8.486318e-001, - 8.192685e-001, - // albedo 0, turbidity 10 - 4.804473e-002, - 1.966076e-001, - -5.859989e-001, - 1.534534e+000, - 1.866946e+000, - 9.528688e-001, - // albedo 1, turbidity 1 - 1.109470e-001, - 8.190043e-002, - 2.023152e-001, - 2.721896e-001, - 5.193682e-001, - 5.401298e-001, - // albedo 1, turbidity 2 - 1.147364e-001, - 8.626295e-002, - 1.944652e-001, - 4.314563e-001, - 5.265573e-001, - 5.928457e-001, - // albedo 1, turbidity 3 - 1.138018e-001, - 9.568157e-002, - 1.324943e-001, - 7.414987e-001, - 4.882138e-001, - 6.992066e-001, - // albedo 1, turbidity 4 - 1.069268e-001, - 1.061070e-001, - 8.235325e-003, - 1.173655e+000, - 5.092401e-001, - 8.123288e-001, - // albedo 1, turbidity 5 - 9.671533e-002, - 1.365510e-001, - -1.887680e-001, - 1.636105e+000, - 4.931799e-001, - 9.534092e-001, - // albedo 1, turbidity 6 - 9.120079e-002, - 1.542261e-001, - -3.079008e-001, - 1.860609e+000, - 5.696775e-001, - 1.003946e+000, - // albedo 1, turbidity 7 - 8.298575e-002, - 1.891728e-001, - -5.047613e-001, - 2.191998e+000, - 6.314728e-001, - 1.138476e+000, - // albedo 1, turbidity 8 - 7.299294e-002, - 2.200614e-001, - -6.649578e-001, - 2.320101e+000, - 9.665028e-001, - 1.260207e+000, - // albedo 1, turbidity 9 - 6.270944e-002, - 2.186724e-001, - -6.537155e-001, - 1.958369e+000, - 1.721545e+000, - 1.362280e+000, - // albedo 1, turbidity 10 - 5.423905e-002, - 1.687944e-001, - -4.102190e-001, - 1.017356e+000, - 2.817177e+000, - 1.498748e+000, -}; - -double dataset720[] = -{ - // albedo 0, turbidity 1 - -1.110553e+000, - -1.675726e-001, - -2.349324e-001, - 2.433790e+000, - -1.342878e-001, - 1.755516e+000, - -1.879493e-006, - 1.509217e+000, - 7.216495e-001, - -1.149960e+000, - -2.418229e-001, - 2.341927e+000, - 1.486508e-001, - -4.333388e-001, - 9.028740e-001, - 9.450710e-003, - -3.134790e-001, - 5.923234e-001, - -9.702430e-001, - -5.384657e-002, - 3.025898e+000, - -6.450284e-001, - 9.728166e-001, - 3.532967e+000, - -2.429753e-002, - 1.343614e+000, - 1.067807e+000, - -1.278773e+000, - -2.072018e-001, - -2.458359e-001, - 3.749133e-001, - -9.580484e+000, - 3.066020e-001, - 4.056471e-002, - 4.343208e+000, - 1.865704e-001, - -9.511618e-001, - -1.674143e-001, - 4.195842e+000, - -1.205785e-001, - 2.160133e+000, - 3.048813e+000, - -4.826924e-002, - -3.779096e+000, - 1.024834e+000, - -1.095577e+000, - -1.855865e-001, - 1.973593e+000, - 7.894097e-002, - 9.578182e-001, - 8.565674e-001, - 4.663966e-002, - 7.375811e-001, - 5.577192e-001, - // albedo 0, turbidity 2 - -1.099352e+000, - -1.338612e-001, - -8.419373e-001, - 2.710346e+000, - -2.241044e-001, - 1.645463e+000, - 7.621625e-002, - 3.548772e+000, - 7.268231e-001, - -1.140694e+000, - -1.723890e-001, - 1.413194e+000, - 3.429051e-001, - -4.431396e-001, - 9.757402e-001, - 1.248306e-001, - 1.780103e+000, - 6.637254e-001, - -9.861499e-001, - -8.032931e-002, - 2.396682e+000, - 7.281382e-001, - 1.472495e-001, - 3.316479e+000, - -1.028439e-001, - 3.729469e+000, - 9.059004e-001, - -1.233397e+000, - -9.896833e-002, - -1.679568e+000, - 1.542653e+000, - -9.977726e+000, - -6.579124e-001, - 6.386315e-001, - 6.157752e+000, - 3.985939e-001, - -9.438092e-001, - -1.629239e-001, - 4.213446e+000, - -3.419684e-001, - 2.110121e+000, - 3.552183e+000, - -2.817116e-001, - -3.323718e+000, - 8.785077e-001, - -1.120794e+000, - -2.121477e-001, - 1.326767e+000, - 2.317528e-001, - 5.648291e-001, - 4.155089e-001, - 3.048162e-001, - 3.186797e-001, - 6.285665e-001, - // albedo 0, turbidity 3 - -1.117191e+000, - -1.510453e-001, - -3.511136e-001, - 1.706946e+000, - -3.820460e-001, - 1.228101e+000, - 1.641555e-001, - 3.663544e+000, - 6.846104e-001, - -1.130950e+000, - -1.622534e-001, - 1.197076e+000, - -1.342532e+000, - 6.608991e-002, - -1.955817e-001, - 3.515286e-001, - 3.237403e+000, - 5.732364e-001, - -1.103903e+000, - -1.810472e-001, - 1.254237e+000, - 3.367565e+000, - -1.746589e+000, - 4.464939e+000, - -2.831757e-001, - -2.424241e-001, - 9.961252e-001, - -1.107818e+000, - -2.407723e-002, - -7.518594e-001, - 7.115830e+000, - -1.603375e+001, - -4.077248e+000, - 1.210904e+000, - 6.281392e+000, - 2.496837e-001, - -1.012153e+000, - -1.911658e-001, - 2.357463e+000, - -2.392720e+000, - 7.080581e+000, - 6.002768e+000, - -5.120158e-001, - -2.039879e+000, - 1.008071e+000, - -1.083766e+000, - -1.889743e-001, - 1.669813e+000, - 1.205140e+000, - -2.973102e+000, - -1.420288e+000, - 5.838643e-001, - 1.338574e-001, - 5.902153e-001, - // albedo 0, turbidity 4 - -1.176390e+000, - -2.045914e-001, - -1.035177e+000, - 1.521425e+000, - -9.698257e-002, - 7.561111e-001, - 2.338582e-001, - 3.264500e+000, - 6.520267e-001, - -1.132876e+000, - -1.921539e-001, - 9.661015e-001, - -2.470184e-001, - -5.825797e-001, - 5.044517e-001, - 1.418233e-001, - 4.416172e+000, - 6.580570e-001, - -1.296062e+000, - -2.855719e-001, - 1.143329e+000, - -1.640682e+000, - 1.921828e+000, - 1.625086e+000, - 5.248871e-001, - -3.757434e+000, - 7.293814e-001, - -9.026255e-001, - 2.670242e-002, - -8.632572e-001, - 7.076787e+000, - -1.407525e+001, - -1.251814e+000, - 1.806495e-001, - 6.575978e+000, - 6.367149e-001, - -1.103623e+000, - -1.818983e-001, - 1.490037e+000, - -3.276017e+000, - 6.936153e+000, - 2.689183e+000, - 5.705211e-001, - -1.354153e+000, - 7.095230e-001, - -1.049370e+000, - -1.854814e-001, - 1.385509e+000, - 1.714977e+000, - -3.205204e+000, - -1.161420e-001, - 3.453320e-001, - 4.355508e-001, - 7.115006e-001, - // albedo 0, turbidity 5 - -1.225291e+000, - -2.574996e-001, - -4.766919e-001, - 4.951357e-001, - 5.242961e-002, - 4.702062e-001, - 2.428653e-001, - 3.095075e+000, - 6.424221e-001, - -1.318856e+000, - -3.713082e-001, - -4.987985e-001, - 2.026237e+000, - -1.457426e+000, - 7.809557e-001, - 1.419197e-003, - 2.776845e+000, - 7.058454e-001, - -1.168038e+000, - -1.572586e-001, - 1.786834e+000, - -4.594005e+000, - 4.780600e+000, - 1.639416e+000, - 5.324063e-001, - -1.000719e+000, - 7.325083e-001, - -9.862998e-001, - -7.482649e-002, - -1.332445e+000, - 1.329260e+001, - -1.803019e+001, - -2.669936e+000, - 3.591475e-001, - 3.852972e+000, - 5.714399e-001, - -1.049025e+000, - -1.404280e-001, - 1.342894e+000, - -5.633938e+000, - 8.396123e+000, - 3.809869e+000, - 4.313231e-001, - -5.373938e-001, - 7.693298e-001, - -1.069033e+000, - -2.091865e-001, - 1.088280e+000, - 3.125506e+000, - -4.664580e+000, - -1.191484e+000, - 5.195344e-001, - 3.961673e-001, - 6.817393e-001, - // albedo 0, turbidity 6 - -1.267895e+000, - -3.004228e-001, - -5.149611e-001, - 4.302967e-001, - 1.504018e-001, - 3.700643e-001, - 2.354209e-001, - 2.887788e+000, - 6.298388e-001, - -1.551925e+000, - -5.917820e-001, - -5.915642e-001, - 2.016019e+000, - -1.252286e+000, - 8.651065e-001, - 7.721402e-003, - 1.148828e+000, - 6.589887e-001, - -9.782795e-001, - 3.652455e-002, - 1.331304e+000, - -4.804135e+000, - 5.130801e+000, - 1.052586e+000, - 4.439877e-001, - 2.100157e+000, - 8.308236e-001, - -1.077598e+000, - -2.015253e-001, - -1.037818e+000, - 1.307045e+001, - -1.715211e+001, - -1.607252e+000, - 4.472382e-001, - 6.802371e-001, - 4.848934e-001, - -1.025969e+000, - -1.170376e-001, - 1.139546e+000, - -3.374680e+000, - 6.330035e+000, - 2.199093e+000, - 3.928627e-001, - 8.428666e-001, - 7.960910e-001, - -1.062382e+000, - -1.881842e-001, - 8.863153e-001, - 4.266858e+000, - -5.011692e+000, - -4.086830e-001, - 5.889147e-001, - 5.341939e-001, - 6.866073e-001, - // albedo 0, turbidity 7 - -1.352417e+000, - -3.836953e-001, - -5.951560e-001, - 4.053297e-001, - 2.468304e-001, - 2.565711e-001, - 2.321365e-001, - 2.512376e+000, - 6.089904e-001, - -1.976438e+000, - -9.152777e-001, - -4.417666e-001, - 1.790189e+000, - -1.085567e+000, - 4.562228e-001, - 2.133332e-002, - 4.989856e-001, - 6.257100e-001, - -7.197412e-001, - 2.165210e-001, - 6.233215e-001, - -3.960686e+000, - 4.694083e+000, - 2.062797e+000, - 3.121864e-001, - 2.942681e+000, - 8.846033e-001, - -1.189984e+000, - -3.151612e-001, - -5.020073e-001, - 1.015136e+001, - -1.483684e+001, - -3.476730e+000, - 6.049863e-001, - -1.941153e-001, - 4.281015e-001, - -9.781383e-001, - -8.764833e-002, - 8.290915e-001, - 1.086960e-001, - 4.467570e+000, - 3.905633e+000, - 1.975895e-001, - 6.964295e-001, - 8.333166e-001, - -1.081242e+000, - -2.051949e-001, - 6.056482e-001, - 5.219268e+000, - -4.410608e+000, - -1.963212e+000, - 7.277904e-001, - 8.509624e-001, - 6.689251e-001, - // albedo 0, turbidity 8 - -1.443212e+000, - -4.725757e-001, - -9.477961e-001, - 2.671049e-001, - 6.163577e-001, - -3.965036e-001, - 4.071134e-001, - 2.464218e+000, - 4.997820e-001, - -3.021428e+000, - -1.558459e+000, - 1.389763e-001, - 1.122031e+000, - -1.014816e+000, - 1.265687e+000, - -1.649604e-001, - -6.627923e-001, - 5.494665e-001, - -1.593477e-001, - 5.076305e-001, - -7.283933e-001, - -1.265076e+000, - 3.904153e+000, - -8.196757e-002, - 6.585734e-001, - 4.998464e+000, - 9.330667e-001, - -1.378374e+000, - -5.064534e-001, - 7.231197e-001, - 1.385088e+000, - -9.500118e+000, - -4.806746e-001, - 1.067642e-001, - -3.297209e+000, - 4.441955e-001, - -9.436176e-001, - -6.189764e-002, - 1.144482e-001, - 9.137694e+000, - 2.948867e-001, - 1.224655e+000, - 3.675148e-001, - 2.124090e+000, - 8.014519e-001, - -1.078915e+000, - -2.051854e-001, - 4.754209e-001, - 5.826389e-003, - -2.498632e+000, - -8.265078e-001, - 7.644670e-001, - 6.066256e-001, - 6.811963e-001, - // albedo 0, turbidity 9 - -1.621711e+000, - -6.425839e-001, - -7.307813e-001, - 1.109519e+000, - -4.107299e-001, - 7.789953e-001, - 7.764812e-002, - 2.335627e+000, - 6.230915e-001, - -4.003597e+000, - -1.736865e+000, - -6.062450e-001, - -7.370264e-001, - 7.002778e-001, - -4.140325e-001, - 3.926087e-001, - 8.316399e-001, - 1.516341e-001, - -7.696712e-001, - -3.872306e-001, - -1.159436e+000, - 1.660752e+000, - 2.031840e+000, - -7.697685e-001, - 5.481684e-001, - 2.788249e+000, - 1.112977e+000, - -8.506589e-001, - -5.430791e-002, - 1.088719e+000, - -2.513532e+000, - -4.144477e+000, - 2.760914e+000, - -3.011272e-001, - -2.383556e+000, - 4.496070e-001, - -1.150061e+000, - -3.009215e-001, - -9.176868e-002, - 8.996074e+000, - -1.753862e+000, - -2.428423e+000, - 5.764492e-001, - 1.218492e+000, - 7.552230e-001, - -1.020853e+000, - -1.499849e-001, - 3.437744e-001, - -2.339597e-003, - -2.646520e+000, - 1.378457e+000, - 6.708410e-001, - 9.149680e-001, - 6.961806e-001, - // albedo 0, turbidity 10 - -1.982394e+000, - -9.369621e-001, - -3.767595e-001, - 2.514582e+000, - -1.501415e+000, - 6.258952e-001, - -5.260430e-006, - 2.100142e+000, - 7.824077e-001, - -3.432415e+000, - -1.264283e+000, - -9.042363e-001, - -2.930432e+000, - 8.249096e-001, - 7.244840e-001, - 3.055253e-002, - 2.527405e+000, - -2.107031e-003, - -4.333533e+000, - -2.156157e+000, - -8.341654e-001, - 5.048387e+000, - 1.803580e+000, - -9.318434e-001, - 1.085401e+000, - 8.728330e-001, - 1.050061e+000, - 4.889224e-001, - 5.956721e-002, - 8.445388e-001, - -7.479177e+000, - -4.049292e+000, - 1.199966e+000, - -7.060560e-001, - -9.742353e-001, - 4.893674e-001, - -1.347508e+000, - -1.874523e-001, - -5.063342e-002, - 1.299813e+001, - -1.707387e+000, - -4.076088e-001, - 6.119042e-001, - 3.717790e-001, - 7.662157e-001, - -1.047037e+000, - -3.743109e-001, - 3.452375e-001, - -3.615559e-003, - -2.169432e+000, - -7.166880e-002, - 3.747046e-001, - 2.746126e-001, - 6.773818e-001, - // albedo 1, turbidity 1 - -1.105396e+000, - -1.663441e-001, - -2.359634e-001, - 2.476496e+000, - -1.329052e-001, - 1.715759e+000, - 2.103991e-003, - 1.421966e+000, - 6.270733e-001, - -1.132480e+000, - -2.330883e-001, - 2.273938e+000, - 2.422717e-001, - -4.159883e-001, - 9.350714e-001, - 1.432347e-002, - -4.176684e-001, - 4.664640e-001, - -1.036155e+000, - -9.432450e-002, - 3.117262e+000, - -6.369808e-001, - 1.060389e+000, - 3.386481e+000, - -4.605081e-002, - 1.248000e+000, - 9.701974e-001, - -1.162485e+000, - -1.382303e-001, - 1.544122e-001, - 3.716511e-001, - -9.520209e+000, - -2.739605e-001, - 8.489054e-002, - 4.371570e+000, - 7.694391e-002, - -1.031787e+000, - -2.165067e-001, - 4.446666e+000, - -1.470711e-001, - 2.143436e+000, - 1.922123e+000, - -9.589030e-002, - -3.594664e+000, - 8.629249e-001, - -1.081125e+000, - -1.623953e-001, - 2.048137e+000, - 8.639386e-002, - 1.225845e+000, - 1.239255e-001, - 8.366038e-002, - 8.322625e-001, - 5.604708e-001, - // albedo 1, turbidity 2 - -1.112606e+000, - -1.514491e-001, - -1.608942e+000, - 3.592344e+000, - -1.616115e-001, - 1.593861e+000, - 5.488306e-002, - 2.854783e+000, - 7.519999e-001, - -1.098630e+000, - -1.410161e-001, - 2.155487e+000, - -4.381610e-001, - -3.635146e-001, - 1.313843e+000, - 1.201277e-001, - 2.469958e+000, - 6.481071e-001, - -1.077575e+000, - -1.275645e-001, - 1.418205e+000, - 2.057232e+000, - -7.778503e-002, - 2.433840e+000, - -7.094034e-002, - 3.347259e+000, - 9.344752e-001, - -1.099714e+000, - -4.474282e-002, - -1.247041e-001, - -1.578342e-001, - -7.968895e+000, - 1.730912e-001, - 5.303765e-001, - 5.523179e+000, - 3.840340e-001, - -1.061945e+000, - -2.200148e-001, - 4.333103e+000, - 1.818948e-002, - 1.907751e+000, - 1.560633e+000, - -3.182192e-001, - -3.010282e+000, - 8.844351e-001, - -1.087782e+000, - -1.709041e-001, - 1.834683e+000, - 7.351214e-002, - 1.282669e+000, - 2.075884e-001, - 2.698971e-001, - 3.373859e-001, - 5.808336e-001, - // albedo 1, turbidity 3 - -1.121417e+000, - -1.551220e-001, - -1.527123e+000, - 2.788105e+000, - -1.477847e-001, - 1.152139e+000, - 1.742181e-001, - 3.473417e+000, - 6.737050e-001, - -1.118910e+000, - -1.496848e-001, - 2.736873e+000, - -1.829596e+000, - -3.411991e-001, - 1.177538e-001, - 2.960683e-001, - 3.273898e+000, - 5.743833e-001, - -1.121145e+000, - -1.980292e-001, - -5.407002e-001, - 2.886807e+000, - 4.877852e-001, - 3.692424e+000, - -1.104033e-001, - -2.358878e-001, - 9.976295e-001, - -1.078889e+000, - -1.541161e-003, - 1.370650e+000, - 1.644450e+000, - -1.425572e+001, - -3.075430e+000, - 9.346385e-001, - 5.871863e+000, - 2.618026e-001, - -1.053346e+000, - -2.262166e-001, - 2.532003e+000, - -8.720058e-001, - 7.667901e+000, - 4.357082e+000, - -5.367969e-001, - -2.073329e+000, - 1.023965e+000, - -1.100093e+000, - -1.810893e-001, - 2.566430e+000, - 4.757700e-001, - -2.069684e+000, - -1.585209e+000, - 4.693140e-001, - -6.719615e-001, - 5.569453e-001, - // albedo 1, turbidity 4 - -1.181528e+000, - -2.151896e-001, - -1.076470e+000, - 2.037517e+000, - -1.683559e-001, - 8.780110e-001, - 1.782773e-001, - 2.768650e+000, - 6.743293e-001, - -1.142132e+000, - -1.825403e-001, - 1.320992e+000, - -1.895472e+000, - -2.160241e-001, - -2.079637e-001, - 3.424953e-001, - 4.333355e+000, - 5.663420e-001, - -1.225408e+000, - -2.906477e-001, - 8.323962e-001, - 2.176300e+000, - 1.943859e+000, - 3.003671e+000, - 1.130255e-001, - -4.449977e+000, - 8.867390e-001, - -9.815988e-001, - 5.577004e-002, - -4.240348e-001, - 1.488466e+000, - -1.279361e+001, - -3.110899e+000, - 7.360104e-001, - 7.937751e+000, - 4.474817e-001, - -1.103439e+000, - -2.481553e-001, - 3.045691e+000, - -6.993993e-001, - 6.081464e+000, - 3.986228e+000, - -1.616828e-001, - -3.373973e+000, - 8.572294e-001, - -1.081695e+000, - -1.943361e-001, - 2.303236e+000, - 3.906537e-001, - -1.498982e+000, - -1.372140e+000, - 3.379214e-001, - -4.953601e-001, - 6.521383e-001, - // albedo 1, turbidity 5 - -1.235776e+000, - -2.745978e-001, - 2.205316e-002, - 4.505193e-001, - -1.569202e-001, - 5.065039e-001, - 2.016320e-001, - 2.449382e+000, - 6.535188e-001, - -1.268478e+000, - -3.078367e-001, - -2.041769e-001, - 1.189583e+000, - -1.311782e+000, - 4.724677e-001, - 1.025764e-001, - 3.300615e+000, - 6.689797e-001, - -1.190389e+000, - -2.597641e-001, - 1.377486e+000, - -2.289003e+000, - 4.214767e+000, - 1.900318e+000, - 3.126604e-001, - -2.537399e+000, - 7.980811e-001, - -9.632300e-001, - 7.067379e-002, - -6.690546e-001, - 9.507059e+000, - -1.721426e+001, - -2.850631e+000, - 6.931159e-001, - 5.722238e+000, - 4.856193e-001, - -1.119689e+000, - -3.019499e-001, - 2.657474e+000, - -5.208105e+000, - 1.015200e+001, - 3.863887e+000, - -1.603721e-001, - -3.132328e+000, - 8.543154e-001, - -1.078742e+000, - -1.840880e-001, - 2.341448e+000, - 2.576821e+000, - -5.011296e+000, - -1.671996e+000, - 3.955131e-001, - -4.700684e-001, - 6.516593e-001, - // albedo 1, turbidity 6 - -1.263449e+000, - -3.016185e-001, - -1.680842e-001, - 4.791728e-001, - -8.989862e-002, - 5.069014e-001, - 1.892810e-001, - 2.535339e+000, - 6.506411e-001, - -1.544305e+000, - -5.656222e-001, - -2.084263e-001, - 1.312304e+000, - -8.580598e-001, - 4.039133e-001, - 1.008588e-001, - 1.268784e+000, - 6.333075e-001, - -9.436041e-001, - -1.620107e-002, - 1.253874e+000, - -3.499120e+000, - 4.452594e+000, - 1.870490e+000, - 1.524710e-001, - 8.031346e-001, - 8.930942e-001, - -1.106718e+000, - -1.102586e-001, - -8.803979e-001, - 1.326904e+001, - -1.878253e+001, - -2.994671e+000, - 9.501205e-001, - 2.284893e+000, - 3.662824e-001, - -1.048783e+000, - -2.156089e-001, - 2.786728e+000, - -4.862603e+000, - 8.438175e+000, - 3.683031e+000, - -3.092444e-001, - -1.293934e+000, - 9.110045e-001, - -1.108140e+000, - -2.156079e-001, - 2.181504e+000, - 2.124553e+000, - -5.007442e+000, - -1.711417e+000, - 4.904871e-001, - -8.710312e-001, - 6.376965e-001, - // albedo 1, turbidity 7 - -1.345282e+000, - -3.856197e-001, - -1.975094e-001, - 3.016919e-001, - 2.765844e-001, - 2.092275e-001, - 2.251325e-001, - 2.058589e+000, - 6.014266e-001, - -1.907309e+000, - -8.881952e-001, - -4.827860e-001, - 1.495665e+000, - -9.243173e-001, - 3.864061e-001, - 7.491538e-002, - 2.719526e-001, - 6.046039e-001, - -7.540737e-001, - 1.800167e-001, - 1.174575e+000, - -3.052295e+000, - 4.669060e+000, - 1.793876e+000, - 1.664066e-001, - 2.376187e+000, - 9.261122e-001, - -1.165479e+000, - -2.500464e-001, - -9.603937e-001, - 8.919733e+000, - -1.561899e+001, - -2.850650e+000, - 8.368531e-001, - 3.404393e-001, - 3.694265e-001, - -1.032259e+000, - -1.593662e-001, - 2.621639e+000, - -5.369281e-001, - 6.011517e+000, - 3.234312e+000, - -1.842335e-001, - -3.749684e-001, - 8.913063e-001, - -1.119906e+000, - -2.533313e-001, - 2.017975e+000, - 4.776492e-001, - -5.005474e+000, - -1.503414e+000, - 4.694448e-001, - -1.039200e+000, - 6.438630e-001, - // albedo 1, turbidity 8 - -1.457842e+000, - -4.806585e-001, - -6.807833e-001, - 2.682520e-001, - 5.586195e-001, - -2.806536e-001, - 3.694491e-001, - 2.169304e+000, - 4.997873e-001, - -2.906600e+000, - -1.558470e+000, - 4.048869e-001, - 1.012321e+000, - -8.709928e-001, - 9.025637e-001, - -9.171486e-002, - -1.279805e+000, - 5.327924e-001, - -2.500868e-001, - 5.175467e-001, - -4.366020e-001, - -1.156645e+000, - 3.657335e+000, - 4.092973e-001, - 4.611188e-001, - 4.971048e+000, - 9.789196e-001, - -1.282240e+000, - -4.792753e-001, - 3.824491e-001, - 2.061672e+000, - -9.474747e+000, - -1.080446e+000, - 3.852100e-001, - -3.234591e+000, - 3.696703e-001, - -1.046065e+000, - -1.097023e-001, - 1.672284e+000, - 4.799701e+000, - 1.286403e+000, - 1.712569e+000, - 1.099301e-001, - 1.214451e+000, - 8.572886e-001, - -1.104124e+000, - -2.576744e-001, - 1.919030e+000, - -1.296687e-003, - -3.500874e+000, - -1.048831e+000, - 3.929400e-001, - -9.229794e-001, - 6.687909e-001, - // albedo 1, turbidity 9 - -1.658918e+000, - -6.637256e-001, - -1.162850e+000, - 1.829549e+000, - -2.525065e-001, - 8.624803e-001, - 5.214746e-002, - 1.977784e+000, - 6.455044e-001, - -3.553256e+000, - -1.639022e+000, - -8.821743e-001, - -2.660037e-001, - 5.168738e-001, - -8.582770e-001, - 4.110780e-001, - 1.034123e-001, - 1.039852e-001, - -1.299367e+000, - -4.890457e-001, - -5.595307e-001, - 1.129115e+000, - 5.445041e-001, - 5.361314e-001, - 4.579589e-001, - 3.385708e+000, - 1.184267e+000, - -4.366852e-001, - -2.303554e-002, - 5.417530e-001, - -9.106900e-001, - -4.398484e-001, - 3.178252e-001, - -2.132156e-001, - -3.682761e+000, - 3.754470e-001, - -1.334075e+000, - -2.466639e-001, - 1.293237e+000, - 4.685982e+000, - -4.032879e+000, - 4.666293e-001, - 5.337822e-001, - 1.603290e+000, - 8.067400e-001, - -1.052460e+000, - -2.501759e-001, - 1.601487e+000, - 1.713504e+000, - -2.810006e+000, - -8.042597e-001, - 3.216101e-001, - -5.944876e-001, - 6.740783e-001, - // albedo 1, turbidity 10 - -1.974746e+000, - -9.111910e-001, - -2.159155e-001, - 2.437415e+000, - -1.592257e+000, - 6.133797e-001, - -6.243023e-006, - 1.960399e+000, - 7.806415e-001, - -2.677119e+000, - -1.100702e+000, - -6.847246e-001, - -2.820855e+000, - 1.577837e+000, - 6.243833e-001, - 2.218481e-002, - 1.568717e+000, - 2.327673e-002, - -5.323827e+000, - -2.461050e+000, - -3.941307e-001, - 4.908417e+000, - -1.657232e-001, - -9.501763e-001, - 1.063520e+000, - 1.455622e+000, - 9.781890e-001, - 1.325000e+000, - 3.538115e-001, - 1.783573e-001, - -6.903650e+000, - -8.079921e-001, - 1.215973e+000, - -6.852540e-001, - -1.735835e+000, - 5.744662e-001, - -1.741196e+000, - -3.448017e-001, - 1.242377e+000, - 1.098613e+001, - -3.386782e+000, - -3.128683e-001, - 5.792848e-001, - 1.364330e-002, - 7.112763e-001, - -9.762671e-001, - -3.368355e-001, - 1.374728e+000, - -3.312353e-003, - -2.576919e+000, - -1.778015e-001, - 2.024288e-001, - -6.128666e-001, - 6.917938e-001, -}; - -double datasetRad720[] = -{ - // albedo 0, turbidity 1 - 9.147390e-002, - 7.018942e-002, - 1.622668e-001, - 2.036338e-001, - 1.635090e-001, - 1.713774e-001, - // albedo 0, turbidity 2 - 9.909969e-002, - 7.154626e-002, - 1.772161e-001, - 3.305464e-001, - 1.553279e-001, - 1.987828e-001, - // albedo 0, turbidity 3 - 1.013563e-001, - 6.482712e-002, - 1.919424e-001, - 5.177933e-001, - 1.653095e-001, - 2.316577e-001, - // albedo 0, turbidity 4 - 9.553482e-002, - 7.250944e-002, - 9.582747e-002, - 9.293376e-001, - 1.096383e-001, - 3.115109e-001, - // albedo 0, turbidity 5 - 8.787796e-002, - 9.182246e-002, - -6.114610e-002, - 1.352986e+000, - 6.824176e-002, - 3.863098e-001, - // albedo 0, turbidity 6 - 8.211688e-002, - 1.136177e-001, - -2.007215e-001, - 1.645362e+000, - 4.150372e-002, - 4.378610e-001, - // albedo 0, turbidity 7 - 7.400462e-002, - 1.477923e-001, - -3.967754e-001, - 2.001798e+000, - 6.469253e-002, - 5.049746e-001, - // albedo 0, turbidity 8 - 6.300931e-002, - 1.904274e-001, - -6.189626e-001, - 2.322083e+000, - 2.089235e-001, - 5.945747e-001, - // albedo 0, turbidity 9 - 5.200819e-002, - 2.169587e-001, - -7.460159e-001, - 2.320149e+000, - 6.242710e-001, - 7.185568e-001, - // albedo 0, turbidity 10 - 4.329013e-002, - 1.900081e-001, - -6.070381e-001, - 1.647416e+000, - 1.517600e+000, - 8.465953e-001, - // albedo 1, turbidity 1 - 9.457245e-002, - 7.644762e-002, - 1.578740e-001, - 2.074747e-001, - 3.827800e-001, - 4.125345e-001, - // albedo 1, turbidity 2 - 1.013784e-001, - 8.198680e-002, - 1.620652e-001, - 3.461549e-001, - 3.867509e-001, - 4.653134e-001, - // albedo 1, turbidity 3 - 1.040624e-001, - 7.855947e-002, - 1.633979e-001, - 5.501949e-001, - 4.194008e-001, - 5.300353e-001, - // albedo 1, turbidity 4 - 9.866276e-002, - 8.661824e-002, - 6.828152e-002, - 9.529887e-001, - 4.147963e-001, - 6.531589e-001, - // albedo 1, turbidity 5 - 9.141347e-002, - 1.084182e-001, - -9.664085e-002, - 1.383297e+000, - 4.048587e-001, - 7.736555e-001, - // albedo 1, turbidity 6 - 8.553065e-002, - 1.271555e-001, - -2.233165e-001, - 1.643686e+000, - 4.299472e-001, - 8.400556e-001, - // albedo 1, turbidity 7 - 7.765393e-002, - 1.591606e-001, - -4.067067e-001, - 1.968938e+000, - 4.995870e-001, - 9.464057e-001, - // albedo 1, turbidity 8 - 6.756910e-002, - 1.954915e-001, - -6.050275e-001, - 2.224385e+000, - 7.084781e-001, - 1.098066e+000, - // albedo 1, turbidity 9 - 5.751694e-002, - 2.034682e-001, - -6.417645e-001, - 1.994080e+000, - 1.364626e+000, - 1.202615e+000, - // albedo 1, turbidity 10 - 4.881952e-002, - 1.632172e-001, - -4.409641e-001, - 1.162848e+000, - 2.405383e+000, - 1.327313e+000, -}; - - - -double* datasets[] = -{ - dataset320, - dataset360, - dataset400, - dataset440, - dataset480, - dataset520, - dataset560, - dataset600, - dataset640, - dataset680, - dataset720 -}; - -double* datasetsRad[] = -{ - datasetRad320, - datasetRad360, - datasetRad400, - datasetRad440, - datasetRad480, - datasetRad520, - datasetRad560, - datasetRad600, - datasetRad640, - datasetRad680, - datasetRad720 -}; - - -double datasetXYZ1[] = -{ - // albedo 0, turbidity 1 - -1.101486e+000, - -1.625977e-001, - -1.638708e+000, - 2.691125e+000, - -1.570727e-001, - 9.434333e-001, - 5.944289e-002, - 4.597857e+000, - 5.192436e-001, - -1.146219e+000, - -1.731352e-001, - -2.017772e+000, - 3.407866e+000, - -1.226220e-001, - 6.479211e-001, - 2.885115e-002, - 5.453907e+000, - 3.603228e-001, - -1.053996e+000, - -1.654194e-001, - 4.328823e+000, - -3.101506e+000, - -7.300690e-001, - 2.099738e+000, - -8.055807e-002, - 1.000556e+000, - 1.125343e+000, - -1.149056e+000, - -2.619810e-001, - 9.589140e-002, - 2.150554e+000, - 9.517496e-001, - 7.542357e-001, - 9.669580e-002, - -1.252807e-001, - 6.431416e-002, - -1.020209e+000, - -1.368326e-001, - 1.895474e+000, - -2.187264e+000, - -6.141343e+000, - 1.825375e+000, - -8.482316e-002, - 2.658493e+000, - 9.470160e-001, - -1.076820e+000, - -1.440642e-001, - 1.432733e+000, - 3.413745e+000, - -2.344518e+000, - 1.213725e+000, - 6.208270e-002, - 3.030371e+000, - 4.998994e-001, - // albedo 0, turbidity 2 - -1.117775e+000, - -1.779226e-001, - -5.134562e+000, - 6.252734e+000, - -8.102730e-002, - 1.049450e+000, - 4.085968e-002, - 4.424605e+000, - 6.475802e-001, - -1.140066e+000, - -1.751408e-001, - 2.533825e+000, - -2.137066e+000, - -1.325967e-001, - 2.837325e-001, - 1.524333e-001, - 5.763824e+000, - 4.045794e-001, - -1.080149e+000, - -2.581561e-001, - 1.743889e+000, - 1.338846e+000, - -6.270160e-001, - 2.415543e+000, - -1.451883e-001, - -2.887826e+000, - 1.095943e+000, - -1.088968e+000, - -3.315172e-002, - -5.423126e-001, - -1.285017e+000, - -2.836525e-001, - 1.106355e-002, - 3.408528e-001, - 7.823781e+000, - 3.120904e-001, - -1.061339e+000, - -2.798560e-001, - 2.462703e+000, - -7.622134e-001, - -9.415643e+000, - 2.173416e+000, - -1.482007e-001, - -2.137092e+000, - 8.709323e-001, - -1.069052e+000, - -1.377888e-001, - 1.204842e+000, - 7.566803e+000, - -2.862954e+000, - 5.810028e-001, - 1.703831e-001, - 3.183023e+000, - 4.999642e-001, - // albedo 0, turbidity 3 - -1.132202e+000, - -1.944061e-001, - -3.088318e+000, - 3.790264e+000, - -1.082306e-001, - 8.484089e-001, - 7.280150e-002, - 4.559532e+000, - 6.448053e-001, - -1.146339e+000, - -1.873527e-001, - 2.717645e-001, - -2.760341e-001, - -1.711107e-001, - 1.650634e-001, - 1.865217e-001, - 6.227743e+000, - 4.657157e-001, - -1.113398e+000, - -2.525943e-001, - 2.464015e+000, - -1.010793e+000, - -4.516208e-001, - 2.181247e+000, - -7.235616e-002, - -1.881470e+000, - 1.014248e+000, - -1.046335e+000, - -5.917753e-004, - -1.524205e+000, - 2.852940e+000, - -2.478880e-001, - -3.286072e-001, - 4.540589e-001, - 7.871340e+000, - 3.592995e-001, - -1.072484e+000, - -2.566241e-001, - 2.273554e+000, - -6.831235e+000, - -5.012665e+000, - 2.159977e+000, - -5.481960e-002, - -1.052033e+000, - 8.894254e-001, - -1.067337e+000, - -1.595660e-001, - 1.088576e+000, - 1.354817e+001, - -3.811848e+000, - 3.518446e-001, - 1.510721e-001, - 2.573394e+000, - 6.071131e-001, - // albedo 0, turbidity 4 - -1.185647e+000, - -2.528115e-001, - -2.437674e+000, - 2.796612e+000, - -9.607830e-002, - 7.181786e-001, - 8.286644e-002, - 4.029493e+000, - 6.385637e-001, - -1.214985e+000, - -2.837320e-001, - -8.427044e-001, - 1.109678e+000, - -1.623519e-001, - 2.800385e-001, - 7.769566e-002, - 4.862665e+000, - 5.863215e-001, - -1.126346e+000, - -2.190142e-001, - 2.404206e+000, - -2.029997e+000, - -4.848325e-001, - 1.914520e+000, - 9.543178e-002, - 4.312553e-001, - 8.722100e-001, - -1.028901e+000, - -3.047034e-002, - -1.765204e+000, - 3.312119e+000, - 5.016337e-001, - -1.300037e+000, - 5.202519e-001, - 5.196915e+000, - 4.632371e-001, - -1.064053e+000, - -2.335792e-001, - 1.899585e+000, - -6.412736e+000, - -4.247619e+000, - 2.799190e+000, - 1.558133e-002, - 2.116759e-001, - 8.234323e-001, - -1.074179e+000, - -1.736113e-001, - 7.909836e-001, - 1.156281e+001, - -3.300053e+000, - -5.142526e-001, - 2.666226e-001, - 2.352668e+000, - 6.596287e-001, - // albedo 0, turbidity 5 - -1.228849e+000, - -3.037428e-001, - -3.471341e-001, - 4.350544e-001, - -3.647964e-001, - 4.740405e-001, - 1.095041e-001, - 3.715388e+000, - 5.953906e-001, - -1.421982e+000, - -5.415118e-001, - -3.421059e-001, - 1.905995e+000, - -1.654769e+000, - 4.861404e-001, - 1.314065e-002, - 1.846742e+000, - 6.325141e-001, - -1.061932e+000, - -4.597166e-002, - 5.943122e-001, - -4.096098e+000, - 5.060566e+000, - 1.243269e+000, - 7.660147e-002, - 4.778453e+000, - 8.933671e-001, - -1.018600e+000, - -1.588265e-001, - -4.221715e-001, - 9.524085e+000, - -1.745260e+001, - -8.306124e-001, - 5.802910e-001, - 4.240811e-001, - 4.185031e-001, - -1.078570e+000, - -1.951610e-001, - 1.028815e+000, - 1.154640e+000, - 4.418362e+000, - 1.663718e+000, - -2.890672e-002, - 2.142532e+000, - 8.181486e-001, - -1.054656e+000, - -1.499753e-001, - 5.109586e-001, - 1.239675e+000, - -4.846160e+000, - 4.503893e-002, - 5.210647e-001, - 2.768949e+000, - 6.726095e-001, - // albedo 0, turbidity 6 - -1.256198e+000, - -3.347739e-001, - -1.209987e+000, - 8.285029e-001, - 1.180869e-001, - 1.753936e-001, - 2.088779e-001, - 3.590526e+000, - 4.999286e-001, - -1.604654e+000, - -7.062520e-001, - -4.240035e-001, - 1.467255e+000, - -4.714837e-001, - 8.506681e-001, - -1.248613e-001, - 1.220216e+000, - 6.542021e-001, - -9.581498e-001, - 2.839298e-002, - 5.118732e-001, - -1.117046e+000, - 4.644809e-001, - 8.577887e-001, - 2.391953e-001, - 5.085931e+000, - 8.500554e-001, - -1.071832e+000, - -2.011442e-001, - -5.882682e-001, - 1.436666e+000, - -2.262832e+000, - -7.777687e-001, - 5.609258e-001, - 8.731629e-002, - 4.618670e-001, - -1.057077e+000, - -1.912628e-001, - 8.410181e-001, - -2.331775e+000, - 3.637049e-001, - 1.638660e+000, - 1.467789e-002, - 1.976998e+000, - 8.168068e-001, - -1.057954e+000, - -1.468896e-001, - 3.321536e-001, - 5.437255e+000, - -4.671045e+000, - -1.358064e-001, - 5.785188e-001, - 3.014237e+000, - 6.672890e-001, - // albedo 0, turbidity 7 - -1.343903e+000, - -4.205350e-001, - -9.993870e-001, - 7.287143e-001, - 4.537888e-002, - 3.291653e-001, - 1.521443e-001, - 3.265017e+000, - 5.012229e-001, - -1.895822e+000, - -9.783864e-001, - 1.424146e+000, - 4.344237e-002, - -8.684624e-001, - 8.203909e-001, - -2.548241e-002, - 1.499495e-001, - 4.605675e-001, - -9.140175e-001, - 1.289977e-001, - -1.664735e+000, - -1.162182e+000, - 1.228762e+000, - -3.508682e-002, - 1.841621e-001, - 6.921907e+000, - 1.095041e+000, - -1.045760e+000, - -3.250604e-001, - 1.079474e+000, - 5.770621e-002, - -1.120456e+001, - 3.498680e-001, - 4.705944e-001, - -3.353592e+000, - 2.717154e-001, - -1.064820e+000, - -1.287183e-001, - 6.377933e-002, - 1.857799e+001, - -3.852349e-001, - 3.275219e-001, - 5.074330e-002, - 3.863174e+000, - 8.538603e-001, - -1.051704e+000, - -1.720625e-001, - 3.343374e-001, - 1.230333e-002, - -3.119730e+000, - 9.286937e-003, - 5.504549e-001, - 2.165011e+000, - 6.772012e-001, - // albedo 0, turbidity 8 - -1.400958e+000, - -4.962991e-001, - -1.472534e+000, - 1.637928e+000, - -1.500740e-001, - 6.363313e-001, - 3.398782e-002, - 3.062964e+000, - 6.181961e-001, - -2.281140e+000, - -1.212929e+000, - 2.066309e+000, - -9.078293e-001, - -7.786086e-001, - 2.674922e-001, - 9.910386e-002, - 3.526180e-001, - 1.031765e-001, - -1.247570e+000, - -1.860524e-001, - -2.480103e+000, - -1.214462e+000, - 4.921450e-001, - 5.073764e-001, - 2.070932e-001, - 5.946086e+000, - 1.371012e+000, - -7.111959e-001, - -1.678064e-001, - 1.754787e+000, - 1.078337e+000, - -8.236462e+000, - -3.652583e-001, - 2.819599e-001, - -3.560758e+000, - 1.289778e-001, - -1.216962e+000, - -2.426196e-001, - -2.761225e-001, - 1.188950e+001, - -6.400520e-001, - 7.522732e-001, - 1.634544e-001, - 3.030162e+000, - 9.178231e-001, - -1.019668e+000, - -1.934685e-001, - 4.011653e-001, - 1.038563e+001, - -3.673953e+000, - -5.730092e-001, - 3.768768e-001, - 1.519136e+000, - 6.627072e-001, - // albedo 0, turbidity 9 - -1.543709e+000, - -6.636039e-001, - -1.809906e+000, - 2.170911e+000, - -1.937131e-001, - 7.968612e-001, - -8.460147e-006, - 2.686099e+000, - 9.000913e-001, - -2.001654e+000, - -9.594942e-001, - 2.079997e+000, - -1.353312e+000, - -5.482266e-001, - -1.459976e-003, - -2.624163e-002, - 1.834867e+000, - -2.747675e-001, - -3.241391e+000, - -1.537084e+000, - -2.481444e+000, - -7.635039e-001, - -7.605263e-001, - 5.191508e-001, - 5.847757e-001, - 3.257599e+000, - 1.487922e+000, - 2.689125e-001, - 2.598647e-001, - 1.725140e+000, - -2.635218e-001, - -3.626237e+000, - 8.275047e-002, - -2.856604e-001, - -2.307654e+000, - 2.134944e-001, - -1.463897e+000, - -4.116973e-001, - -1.916056e-001, - 1.574040e+001, - -3.593091e+000, - -1.773656e-001, - 3.519763e-001, - 1.614908e+000, - 8.302769e-001, - -9.864921e-001, - -2.005394e-001, - 2.091380e-001, - 4.013374e-002, - -2.015258e+000, - 1.418678e-001, - 4.259543e-001, - 1.368687e+000, - 6.820722e-001, - // albedo 0, turbidity 10 - -2.262384e+000, - -1.148119e+000, - -3.593889e+000, - 3.776156e+000, - -6.404236e-002, - 6.193772e-001, - -7.094359e-006, - 2.237025e+000, - 8.931620e-001, - -1.276920e+000, - -8.302892e-001, - 3.189973e+000, - -2.359861e+000, - -2.929750e-001, - 1.562370e-001, - -7.604893e-003, - 1.609136e+000, - -2.270658e-001, - -6.611222e+000, - -2.656391e+000, - -3.600171e+000, - 1.023390e+000, - 6.030035e-001, - 9.329641e-001, - 1.651021e-001, - 3.756497e+000, - 1.403624e+000, - 1.026923e+000, - 2.946641e-002, - 1.795470e+000, - 2.540858e-001, - -5.953577e+000, - -4.162474e-001, - 3.559647e-001, - -1.540672e+000, - 1.581254e-001, - -1.547540e+000, - -6.243264e-001, - 1.732470e-001, - 1.096480e+001, - -1.286094e+000, - -2.143584e-001, - -1.972282e-001, - -1.319792e-001, - 8.731654e-001, - -9.875272e-001, - -1.822978e-001, - 4.548775e-002, - 5.387053e+000, - -3.062190e+000, - 2.906349e-001, - 4.781276e-001, - 1.300372e+000, - 6.730039e-001, - // albedo 1, turbidity 1 - -1.104052e+000, - -1.634691e-001, - -1.387391e+000, - 2.942748e+000, - -2.259220e-001, - 1.010486e+000, - 2.204942e-002, - 4.310299e+000, - 5.138674e-001, - -1.116156e+000, - -1.683774e-001, - -1.858271e+000, - 3.430711e+000, - -2.377475e-001, - 8.108399e-001, - 1.060377e-002, - 5.208319e+000, - 3.989719e-001, - -1.078962e+000, - -1.538849e-001, - 4.367510e+000, - -3.165369e+000, - -6.711199e-001, - 2.062774e+000, - -3.202848e-002, - 8.503602e-001, - 9.692679e-001, - -1.111541e+000, - -2.728946e-001, - 2.255183e-001, - 2.174348e+000, - 1.031057e+000, - 3.183663e-001, - 3.920242e-002, - -1.516022e-001, - -2.159894e-002, - -1.039419e+000, - -1.206100e-001, - 2.290060e+000, - -2.243307e+000, - -6.142358e+000, - 1.056594e+000, - -3.303547e-002, - 2.713636e+000, - 9.106202e-001, - -1.076578e+000, - -1.432110e-001, - 1.639488e+000, - 3.282302e+000, - -2.493190e+000, - 5.608864e-001, - 2.261511e-002, - 3.056882e+000, - 5.003018e-001, - // albedo 1, turbidity 2 - -1.114018e+000, - -1.764798e-001, - -7.677623e+000, - 8.808307e+000, - -4.847876e-002, - 9.534913e-001, - 5.618491e-002, - 4.212917e+000, - 6.023125e-001, - -1.126231e+000, - -1.672111e-001, - 4.388054e+000, - -3.703504e+000, - -8.553161e-002, - 2.885906e-001, - 1.306424e-001, - 5.639266e+000, - 4.398425e-001, - -1.099800e+000, - -2.630132e-001, - 4.787770e-001, - 2.105288e+000, - -5.251653e-001, - 2.427252e+000, - -1.246785e-001, - -2.933590e+000, - 1.063575e+000, - -1.057713e+000, - -3.084726e-002, - 6.768199e-001, - -1.044275e+000, - 4.866777e-001, - -4.646566e-001, - 3.030455e-001, - 7.489353e+000, - 3.358166e-001, - -1.076440e+000, - -2.718000e-001, - 2.524154e+000, - -4.838771e-001, - -9.977367e+000, - 1.820647e+000, - -1.723508e-001, - -2.072269e+000, - 8.536330e-001, - -1.070888e+000, - -1.374705e-001, - 1.629302e+000, - 3.428098e+000, - -2.601212e+000, - -2.974475e-001, - 1.394611e-001, - 2.984174e+000, - 5.419294e-001, - // albedo 1, turbidity 3 - -1.130412e+000, - -1.933669e-001, - -4.857386e+000, - 5.769973e+000, - -7.535259e-002, - 8.797336e-001, - 5.043900e-002, - 4.337387e+000, - 6.753643e-001, - -1.161688e+000, - -1.960287e-001, - 1.106545e+000, - -8.577884e-001, - -9.360930e-002, - -7.801522e-002, - 1.647885e-001, - 5.848615e+000, - 4.471543e-001, - -1.067258e+000, - -2.455886e-001, - 2.084800e+000, - -5.197051e-001, - -5.325673e-001, - 2.777012e+000, - -8.039336e-002, - -2.543091e+000, - 1.079026e+000, - -1.097567e+000, - -5.464719e-003, - -8.165063e-001, - 2.596105e+000, - 9.459394e-001, - -1.468011e+000, - 4.630859e-001, - 8.461670e+000, - 2.460684e-001, - -1.035713e+000, - -2.587340e-001, - 2.864353e+000, - -6.828294e+000, - -6.971908e+000, - 2.583928e+000, - -1.921443e-001, - -1.937886e+000, - 1.017362e+000, - -1.096681e+000, - -1.527298e-001, - 1.482432e+000, - 1.313477e+001, - -3.016722e+000, - -8.479338e-001, - 1.294546e-001, - 2.716000e+000, - 4.999595e-001, - // albedo 1, turbidity 4 - -1.169876e+000, - -2.412093e-001, - -3.946023e+000, - 4.525235e+000, - -6.225248e-002, - 6.686438e-001, - 7.725227e-002, - 3.834185e+000, - 6.336494e-001, - -1.225511e+000, - -2.825782e-001, - -1.528308e-001, - 4.349972e-001, - -9.851306e-002, - 2.563982e-001, - 7.882497e-002, - 4.716580e+000, - 5.901271e-001, - -1.096536e+000, - -2.581517e-001, - 2.344027e+000, - -1.068223e+000, - -4.165502e-001, - 2.094143e+000, - 4.314056e-003, - -1.406154e+000, - 9.368852e-001, - -1.056016e+000, - 2.810766e-002, - -1.383733e+000, - 2.916831e+000, - 7.615073e-001, - -1.587747e+000, - 5.845122e-001, - 7.180950e+000, - 3.747069e-001, - -1.054600e+000, - -2.844119e-001, - 2.873617e+000, - -6.879472e+000, - -6.837078e+000, - 2.552183e+000, - -1.730378e-001, - -1.664886e+000, - 9.019748e-001, - -1.100561e+000, - -1.705639e-001, - 1.407614e+000, - 1.211381e+001, - -3.074279e+000, - -9.390883e-001, - 1.811676e-001, - 2.093695e+000, - 5.995081e-001, - // albedo 1, turbidity 5 - -1.208279e+000, - -2.897170e-001, - -1.476546e-001, - 5.890126e-001, - -4.981961e-001, - 4.583529e-001, - 8.688694e-002, - 3.436587e+000, - 6.179337e-001, - -1.431865e+000, - -5.637869e-001, - 1.387813e-001, - 1.280784e+000, - -1.554694e+000, - 3.086383e-001, - 5.996838e-002, - 1.263023e+000, - 5.584827e-001, - -1.008065e+000, - -1.511029e-002, - 3.503926e-001, - -3.436937e+000, - 5.368936e+000, - 1.418578e+000, - -1.024279e-002, - 4.433483e+000, - 1.012857e+000, - -1.063774e+000, - -1.747988e-001, - 1.386619e-001, - 9.452941e+000, - -1.800934e+001, - -1.193473e+000, - 6.588347e-001, - 4.905837e-001, - 2.953989e-001, - -1.067953e+000, - -1.932052e-001, - 1.877574e+000, - 4.291478e-001, - 3.924028e+000, - 1.870800e+000, - -2.168527e-001, - 1.746841e+000, - 8.941231e-001, - -1.091804e+000, - -1.887841e-001, - 1.459507e+000, - -2.411611e-003, - -5.007685e+000, - -5.384484e-001, - 3.273158e-001, - 1.389896e+000, - 6.481899e-001, - // albedo 1, turbidity 6 - -1.244637e+000, - -3.352956e-001, - -7.729831e-001, - 9.902457e-001, - -6.408322e-002, - 4.089615e-001, - 1.079801e-001, - 3.069518e+000, - 5.700739e-001, - -1.582813e+000, - -7.186917e-001, - -2.051782e+000, - 2.745735e+000, - -5.882307e-002, - 2.724410e-001, - 4.057660e-002, - 8.511673e-001, - 5.731486e-001, - -9.671558e-001, - 1.950082e-002, - 1.810232e+000, - -1.217155e+000, - -1.071386e-001, - 1.908662e+000, - -8.193543e-002, - 4.082294e+000, - 1.012666e+000, - -1.060235e+000, - -1.751755e-001, - -8.530449e-001, - 1.475536e+000, - -6.133057e-001, - -1.967505e+000, - 8.653180e-001, - 9.681735e-001, - 2.746134e-001, - -1.070553e+000, - -2.087976e-001, - 2.149017e+000, - -3.787703e+000, - -1.475900e+000, - 2.401470e+000, - -2.897798e-001, - 1.002619e+000, - 9.514204e-001, - -1.097750e+000, - -1.941377e-001, - 1.296961e+000, - 7.603643e+000, - -5.010009e+000, - -9.621720e-001, - 3.499847e-001, - 1.552155e+000, - 6.142077e-001, - // albedo 1, turbidity 7 - -1.317243e+000, - -4.124129e-001, - -2.112784e-001, - 2.358159e-001, - 7.933267e-002, - 2.953331e-001, - 1.393908e-001, - 2.797095e+000, - 5.001629e-001, - -1.936943e+000, - -1.047386e+000, - 7.900712e-001, - 7.391704e-001, - -1.761740e+000, - 4.555495e-001, - 7.089075e-003, - -4.904502e-001, - 4.687010e-001, - -7.950385e-001, - 2.145152e-001, - -7.466747e-001, - -1.478622e+000, - 5.440532e+000, - 1.045622e+000, - 2.731993e-002, - 6.502641e+000, - 1.131266e+000, - -1.144490e+000, - -3.809627e-001, - 6.924196e-001, - 2.313561e+000, - -1.492566e+001, - -1.261390e+000, - 6.493101e-001, - -3.111817e+000, - 2.197202e-001, - -1.033182e+000, - -1.134661e-001, - 1.362390e+000, - 7.974857e+000, - 2.098611e+000, - 1.676310e+000, - -1.459275e-001, - 3.060691e+000, - 9.001197e-001, - -1.099954e+000, - -2.081654e-001, - 1.288675e+000, - 3.154435e+000, - -4.977442e+000, - -7.563663e-001, - 3.316278e-001, - 1.310469e+000, - 6.638634e-001, - // albedo 1, turbidity 8 - -1.398360e+000, - -5.091482e-001, - -6.128087e-001, - 1.064324e+000, - -2.655754e-001, - 5.784825e-001, - 2.447271e-002, - 2.556213e+000, - 6.406131e-001, - -2.292408e+000, - -1.287064e+000, - 1.698575e+000, - -4.555523e-001, - -1.098610e+000, - 4.172403e-002, - 1.458605e-001, - -4.711102e-001, - 4.042647e-002, - -1.098655e+000, - -5.631273e-002, - -1.686446e+000, - -1.324818e+000, - 6.189470e-001, - 1.015319e+000, - 4.519728e-002, - 6.306605e+000, - 1.495579e+000, - -8.179258e-001, - -2.762936e-001, - 1.360129e+000, - 1.082906e+000, - -8.142899e+000, - -1.145783e+000, - 4.835959e-001, - -4.634913e+000, - -9.753444e-003, - -1.182319e+000, - -1.786040e-001, - 9.066952e-001, - 1.133717e+001, - -1.070025e+000, - 1.405348e+000, - -7.513401e-002, - 3.297654e+000, - 1.003184e+000, - -1.060857e+000, - -2.086912e-001, - 1.253454e+000, - 8.836029e+000, - -4.146867e+000, - -8.924448e-001, - 2.793886e-001, - 9.711994e-001, - 6.371753e-001, - // albedo 1, turbidity 9 - -1.521357e+000, - -6.741763e-001, - -1.153037e+000, - 1.777504e+000, - -2.339845e-001, - 7.149374e-001, - -8.169860e-006, - 2.158744e+000, - 9.000908e-001, - -2.063901e+000, - -1.050348e+000, - 1.888832e+000, - -7.193047e-001, - -6.376830e-001, - -8.892313e-002, - -2.207132e-002, - 9.541427e-001, - -2.903996e-001, - -3.079068e+000, - -1.419114e+000, - -1.810205e+000, - -1.419799e+000, - -6.498295e-001, - 9.599459e-001, - 4.898180e-001, - 3.881219e+000, - 1.541392e+000, - 3.182043e-001, - 1.995494e-001, - 1.434280e+000, - 1.894230e-001, - -4.081692e+000, - -9.559909e-001, - -1.349792e-001, - -3.617047e+000, - 1.281326e-001, - -1.521852e+000, - -3.451241e-001, - 7.272857e-001, - 1.443762e+001, - -3.427250e+000, - 9.841537e-001, - 2.142994e-001, - 2.000402e+000, - 8.885077e-001, - -1.000647e+000, - -2.295867e-001, - 1.144994e+000, - -2.393324e-003, - -2.630422e+000, - -6.861019e-001, - 2.825890e-001, - 5.805290e-001, - 6.620424e-001, - // albedo 1, turbidity 10 - -1.923394e+000, - -1.036111e+000, - -2.560678e+000, - 2.987334e+000, - -7.660880e-002, - 6.060592e-001, - -7.414202e-006, - 1.792845e+000, - 9.001463e-001, - -1.938155e+000, - -1.049658e+000, - 2.934957e+000, - -2.112628e+000, - -3.195476e-001, - -2.020638e-002, - -9.686121e-003, - 1.455635e+000, - -2.181714e-001, - -5.889712e+000, - -2.639521e+000, - -2.752599e+000, - 8.110383e-001, - 5.758426e-001, - 1.080493e+000, - 2.073045e-001, - 2.349084e+000, - 1.355521e+000, - 1.037526e+000, - 1.432077e-001, - 1.320726e+000, - 2.881663e-001, - -5.803075e+000, - -8.863853e-001, - 2.717468e-001, - -5.351612e-001, - 2.186762e-001, - -1.507983e+000, - -5.787687e-001, - 1.138616e+000, - 1.024246e+001, - -1.554095e+000, - 5.415668e-001, - -1.499505e-001, - -1.523118e+000, - 8.418226e-001, - -1.031267e+000, - -2.072990e-001, - 7.887604e-001, - 4.217895e+000, - -2.995052e+000, - -4.380607e-001, - 3.324471e-001, - 1.063346e+000, - 6.807500e-001, -}; - -double datasetXYZRad1[] = -{ - // albedo 0, turbidity 1 - 9.005710e-003, - 8.182992e-003, - 6.957843e-003, - 6.306849e-002, - 3.425256e-002, - 4.218684e-002, - // albedo 0, turbidity 2 - 8.928056e-003, - 8.633753e-003, - 4.500547e-003, - 7.073306e-002, - 3.305915e-002, - 4.362185e-002, - // albedo 0, turbidity 3 - 8.848416e-003, - 9.009571e-003, - 2.113216e-003, - 7.825675e-002, - 3.201372e-002, - 4.500035e-002, - // albedo 0, turbidity 4 - 8.679785e-003, - 9.554857e-003, - -1.631724e-003, - 8.887206e-002, - 3.173559e-002, - 4.661125e-002, - // albedo 0, turbidity 5 - 8.490013e-003, - 1.008158e-002, - -5.387675e-003, - 9.934433e-002, - 3.160711e-002, - 4.814191e-002, - // albedo 0, turbidity 6 - 8.176708e-003, - 1.116184e-002, - -1.232061e-002, - 1.152735e-001, - 3.149746e-002, - 5.090645e-002, - // albedo 0, turbidity 7 - 7.825887e-003, - 1.217907e-002, - -1.904565e-002, - 1.307615e-001, - 3.150599e-002, - 5.372829e-002, - // albedo 0, turbidity 8 - 7.509914e-003, - 1.349140e-002, - -2.655743e-002, - 1.453788e-001, - 3.160182e-002, - 5.709059e-002, - // albedo 0, turbidity 9 - 7.185144e-003, - 1.470882e-002, - -3.373863e-002, - 1.591499e-001, - 3.221303e-002, - 6.023953e-002, - // albedo 0, turbidity 10 - 6.992372e-003, - 1.542746e-002, - -3.779775e-002, - 1.657643e-001, - 3.455624e-002, - 6.176418e-002, - // albedo 1, turbidity 1 - 9.606797e-003, - 9.089278e-003, - 8.202458e-003, - 5.641609e-002, - 8.358347e-002, - 9.499950e-002, - // albedo 1, turbidity 2 - 9.539700e-003, - 9.514892e-003, - 5.777662e-003, - 6.403082e-002, - 8.257854e-002, - 9.744811e-002, - // albedo 1, turbidity 3 - 9.456190e-003, - 9.927642e-003, - 3.328348e-003, - 7.160160e-002, - 8.173734e-002, - 9.982680e-002, - // albedo 1, turbidity 4 - 9.276166e-003, - 1.052422e-002, - -5.679250e-004, - 8.230185e-002, - 8.188579e-002, - 1.026310e-001, - // albedo 1, turbidity 5 - 9.076613e-003, - 1.109440e-002, - -4.469722e-003, - 9.292079e-002, - 8.205840e-002, - 1.054416e-001, - // albedo 1, turbidity 6 - 8.801736e-003, - 1.192704e-002, - -1.043735e-002, - 1.063672e-001, - 8.512298e-002, - 1.085586e-001, - // albedo 1, turbidity 7 - 8.474727e-003, - 1.277127e-002, - -1.644412e-002, - 1.197926e-001, - 8.806212e-002, - 1.118848e-001, - // albedo 1, turbidity 8 - 8.155408e-003, - 1.379662e-002, - -2.265334e-002, - 1.312810e-001, - 9.129692e-002, - 1.156650e-001, - // albedo 1, turbidity 9 - 7.820697e-003, - 1.475906e-002, - -2.864690e-002, - 1.420061e-001, - 9.520393e-002, - 1.192700e-001, - // albedo 1, turbidity 10 - 7.644931e-003, - 1.534608e-002, - -3.196959e-002, - 1.464542e-001, - 9.985241e-002, - 1.208171e-001, -}; - -double datasetXYZ2[] = -{ - // albedo 0, turbidity 1 - -1.122914e+000, - -1.807235e-001, - -1.619165e+000, - 2.731045e+000, - -1.975906e-001, - 9.087980e-001, - 4.034744e-002, - 4.576616e+000, - 5.161273e-001, - -1.154388e+000, - -1.988315e-001, - -2.030717e+000, - 3.373363e+000, - -2.460481e-001, - 6.460481e-001, - 3.157532e-002, - 5.421385e+000, - 3.782806e-001, - -1.079334e+000, - -1.658789e-001, - 4.322620e+000, - -3.142670e+000, - -7.643807e-001, - 2.131864e+000, - -9.013664e-002, - 9.705869e-001, - 1.078954e+000, - -1.134921e+000, - -2.543435e-001, - 9.573512e-002, - 2.124979e+000, - 9.555775e-001, - 8.037731e-001, - 1.184837e-001, - -1.496420e-001, - -8.840597e-003, - -1.049115e+000, - -1.444870e-001, - 1.981646e+000, - -2.194727e+000, - -6.137320e+000, - 1.876768e+000, - -1.074934e-001, - 2.649021e+000, - 8.652867e-001, - -1.072213e+000, - -1.379147e-001, - 1.507428e+000, - 3.410012e+000, - -2.362891e+000, - 1.245730e+000, - 7.913373e-002, - 3.022137e+000, - 4.999200e-001, - // albedo 0, turbidity 2 - -1.131878e+000, - -1.911417e-001, - -5.546343e+000, - 6.486312e+000, - -7.540655e-002, - 9.642554e-001, - 3.999667e-002, - 4.609125e+000, - 6.292406e-001, - -1.126486e+000, - -1.582147e-001, - 2.323428e+000, - -2.107498e+000, - -1.516963e-001, - 2.866962e-001, - 1.540643e-001, - 7.073975e+000, - 3.562770e-001, - -1.159513e+000, - -3.101117e-001, - 1.722605e+000, - 8.457975e-001, - -5.367977e-001, - 2.084499e+000, - -1.638125e-001, - -3.350490e+000, - 1.149230e+000, - -1.026013e+000, - -1.328421e-004, - -2.569728e-001, - 6.293616e-002, - -7.518545e-001, - 4.849009e-001, - 3.378441e-001, - 7.293808e+000, - 2.684199e-001, - -1.107049e+000, - -2.912417e-001, - 2.313578e+000, - -2.877340e+000, - -8.789791e+000, - 1.964722e+000, - -1.326046e-001, - -1.641421e+000, - 9.088870e-001, - -1.062899e+000, - -1.366999e-001, - 1.374840e+000, - 9.253357e+000, - -3.285853e+000, - 7.598081e-001, - 1.518365e-001, - 2.825418e+000, - 4.999470e-001, - // albedo 0, turbidity 3 - -1.149828e+000, - -2.119093e-001, - -3.083260e+000, - 3.704001e+000, - -1.121437e-001, - 8.021617e-001, - 5.920592e-002, - 4.604865e+000, - 6.398452e-001, - -1.173890e+000, - -2.156342e-001, - 2.565790e-001, - -1.267097e-001, - -2.072132e-001, - 1.829126e-001, - 1.283318e-001, - 6.095559e+000, - 4.937362e-001, - -1.116949e+000, - -2.482856e-001, - 2.218113e+000, - -8.794890e-001, - -5.644284e-001, - 2.082300e+000, - -5.169108e-002, - -7.659116e-001, - 9.558886e-001, - -1.054217e+000, - 8.365248e-004, - -1.216753e+000, - 2.368297e+000, - -7.221626e-001, - -2.645171e-001, - 4.218527e-001, - 6.847504e+000, - 4.451660e-001, - -1.078108e+000, - -2.751379e-001, - 2.237058e+000, - -6.031771e+000, - -6.013303e+000, - 2.276389e+000, - -3.578611e-002, - -1.090788e+000, - 8.050813e-001, - -1.074500e+000, - -1.518904e-001, - 1.142963e+000, - 1.249282e+001, - -3.264809e+000, - 3.225364e-001, - 1.546626e-001, - 2.625043e+000, - 6.604471e-001, - // albedo 0, turbidity 4 - -1.204183e+000, - -2.690555e-001, - -2.118885e+000, - 2.333211e+000, - -9.144809e-002, - 6.235965e-001, - 9.022505e-002, - 4.107881e+000, - 5.935340e-001, - -1.249364e+000, - -3.302901e-001, - -1.015855e+000, - 1.626302e+000, - -2.098635e-001, - 3.586044e-001, - 3.433743e-002, - 4.259679e+000, - 6.186639e-001, - -1.130739e+000, - -1.893714e-001, - 2.212068e+000, - -2.632060e+000, - -5.355575e-001, - 1.855859e+000, - 5.156915e-002, - 2.331263e+000, - 8.620975e-001, - -1.029212e+000, - -5.804296e-002, - -1.456592e+000, - 4.450693e+000, - 4.508010e-001, - -1.190723e+000, - 5.486355e-001, - 3.324973e+000, - 4.658997e-001, - -1.071594e+000, - -2.295521e-001, - 1.797098e+000, - -8.426178e+000, - -4.838257e+000, - 2.749226e+000, - -7.145818e-003, - 9.376112e-001, - 8.234331e-001, - -1.076084e+000, - -1.644066e-001, - 8.169316e-001, - 1.447937e+001, - -3.328583e+000, - -4.635255e-001, - 2.876957e-001, - 2.371624e+000, - 6.607566e-001, - // albedo 0, turbidity 5 - -1.249210e+000, - -3.222757e-001, - -3.993402e-001, - 4.023211e-001, - -2.849433e-001, - 4.535075e-001, - 1.115902e-001, - 3.744528e+000, - 5.563504e-001, - -1.477704e+000, - -6.045061e-001, - -3.822014e-001, - 1.661732e+000, - -1.238864e+000, - 4.237514e-001, - 8.886169e-003, - 1.420669e+000, - 6.186606e-001, - -1.035944e+000, - 6.890505e-003, - 6.684449e-001, - -2.790536e+000, - 3.601830e+000, - 1.380572e+000, - -5.081267e-003, - 6.133132e+000, - 9.371410e-001, - -1.055090e+000, - -2.222588e-001, - -5.205025e-001, - 5.816522e+000, - -1.516023e+001, - -1.026305e+000, - 6.623858e-001, - -9.657356e-001, - 3.741606e-001, - -1.059766e+000, - -1.598774e-001, - 1.157297e+000, - 5.532982e+000, - 2.638082e+000, - 2.027566e+000, - -1.199808e-001, - 2.770544e+000, - 8.444287e-001, - -1.066947e+000, - -1.591492e-001, - 4.375334e-001, - 4.423892e-001, - -4.533511e+000, - -3.404865e-001, - 5.901014e-001, - 2.719634e+000, - 6.625956e-001, - // albedo 0, turbidity 6 - -1.284441e+000, - -3.609807e-001, - -9.984029e-001, - 7.536405e-001, - 2.158548e-002, - 3.401340e-001, - 1.517400e-001, - 3.584038e+000, - 4.998561e-001, - -1.642638e+000, - -7.512595e-001, - -5.758545e-001, - 1.892728e+000, - -6.026600e-001, - 6.764253e-001, - -6.644974e-002, - 9.368823e-001, - 5.881781e-001, - -9.687452e-001, - 5.694871e-002, - 4.808739e-001, - -2.494357e+000, - 7.817431e-001, - 9.839932e-001, - 1.281253e-001, - 6.408919e+000, - 9.352341e-001, - -1.067115e+000, - -2.459833e-001, - -4.332687e-001, - 4.019233e+000, - -2.284292e+000, - -7.820544e-001, - 5.997262e-001, - -1.481944e+000, - 4.002165e-001, - -1.062319e+000, - -1.694356e-001, - 8.089156e-001, - -5.809914e+000, - -3.376530e-001, - 1.664714e+000, - 1.171593e-002, - 2.709085e+000, - 8.406936e-001, - -1.059995e+000, - -1.476748e-001, - 3.041194e-001, - 9.109686e+000, - -4.692319e+000, - -2.445953e-001, - 5.867979e-001, - 3.010372e+000, - 6.649859e-001, - // albedo 0, turbidity 7 - -1.356626e+000, - -4.344649e-001, - -1.447889e+000, - 1.316070e+000, - -3.231971e-002, - 4.115335e-001, - 1.070600e-001, - 3.299847e+000, - 5.078718e-001, - -1.908978e+000, - -9.880442e-001, - 1.734223e+000, - -3.331857e-001, - -6.564627e-001, - 7.778246e-001, - -2.493316e-003, - 2.301123e-001, - 4.057979e-001, - -9.822537e-001, - 7.415023e-002, - -1.823900e+000, - -5.375540e-001, - 7.367396e-001, - 3.368504e-002, - 1.007106e-001, - 7.096159e+000, - 1.148616e+000, - -9.972614e-001, - -2.851500e-001, - 1.076035e+000, - -1.429468e+000, - -1.018551e+001, - 3.978549e-001, - 5.298517e-001, - -3.271319e+000, - 2.447665e-001, - -1.091570e+000, - -1.638435e-001, - 1.867819e-001, - 1.968715e+001, - -9.281292e-001, - 2.334219e-001, - -8.687501e-003, - 3.377805e+000, - 8.598541e-001, - -1.048522e+000, - -1.614766e-001, - 2.718072e-001, - 7.482388e-003, - -3.077932e+000, - 8.851555e-002, - 5.774509e-001, - 2.395370e+000, - 6.787352e-001, - // albedo 0, turbidity 8 - -1.402258e+000, - -5.000147e-001, - -1.953453e+000, - 2.236805e+000, - -1.565432e-001, - 7.284951e-001, - 7.637932e-003, - 3.157646e+000, - 6.973669e-001, - -2.139018e+000, - -1.131695e+000, - 2.538143e+000, - -1.588990e+000, - -5.632198e-001, - 2.000549e-001, - 5.533031e-002, - 4.863742e-001, - -3.692560e-002, - -1.508179e+000, - -3.385328e-001, - -2.890536e+000, - 4.392917e-001, - -2.160104e-001, - 4.321423e-001, - 2.859367e-001, - 6.164596e+000, - 1.460664e+000, - -5.946662e-001, - -1.226202e-001, - 1.975459e+000, - -4.214771e+000, - -6.102017e+000, - 1.242637e-001, - 1.413993e-001, - -3.812389e+000, - 1.352672e-001, - -1.243217e+000, - -2.621981e-001, - -2.366563e-001, - 2.337274e+001, - -3.000507e+000, - 7.773696e-002, - 1.592284e-001, - 2.841483e+000, - 8.722272e-001, - -1.016039e+000, - -1.664222e-001, - 2.477921e-001, - 3.645234e-002, - -2.538394e+000, - -5.133680e-002, - 5.200253e-001, - 1.965000e+000, - 6.779353e-001, - // albedo 0, turbidity 9 - -1.603220e+000, - -7.076823e-001, - -2.233113e+000, - 2.499871e+000, - -1.306915e-001, - 7.341952e-001, - -8.135566e-006, - 2.650817e+000, - 9.001136e-001, - -1.848857e+000, - -8.949301e-001, - 2.568410e+000, - -1.739167e+000, - -4.613569e-001, - 2.355479e-002, - -1.885319e-002, - 1.873327e+000, - -2.914893e-001, - -3.533969e+000, - -1.665575e+000, - -2.860794e+000, - -2.842810e-001, - -2.235740e-001, - 6.939897e-001, - 4.165640e-001, - 3.409915e+000, - 1.543612e+000, - 4.143747e-001, - 3.149978e-001, - 1.888906e+000, - -1.013183e+000, - -4.994871e+000, - -2.117057e-001, - -5.263550e-002, - -2.147159e+000, - 1.293928e-001, - -1.522103e+000, - -4.654974e-001, - -1.701403e-001, - 1.692673e+001, - -2.752530e+000, - 7.045914e-002, - 1.899328e-001, - 1.276994e+000, - 8.783455e-001, - -9.829618e-001, - -2.093400e-001, - 2.225879e-001, - -1.929224e-004, - -2.153428e+000, - -2.570729e-002, - 4.314043e-001, - 1.287312e+000, - 6.728048e-001, - // albedo 0, turbidity 10 - -2.204582e+000, - -1.133269e+000, - -3.567686e+000, - 3.691437e+000, - -5.609072e-002, - 5.815449e-001, - -7.619855e-006, - 2.272998e+000, - 9.001409e-001, - -1.295809e+000, - -8.555245e-001, - 3.224414e+000, - -2.416681e+000, - -2.909513e-001, - 1.419765e-001, - -4.780137e-003, - 1.653556e+000, - -2.383716e-001, - -6.623633e+000, - -2.685647e+000, - -3.573099e+000, - 1.039728e+000, - 6.517956e-001, - 9.342824e-001, - 9.620348e-002, - 3.719962e+000, - 1.413863e+000, - 1.011824e+000, - -4.712038e-003, - 1.840273e+000, - 2.670188e-001, - -5.934827e+000, - -4.000691e-001, - 4.055636e-001, - -1.576287e+000, - 1.625110e-001, - -1.528649e+000, - -6.319570e-001, - 1.759796e-001, - 1.096345e+001, - -1.281789e+000, - -2.029316e-001, - -2.287413e-001, - -1.879906e-001, - 8.681681e-001, - -1.004153e+000, - -1.969335e-001, - 3.961794e-002, - 5.389883e+000, - -3.037866e+000, - 2.821557e-001, - 4.772254e-001, - 1.246164e+000, - 6.737333e-001, - // albedo 1, turbidity 1 - -1.119344e+000, - -1.778838e-001, - -1.508412e+000, - 2.870124e+000, - -2.239333e-001, - 8.733617e-001, - 2.986154e-002, - 4.430712e+000, - 5.135851e-001, - -1.135624e+000, - -1.892481e-001, - -1.925788e+000, - 3.394714e+000, - -2.507147e-001, - 6.564287e-001, - 1.890654e-002, - 5.264438e+000, - 3.955314e-001, - -1.089894e+000, - -1.644770e-001, - 4.378723e+000, - -3.163341e+000, - -7.647141e-001, - 2.071685e+000, - -5.411723e-002, - 8.601366e-001, - 1.014955e+000, - -1.115740e+000, - -2.553530e-001, - 2.736970e-001, - 2.183258e+000, - 9.796187e-001, - 4.044719e-001, - 6.919363e-002, - -1.499169e-001, - -5.072956e-002, - -1.044489e+000, - -1.247379e-001, - 2.360130e+000, - -2.225798e+000, - -6.163017e+000, - 1.085341e+000, - -6.292495e-002, - 2.724664e+000, - 8.346156e-001, - -1.083384e+000, - -1.428958e-001, - 1.674826e+000, - 3.290022e+000, - -2.508268e+000, - 5.171812e-001, - 4.707754e-002, - 3.056420e+000, - 5.205018e-001, - // albedo 1, turbidity 2 - -1.126203e+000, - -1.874434e-001, - -8.225386e+000, - 9.269649e+000, - -4.877404e-002, - 9.126623e-001, - 4.343544e-002, - 4.398148e+000, - 6.048192e-001, - -1.127515e+000, - -1.550387e-001, - 4.222531e+000, - -3.896625e+000, - -9.271714e-002, - 2.272982e-001, - 1.474878e-001, - 7.073835e+000, - 3.534149e-001, - -1.140955e+000, - -3.141082e-001, - 7.494281e-001, - 1.928069e+000, - -5.030279e-001, - 2.213426e+000, - -1.778000e-001, - -4.450330e+000, - 1.208623e+000, - -1.036406e+000, - 6.146237e-003, - 4.836567e-001, - -4.637645e-001, - 3.971223e-001, - -8.322950e-002, - 3.525289e-001, - 8.416154e+000, - 1.781471e-001, - -1.091202e+000, - -2.793346e-001, - 2.677430e+000, - -1.228281e+000, - -9.791189e+000, - 1.628287e+000, - -2.033050e-001, - -2.250860e+000, - 9.727505e-001, - -1.077631e+000, - -1.444596e-001, - 1.677057e+000, - 3.028066e+000, - -2.741089e+000, - -2.423031e-001, - 1.570363e-001, - 2.711075e+000, - 5.193949e-001, - // albedo 1, turbidity 3 - -1.145360e+000, - -2.105117e-001, - -5.077634e+000, - 5.952346e+000, - -7.390363e-002, - 8.359362e-001, - 3.894082e-002, - 4.272124e+000, - 6.689348e-001, - -1.169021e+000, - -1.984243e-001, - 1.727631e+000, - -1.660273e+000, - -1.204151e-001, - -3.657555e-002, - 1.396934e-001, - 6.459890e+000, - 4.429674e-001, - -1.095745e+000, - -2.703153e-001, - 1.524693e+000, - 4.786023e-001, - -5.195445e-001, - 2.454992e+000, - -9.359784e-002, - -2.494334e+000, - 1.062193e+000, - -1.080084e+000, - 1.859535e-002, - -5.240918e-001, - 1.058138e+000, - 3.243268e-001, - -1.013826e+000, - 4.696901e-001, - 8.386396e+000, - 2.995756e-001, - -1.055753e+000, - -2.828392e-001, - 2.890561e+000, - -3.996377e+000, - -8.871250e+000, - 2.270188e+000, - -2.078015e-001, - -2.350737e+000, - 9.407089e-001, - -1.098941e+000, - -1.572908e-001, - 1.543062e+000, - 8.155922e+000, - -2.961933e+000, - -6.409603e-001, - 1.797896e-001, - 2.512159e+000, - 5.535961e-001, - // albedo 1, turbidity 4 - -1.184914e+000, - -2.566244e-001, - -3.846003e+000, - 4.420609e+000, - -6.973320e-002, - 6.818036e-001, - 5.691508e-002, - 3.866452e+000, - 6.359155e-001, - -1.261831e+000, - -3.275588e-001, - 7.852943e-002, - 2.205681e-001, - -9.853502e-002, - 4.286207e-002, - 9.083512e-002, - 4.172143e+000, - 5.440606e-001, - -1.078705e+000, - -2.152762e-001, - 1.912472e+000, - -1.012286e+000, - -4.044678e-001, - 2.400412e+000, - -8.055112e-002, - 4.643356e-001, - 1.007864e+000, - -1.086128e+000, - -1.844862e-002, - -1.041382e+000, - 3.081237e+000, - 6.333381e-001, - -1.901209e+000, - 6.588684e-001, - 5.373024e+000, - 3.074915e-001, - -1.041302e+000, - -2.639676e-001, - 2.783729e+000, - -7.142120e+000, - -7.159345e+000, - 2.843385e+000, - -2.319381e-001, - -9.181803e-001, - 9.458627e-001, - -1.115824e+000, - -1.814189e-001, - 1.440363e+000, - 1.228528e+001, - -3.111162e+000, - -1.091867e+000, - 2.170530e-001, - 1.853334e+000, - 5.820210e-001, - // albedo 1, turbidity 5 - -1.232446e+000, - -3.127409e-001, - -1.622789e-001, - 4.915046e-001, - -4.065352e-001, - 4.224392e-001, - 9.198375e-002, - 3.391924e+000, - 5.731891e-001, - -1.443917e+000, - -5.875923e-001, - 1.658220e-001, - 1.351501e+000, - -1.644611e+000, - 3.257529e-001, - 3.153559e-002, - 1.195318e+000, - 5.653871e-001, - -1.043103e+000, - -1.694476e-002, - 2.932353e-001, - -2.984651e+000, - 4.702246e+000, - 1.309969e+000, - -1.346309e-002, - 5.174512e+000, - 1.009478e+000, - -1.048629e+000, - -1.972413e-001, - 1.662522e-001, - 7.139297e+000, - -1.583388e+001, - -9.428178e-001, - 6.162218e-001, - -4.325526e-001, - 3.161814e-001, - -1.077482e+000, - -1.788140e-001, - 1.914283e+000, - 2.374649e+000, - 2.030094e+000, - 1.702760e+000, - -1.769197e-001, - 2.149751e+000, - 8.693740e-001, - -1.094960e+000, - -1.913894e-001, - 1.426293e+000, - -2.499581e-003, - -5.010191e+000, - -5.223956e-001, - 3.183908e-001, - 1.428610e+000, - 6.591116e-001, - // albedo 1, turbidity 6 - -1.264029e+000, - -3.549419e-001, - -1.406577e+000, - 1.507000e+000, - -8.434063e-003, - 3.365377e-001, - 1.289022e-001, - 3.066945e+000, - 5.080897e-001, - -1.610970e+000, - -7.451223e-001, - -7.941481e-001, - 1.856694e+000, - -1.795623e-001, - 3.454217e-001, - -2.784437e-003, - 7.329015e-001, - 5.715167e-001, - -9.666391e-001, - 3.876303e-002, - 8.648352e-001, - -1.587177e+000, - 5.145482e-002, - 1.711765e+000, - -5.636895e-002, - 5.223236e+000, - 1.024660e+000, - -1.080803e+000, - -2.247415e-001, - -2.913792e-001, - 3.381244e+000, - -6.921786e-001, - -1.689096e+000, - 7.923716e-001, - -5.143487e-001, - 2.724712e-001, - -1.059741e+000, - -1.809840e-001, - 1.942598e+000, - -7.101628e+000, - -2.477121e+000, - 2.198085e+000, - -2.267978e-001, - 1.738299e+000, - 9.444295e-001, - -1.103098e+000, - -1.914456e-001, - 1.299857e+000, - 1.221396e+001, - -4.937333e+000, - -8.898276e-001, - 3.150947e-001, - 1.699920e+000, - 6.222964e-001, - // albedo 1, turbidity 7 - -1.331835e+000, - -4.251342e-001, - -6.041415e-001, - 7.867983e-001, - -1.040816e-001, - 4.133208e-001, - 8.617309e-002, - 2.875871e+000, - 5.195064e-001, - -1.926241e+000, - -1.044496e+000, - 1.348627e+000, - 5.796068e-002, - -9.951364e-001, - 3.106924e-001, - 7.828124e-002, - -5.033876e-001, - 3.443558e-001, - -8.746306e-001, - 1.684892e-001, - -1.131114e+000, - -1.142233e+000, - 2.657255e+000, - 1.083562e+000, - -1.051614e-001, - 7.051685e+000, - 1.280761e+000, - -1.092601e+000, - -3.652440e-001, - 8.395056e-001, - 1.876542e+000, - -1.293821e+001, - -1.197457e+000, - 7.676588e-001, - -3.675501e+000, - 8.835534e-002, - -1.058669e+000, - -1.227902e-001, - 1.351437e+000, - 1.010666e+001, - 1.334936e+000, - 1.644623e+000, - -2.421837e-001, - 3.267276e+000, - 9.679541e-001, - -1.100225e+000, - -2.126091e-001, - 1.294536e+000, - 4.106722e+000, - -4.882368e+000, - -8.109179e-001, - 3.455974e-001, - 1.171128e+000, - 6.467468e-001, - // albedo 1, turbidity 8 - -1.392910e+000, - -5.069860e-001, - -1.142949e+000, - 1.640913e+000, - -1.966830e-001, - 6.482210e-001, - 6.953198e-003, - 2.652369e+000, - 6.996688e-001, - -2.172107e+000, - -1.209059e+000, - 2.139161e+000, - -1.059948e+000, - -5.782265e-001, - 4.811473e-002, - 8.485675e-002, - -3.292543e-001, - -6.032595e-002, - -1.335264e+000, - -2.069000e-001, - -1.982960e+000, - 8.070808e-001, - -4.710386e-001, - 9.418094e-001, - 1.195574e-001, - 6.509415e+000, - 1.546262e+000, - -6.990349e-001, - -2.244664e-001, - 1.513781e+000, - -6.074608e+000, - -6.749382e+000, - -9.377171e-001, - 4.125712e-001, - -4.914209e+000, - 5.574207e-003, - -1.214571e+000, - -1.960482e-001, - 9.045432e-001, - 2.394870e+001, - -2.765233e+000, - 1.132797e+000, - -8.917130e-002, - 3.246801e+000, - 9.419349e-001, - -1.059957e+000, - -1.995737e-001, - 1.176967e+000, - 1.405613e-003, - -3.383990e+000, - -7.123966e-001, - 3.495155e-001, - 1.196716e+000, - 6.635052e-001, - // albedo 1, turbidity 9 - -1.584877e+000, - -7.262168e-001, - -1.740843e+000, - 2.262110e+000, - -1.295187e-001, - 6.690681e-001, - -7.904979e-006, - 2.078188e+000, - 9.001230e-001, - -1.904657e+000, - -9.791879e-001, - 2.526185e+000, - -1.393353e+000, - -4.377071e-001, - -7.490654e-003, - -1.508279e-002, - 1.086965e+000, - -3.083812e-001, - -3.371479e+000, - -1.560656e+000, - -2.231093e+000, - -2.427120e-001, - -2.338193e-001, - 9.563028e-001, - 3.304433e-001, - 3.739686e+000, - 1.599714e+000, - 4.387745e-001, - 2.628599e-001, - 1.524571e+000, - -1.970968e+000, - -5.345634e+000, - -9.987550e-001, - 9.361642e-002, - -3.014998e+000, - 4.664222e-002, - -1.546981e+000, - -4.036780e-001, - 8.325325e-001, - 1.715800e+001, - -2.851827e+000, - 1.017658e+000, - 5.047605e-002, - 1.280570e+000, - 9.205303e-001, - -1.007805e+000, - -2.280094e-001, - 1.094464e+000, - -2.536201e-003, - -2.625881e+000, - -7.694080e-001, - 3.014068e-001, - 6.863553e-001, - 6.618797e-001, - // albedo 1, turbidity 10 - -2.053568e+000, - -1.118817e+000, - -2.476651e+000, - 2.850408e+000, - -6.473262e-002, - 5.621066e-001, - -7.416765e-006, - 1.745013e+000, - 9.001462e-001, - -1.709489e+000, - -9.819671e-001, - 2.761507e+000, - -1.714474e+000, - -3.528594e-001, - -4.119396e-002, - -4.730579e-003, - 1.499789e+000, - -2.391912e-001, - -6.391469e+000, - -2.761260e+000, - -2.577416e+000, - 3.597562e-002, - 5.989102e-001, - 1.364694e+000, - 9.601535e-002, - 2.454903e+000, - 1.416630e+000, - 1.216754e+000, - 9.574717e-002, - 1.225522e+000, - 1.738200e+000, - -5.694060e+000, - -1.293189e+000, - 3.689231e-001, - -6.089362e-001, - 1.579300e-001, - -1.525011e+000, - -5.441954e-001, - 1.133633e+000, - 1.006755e+001, - -2.040823e+000, - 8.661522e-001, - -2.113994e-001, - -1.412329e+000, - 8.753097e-001, - -1.042371e+000, - -2.363937e-001, - 7.521052e-001, - 2.049669e-002, - -1.941391e+000, - -4.961140e-001, - 3.981498e-001, - 9.201797e-001, - 6.656735e-001, -}; - -double datasetXYZRad2[] = -{ - // albedo 0, turbidity 1 - 9.427554e-003, - 8.058571e-003, - 7.941874e-003, - 7.152767e-002, - 3.420213e-002, - 4.486364e-002, - // albedo 0, turbidity 2 - 9.343795e-003, - 8.500973e-003, - 5.220239e-003, - 7.911633e-002, - 3.371270e-002, - 4.595605e-002, - // albedo 0, turbidity 3 - 9.223919e-003, - 8.979357e-003, - 2.266151e-003, - 8.695394e-002, - 3.307117e-002, - 4.712533e-002, - // albedo 0, turbidity 4 - 9.022225e-003, - 9.826422e-003, - -2.734701e-003, - 9.906042e-002, - 3.211211e-002, - 4.915850e-002, - // albedo 0, turbidity 5 - 8.790138e-003, - 1.065429e-002, - -7.647537e-003, - 1.108126e-001, - 3.142813e-002, - 5.104678e-002, - // albedo 0, turbidity 6 - 8.449344e-003, - 1.204669e-002, - -1.569449e-002, - 1.276238e-001, - 3.143630e-002, - 5.399848e-002, - // albedo 0, turbidity 7 - 8.102946e-003, - 1.323220e-002, - -2.319017e-002, - 1.435403e-001, - 3.189872e-002, - 5.687037e-002, - // albedo 0, turbidity 8 - 7.772349e-003, - 1.470008e-002, - -3.103115e-002, - 1.578796e-001, - 3.281949e-002, - 6.018986e-002, - // albedo 0, turbidity 9 - 7.429019e-003, - 1.602571e-002, - -3.840462e-002, - 1.712024e-001, - 3.422270e-002, - 6.336843e-002, - // albedo 0, turbidity 10 - 7.217988e-003, - 1.684335e-002, - -4.272209e-002, - 1.780005e-001, - 3.647559e-002, - 6.525172e-002, - // albedo 1, turbidity 1 - 1.007930e-002, - 9.469359e-003, - 7.751882e-003, - 6.735888e-002, - 8.607559e-002, - 1.024772e-001, - // albedo 1, turbidity 2 - 9.994748e-003, - 1.000808e-002, - 4.606871e-003, - 7.572962e-002, - 8.492733e-002, - 1.050286e-001, - // albedo 1, turbidity 3 - 9.867055e-003, - 1.050709e-002, - 1.632528e-003, - 8.364781e-002, - 8.428999e-002, - 1.073660e-001, - // albedo 1, turbidity 4 - 9.657944e-003, - 1.132287e-002, - -3.178687e-003, - 9.510100e-002, - 8.436936e-002, - 1.103412e-001, - // albedo 1, turbidity 5 - 9.423656e-003, - 1.209974e-002, - -7.969914e-003, - 1.064676e-001, - 8.451926e-002, - 1.133836e-001, - // albedo 1, turbidity 6 - 9.102522e-003, - 1.313191e-002, - -1.453139e-002, - 1.197732e-001, - 8.837563e-002, - 1.164319e-001, - // albedo 1, turbidity 7 - 8.758492e-003, - 1.408607e-002, - -2.093813e-002, - 1.327661e-001, - 9.241165e-002, - 1.195703e-001, - // albedo 1, turbidity 8 - 8.449389e-003, - 1.515206e-002, - -2.716582e-002, - 1.432571e-001, - 9.701279e-002, - 1.230409e-001, - // albedo 1, turbidity 9 - 8.119285e-003, - 1.608683e-002, - -3.295498e-002, - 1.527686e-001, - 1.021520e-001, - 1.266069e-001, - // albedo 1, turbidity 10 - 7.942180e-003, - 1.664579e-002, - -3.594293e-002, - 1.559130e-001, - 1.083492e-001, - 1.276285e-001, -}; - -double datasetXYZ3[] = -{ - // albedo 0, turbidity 1 - -1.311888e+000, - -4.420623e-001, - -8.214623e+000, - 8.648177e+000, - -3.635749e-002, - 5.335267e-001, - 1.131124e-002, - 3.149016e+000, - 4.999443e-001, - -1.425950e+000, - -5.484125e-001, - -1.397730e+000, - 2.129249e+000, - -8.008800e-002, - 5.424854e-001, - 9.998297e-003, - 2.644282e+000, - 5.135004e-001, - -1.104356e+000, - -1.940769e-001, - 2.507502e+000, - -3.111118e+000, - -1.123243e-001, - 4.371704e-001, - -1.567242e-002, - 5.499670e+000, - 4.026340e-001, - -1.192319e+000, - -4.462048e-001, - 5.371843e-001, - 1.752080e+000, - -5.827109e-001, - 1.447609e+000, - 4.110161e-002, - -3.291197e+000, - 8.331939e-001, - -1.005527e+000, - -1.072900e-001, - 1.013645e+000, - -6.226680e-001, - 7.023087e-001, - 5.090545e-001, - -6.104120e-002, - 4.522197e+000, - 6.585009e-001, - -1.074276e+000, - -1.717007e-001, - 8.668669e-001, - 1.635690e-001, - -5.004160e+000, - 1.450587e+000, - 1.000051e-001, - 3.366395e+000, - 4.999445e-001, - // albedo 0, turbidity 2 - -1.331333e+000, - -4.626283e-001, - -6.305924e+000, - 6.766781e+000, - -5.051313e-002, - 5.556381e-001, - 4.156655e-003, - 3.095492e+000, - 5.777151e-001, - -1.575536e+000, - -7.238005e-001, - 2.173605e-002, - 9.741010e-001, - -1.103266e-001, - 5.139781e-001, - 1.587703e-002, - 1.459081e+000, - 2.112299e-001, - -8.709656e-001, - 6.710823e-002, - 1.020573e+000, - -2.360032e+000, - -1.540314e-001, - 4.154631e-001, - -1.385436e-002, - 7.471963e+000, - 1.182792e+000, - -1.285011e+000, - -5.166853e-001, - 8.665324e-001, - 1.692490e+000, - -7.961840e-001, - 1.256981e+000, - 1.009228e-001, - -3.544266e+000, - 2.688645e-001, - -9.893626e-001, - -9.370750e-002, - 7.783371e-001, - -8.390834e-001, - 1.050487e-001, - 6.421791e-001, - -6.671917e-002, - 4.897068e+000, - 8.901579e-001, - -1.076705e+000, - -1.802849e-001, - 8.245262e-001, - 3.292666e-001, - -5.004096e+000, - 1.146985e+000, - 1.568911e-001, - 3.093827e+000, - 5.240784e-001, - // albedo 0, turbidity 3 - -1.350265e+000, - -4.789632e-001, - -4.518654e+000, - 4.892352e+000, - -6.730528e-002, - 5.459274e-001, - 6.104279e-003, - 3.152799e+000, - 5.387910e-001, - -1.655122e+000, - -8.206123e-001, - 6.170559e-001, - 2.808772e-001, - -1.358176e-001, - 5.332729e-001, - 2.780488e-002, - 1.104735e+000, - 2.869065e-001, - -7.543663e-001, - 1.668019e-001, - 2.587982e-001, - -1.385098e+000, - -2.965985e-001, - 1.255789e-001, - -5.621719e-002, - 7.402862e+000, - 1.248826e+000, - -1.305139e+000, - -4.469096e-001, - 4.910604e-001, - 1.908400e+000, - -4.318161e-001, - 1.569090e+000, - 1.923636e-001, - -1.167472e+000, - 2.045414e-001, - -9.935607e-001, - -1.439402e-001, - 8.263513e-001, - -2.915009e+000, - -5.527549e+000, - 8.037532e-002, - -7.526778e-003, - 3.769175e+000, - 8.937858e-001, - -1.083111e+000, - -1.916481e-001, - 7.362846e-001, - 4.367754e+000, - -4.060770e+000, - 1.350372e+000, - 1.200770e-001, - 2.889067e+000, - 5.899180e-001, - // albedo 0, turbidity 4 - -1.373374e+000, - -5.100680e-001, - -3.039093e+000, - 3.413389e+000, - -9.466214e-002, - 4.973266e-001, - 8.466897e-003, - 3.014455e+000, - 5.101163e-001, - -1.840141e+000, - -9.808119e-001, - 6.416855e-001, - 1.635225e-001, - -1.891191e-001, - 4.956113e-001, - 1.624685e-002, - 9.842522e-001, - 4.001240e-001, - -6.544802e-001, - 1.776027e-001, - -1.115127e-001, - -1.815564e-001, - -5.015203e-001, - 3.345275e-001, - -6.851344e-002, - 6.281235e+000, - 1.105559e+000, - -1.301369e+000, - -3.174570e-001, - 6.940684e-002, - -6.766562e-001, - -2.472675e-001, - 9.532933e-001, - 2.652804e-001, - 1.382351e+000, - 3.872409e-001, - -1.000531e+000, - -2.370102e-001, - 8.777148e-001, - 2.465815e+000, - -1.032874e+001, - 3.288488e-001, - 2.599159e-002, - 2.171819e+000, - 7.430662e-001, - -1.106629e+000, - -2.267646e-001, - 6.647827e-001, - 8.473269e-001, - -1.995761e+000, - 9.933816e-001, - 1.593503e-001, - 2.349060e+000, - 6.768979e-001, - // albedo 0, turbidity 5 - -1.451695e+000, - -5.853568e-001, - -2.498264e+000, - 2.828335e+000, - -1.021180e-001, - 4.463749e-001, - 1.084684e-002, - 2.835571e+000, - 5.003887e-001, - -1.883066e+000, - -1.028171e+000, - 1.581882e+000, - -1.304488e+000, - -2.563745e-001, - 5.796013e-001, - 4.006731e-002, - 1.172546e+000, - 4.705877e-001, - -8.036150e-001, - 1.421039e-002, - -1.224287e+000, - 3.345430e+000, - -7.822678e-002, - -8.034004e-002, - -1.981820e-001, - 5.281135e+000, - 1.054045e+000, - -1.107203e+000, - -1.301295e-001, - 4.868606e-001, - -4.658867e+000, - -8.327308e+000, - 1.360841e+000, - 4.849250e-001, - 2.170094e+000, - 3.667511e-001, - -1.113339e+000, - -3.526006e-001, - 5.749117e-001, - 9.771155e+000, - -1.239915e+000, - -3.274243e-001, - -1.014052e-001, - 1.580264e+000, - 7.824541e-001, - -1.071144e+000, - -2.129768e-001, - 6.020160e-001, - 1.069035e-003, - -3.513311e+000, - 1.059215e+000, - 1.897841e-001, - 2.314860e+000, - 6.921064e-001, - // albedo 0, turbidity 6 - -1.475550e+000, - -6.235784e-001, - -2.739219e+000, - 3.102316e+000, - -9.871396e-002, - 4.894712e-001, - 1.512045e-003, - 2.716438e+000, - 5.202016e-001, - -2.100286e+000, - -1.174158e+000, - 1.810953e+000, - -1.623774e+000, - -2.261133e-001, - 5.442875e-001, - 4.655874e-002, - 1.098479e+000, - 3.540358e-001, - -5.874487e-001, - 1.046816e-001, - -1.318062e+000, - 3.853206e+000, - -1.574024e-001, - -7.611052e-002, - -2.255800e-001, - 5.023688e+000, - 1.139217e+000, - -1.255342e+000, - -1.702924e-001, - 1.930147e-001, - -6.472261e+000, - -7.280723e+000, - 1.320492e+000, - 5.794775e-001, - 2.703602e+000, - 3.045391e-001, - -1.036406e+000, - -3.366023e-001, - 6.357367e-001, - 1.135332e+001, - -8.266441e-001, - -5.135191e-001, - -1.539050e-001, - 1.191031e+000, - 8.387967e-001, - -1.102701e+000, - -2.398535e-001, - 4.559688e-001, - -2.013559e-003, - -3.550343e+000, - 1.051510e+000, - 2.182405e-001, - 2.311132e+000, - 6.821927e-001, - // albedo 0, turbidity 7 - -1.547031e+000, - -6.877917e-001, - -3.473587e+000, - 3.780188e+000, - -7.225087e-002, - 4.498234e-001, - -9.858722e-007, - 2.658526e+000, - 5.167507e-001, - -2.064595e+000, - -1.170986e+000, - 2.388138e+000, - -2.247533e+000, - -1.622052e-001, - 5.117292e-001, - 5.911014e-002, - 1.131937e+000, - 3.718462e-001, - -9.685079e-001, - -2.158542e-001, - -1.719697e+000, - 3.990801e+000, - -7.427683e-002, - 2.332378e-001, - -2.661236e-001, - 4.625093e+000, - 1.104653e+000, - -8.970945e-001, - 8.323946e-002, - 3.367617e-001, - -6.209571e+000, - -6.061473e+000, - 6.627023e-001, - 6.095066e-001, - 2.260073e+000, - 3.429540e-001, - -1.198498e+000, - -4.510515e-001, - 4.388823e-001, - 1.113762e+001, - -1.660976e+000, - -9.334453e-002, - -1.097612e-001, - 1.301591e+000, - 8.116829e-001, - -1.082711e+000, - -2.783680e-001, - 4.468370e-001, - 6.363411e-001, - -2.892323e+000, - 5.460732e-001, - 2.027693e-001, - 1.745605e+000, - 6.915067e-001, - // albedo 0, turbidity 8 - -1.698899e+000, - -8.367919e-001, - -4.302314e+000, - 4.563539e+000, - -4.785560e-002, - 4.111800e-001, - -1.874868e-006, - 2.392578e+000, - 5.671278e-001, - -2.186667e+000, - -1.203216e+000, - 3.101762e+000, - -3.003775e+000, - -1.159056e-001, - 3.095751e-001, - 6.628745e-002, - 1.421465e+000, - 2.244936e-001, - -1.432555e+000, - -7.167314e-001, - -2.167274e+000, - 4.075338e+000, - 6.408773e-002, - 8.131324e-001, - -2.893191e-001, - 3.927968e+000, - 1.227801e+000, - -5.759409e-001, - 3.350147e-001, - 5.792035e-001, - -6.077718e+000, - -5.495646e+000, - -3.000352e-001, - 6.441570e-001, - 1.466788e+000, - 2.406916e-001, - -1.311503e+000, - -5.925982e-001, - 3.307142e-001, - 1.089626e+001, - -1.249587e+000, - 5.174552e-001, - -1.492856e-001, - 9.061259e-001, - 8.814459e-001, - -1.089719e+000, - -3.246084e-001, - 3.677823e-001, - 1.541657e+000, - -3.032948e+000, - 4.760454e-002, - 2.299367e-001, - 1.476567e+000, - 6.684034e-001, - // albedo 0, turbidity 9 - -2.103618e+000, - -1.132994e+000, - -4.590875e+000, - 4.750566e+000, - -3.515167e-002, - 3.942989e-001, - -2.898367e-006, - 2.183169e+000, - 6.470920e-001, - -1.636508e+000, - -8.262485e-001, - 3.365690e+000, - -3.097147e+000, - -1.333573e-001, - 2.142492e-001, - 4.660433e-002, - 1.930268e+000, - 6.372777e-002, - -3.513446e+000, - -2.169842e+000, - -2.453532e+000, - 3.012257e+000, - 2.293273e-001, - 8.800788e-001, - -2.045822e-001, - 2.988254e+000, - 1.334491e+000, - 6.299066e-001, - 9.712599e-001, - 9.122987e-001, - -4.113695e+000, - -5.133434e+000, - -2.746053e-001, - 4.512841e-001, - 7.482225e-001, - 2.176656e-001, - -1.729124e+000, - -8.961104e-001, - 1.416097e-001, - 1.156449e+001, - -1.713114e+000, - 9.200428e-002, - -4.258075e-002, - 5.910965e-001, - 8.549823e-001, - -1.002796e+000, - -3.188077e-001, - 3.083129e-001, - 6.623051e-001, - -2.560582e+000, - 2.459886e-001, - 2.127178e-001, - 1.224087e+000, - 6.830473e-001, - // albedo 0, turbidity 10 - -2.774006e+000, - -1.579782e+000, - -3.983600e+000, - 4.085097e+000, - -3.032315e-002, - 3.048476e-001, - -4.148488e-006, - 1.965812e+000, - 7.195398e-001, - -1.133820e+000, - -7.717168e-001, - 2.805407e+000, - -2.464148e+000, - -1.506218e-001, - 1.790959e-001, - 4.858177e-002, - 1.824955e+000, - -3.404481e-002, - -6.492776e+000, - -3.311990e+000, - -2.236767e+000, - 1.846738e+000, - 3.120065e-001, - 6.711671e-001, - -1.968289e-001, - 3.151885e+000, - 1.340389e+000, - 1.261591e+000, - 6.328827e-001, - 6.625715e-001, - -2.573150e+000, - -4.327788e+000, - 2.392943e-001, - 4.142411e-001, - 1.626791e-001, - 2.558303e-001, - -1.635953e+000, - -8.632853e-001, - 3.638306e-001, - 1.178910e+001, - -2.213853e+000, - -5.985963e-001, - -1.411031e-001, - -4.697450e-002, - 8.275285e-001, - -1.036112e+000, - -3.064725e-001, - 6.676653e-002, - -2.658343e-003, - -2.226863e+000, - 6.336803e-001, - 3.174833e-001, - 1.300817e+000, - 6.757297e-001, - // albedo 1, turbidity 1 - -1.278934e+000, - -4.266107e-001, - -1.235449e+001, - 1.301378e+001, - -2.286229e-002, - 5.011387e-001, - 1.252610e-002, - 2.717347e+000, - 4.999421e-001, - -1.453838e+000, - -5.905132e-001, - 3.010002e+000, - -2.045614e+000, - -5.107792e-002, - 3.025847e-001, - 2.930079e-002, - 1.721588e+000, - 4.997147e-001, - -1.020968e+000, - -1.655083e-001, - 2.393053e-001, - -7.842962e-001, - -1.093614e-001, - 7.482797e-001, - -4.499164e-002, - 5.672841e+000, - 5.092278e-001, - -1.157174e+000, - -3.644371e-001, - 1.765101e+000, - 8.851871e-001, - -4.206434e-001, - 8.388970e-001, - 7.564143e-002, - -3.961135e+000, - 4.268443e-001, - -1.002681e+000, - -7.845491e-002, - 8.361537e-001, - -4.692559e-001, - -5.310315e-001, - 4.461649e-001, - -6.564163e-002, - 6.116065e+000, - 7.999559e-001, - -1.078227e+000, - -1.728760e-001, - 1.200918e+000, - 1.804492e-001, - -5.003140e+000, - 5.363958e-001, - 7.966617e-002, - 3.047472e+000, - 4.999439e-001, - // albedo 1, turbidity 2 - -1.315307e+000, - -4.637043e-001, - -8.460782e+000, - 9.039007e+000, - -2.854979e-002, - 4.312812e-001, - 1.962972e-002, - 2.633290e+000, - 5.353702e-001, - -1.479455e+000, - -6.406754e-001, - 1.726747e+000, - -5.285200e-001, - -7.870318e-002, - 5.230240e-001, - -4.621225e-003, - 1.380045e+000, - 3.265295e-001, - -9.582427e-001, - -6.316786e-002, - 4.850994e-001, - -1.439690e+000, - -1.342330e-001, - 2.835928e-001, - 8.701807e-003, - 6.390283e+000, - 1.026493e+000, - -1.165746e+000, - -3.814278e-001, - 1.422304e+000, - 1.154808e+000, - -6.366475e-001, - 1.159796e+000, - 7.795290e-002, - -3.713275e+000, - 3.796947e-001, - -1.014936e+000, - -8.039227e-002, - 8.741110e-001, - -5.380748e-001, - -2.829132e-001, - 3.008224e-001, - -5.677102e-002, - 6.161057e+000, - 8.319051e-001, - -1.071826e+000, - -1.735548e-001, - 1.149064e+000, - 1.867569e-001, - -5.002087e+000, - 3.926498e-001, - 1.190023e-001, - 2.923191e+000, - 5.123194e-001, - // albedo 1, turbidity 3 - -1.325328e+000, - -4.754775e-001, - -6.030560e+000, - 6.613063e+000, - -4.269386e-002, - 4.715374e-001, - 7.358240e-003, - 2.657615e+000, - 5.593666e-001, - -1.624180e+000, - -8.094649e-001, - 1.735206e+000, - -6.343355e-001, - -9.197103e-002, - 3.486869e-001, - 4.423550e-002, - 7.200739e-001, - 2.047150e-001, - -7.256930e-001, - 1.644973e-001, - -1.514868e-001, - -8.475176e-001, - -2.033383e-001, - 5.118070e-001, - -1.001742e-001, - 6.856190e+000, - 1.437906e+000, - -1.326390e+000, - -4.608617e-001, - 1.225254e+000, - 1.574815e+000, - -4.162977e-001, - 9.049236e-001, - 2.449473e-001, - -1.919735e+000, - -3.623446e-002, - -9.472798e-001, - -8.325384e-002, - 1.014683e+000, - -2.622519e+000, - -3.422335e+000, - 1.797932e-001, - -9.031335e-002, - 4.504420e+000, - 1.093961e+000, - -1.097737e+000, - -1.963290e-001, - 1.161926e+000, - 3.934307e+000, - -5.006855e+000, - 5.610052e-001, - 9.326543e-002, - 2.582889e+000, - 4.999522e-001, - // albedo 1, turbidity 4 - -1.355405e+000, - -5.136983e-001, - -3.702103e+000, - 4.227707e+000, - -5.697320e-002, - 3.973961e-001, - 1.259334e-002, - 2.530478e+000, - 5.263474e-001, - -1.746851e+000, - -9.649533e-001, - 8.702134e-001, - 3.591285e-001, - -1.363910e-001, - 5.205780e-001, - 2.734811e-002, - 2.767819e-001, - 3.181624e-001, - -6.762497e-001, - 2.385826e-001, - 7.976268e-002, - -1.129624e+000, - -2.516586e-001, - 2.778869e-001, - -1.092787e-001, - 6.853386e+000, - 1.277624e+000, - -1.307943e+000, - -4.480330e-001, - 5.995796e-001, - 1.612401e+000, - -6.924595e-001, - 8.015640e-001, - 3.344989e-001, - -9.589034e-001, - 1.453526e-001, - -9.700917e-001, - -1.197321e-001, - 1.241096e+000, - -2.502490e+000, - -3.753413e+000, - 1.769959e-001, - -8.447797e-002, - 3.447177e+000, - 9.516305e-001, - -1.091235e+000, - -1.919335e-001, - 9.970199e-001, - 3.549449e+000, - -4.306689e+000, - 4.962728e-001, - 1.238430e-001, - 2.758578e+000, - 6.013159e-001, - // albedo 1, turbidity 5 - -1.392447e+000, - -5.579332e-001, - -2.567321e+000, - 3.088258e+000, - -8.579040e-002, - 4.621026e-001, - 4.565959e-003, - 2.445922e+000, - 5.565956e-001, - -1.956557e+000, - -1.134455e+000, - 1.416415e+000, - -4.109731e-001, - -1.999037e-001, - 3.035066e-001, - 5.289490e-002, - 2.444984e-001, - 2.199443e-001, - -5.536306e-001, - 2.669274e-001, - -6.183169e-001, - 1.745223e-001, - -1.311617e-001, - 5.290580e-001, - -1.792890e-001, - 6.114569e+000, - 1.378717e+000, - -1.376163e+000, - -4.446270e-001, - 5.943493e-001, - 1.222020e+000, - -2.809079e+000, - 4.104369e-001, - 4.456987e-001, - -2.749475e-001, - 6.876941e-002, - -9.221449e-001, - -1.189414e-001, - 1.193682e+000, - -3.876951e+000, - -3.618624e+000, - 2.508265e-001, - -7.996779e-002, - 3.060098e+000, - 1.001817e+000, - -1.124365e+000, - -2.449169e-001, - 1.067130e+000, - 7.941036e+000, - -4.040194e+000, - 3.627627e-001, - 9.585876e-002, - 1.793268e+000, - 5.802275e-001, - // albedo 1, turbidity 6 - -1.416356e+000, - -5.884181e-001, - -2.434923e+000, - 2.989620e+000, - -9.143356e-002, - 4.306519e-001, - -6.626430e-007, - 2.370120e+000, - 5.543846e-001, - -2.036822e+000, - -1.235608e+000, - 2.235972e+000, - -1.594146e+000, - -2.250287e-001, - 4.041790e-001, - 6.020190e-002, - 1.324026e-001, - 2.311588e-001, - -6.100902e-001, - 2.187419e-001, - -1.458361e+000, - 3.029719e+000, - 8.679713e-002, - 2.147092e-001, - -2.294104e-001, - 5.602675e+000, - 1.338276e+000, - -1.245646e+000, - -3.217976e-001, - 8.337516e-001, - -4.097808e+000, - -7.336715e+000, - 7.497411e-001, - 5.383807e-001, - 7.421823e-001, - 1.409221e-001, - -1.020851e+000, - -2.276978e-001, - 1.089822e+000, - 7.262143e+000, - -1.712580e+000, - -2.187467e-001, - -1.665151e-001, - 1.999861e+000, - 9.036180e-001, - -1.082805e+000, - -2.009170e-001, - 9.834561e-001, - 1.962586e+000, - -3.968345e+000, - 5.620788e-001, - 1.501137e-001, - 2.293511e+000, - 6.539755e-001, - // albedo 1, turbidity 7 - -1.455097e+000, - -6.377708e-001, - -3.056790e+000, - 3.531290e+000, - -6.726070e-002, - 4.008309e-001, - -7.720256e-007, - 2.336308e+000, - 5.628152e-001, - -2.233654e+000, - -1.384154e+000, - 2.850003e+000, - -2.395164e+000, - -1.519300e-001, - 3.482269e-001, - 6.872621e-002, - 1.501730e-001, - 2.173574e-001, - -5.769213e-001, - 1.376470e-001, - -1.834490e+000, - 4.179173e+000, - 8.998180e-002, - 5.029472e-001, - -2.794634e-001, - 4.935213e+000, - 1.315894e+000, - -1.254086e+000, - -2.557369e-001, - 8.003818e-001, - -6.221100e+000, - -7.022007e+000, - 2.179719e-001, - 6.137258e-001, - 9.926229e-001, - 1.832485e-001, - -9.955460e-001, - -2.588225e-001, - 1.038675e+000, - 1.121541e+001, - -1.790333e+000, - 2.385889e-002, - -1.909201e-001, - 1.672978e+000, - 8.630985e-001, - -1.110471e+000, - -2.589342e-001, - 1.046373e+000, - 1.105839e+000, - -3.835543e+000, - 3.726309e-001, - 1.505174e-001, - 1.451357e+000, - 6.730513e-001, - // albedo 1, turbidity 8 - -1.635744e+000, - -8.131883e-001, - -4.173952e+000, - 4.643640e+000, - -4.347971e-002, - 3.723717e-001, - -2.050838e-006, - 2.010619e+000, - 5.933561e-001, - -2.214302e+000, - -1.311257e+000, - 3.795249e+000, - -3.352616e+000, - -1.225978e-001, - 3.357912e-001, - 5.780200e-002, - 7.000075e-001, - 1.532865e-001, - -1.240030e+000, - -5.251359e-001, - -2.462401e+000, - 4.199373e+000, - 2.198326e-001, - 5.820900e-001, - -2.528969e-001, - 3.969682e+000, - 1.323585e+000, - -7.335051e-001, - 1.348211e-001, - 1.117508e+000, - -5.736812e+000, - -5.947695e+000, - 5.484914e-003, - 5.667800e-001, - 4.203315e-001, - 1.901034e-001, - -1.218142e+000, - -4.652876e-001, - 8.454010e-001, - 1.094323e+001, - -1.555471e+000, - -6.514268e-004, - -1.486863e-001, - 1.215668e+000, - 8.730318e-001, - -1.060175e+000, - -2.649293e-001, - 1.050104e+000, - 3.755117e-001, - -3.691971e+000, - 3.635470e-001, - 1.517157e-001, - 1.040222e+000, - 6.741737e-001, - // albedo 1, turbidity 9 - -1.965171e+000, - -1.110977e+000, - -3.975371e+000, - 4.402380e+000, - -3.781046e-002, - 3.442826e-001, - -3.206313e-006, - 1.722681e+000, - 7.137791e-001, - -2.076631e+000, - -1.135266e+000, - 3.495989e+000, - -2.951976e+000, - -1.431175e-001, - 2.313894e-001, - 4.838592e-002, - 1.154473e+000, - -5.960279e-002, - -2.741027e+000, - -1.710606e+000, - -2.098317e+000, - 2.856980e+000, - 3.092012e-001, - 7.699211e-001, - -2.114227e-001, - 3.077816e+000, - 1.467774e+000, - 8.957317e-002, - 5.539637e-001, - 8.640813e-001, - -3.998637e+000, - -5.613935e+000, - -2.914646e-001, - 4.722521e-001, - -1.125185e-001, - 1.188316e-001, - -1.420326e+000, - -6.360910e-001, - 9.080250e-001, - 1.138477e+001, - -1.566010e+000, - 9.528291e-002, - -1.176358e-001, - 5.778964e-001, - 8.949048e-001, - -1.046287e+000, - -3.098941e-001, - 9.483681e-001, - 5.415214e-001, - -3.375804e+000, - 1.960618e-001, - 1.620471e-001, - 7.370266e-001, - 6.676636e-001, - // albedo 1, turbidity 10 - -2.805422e+000, - -1.616587e+000, - -4.192218e+000, - 4.466438e+000, - -2.546462e-002, - 3.308681e-001, - -4.461434e-006, - 1.619262e+000, - 7.556575e-001, - -1.725173e+000, - -1.156569e+000, - 3.580993e+000, - -2.892076e+000, - -1.189607e-001, - 1.286486e-001, - 4.079482e-002, - 1.063847e+000, - -6.582657e-002, - -5.636612e+000, - -2.816844e+000, - -2.322376e+000, - 2.161365e+000, - 2.108298e-001, - 6.220582e-001, - -1.804825e-001, - 3.007238e+000, - 1.307987e+000, - 9.476952e-001, - 1.996303e-001, - 6.847905e-001, - -2.704996e+000, - -3.436784e+000, - 2.883236e-001, - 4.180512e-001, - 1.200158e-001, - 3.259385e-001, - -1.433266e+000, - -6.003231e-001, - 1.164057e+000, - 1.018945e+001, - -2.896672e+000, - -6.514654e-001, - -1.962561e-001, - -1.267212e+000, - 7.789219e-001, - -1.009612e+000, - -1.798906e-001, - 4.963464e-001, - -2.286995e-003, - -2.469826e+000, - 6.499727e-001, - 3.226465e-001, - 1.912468e+000, - 6.786669e-001, -}; - -double datasetXYZRad3[] = -{ - // albedo 0, turbidity 1 - 6.748228e-003, - 1.245822e-002, - -2.299497e-002, - 1.149254e-001, - 7.674022e-002, - 8.293835e-002, - // albedo 0, turbidity 2 - 6.664536e-003, - 1.290106e-002, - -2.480392e-002, - 1.180803e-001, - 7.712743e-002, - 8.403643e-002, - // albedo 0, turbidity 3 - 6.559916e-003, - 1.325689e-002, - -2.649347e-002, - 1.207550e-001, - 7.786707e-002, - 8.478919e-002, - // albedo 0, turbidity 4 - 6.499438e-003, - 1.353255e-002, - -2.801609e-002, - 1.225208e-001, - 8.205891e-002, - 8.470021e-002, - // albedo 0, turbidity 5 - 6.397692e-003, - 1.376565e-002, - -2.953498e-002, - 1.240835e-001, - 8.626065e-002, - 8.439770e-002, - // albedo 0, turbidity 6 - 6.247701e-003, - 1.446960e-002, - -3.269905e-002, - 1.281632e-001, - 8.995242e-002, - 8.634051e-002, - // albedo 0, turbidity 7 - 6.090256e-003, - 1.497959e-002, - -3.532743e-002, - 1.310822e-001, - 9.449566e-002, - 8.775524e-002, - // albedo 0, turbidity 8 - 5.965851e-003, - 1.535956e-002, - -3.712273e-002, - 1.319752e-001, - 1.002717e-001, - 8.924543e-002, - // albedo 0, turbidity 9 - 5.817304e-003, - 1.562969e-002, - -3.870089e-002, - 1.324030e-001, - 1.059721e-001, - 9.073928e-002, - // albedo 0, turbidity 10 - 5.747920e-003, - 1.576308e-002, - -3.904300e-002, - 1.306544e-001, - 1.121448e-001, - 9.062238e-002, - // albedo 1, turbidity 1 - 7.815700e-003, - 1.183664e-002, - -1.186281e-002, - 8.121980e-002, - 1.759349e-001, - 1.758821e-001, - // albedo 1, turbidity 2 - 7.761406e-003, - 1.209518e-002, - -1.309164e-002, - 8.320275e-002, - 1.771012e-001, - 1.766797e-001, - // albedo 1, turbidity 3 - 7.686516e-003, - 1.228515e-002, - -1.424823e-002, - 8.478350e-002, - 1.785574e-001, - 1.773424e-001, - // albedo 1, turbidity 4 - 7.573618e-003, - 1.252190e-002, - -1.545068e-002, - 8.569616e-002, - 1.826553e-001, - 1.776316e-001, - // albedo 1, turbidity 5 - 7.431437e-003, - 1.271230e-002, - -1.662223e-002, - 8.623589e-002, - 1.869661e-001, - 1.777765e-001, - // albedo 1, turbidity 6 - 7.296445e-003, - 1.303427e-002, - -1.829775e-002, - 8.679538e-002, - 1.934616e-001, - 1.781220e-001, - // albedo 1, turbidity 7 - 7.131506e-003, - 1.322757e-002, - -1.966949e-002, - 8.662494e-002, - 2.003751e-001, - 1.782167e-001, - // albedo 1, turbidity 8 - 6.985675e-003, - 1.329179e-002, - -2.001190e-002, - 8.388650e-002, - 2.091531e-001, - 1.777761e-001, - // albedo 1, turbidity 9 - 6.809328e-003, - 1.332258e-002, - -2.050411e-002, - 8.151631e-002, - 2.168861e-001, - 1.779214e-001, - // albedo 1, turbidity 10 - 6.742967e-003, - 1.344217e-002, - -2.111739e-002, - 8.050785e-002, - 2.209232e-001, - 1.786115e-001, -}; - -double* datasetsXYZ[] = -{ - datasetXYZ1, - datasetXYZ2, - datasetXYZ3 -}; - -double* datasetsXYZRad[] = -{ - datasetXYZRad1, - datasetXYZRad2, - datasetXYZRad3 -}; \ No newline at end of file diff --git a/extern/skylight/README.txt b/extern/skylight/README.txt deleted file mode 100644 index 7ccf9ff1..00000000 --- a/extern/skylight/README.txt +++ /dev/null @@ -1,33 +0,0 @@ -The files in this archive are a sample implementation of the analytical -skylight model presented in the SIGGRAPH 2012 paper - - - "An Analytic Model for Full Spectral Sky-Dome Radiance" - - by - - Lukas Hosek and Alexander Wilkie - Charles University in Prague, Czech Republic - - - Version: 1.0, May 11th, 2012 - - -Please visit http://cgg.mff.cuni.cz/projects/SkylightModelling/ to check if -an updated version of this code has been published! - - -This archive contains the following files: - -README.txt This file. - -ArHosekSkyModel.h Header file for the reference functions. Their - usage is explained there, and sample code for - calling them is given. - -ArHosekSkyModel.c Implementation of the functions. - -ArHosekSkyModelData.h Coefficient data. - -Please note that the source files are in C99, so that when e.g. compiling this -code with gcc, you have to add the "-std=c99" or "-std=gnu99" flags. \ No newline at end of file diff --git a/extern/stb/stb_dxt.h b/extern/stb/stb_dxt.h index bec72798..04bd6392 100644 --- a/extern/stb/stb_dxt.h +++ b/extern/stb/stb_dxt.h @@ -1,624 +1,777 @@ -// stb_dxt.h - v1.04 - DXT1/DXT5 compressor - public domain -// original by fabian "ryg" giesen - ported to C by stb -// use '#define STB_DXT_IMPLEMENTATION' before including to create the implementation -// -// USAGE: -// call stb_compress_dxt_block() for every block (you must pad) -// source should be a 4x4 block of RGBA data in row-major order; -// A is ignored if you specify alpha=0; you can turn on dithering -// and "high quality" using mode. -// -// version history: -// v1.04 - (ryg) default to no rounding bias for lerped colors (as per S3TC/DX10 spec); -// single color match fix (allow for inexact color interpolation); -// optimal DXT5 index finder; "high quality" mode that runs multiple refinement steps. -// v1.03 - (stb) endianness support -// v1.02 - (stb) fix alpha encoding bug -// v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom -// v1.00 - (stb) first release - -#ifndef STB_INCLUDE_STB_DXT_H -#define STB_INCLUDE_STB_DXT_H - -// compression mode (bitflags) -#define STB_DXT_NORMAL 0 -#define STB_DXT_DITHER 1 // use dithering. dubious win. never use for normal maps and the like! -#define STB_DXT_HIGHQUAL 2 // high quality mode, does two refinement steps instead of 1. ~30-40% slower. - -void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int alpha, int mode); -#define STB_COMPRESS_DXT_BLOCK - -#ifdef STB_DXT_IMPLEMENTATION - -// configuration options for DXT encoder. set them in the project/makefile or just define -// them at the top. - -// STB_DXT_USE_ROUNDING_BIAS -// use a rounding bias during color interpolation. this is closer to what "ideal" -// interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03) -// implicitly had this turned on. -// -// in case you're targeting a specific type of hardware (e.g. console programmers): -// NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer -// to STB_DXT_USE_ROUNDING_BIAS. AMD/ATI, S3 and DX10 ref are closer to rounding with no bias. -// you also see "(a*5 + b*3) / 8" on some old GPU designs. -// #define STB_DXT_USE_ROUNDING_BIAS - -#include -#include -#include // memset - -static unsigned char stb__Expand5[32]; -static unsigned char stb__Expand6[64]; -static unsigned char stb__OMatch5[256][2]; -static unsigned char stb__OMatch6[256][2]; -static unsigned char stb__QuantRBTab[256+16]; -static unsigned char stb__QuantGTab[256+16]; - -static int stb__Mul8Bit(int a, int b) -{ - int t = a*b + 128; - return (t + (t >> 8)) >> 8; -} - -static void stb__From16Bit(unsigned char *out, unsigned short v) -{ - int rv = (v & 0xf800) >> 11; - int gv = (v & 0x07e0) >> 5; - int bv = (v & 0x001f) >> 0; - - out[0] = stb__Expand5[rv]; - out[1] = stb__Expand6[gv]; - out[2] = stb__Expand5[bv]; - out[3] = 0; -} - -static unsigned short stb__As16Bit(int r, int g, int b) -{ - return (stb__Mul8Bit(r,31) << 11) + (stb__Mul8Bit(g,63) << 5) + stb__Mul8Bit(b,31); -} - -// linear interpolation at 1/3 point between a and b, using desired rounding type -static int stb__Lerp13(int a, int b) -{ -#ifdef STB_DXT_USE_ROUNDING_BIAS - // with rounding bias - return a + stb__Mul8Bit(b-a, 0x55); -#else - // without rounding bias - // replace "/ 3" by "* 0xaaab) >> 17" if your compiler sucks or you really need every ounce of speed. - return (2*a + b) / 3; -#endif -} - -// lerp RGB color -static void stb__Lerp13RGB(unsigned char *out, unsigned char *p1, unsigned char *p2) -{ - out[0] = stb__Lerp13(p1[0], p2[0]); - out[1] = stb__Lerp13(p1[1], p2[1]); - out[2] = stb__Lerp13(p1[2], p2[2]); -} - -/****************************************************************************/ - -// compute table to reproduce constant colors as accurately as possible -static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expand,int size) -{ - int i,mn,mx; - for (i=0;i<256;i++) { - int bestErr = 256; - for (mn=0;mn> 4)]; - ep1[0] = bp[ 0] - dp[ 0]; - dp[ 4] = quant[bp[ 4] + ((7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]) >> 4)]; - ep1[1] = bp[ 4] - dp[ 4]; - dp[ 8] = quant[bp[ 8] + ((7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]) >> 4)]; - ep1[2] = bp[ 8] - dp[ 8]; - dp[12] = quant[bp[12] + ((7*ep1[2] + 5*ep2[3] + ep2[2]) >> 4)]; - ep1[3] = bp[12] - dp[12]; - bp += 16; - dp += 16; - et = ep1, ep1 = ep2, ep2 = et; // swap - } - } -} - -// The color matching function -static unsigned int stb__MatchColorsBlock(unsigned char *block, unsigned char *color,int dither) -{ - unsigned int mask = 0; - int dirr = color[0*4+0] - color[1*4+0]; - int dirg = color[0*4+1] - color[1*4+1]; - int dirb = color[0*4+2] - color[1*4+2]; - int dots[16]; - int stops[4]; - int i; - int c0Point, halfPoint, c3Point; - - for(i=0;i<16;i++) - dots[i] = block[i*4+0]*dirr + block[i*4+1]*dirg + block[i*4+2]*dirb; - - for(i=0;i<4;i++) - stops[i] = color[i*4+0]*dirr + color[i*4+1]*dirg + color[i*4+2]*dirb; - - // think of the colors as arranged on a line; project point onto that line, then choose - // next color out of available ones. we compute the crossover points for "best color in top - // half"/"best in bottom half" and then the same inside that subinterval. - // - // relying on this 1d approximation isn't always optimal in terms of euclidean distance, - // but it's very close and a lot faster. - // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html - - c0Point = (stops[1] + stops[3]) >> 1; - halfPoint = (stops[3] + stops[2]) >> 1; - c3Point = (stops[2] + stops[0]) >> 1; - - if(!dither) { - // the version without dithering is straightforward - for (i=15;i>=0;i--) { - int dot = dots[i]; - mask <<= 2; - - if(dot < halfPoint) - mask |= (dot < c0Point) ? 1 : 3; - else - mask |= (dot < c3Point) ? 2 : 0; - } - } else { - // with floyd-steinberg dithering - int err[8],*ep1 = err,*ep2 = err+4; - int *dp = dots, y; - - c0Point <<= 4; - halfPoint <<= 4; - c3Point <<= 4; - for(i=0;i<8;i++) - err[i] = 0; - - for(y=0;y<4;y++) - { - int dot,lmask,step; - - dot = (dp[0] << 4) + (3*ep2[1] + 5*ep2[0]); - if(dot < halfPoint) - step = (dot < c0Point) ? 1 : 3; - else - step = (dot < c3Point) ? 2 : 0; - ep1[0] = dp[0] - stops[step]; - lmask = step; - - dot = (dp[1] << 4) + (7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]); - if(dot < halfPoint) - step = (dot < c0Point) ? 1 : 3; - else - step = (dot < c3Point) ? 2 : 0; - ep1[1] = dp[1] - stops[step]; - lmask |= step<<2; - - dot = (dp[2] << 4) + (7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]); - if(dot < halfPoint) - step = (dot < c0Point) ? 1 : 3; - else - step = (dot < c3Point) ? 2 : 0; - ep1[2] = dp[2] - stops[step]; - lmask |= step<<4; - - dot = (dp[3] << 4) + (7*ep1[2] + 5*ep2[3] + ep2[2]); - if(dot < halfPoint) - step = (dot < c0Point) ? 1 : 3; - else - step = (dot < c3Point) ? 2 : 0; - ep1[3] = dp[3] - stops[step]; - lmask |= step<<6; - - dp += 4; - mask |= lmask << (y*8); - { int *et = ep1; ep1 = ep2; ep2 = et; } // swap - } - } - - return mask; -} - -// The color optimization function. (Clever code, part 1) -static void stb__OptimizeColorsBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16) -{ - int mind = 0x7fffffff,maxd = -0x7fffffff; - unsigned char *minp, *maxp; - double magn; - int v_r,v_g,v_b; - static const int nIterPower = 4; - float covf[6],vfr,vfg,vfb; - - // determine color distribution - int cov[6]; - int mu[3],min[3],max[3]; - int ch,i,iter; - - for(ch=0;ch<3;ch++) - { - const unsigned char *bp = ((const unsigned char *) block) + ch; - int muv,minv,maxv; - - muv = minv = maxv = bp[0]; - for(i=4;i<64;i+=4) - { - muv += bp[i]; - if (bp[i] < minv) minv = bp[i]; - else if (bp[i] > maxv) maxv = bp[i]; - } - - mu[ch] = (muv + 8) >> 4; - min[ch] = minv; - max[ch] = maxv; - } - - // determine covariance matrix - for (i=0;i<6;i++) - cov[i] = 0; - - for (i=0;i<16;i++) - { - int r = block[i*4+0] - mu[0]; - int g = block[i*4+1] - mu[1]; - int b = block[i*4+2] - mu[2]; - - cov[0] += r*r; - cov[1] += r*g; - cov[2] += r*b; - cov[3] += g*g; - cov[4] += g*b; - cov[5] += b*b; - } - - // convert covariance matrix to float, find principal axis via power iter - for(i=0;i<6;i++) - covf[i] = cov[i] / 255.0f; - - vfr = (float) (max[0] - min[0]); - vfg = (float) (max[1] - min[1]); - vfb = (float) (max[2] - min[2]); - - for(iter=0;iter magn) magn = fabs(vfg); - if (fabs(vfb) > magn) magn = fabs(vfb); - - if(magn < 4.0f) { // too small, default to luminance - v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000. - v_g = 587; - v_b = 114; - } else { - magn = 512.0 / magn; - v_r = (int) (vfr * magn); - v_g = (int) (vfg * magn); - v_b = (int) (vfb * magn); - } - - // Pick colors at extreme points - for(i=0;i<16;i++) - { - int dot = block[i*4+0]*v_r + block[i*4+1]*v_g + block[i*4+2]*v_b; - - if (dot < mind) { - mind = dot; - minp = block+i*4; - } - - if (dot > maxd) { - maxd = dot; - maxp = block+i*4; - } - } - - *pmax16 = stb__As16Bit(maxp[0],maxp[1],maxp[2]); - *pmin16 = stb__As16Bit(minp[0],minp[1],minp[2]); -} - -static int stb__sclamp(float y, int p0, int p1) -{ - int x = (int) y; - if (x < p0) return p0; - if (x > p1) return p1; - return x; -} - -// The refinement function. (Clever code, part 2) -// Tries to optimize colors to suit block contents better. -// (By solving a least squares system via normal equations+Cramer's rule) -static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16, unsigned int mask) -{ - static const int w1Tab[4] = { 3,0,2,1 }; - static const int prods[4] = { 0x090000,0x000900,0x040102,0x010402 }; - // ^some magic to save a lot of multiplies in the accumulating loop... - // (precomputed products of weights for least squares system, accumulated inside one 32-bit register) - - float frb,fg; - unsigned short oldMin, oldMax, min16, max16; - int i, akku = 0, xx,xy,yy; - int At1_r,At1_g,At1_b; - int At2_r,At2_g,At2_b; - unsigned int cm = mask; - - oldMin = *pmin16; - oldMax = *pmax16; - - if((mask ^ (mask<<2)) < 4) // all pixels have the same index? - { - // yes, linear system would be singular; solve using optimal - // single-color match on average color - int r = 8, g = 8, b = 8; - for (i=0;i<16;++i) { - r += block[i*4+0]; - g += block[i*4+1]; - b += block[i*4+2]; - } - - r >>= 4; g >>= 4; b >>= 4; - - max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0]; - min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1]; - } else { - At1_r = At1_g = At1_b = 0; - At2_r = At2_g = At2_b = 0; - for (i=0;i<16;++i,cm>>=2) { - int step = cm&3; - int w1 = w1Tab[step]; - int r = block[i*4+0]; - int g = block[i*4+1]; - int b = block[i*4+2]; - - akku += prods[step]; - At1_r += w1*r; - At1_g += w1*g; - At1_b += w1*b; - At2_r += r; - At2_g += g; - At2_b += b; - } - - At2_r = 3*At2_r - At1_r; - At2_g = 3*At2_g - At1_g; - At2_b = 3*At2_b - At1_b; - - // extract solutions and decide solvability - xx = akku >> 16; - yy = (akku >> 8) & 0xff; - xy = (akku >> 0) & 0xff; - - frb = 3.0f * 31.0f / 255.0f / (xx*yy - xy*xy); - fg = frb * 63.0f / 31.0f; - - // solve. - max16 = stb__sclamp((At1_r*yy - At2_r*xy)*frb+0.5f,0,31) << 11; - max16 |= stb__sclamp((At1_g*yy - At2_g*xy)*fg +0.5f,0,63) << 5; - max16 |= stb__sclamp((At1_b*yy - At2_b*xy)*frb+0.5f,0,31) << 0; - - min16 = stb__sclamp((At2_r*xx - At1_r*xy)*frb+0.5f,0,31) << 11; - min16 |= stb__sclamp((At2_g*xx - At1_g*xy)*fg +0.5f,0,63) << 5; - min16 |= stb__sclamp((At2_b*xx - At1_b*xy)*frb+0.5f,0,31) << 0; - } - - *pmin16 = min16; - *pmax16 = max16; - return oldMin != min16 || oldMax != max16; -} - -// Color block compression -static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, int mode) -{ - unsigned int mask; - int i; - int dither; - int refinecount; - unsigned short max16, min16; - unsigned char dblock[16*4],color[4*4]; - - dither = mode & STB_DXT_DITHER; - refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1; - - // check if block is constant - for (i=1;i<16;i++) - if (((unsigned int *) block)[i] != ((unsigned int *) block)[0]) - break; - - if(i == 16) { // constant color - int r = block[0], g = block[1], b = block[2]; - mask = 0xaaaaaaaa; - max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0]; - min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1]; - } else { - // first step: compute dithered version for PCA if desired - if(dither) - stb__DitherBlock(dblock,block); - - // second step: pca+map along principal axis - stb__OptimizeColorsBlock(dither ? dblock : block,&max16,&min16); - if (max16 != min16) { - stb__EvalColors(color,max16,min16); - mask = stb__MatchColorsBlock(block,color,dither); - } else - mask = 0; - - // third step: refine (multiple times if requested) - for (i=0;i> 8); - dest[2] = (unsigned char) (min16); - dest[3] = (unsigned char) (min16 >> 8); - dest[4] = (unsigned char) (mask); - dest[5] = (unsigned char) (mask >> 8); - dest[6] = (unsigned char) (mask >> 16); - dest[7] = (unsigned char) (mask >> 24); -} - -// Alpha block compression (this is easy for a change) -static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src,int mode) -{ - int i,dist,bias,dist4,dist2,bits,mask; - - // find min/max color - int mn,mx; - mn = mx = src[3]; - - for (i=1;i<16;i++) - { - if (src[i*4+3] < mn) mn = src[i*4+3]; - else if (src[i*4+3] > mx) mx = src[i*4+3]; - } - - // encode them - ((unsigned char *)dest)[0] = mx; - ((unsigned char *)dest)[1] = mn; - dest += 2; - - // determine bias and emit color indices - // given the choice of mx/mn, these indices are optimal: - // http://fgiesen.wordpress.com/2009/12/15/dxt5-alpha-block-index-determination/ - dist = mx-mn; - dist4 = dist*4; - dist2 = dist*2; - bias = (dist < 8) ? (dist - 1) : (dist/2 + 2); - bias -= mn * 7; - bits = 0,mask=0; - - for (i=0;i<16;i++) { - int a = src[i*4+3]*7 + bias; - int ind,t; - - // select index. this is a "linear scale" lerp factor between 0 (val=min) and 7 (val=max). - t = (a >= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t; - t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t; - ind += (a >= dist); - - // turn linear scale into DXT index (0/1 are extremal pts) - ind = -ind & 7; - ind ^= (2 > ind); - - // write index - mask |= ind << bits; - if((bits += 3) >= 8) { - *dest++ = mask; - mask >>= 8; - bits -= 8; - } - } -} - -static void stb__InitDXT() -{ - int i; - for(i=0;i<32;i++) - stb__Expand5[i] = (i<<3)|(i>>2); - - for(i=0;i<64;i++) - stb__Expand6[i] = (i<<2)|(i>>4); - - for(i=0;i<256+16;i++) - { - int v = i-8 < 0 ? 0 : i-8 > 255 ? 255 : i-8; - stb__QuantRBTab[i] = stb__Expand5[stb__Mul8Bit(v,31)]; - stb__QuantGTab[i] = stb__Expand6[stb__Mul8Bit(v,63)]; - } - - stb__PrepareOptTable(&stb__OMatch5[0][0],stb__Expand5,32); - stb__PrepareOptTable(&stb__OMatch6[0][0],stb__Expand6,64); -} - -void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int alpha, int mode) -{ - static int init=1; - if (init) { - stb__InitDXT(); - init=0; - } - - if (alpha) { - stb__CompressAlphaBlock(dest,(unsigned char*) src,mode); - dest += 8; - } - - stb__CompressColorBlock(dest,(unsigned char*) src,mode); -} -#endif // STB_DXT_IMPLEMENTATION - -#endif // STB_INCLUDE_STB_DXT_H +// stb_dxt.h - v1.09 - DXT1/DXT5 compressor - public domain +// original by fabian "ryg" giesen - ported to C by stb +// use '#define STB_DXT_IMPLEMENTATION' before including to create the implementation +// +// USAGE: +// call stb_compress_dxt_block() for every block (you must pad) +// source should be a 4x4 block of RGBA data in row-major order; +// Alpha channel is not stored if you specify alpha=0 (but you +// must supply some constant alpha in the alpha channel). +// You can turn on dithering and "high quality" using mode. +// +// version history: +// v1.09 - (stb) update documentation re: surprising alpha channel requirement +// v1.08 - (stb) fix bug in dxt-with-alpha block +// v1.07 - (stb) bc4; allow not using libc; add STB_DXT_STATIC +// v1.06 - (stb) fix to known-broken 1.05 +// v1.05 - (stb) support bc5/3dc (Arvids Kokins), use extern "C" in C++ (Pavel Krajcevski) +// v1.04 - (ryg) default to no rounding bias for lerped colors (as per S3TC/DX10 spec); +// single color match fix (allow for inexact color interpolation); +// optimal DXT5 index finder; "high quality" mode that runs multiple refinement steps. +// v1.03 - (stb) endianness support +// v1.02 - (stb) fix alpha encoding bug +// v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom +// v1.00 - (stb) first release +// +// contributors: +// Kevin Schmidt (#defines for "freestanding" compilation) +// github:ppiastucki (BC4 support) +// +// LICENSE +// +// See end of file for license information. + +#ifndef STB_INCLUDE_STB_DXT_H +#define STB_INCLUDE_STB_DXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef STB_DXT_STATIC +#define STBDDEF static +#else +#define STBDDEF extern +#endif + +// compression mode (bitflags) +#define STB_DXT_NORMAL 0 +#define STB_DXT_DITHER 1 // use dithering. dubious win. never use for normal maps and the like! +#define STB_DXT_HIGHQUAL 2 // high quality mode, does two refinement steps instead of 1. ~30-40% slower. + +STBDDEF void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src_rgba_four_bytes_per_pixel, int alpha, int mode); +STBDDEF void stb_compress_bc4_block(unsigned char *dest, const unsigned char *src_r_one_byte_per_pixel); +STBDDEF void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two_byte_per_pixel); + +#define STB_COMPRESS_DXT_BLOCK + +#ifdef __cplusplus +} +#endif +#endif // STB_INCLUDE_STB_DXT_H + +#ifdef STB_DXT_IMPLEMENTATION + +// configuration options for DXT encoder. set them in the project/makefile or just define +// them at the top. + +// STB_DXT_USE_ROUNDING_BIAS +// use a rounding bias during color interpolation. this is closer to what "ideal" +// interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03) +// implicitly had this turned on. +// +// in case you're targeting a specific type of hardware (e.g. console programmers): +// NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer +// to STB_DXT_USE_ROUNDING_BIAS. AMD/ATI, S3 and DX10 ref are closer to rounding with no bias. +// you also see "(a*5 + b*3) / 8" on some old GPU designs. +// #define STB_DXT_USE_ROUNDING_BIAS + +#include + +#if !defined(STBD_ABS) || !defined(STBI_FABS) +#include +#endif + +#ifndef STBD_ABS +#define STBD_ABS(i) abs(i) +#endif + +#ifndef STBD_FABS +#define STBD_FABS(x) fabs(x) +#endif + +#ifndef STBD_MEMSET +#include +#define STBD_MEMSET memset +#endif + +static unsigned char stb__Expand5[32]; +static unsigned char stb__Expand6[64]; +static unsigned char stb__OMatch5[256][2]; +static unsigned char stb__OMatch6[256][2]; +static unsigned char stb__QuantRBTab[256+16]; +static unsigned char stb__QuantGTab[256+16]; + +static int stb__Mul8Bit(int a, int b) +{ + int t = a*b + 128; + return (t + (t >> 8)) >> 8; +} + +static void stb__From16Bit(unsigned char *out, unsigned short v) +{ + int rv = (v & 0xf800) >> 11; + int gv = (v & 0x07e0) >> 5; + int bv = (v & 0x001f) >> 0; + + out[0] = stb__Expand5[rv]; + out[1] = stb__Expand6[gv]; + out[2] = stb__Expand5[bv]; + out[3] = 0; +} + +static unsigned short stb__As16Bit(int r, int g, int b) +{ + return (unsigned short)((stb__Mul8Bit(r,31) << 11) + (stb__Mul8Bit(g,63) << 5) + stb__Mul8Bit(b,31)); +} + +// linear interpolation at 1/3 point between a and b, using desired rounding type +static int stb__Lerp13(int a, int b) +{ +#ifdef STB_DXT_USE_ROUNDING_BIAS + // with rounding bias + return a + stb__Mul8Bit(b-a, 0x55); +#else + // without rounding bias + // replace "/ 3" by "* 0xaaab) >> 17" if your compiler sucks or you really need every ounce of speed. + return (2*a + b) / 3; +#endif +} + +// lerp RGB color +static void stb__Lerp13RGB(unsigned char *out, unsigned char *p1, unsigned char *p2) +{ + out[0] = (unsigned char)stb__Lerp13(p1[0], p2[0]); + out[1] = (unsigned char)stb__Lerp13(p1[1], p2[1]); + out[2] = (unsigned char)stb__Lerp13(p1[2], p2[2]); +} + +/****************************************************************************/ + +// compute table to reproduce constant colors as accurately as possible +static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expand,int size) +{ + int i,mn,mx; + for (i=0;i<256;i++) { + int bestErr = 256; + for (mn=0;mn> 4)]; + ep1[0] = bp[ 0] - dp[ 0]; + dp[ 4] = quant[bp[ 4] + ((7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]) >> 4)]; + ep1[1] = bp[ 4] - dp[ 4]; + dp[ 8] = quant[bp[ 8] + ((7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]) >> 4)]; + ep1[2] = bp[ 8] - dp[ 8]; + dp[12] = quant[bp[12] + ((7*ep1[2] + 5*ep2[3] + ep2[2]) >> 4)]; + ep1[3] = bp[12] - dp[12]; + bp += 16; + dp += 16; + et = ep1, ep1 = ep2, ep2 = et; // swap + } + } +} + +// The color matching function +static unsigned int stb__MatchColorsBlock(unsigned char *block, unsigned char *color,int dither) +{ + unsigned int mask = 0; + int dirr = color[0*4+0] - color[1*4+0]; + int dirg = color[0*4+1] - color[1*4+1]; + int dirb = color[0*4+2] - color[1*4+2]; + int dots[16]; + int stops[4]; + int i; + int c0Point, halfPoint, c3Point; + + for(i=0;i<16;i++) + dots[i] = block[i*4+0]*dirr + block[i*4+1]*dirg + block[i*4+2]*dirb; + + for(i=0;i<4;i++) + stops[i] = color[i*4+0]*dirr + color[i*4+1]*dirg + color[i*4+2]*dirb; + + // think of the colors as arranged on a line; project point onto that line, then choose + // next color out of available ones. we compute the crossover points for "best color in top + // half"/"best in bottom half" and then the same inside that subinterval. + // + // relying on this 1d approximation isn't always optimal in terms of euclidean distance, + // but it's very close and a lot faster. + // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html + + c0Point = (stops[1] + stops[3]); + halfPoint = (stops[3] + stops[2]); + c3Point = (stops[2] + stops[0]); + + if(!dither) { + // the version without dithering is straightforward + for (i=15;i>=0;i--) { + int dot = 2 * dots[i]; + mask <<= 2; + + if(dot < halfPoint) + mask |= (dot < c0Point) ? 1 : 3; + else + mask |= (dot < c3Point) ? 2 : 0; + } + } else { + // with floyd-steinberg dithering + int err[8],*ep1 = err,*ep2 = err+4; + int *dp = dots, y; + + c0Point <<= 4; + halfPoint <<= 4; + c3Point <<= 4; + for(i=0;i<8;i++) + err[i] = 0; + + for(y=0;y<4;y++) + { + int dot,lmask,step; + + dot = (dp[0] << 4) + (3*ep2[1] + 5*ep2[0]); + if(dot < halfPoint) + step = (dot < c0Point) ? 1 : 3; + else + step = (dot < c3Point) ? 2 : 0; + ep1[0] = dp[0] - stops[step]; + lmask = step; + + dot = (dp[1] << 4) + (7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]); + if(dot < halfPoint) + step = (dot < c0Point) ? 1 : 3; + else + step = (dot < c3Point) ? 2 : 0; + ep1[1] = dp[1] - stops[step]; + lmask |= step<<2; + + dot = (dp[2] << 4) + (7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]); + if(dot < halfPoint) + step = (dot < c0Point) ? 1 : 3; + else + step = (dot < c3Point) ? 2 : 0; + ep1[2] = dp[2] - stops[step]; + lmask |= step<<4; + + dot = (dp[3] << 4) + (7*ep1[2] + 5*ep2[3] + ep2[2]); + if(dot < halfPoint) + step = (dot < c0Point) ? 1 : 3; + else + step = (dot < c3Point) ? 2 : 0; + ep1[3] = dp[3] - stops[step]; + lmask |= step<<6; + + dp += 4; + mask |= lmask << (y*8); + { int *et = ep1; ep1 = ep2; ep2 = et; } // swap + } + } + + return mask; +} + +// The color optimization function. (Clever code, part 1) +static void stb__OptimizeColorsBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16) +{ + int mind = 0x7fffffff,maxd = -0x7fffffff; + unsigned char *minp, *maxp; + double magn; + int v_r,v_g,v_b; + static const int nIterPower = 4; + float covf[6],vfr,vfg,vfb; + + + // determine color distribution + int cov[6]; + int mu[3],min[3],max[3]; + int ch,i,iter; + + for(ch=0;ch<3;ch++) + { + const unsigned char *bp = ((const unsigned char *) block) + ch; + int muv,minv,maxv; + + muv = minv = maxv = bp[0]; + for(i=4;i<64;i+=4) + { + muv += bp[i]; + if (bp[i] < minv) minv = bp[i]; + else if (bp[i] > maxv) maxv = bp[i]; + } + + mu[ch] = (muv + 8) >> 4; + min[ch] = minv; + max[ch] = maxv; + } + + #if 1 + // determine covariance matrix + for (i=0;i<6;i++) + cov[i] = 0; + + for (i=0;i<16;i++) + { + int r = block[i*4+0] - mu[0]; + int g = block[i*4+1] - mu[1]; + int b = block[i*4+2] - mu[2]; + + cov[0] += r*r; + cov[1] += r*g; + cov[2] += r*b; + cov[3] += g*g; + cov[4] += g*b; + cov[5] += b*b; + } + + // convert covariance matrix to float, find principal axis via power iter + for(i=0;i<6;i++) + covf[i] = cov[i] / 255.0f; + + vfr = (float) (max[0] - min[0]); + vfg = (float) (max[1] - min[1]); + vfb = (float) (max[2] - min[2]); + + for(iter=0;iter magn) magn = STBD_FABS(vfg); + if (STBD_FABS(vfb) > magn) magn = STBD_FABS(vfb); + + if(magn < 4.0f) { // too small, default to luminance + v_r = 299; // JPEG YCbCr luma coefs, scaled by 1000. + v_g = 587; + v_b = 114; + } else { + magn = 512.0 / magn; + v_r = (int) (vfr * magn); + v_g = (int) (vfg * magn); + v_b = (int) (vfb * magn); + } + + // Pick colors at extreme points + for(i=0;i<16;i++) + { + int dot = block[i*4+0]*v_r + block[i*4+1]*v_g + block[i*4+2]*v_b; + + if (dot < mind) { + mind = dot; + minp = block+i*4; + } + + if (dot > maxd) { + maxd = dot; + maxp = block+i*4; + } + } + + *pmax16 = stb__As16Bit(maxp[0],maxp[1],maxp[2]); + *pmin16 = stb__As16Bit(minp[0],minp[1],minp[2]); +#else + int center[3] = { (min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2 }; + cov[0] = 0; + cov[1] = 0; + for(i=0;i<16;i++) { + //int r = block[i * 4 + 0] - mu[0]; + //int g = block[i * 4 + 1] - mu[1]; + //int b = block[i * 4 + 2] - mu[2]; + int r = block[i * 4 + 0] - center[0]; + int g = block[i * 4 + 1] - center[1]; + int b = block[i * 4 + 2] - center[2]; + + cov[0] += r * b; + cov[1] += g * b; + } + + v_r = max[0] - min[0]; + v_g = max[1] - min[1]; + v_b = max[2] - min[2]; + + if (cov[0]<0) { int t = max[0]; max[0] = min[0]; min[0] = t; } + if (cov[1]<0) { int t = max[1]; max[1] = min[1]; min[1] = t; } + + //Vector3 inset = (*c0 - *c1) / 16.0f - (8.0f / 255.0f) / 16.0f; + //*c0 = saturate(*c0 - inset); + //*c1 = saturate(*c1 + inset); + + *pmax16 = stb__As16Bit(max[0], max[1], max[2]); + *pmin16 = stb__As16Bit(min[0], min[1], min[2]); +#endif +} + +static const float midpoints5[32] = { + 0.015686f, 0.047059f, 0.078431f, 0.111765f, 0.145098f, 0.176471f, 0.207843f, 0.241176f, 0.274510f, 0.305882f, 0.337255f, 0.370588f, 0.403922f, 0.435294f, 0.466667f, 0.5f, + 0.533333f, 0.564706f, 0.596078f, 0.629412f, 0.662745f, 0.694118f, 0.725490f, 0.758824f, 0.792157f, 0.823529f, 0.854902f, 0.888235f, 0.921569f, 0.952941f, 0.984314f, 1.0f +}; + +static const float midpoints6[64] = { + 0.007843f, 0.023529f, 0.039216f, 0.054902f, 0.070588f, 0.086275f, 0.101961f, 0.117647f, 0.133333f, 0.149020f, 0.164706f, 0.180392f, 0.196078f, 0.211765f, 0.227451f, 0.245098f, + 0.262745f, 0.278431f, 0.294118f, 0.309804f, 0.325490f, 0.341176f, 0.356863f, 0.372549f, 0.388235f, 0.403922f, 0.419608f, 0.435294f, 0.450980f, 0.466667f, 0.482353f, 0.500000f, + 0.517647f, 0.533333f, 0.549020f, 0.564706f, 0.580392f, 0.596078f, 0.611765f, 0.627451f, 0.643137f, 0.658824f, 0.674510f, 0.690196f, 0.705882f, 0.721569f, 0.737255f, 0.754902f, + 0.772549f, 0.788235f, 0.803922f, 0.819608f, 0.835294f, 0.850980f, 0.866667f, 0.882353f, 0.898039f, 0.913725f, 0.929412f, 0.945098f, 0.960784f, 0.976471f, 0.992157f, 1.0f +}; + +static unsigned short stb__Quantize5(float x) { + x = x < 0 ? 0 : x > 1 ? 1 : x; // saturate + unsigned short q = (unsigned short)(x * 31); + q += (x > midpoints5[q]); + return q; +} +static unsigned short stb__Quantize6(float x) { + x = x < 0 ? 0 : x > 1 ? 1 : x; // saturate + unsigned short q = (unsigned short)(x * 63); + q += (x > midpoints6[q]); + return q; +} + +// The refinement function. (Clever code, part 2) +// Tries to optimize colors to suit block contents better. +// (By solving a least squares system via normal equations+Cramer's rule) +static int stb__RefineBlock(unsigned char *block, unsigned short *pmax16, unsigned short *pmin16, unsigned int mask) +{ + static const int w1Tab[4] = { 3,0,2,1 }; + static const int prods[4] = { 0x090000,0x000900,0x040102,0x010402 }; + // ^some magic to save a lot of multiplies in the accumulating loop... + // (precomputed products of weights for least squares system, accumulated inside one 32-bit register) + + float f; + unsigned short oldMin, oldMax, min16, max16; + int i, akku = 0, xx,xy,yy; + int At1_r,At1_g,At1_b; + int At2_r,At2_g,At2_b; + unsigned int cm = mask; + + oldMin = *pmin16; + oldMax = *pmax16; + + if((mask ^ (mask<<2)) < 4) // all pixels have the same index? + { + // yes, linear system would be singular; solve using optimal + // single-color match on average color + int r = 8, g = 8, b = 8; + for (i=0;i<16;++i) { + r += block[i*4+0]; + g += block[i*4+1]; + b += block[i*4+2]; + } + + r >>= 4; g >>= 4; b >>= 4; + + max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0]; + min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1]; + } else { + At1_r = At1_g = At1_b = 0; + At2_r = At2_g = At2_b = 0; + for (i=0;i<16;++i,cm>>=2) { + int step = cm&3; + int w1 = w1Tab[step]; + int r = block[i*4+0]; + int g = block[i*4+1]; + int b = block[i*4+2]; + + akku += prods[step]; + At1_r += w1*r; + At1_g += w1*g; + At1_b += w1*b; + At2_r += r; + At2_g += g; + At2_b += b; + } + + At2_r = 3*At2_r - At1_r; + At2_g = 3*At2_g - At1_g; + At2_b = 3*At2_b - At1_b; + + // extract solutions and decide solvability + xx = akku >> 16; + yy = (akku >> 8) & 0xff; + xy = (akku >> 0) & 0xff; + + f = 3.0f / 255.0f / (xx*yy - xy*xy); + + max16 = stb__Quantize5((At1_r*yy - At2_r * xy) * f) << 11; + max16 |= stb__Quantize6((At1_g*yy - At2_g * xy) * f) << 5; + max16 |= stb__Quantize5((At1_b*yy - At2_b * xy) * f) << 0; + + min16 = stb__Quantize5((At2_r*xx - At1_r * xy) * f) << 11; + min16 |= stb__Quantize6((At2_g*xx - At1_g * xy) * f) << 5; + min16 |= stb__Quantize5((At2_b*xx - At1_b * xy) * f) << 0; + } + + *pmin16 = min16; + *pmax16 = max16; + return oldMin != min16 || oldMax != max16; +} + +// Color block compression +static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, int mode) +{ + unsigned int mask; + int i; + int dither; + int refinecount; + unsigned short max16, min16; + unsigned char dblock[16*4],color[4*4]; + + dither = mode & STB_DXT_DITHER; + refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1; + + // check if block is constant + for (i=1;i<16;i++) + if (((unsigned int *) block)[i] != ((unsigned int *) block)[0]) + break; + + if(i == 16) { // constant color + int r = block[0], g = block[1], b = block[2]; + mask = 0xaaaaaaaa; + max16 = (stb__OMatch5[r][0]<<11) | (stb__OMatch6[g][0]<<5) | stb__OMatch5[b][0]; + min16 = (stb__OMatch5[r][1]<<11) | (stb__OMatch6[g][1]<<5) | stb__OMatch5[b][1]; + } else { + // first step: compute dithered version for PCA if desired + if(dither) + stb__DitherBlock(dblock,block); + + // second step: pca+map along principal axis + stb__OptimizeColorsBlock(dither ? dblock : block,&max16,&min16); + if (max16 != min16) { + stb__EvalColors(color,max16,min16); + mask = stb__MatchColorsBlock(block,color,dither); + } else + mask = 0; + + // third step: refine (multiple times if requested) + for (i=0;i> 8); + dest[2] = (unsigned char) (min16); + dest[3] = (unsigned char) (min16 >> 8); + dest[4] = (unsigned char) (mask); + dest[5] = (unsigned char) (mask >> 8); + dest[6] = (unsigned char) (mask >> 16); + dest[7] = (unsigned char) (mask >> 24); +} + +// Alpha block compression (this is easy for a change) +static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src, int stride) +{ + int i,dist,bias,dist4,dist2,bits,mask; + + // find min/max color + int mn,mx; + mn = mx = src[0]; + + for (i=1;i<16;i++) + { + if (src[i*stride] < mn) mn = src[i*stride]; + else if (src[i*stride] > mx) mx = src[i*stride]; + } + + // encode them + dest[0] = (unsigned char)mx; + dest[1] = (unsigned char)mn; + dest += 2; + + // determine bias and emit color indices + // given the choice of mx/mn, these indices are optimal: + // http://fgiesen.wordpress.com/2009/12/15/dxt5-alpha-block-index-determination/ + dist = mx-mn; + dist4 = dist*4; + dist2 = dist*2; + bias = (dist < 8) ? (dist - 1) : (dist/2 + 2); + bias -= mn * 7; + bits = 0,mask=0; + + for (i=0;i<16;i++) { + int a = src[i*stride]*7 + bias; + int ind,t; + + // select index. this is a "linear scale" lerp factor between 0 (val=min) and 7 (val=max). + t = (a >= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t; + t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t; + ind += (a >= dist); + + // turn linear scale into DXT index (0/1 are extremal pts) + ind = -ind & 7; + ind ^= (2 > ind); + + // write index + mask |= ind << bits; + if((bits += 3) >= 8) { + *dest++ = (unsigned char)mask; + mask >>= 8; + bits -= 8; + } + } +} + +static void stb__InitDXT() +{ + int i; + for(i=0;i<32;i++) + stb__Expand5[i] = (unsigned char)((i<<3)|(i>>2)); + + for(i=0;i<64;i++) + stb__Expand6[i] = (unsigned char)((i<<2)|(i>>4)); + + for(i=0;i<256+16;i++) + { + int v = i-8 < 0 ? 0 : i-8 > 255 ? 255 : i-8; + stb__QuantRBTab[i] = stb__Expand5[stb__Mul8Bit(v,31)]; + stb__QuantGTab[i] = stb__Expand6[stb__Mul8Bit(v,63)]; + } + + stb__PrepareOptTable(&stb__OMatch5[0][0],stb__Expand5,32); + stb__PrepareOptTable(&stb__OMatch6[0][0],stb__Expand6,64); +} + +void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int alpha, int mode) +{ + unsigned char data[16][4]; + static int init=1; + if (init) { + stb__InitDXT(); + init=0; + } + + if (alpha) { + int i; + stb__CompressAlphaBlock(dest,(unsigned char*) src+3, 4); + dest += 8; + // make a new copy of the data in which alpha is opaque, + // because code uses a fast test for color constancy + memcpy(data, src, 4*16); + for (i=0; i < 16; ++i) + data[i][3] = 255; + src = &data[0][0]; + } + + stb__CompressColorBlock(dest,(unsigned char*) src,mode); +} + +void stb_compress_bc4_block(unsigned char *dest, const unsigned char *src) +{ + stb__CompressAlphaBlock(dest,(unsigned char*) src, 1); +} + +void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src) +{ + stb__CompressAlphaBlock(dest,(unsigned char*) src,2); + stb__CompressAlphaBlock(dest + 8,(unsigned char*) src+1,2); +} +#endif // STB_DXT_IMPLEMENTATION + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/extern/stb/stb_image.h b/extern/stb/stb_image.h index c26b4201..2857f05d 100644 --- a/extern/stb/stb_image.h +++ b/extern/stb/stb_image.h @@ -1,4954 +1,7656 @@ -/* stbi-1.29 - public domain JPEG/PNG reader - http://nothings.org/stb_image.c - when you control the images you're loading - no warranty implied; use at your own risk - - QUICK NOTES: - Primarily of interest to game developers and other people who can - avoid problematic images and only need the trivial interface - - JPEG baseline (no JPEG progressive) - PNG 8-bit only - - TGA (not sure what subset, if a subset) - BMP non-1bpp, non-RLE - PSD (composited view only, no extra channels) - - GIF (*comp always reports as 4-channel) - HDR (radiance rgbE format) - PIC (Softimage PIC) - - - decoded from memory or through stdio FILE (define STBI_NO_STDIO to remove code) - - supports installable dequantizing-IDCT, YCbCr-to-RGB conversion (define STBI_SIMD) - - Latest revisions: - 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville - 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) - 1.27 (2010-08-01) cast-to-uint8 to fix warnings (Laurent Gomila) - allow trailing 0s at end of image data (Laurent Gomila) - 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ - 1.25 (2010-07-17) refix trans_data warning (Won Chun) - 1.24 (2010-07-12) perf improvements reading from files - minor perf improvements for jpeg - deprecated type-specific functions in hope of feedback - attempt to fix trans_data warning (Won Chun) - 1.23 fixed bug in iPhone support - 1.22 (2010-07-10) removed image *writing* support to stb_image_write.h - stbi_info support from Jetro Lauha - GIF support from Jean-Marc Lienher - iPhone PNG-extensions from James Brown - warning-fixes from Nicolas Schulz and Janez Zemva - 1.21 fix use of 'uint8' in header (reported by jon blow) - 1.20 added support for Softimage PIC, by Tom Seddon - - See end of file for full revision history. - - TODO: - stbi_info support for BMP,PSD,HDR,PIC - rewrite stbi_info and load_file variations to share file handling code - (current system allows individual functions to be called directly, - since each does all the work, but I doubt anyone uses this in practice) - - - ============================ Contributors ========================= - - Image formats Optimizations & bugfixes - Sean Barrett (jpeg, png, bmp) Fabian "ryg" Giesen - Nicolas Schulz (hdr, psd) - Jonathan Dummer (tga) Bug fixes & warning fixes - Jean-Marc Lienher (gif) Marc LeBlanc - Tom Seddon (pic) Christpher Lloyd - Thatcher Ulrich (psd) Dave Moore - Won Chun - the Horde3D community - Extensions, features Janez Zemva - Jetro Lauha (stbi_info) Jonathan Blow - James "moose2000" Brown (iPhone PNG) Laurent Gomila - Aruelien Pocheville - - If your name should be here but isn't, let Sean know. - -*/ - -#ifndef STBI_INCLUDE_STB_IMAGE_H -#define STBI_INCLUDE_STB_IMAGE_H - -// To get a header file for this, either cut and paste the header, -// or create stb_image.h, #define STBI_HEADER_FILE_ONLY, and -// then include stb_image.c from it. - -//// begin header file //////////////////////////////////////////////////// -// -// Limitations: -// - no jpeg progressive support -// - non-HDR formats support 8-bit samples only (jpeg, png) -// - no delayed line count (jpeg) -- IJG doesn't support either -// - no 1-bit BMP -// - GIF always returns *comp=4 -// -// Basic usage (see HDR discussion below): -// int x,y,n; -// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); -// // ... process data if not NULL ... -// // ... x = width, y = height, n = # 8-bit components per pixel ... -// // ... replace '0' with '1'..'4' to force that many components per pixel -// stbi_image_free(data) -// -// Standard parameters: -// int *x -- outputs image width in pixels -// int *y -- outputs image height in pixels -// int *comp -- outputs # of image components in image file -// int req_comp -- if non-zero, # of image components requested in result -// -// The return value from an image loader is an 'unsigned char *' which points -// to the pixel data. The pixel data consists of *y scanlines of *x pixels, -// with each pixel consisting of N interleaved 8-bit components; the first -// pixel pointed to is top-left-most in the image. There is no padding between -// image scanlines or between pixels, regardless of format. The number of -// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. -// If req_comp is non-zero, *comp has the number of components that _would_ -// have been output otherwise. E.g. if you set req_comp to 4, you will always -// get RGBA output, but you can check *comp to easily see if it's opaque. -// -// An output image with N components has the following components interleaved -// in this order in each pixel: -// -// N=#comp components -// 1 grey -// 2 grey, alpha -// 3 red, green, blue -// 4 red, green, blue, alpha -// -// If image loading fails for any reason, the return value will be NULL, -// and *x, *y, *comp will be unchanged. The function stbi_failure_reason() -// can be queried for an extremely brief, end-user unfriendly explanation -// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid -// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly -// more user-friendly ones. -// -// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. -// -// =========================================================================== -// -// iPhone PNG support: -// -// By default we convert iphone-formatted PNGs back to RGB; nominally they -// would silently load as BGR, except the existing code should have just -// failed on such iPhone PNGs. But you can disable this conversion by -// by calling stbi_convert_iphone_png_to_rgb(0), in which case -// you will always just get the native iphone "format" through. -// -// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per -// pixel to remove any premultiplied alpha *only* if the image file explicitly -// says there's premultiplied data (currently only happens in iPhone images, -// and only if iPhone convert-to-rgb processing is on). -// -// =========================================================================== -// -// HDR image support (disable by defining STBI_NO_HDR) -// -// stb_image now supports loading HDR images in general, and currently -// the Radiance .HDR file format, although the support is provided -// generically. You can still load any file through the existing interface; -// if you attempt to load an HDR file, it will be automatically remapped to -// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; -// both of these constants can be reconfigured through this interface: -// -// stbi_hdr_to_ldr_gamma(2.2f); -// stbi_hdr_to_ldr_scale(1.0f); -// -// (note, do not use _inverse_ constants; stbi_image will invert them -// appropriately). -// -// Additionally, there is a new, parallel interface for loading files as -// (linear) floats to preserve the full dynamic range: -// -// float *data = stbi_loadf(filename, &x, &y, &n, 0); -// -// If you load LDR images through this interface, those images will -// be promoted to floating point values, run through the inverse of -// constants corresponding to the above: -// -// stbi_ldr_to_hdr_scale(1.0f); -// stbi_ldr_to_hdr_gamma(2.2f); -// -// Finally, given a filename (or an open file or memory block--see header -// file for details) containing image data, you can query for the "most -// appropriate" interface to use (that is, whether the image is HDR or -// not), using: -// -// stbi_is_hdr(char *filename); - -#ifndef STBI_NO_STDIO -#include -#endif - -#define STBI_VERSION 1 - -enum -{ - STBI_default = 0, // only used for req_comp - - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4 -}; - -typedef unsigned char stbi_uc; - -#ifdef __cplusplus -extern "C" { -#endif - -// PRIMARY API - works on images of any type - -// load image by filename, open file, or memory buffer -extern stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -// for stbi_load_from_file, file pointer is left pointing immediately after image -#endif - -#ifndef STBI_NO_HDR - extern float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); - - #ifndef STBI_NO_STDIO - extern float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp); - extern float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); - #endif - - extern void stbi_hdr_to_ldr_gamma(float gamma); - extern void stbi_hdr_to_ldr_scale(float scale); - - extern void stbi_ldr_to_hdr_gamma(float gamma); - extern void stbi_ldr_to_hdr_scale(float scale); -#endif // STBI_NO_HDR - -// get a VERY brief reason for failure -// NOT THREADSAFE -extern const char *stbi_failure_reason (void); - -// free the loaded image -- this is just free() -extern void stbi_image_free (void *retval_from_stbi_load); - -// get image dimensions & components without fully decoding -extern int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); -extern int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); - -#ifndef STBI_NO_STDIO -extern int stbi_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); - -extern int stbi_is_hdr (char const *filename); -extern int stbi_is_hdr_from_file(FILE *f); -#endif - -// for image formats that explicitly notate that they have premultiplied alpha, -// we just return the colors as stored in the file. set this flag to force -// unpremultiplication. results are undefined if the unpremultiply overflow. -extern void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); - -// indicate whether we should process iphone images back to canonical format, -// or just pass them through "as-is" -extern void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); - - -// ZLIB client - used by PNG, available for other purposes - -extern char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); -extern char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); -extern int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -extern char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); -extern int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -// define new loaders -typedef struct -{ - int (*test_memory)(stbi_uc const *buffer, int len); - stbi_uc * (*load_from_memory)(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); - #ifndef STBI_NO_STDIO - int (*test_file)(FILE *f); - stbi_uc * (*load_from_file)(FILE *f, int *x, int *y, int *comp, int req_comp); - #endif -} stbi_loader; - -// register a loader by filling out the above structure (you must define ALL functions) -// returns 1 if added or already added, 0 if not added (too many loaders) -// NOT THREADSAFE -extern int stbi_register_loader(stbi_loader *loader); - -// define faster low-level operations (typically SIMD support) -#ifdef STBI_SIMD -typedef void (*stbi_idct_8x8)(stbi_uc *out, int out_stride, short data[64], unsigned short *dequantize); -// compute an integer IDCT on "input" -// input[x] = data[x] * dequantize[x] -// write results to 'out': 64 samples, each run of 8 spaced by 'out_stride' -// CLAMP results to 0..255 -typedef void (*stbi_YCbCr_to_RGB_run)(stbi_uc *output, stbi_uc const *y, stbi_uc const *cb, stbi_uc const *cr, int count, int step); -// compute a conversion from YCbCr to RGB -// 'count' pixels -// write pixels to 'output'; each pixel is 'step' bytes (either 3 or 4; if 4, write '255' as 4th), order R,G,B -// y: Y input channel -// cb: Cb input channel; scale/biased to be 0..255 -// cr: Cr input channel; scale/biased to be 0..255 - -extern void stbi_install_idct(stbi_idct_8x8 func); -extern void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func); -#endif // STBI_SIMD - - - - -// TYPE-SPECIFIC ACCESS - -#ifdef STBI_TYPE_SPECIFIC_FUNCTIONS - -// is it a jpeg? -extern int stbi_jpeg_test_memory (stbi_uc const *buffer, int len); -extern stbi_uc *stbi_jpeg_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_jpeg_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern int stbi_jpeg_test_file (FILE *f); -extern stbi_uc *stbi_jpeg_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); - -extern int stbi_jpeg_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -// is it a png? -extern int stbi_png_test_memory (stbi_uc const *buffer, int len); -extern stbi_uc *stbi_png_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_png_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_png_test_file (FILE *f); -extern stbi_uc *stbi_png_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -// is it a bmp? -extern int stbi_bmp_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_bmp_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_bmp_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_bmp_test_file (FILE *f); -extern stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a tga? -extern int stbi_tga_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_tga_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_tga_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_tga_test_file (FILE *f); -extern stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a psd? -extern int stbi_psd_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_psd_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_psd_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_psd_test_file (FILE *f); -extern stbi_uc *stbi_psd_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it an hdr? -extern int stbi_hdr_test_memory (stbi_uc const *buffer, int len); - -extern float * stbi_hdr_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern float * stbi_hdr_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_hdr_test_file (FILE *f); -extern float * stbi_hdr_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a pic? -extern int stbi_pic_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_pic_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_pic_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_pic_test_file (FILE *f); -extern stbi_uc *stbi_pic_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a gif? -extern int stbi_gif_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_gif_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_gif_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_gif_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern int stbi_gif_test_file (FILE *f); -extern stbi_uc *stbi_gif_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern int stbi_gif_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_gif_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -#endif//STBI_TYPE_SPECIFIC_FUNCTIONS - - - - -#ifdef __cplusplus -} -#endif - -// -// -//// end header file ///////////////////////////////////////////////////// -#endif // STBI_INCLUDE_STB_IMAGE_H - -#ifndef STBI_HEADER_FILE_ONLY - -#ifndef STBI_NO_HDR -#include // ldexp -#include // strcmp -#endif - -#ifndef STBI_NO_STDIO -#include -#endif -#include -#include -#include -#include - -#ifndef _MSC_VER - #ifdef __cplusplus - #define __forceinline inline - #else - #define __forceinline - #endif -#endif - - -// implementation: -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned int uint32; -typedef signed int int32; -typedef unsigned int uint; - -// should produce compiler error if size is wrong -typedef unsigned char validate_uint32[sizeof(uint32)==4 ? 1 : -1]; - -#if defined(STBI_NO_STDIO) && !defined(STBI_NO_WRITE) -#define STBI_NO_WRITE -#endif - -#define STBI_NOTUSED(v) v=v - -#ifdef _MSC_VER -#define STBI_HAS_LRTOL -#endif - -#ifdef STBI_HAS_LRTOL - #define stbi_lrot(x,y) _lrotl(x,y) -#else - #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// Generic API that works on all image types -// - -// deprecated functions - -// is it a jpeg? -extern int stbi_jpeg_test_memory (stbi_uc const *buffer, int len); -extern stbi_uc *stbi_jpeg_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_jpeg_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern int stbi_jpeg_test_file (FILE *f); -extern stbi_uc *stbi_jpeg_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); - -extern int stbi_jpeg_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -// is it a png? -extern int stbi_png_test_memory (stbi_uc const *buffer, int len); -extern stbi_uc *stbi_png_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern stbi_uc *stbi_png_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_png_test_file (FILE *f); -extern stbi_uc *stbi_png_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern int stbi_png_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - -// is it a bmp? -extern int stbi_bmp_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_bmp_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_bmp_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_bmp_test_file (FILE *f); -extern stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a tga? -extern int stbi_tga_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_tga_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_tga_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_tga_test_file (FILE *f); -extern stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a psd? -extern int stbi_psd_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_psd_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_psd_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_psd_test_file (FILE *f); -extern stbi_uc *stbi_psd_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it an hdr? -extern int stbi_hdr_test_memory (stbi_uc const *buffer, int len); - -extern float * stbi_hdr_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern float * stbi_hdr_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_hdr_test_file (FILE *f); -extern float * stbi_hdr_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a pic? -extern int stbi_pic_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_pic_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_pic_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -#ifndef STBI_NO_STDIO -extern int stbi_pic_test_file (FILE *f); -extern stbi_uc *stbi_pic_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -#endif - -// is it a gif? -extern int stbi_gif_test_memory (stbi_uc const *buffer, int len); - -extern stbi_uc *stbi_gif_load (char const *filename, int *x, int *y, int *comp, int req_comp); -extern stbi_uc *stbi_gif_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); -extern int stbi_gif_info_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -#ifndef STBI_NO_STDIO -extern int stbi_gif_test_file (FILE *f); -extern stbi_uc *stbi_gif_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); -extern int stbi_gif_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_gif_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif - - -// this is not threadsafe -static const char *failure_reason; - -const char *stbi_failure_reason(void) -{ - return failure_reason; -} - -static int e(const char *str) -{ - failure_reason = str; - return 0; -} - -#ifdef STBI_NO_FAILURE_STRINGS - #define e(x,y) 0 -#elif defined(STBI_FAILURE_USERMSG) - #define e(x,y) e(y) -#else - #define e(x,y) e(x) -#endif - -#define epf(x,y) ((float *) (e(x,y)?NULL:NULL)) -#define epuc(x,y) ((unsigned char *) (e(x,y)?NULL:NULL)) - -void stbi_image_free(void *retval_from_stbi_load) -{ - free(retval_from_stbi_load); -} - -#define MAX_LOADERS 32 -stbi_loader *loaders[MAX_LOADERS]; -static int max_loaders = 0; - -int stbi_register_loader(stbi_loader *loader) -{ - int i; - for (i=0; i < MAX_LOADERS; ++i) { - // already present? - if (loaders[i] == loader) - return 1; - // end of the list? - if (loaders[i] == NULL) { - loaders[i] = loader; - max_loaders = i+1; - return 1; - } - } - // no room for it - return 0; -} - -#ifndef STBI_NO_HDR -static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp); -static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp); -#endif - -#ifndef STBI_NO_STDIO -unsigned char *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = fopen(filename, "rb"); - unsigned char *result; - if (!f) return epuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -unsigned char *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - int i; - if (stbi_jpeg_test_file(f)) return stbi_jpeg_load_from_file(f,x,y,comp,req_comp); - if (stbi_png_test_file(f)) return stbi_png_load_from_file(f,x,y,comp,req_comp); - if (stbi_bmp_test_file(f)) return stbi_bmp_load_from_file(f,x,y,comp,req_comp); - if (stbi_gif_test_file(f)) return stbi_gif_load_from_file(f,x,y,comp,req_comp); - if (stbi_psd_test_file(f)) return stbi_psd_load_from_file(f,x,y,comp,req_comp); - if (stbi_pic_test_file(f)) return stbi_pic_load_from_file(f,x,y,comp,req_comp); - - #ifndef STBI_NO_HDR - if (stbi_hdr_test_file(f)) { - float *hdr = stbi_hdr_load_from_file(f, x,y,comp,req_comp); - return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - - for (i=0; i < max_loaders; ++i) - if (loaders[i]->test_file(f)) - return loaders[i]->load_from_file(f,x,y,comp,req_comp); - // test tga last because it's a crappy test! - if (stbi_tga_test_file(f)) - return stbi_tga_load_from_file(f,x,y,comp,req_comp); - return epuc("unknown image type", "Image not of any known type, or corrupt"); -} -#endif - -unsigned char *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - int i; - if (stbi_jpeg_test_memory(buffer,len)) return stbi_jpeg_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_png_test_memory(buffer,len)) return stbi_png_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_bmp_test_memory(buffer,len)) return stbi_bmp_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_gif_test_memory(buffer,len)) return stbi_gif_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_psd_test_memory(buffer,len)) return stbi_psd_load_from_memory(buffer,len,x,y,comp,req_comp); - if (stbi_pic_test_memory(buffer,len)) return stbi_pic_load_from_memory(buffer,len,x,y,comp,req_comp); - - #ifndef STBI_NO_HDR - if (stbi_hdr_test_memory(buffer, len)) { - float *hdr = stbi_hdr_load_from_memory(buffer, len,x,y,comp,req_comp); - return hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - - for (i=0; i < max_loaders; ++i) - if (loaders[i]->test_memory(buffer,len)) - return loaders[i]->load_from_memory(buffer,len,x,y,comp,req_comp); - // test tga last because it's a crappy test! - if (stbi_tga_test_memory(buffer,len)) - return stbi_tga_load_from_memory(buffer,len,x,y,comp,req_comp); - return epuc("unknown image type", "Image not of any known type, or corrupt"); -} - -#ifndef STBI_NO_HDR - -#ifndef STBI_NO_STDIO -float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = fopen(filename, "rb"); - float *result; - if (!f) return epf("can't fopen", "Unable to open file"); - result = stbi_loadf_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - #ifndef STBI_NO_HDR - if (stbi_hdr_test_file(f)) - return stbi_hdr_load_from_file(f,x,y,comp,req_comp); - #endif - data = stbi_load_from_file(f, x, y, comp, req_comp); - if (data) - return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return epf("unknown image type", "Image not of any known type, or corrupt"); -} -#endif - -float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - #ifndef STBI_NO_HDR - if (stbi_hdr_test_memory(buffer, len)) - return stbi_hdr_load_from_memory(buffer, len,x,y,comp,req_comp); - #endif - data = stbi_load_from_memory(buffer, len, x, y, comp, req_comp); - if (data) - return ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return epf("unknown image type", "Image not of any known type, or corrupt"); -} -#endif - -// these is-hdr-or-not is defined independent of whether STBI_NO_HDR is -// defined, for API simplicity; if STBI_NO_HDR is defined, it always -// reports false! - -int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) -{ - #ifndef STBI_NO_HDR - return stbi_hdr_test_memory(buffer, len); - #else - STBI_NOTUSED(buffer); - STBI_NOTUSED(len); - return 0; - #endif -} - -#ifndef STBI_NO_STDIO -extern int stbi_is_hdr (char const *filename) -{ - FILE *f = fopen(filename, "rb"); - int result=0; - if (f) { - result = stbi_is_hdr_from_file(f); - fclose(f); - } - return result; -} - -extern int stbi_is_hdr_from_file(FILE *f) -{ - #ifndef STBI_NO_HDR - return stbi_hdr_test_file(f); - #else - return 0; - #endif -} - -#endif - -#ifndef STBI_NO_HDR -static float h2l_gamma_i=1.0f/2.2f, h2l_scale_i=1.0f; -static float l2h_gamma=2.2f, l2h_scale=1.0f; - -void stbi_hdr_to_ldr_gamma(float gamma) { h2l_gamma_i = 1/gamma; } -void stbi_hdr_to_ldr_scale(float scale) { h2l_scale_i = 1/scale; } - -void stbi_ldr_to_hdr_gamma(float gamma) { l2h_gamma = gamma; } -void stbi_ldr_to_hdr_scale(float scale) { l2h_scale = scale; } -#endif - - -////////////////////////////////////////////////////////////////////////////// -// -// Common code used by all image loaders -// - -enum -{ - SCAN_load=0, - SCAN_type, - SCAN_header -}; - -typedef struct -{ - uint32 img_x, img_y; - int img_n, img_out_n; - - #ifndef STBI_NO_STDIO - FILE *img_file; - int buflen; - uint8 buffer_start[128]; - int from_file; - #endif - uint8 *img_buffer, *img_buffer_end; -} stbi; - -#ifndef STBI_NO_STDIO -static void start_file(stbi *s, FILE *f) -{ - s->img_file = f; - s->buflen = sizeof(s->buffer_start); - s->img_buffer_end = s->buffer_start + s->buflen; - s->img_buffer = s->img_buffer_end; - s->from_file = 1; -} -#endif - -static void start_mem(stbi *s, uint8 const *buffer, int len) -{ -#ifndef STBI_NO_STDIO - s->img_file = NULL; - s->from_file = 0; -#endif - s->img_buffer = (uint8 *) buffer; - s->img_buffer_end = (uint8 *) buffer+len; -} - -#ifndef STBI_NO_STDIO -static void refill_buffer(stbi *s) -{ - int n = fread(s->buffer_start, 1, s->buflen, s->img_file); - if (n == 0) { - s->from_file = 0; - s->img_buffer = s->img_buffer_end-1; - *s->img_buffer = 0; - } else { - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start + n; - } -} -#endif - -__forceinline static int get8(stbi *s) -{ - if (s->img_buffer < s->img_buffer_end) - return *s->img_buffer++; -#ifndef STBI_NO_STDIO - if (s->from_file) { - refill_buffer(s); - return *s->img_buffer++; - } -#endif - return 0; -} - -__forceinline static int at_eof(stbi *s) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) { - if (!feof(s->img_file)) return 0; - // if feof() is true, check if buffer = end - // special case: we've only got the special 0 character at the end - if (s->from_file == 0) return 1; - } -#endif - return s->img_buffer >= s->img_buffer_end; -} - -__forceinline static uint8 get8u(stbi *s) -{ - return (uint8) get8(s); -} - -static void skip(stbi *s, int n) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) { - int blen = s->img_buffer_end - s->img_buffer; - if (blen < n) { - s->img_buffer = s->img_buffer_end; - fseek(s->img_file, n - blen, SEEK_CUR); - return; - } - } -#endif - s->img_buffer += n; -} - -static int getn(stbi *s, stbi_uc *buffer, int n) -{ -#ifndef STBI_NO_STDIO - if (s->img_file) { - int blen = s->img_buffer_end - s->img_buffer; - if (blen < n) { - int res; - memcpy(buffer, s->img_buffer, blen); - res = ((int) fread(buffer + blen, 1, n - blen, s->img_file) == (n-blen)); - s->img_buffer = s->img_buffer_end; - return res; - } - } -#endif - if (s->img_buffer+n <= s->img_buffer_end) { - memcpy(buffer, s->img_buffer, n); - s->img_buffer += n; - return 1; - } else - return 0; -} - -static int get16(stbi *s) -{ - int z = get8(s); - return (z << 8) + get8(s); -} - -static uint32 get32(stbi *s) -{ - uint32 z = get16(s); - return (z << 16) + get16(s); -} - -static int get16le(stbi *s) -{ - int z = get8(s); - return z + (get8(s) << 8); -} - -static uint32 get32le(stbi *s) -{ - uint32 z = get16le(s); - return z + (get16le(s) << 16); -} - -////////////////////////////////////////////////////////////////////////////// -// -// generic converter from built-in img_n to req_comp -// individual types do this automatically as much as possible (e.g. jpeg -// does all cases internally since it needs to colorspace convert anyway, -// and it never has alpha, so very few cases ). png can automatically -// interleave an alpha=255 channel, but falls back to this for other cases -// -// assume data buffer is malloced, so malloc a new one and free that one -// only failure mode is malloc failing - -static uint8 compute_y(int r, int g, int b) -{ - return (uint8) (((r*77) + (g*150) + (29*b)) >> 8); -} - -static unsigned char *convert_format(unsigned char *data, int img_n, int req_comp, uint x, uint y) -{ - int i,j; - unsigned char *good; - - if (req_comp == img_n) return data; - assert(req_comp >= 1 && req_comp <= 4); - - good = (unsigned char *) malloc(req_comp * x * y); - if (good == NULL) { - free(data); - return epuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - unsigned char *src = data + j * x * img_n ; - unsigned char *dest = good + j * x * req_comp; - - #define COMBO(a,b) ((a)*8+(b)) - #define CASE(a,b) case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (COMBO(img_n, req_comp)) { - CASE(1,2) dest[0]=src[0], dest[1]=255; break; - CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; - CASE(2,1) dest[0]=src[0]; break; - CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; - CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; - CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; - CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]); break; - CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255; break; - CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]); break; - CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; - CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; - default: assert(0); - } - #undef CASE - } - - free(data); - return good; -} - -#ifndef STBI_NO_HDR -static float *ldr_to_hdr(stbi_uc *data, int x, int y, int comp) -{ - int i,k,n; - float *output = (float *) malloc(x * y * comp * sizeof(float)); - if (output == NULL) { free(data); return epf("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - output[i*comp + k] = (float) pow(data[i*comp+k]/255.0f, l2h_gamma) * l2h_scale; - } - if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; - } - free(data); - return output; -} - -#define float2int(x) ((int) (x)) -static stbi_uc *hdr_to_ldr(float *data, int x, int y, int comp) -{ - int i,k,n; - stbi_uc *output = (stbi_uc *) malloc(x * y * comp); - if (output == NULL) { free(data); return epuc("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*h2l_scale_i, h2l_gamma_i) * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (uint8) float2int(z); - } - if (k < comp) { - float z = data[i*comp+k] * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (uint8) float2int(z); - } - } - free(data); - return output; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// "baseline" JPEG/JFIF decoder (not actually fully baseline implementation) -// -// simple implementation -// - channel subsampling of at most 2 in each dimension -// - doesn't support delayed output of y-dimension -// - simple interface (only one output format: 8-bit interleaved RGB) -// - doesn't try to recover corrupt jpegs -// - doesn't allow partial loading, loading multiple at once -// - still fast on x86 (copying globals into locals doesn't help x86) -// - allocates lots of intermediate memory (full size of all components) -// - non-interleaved case requires this anyway -// - allows good upsampling (see next) -// high-quality -// - upsampled channels are bilinearly interpolated, even across blocks -// - quality integer IDCT derived from IJG's 'slow' -// performance -// - fast huffman; reasonable integer IDCT -// - uses a lot of intermediate memory, could cache poorly -// - load http://nothings.org/remote/anemones.jpg 3 times on 2.8Ghz P4 -// stb_jpeg: 1.34 seconds (MSVC6, default release build) -// stb_jpeg: 1.06 seconds (MSVC6, processor = Pentium Pro) -// IJL11.dll: 1.08 seconds (compiled by intel) -// IJG 1998: 0.98 seconds (MSVC6, makefile provided by IJG) -// IJG 1998: 0.95 seconds (MSVC6, makefile + proc=PPro) - -// huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache - -typedef struct -{ - uint8 fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win - uint16 code[256]; - uint8 values[256]; - uint8 size[257]; - unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' -} huffman; - -typedef struct -{ - #ifdef STBI_SIMD - unsigned short dequant2[4][64]; - #endif - stbi s; - huffman huff_dc[4]; - huffman huff_ac[4]; - uint8 dequant[4][64]; - -// sizes for components, interleaved MCUs - int img_h_max, img_v_max; - int img_mcu_x, img_mcu_y; - int img_mcu_w, img_mcu_h; - -// definition of jpeg image component - struct - { - int id; - int h,v; - int tq; - int hd,ha; - int dc_pred; - - int x,y,w2,h2; - uint8 *data; - void *raw_data; - uint8 *linebuf; - } img_comp[4]; - - uint32 code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop - - int scan_n, order[4]; - int restart_interval, todo; -} jpeg; - -static int build_huffman(huffman *h, int *count) -{ - int i,j,k=0,code; - // build size list for each symbol (from JPEG spec) - for (i=0; i < 16; ++i) - for (j=0; j < count[i]; ++j) - h->size[k++] = (uint8) (i+1); - h->size[k] = 0; - - // compute actual symbols (from jpeg spec) - code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id - h->delta[j] = k - code; - if (h->size[k] == j) { - while (h->size[k] == j) - h->code[k++] = (uint16) (code++); - if (code-1 >= (1 << j)) return e("bad code lengths","Corrupt JPEG"); - } - // compute largest code + 1 for this size, preshifted as needed later - h->maxcode[j] = code << (16-j); - code <<= 1; - } - h->maxcode[j] = 0xffffffff; - - // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); - for (i=0; i < k; ++i) { - int s = h->size[i]; - if (s <= FAST_BITS) { - int c = h->code[i] << (FAST_BITS-s); - int m = 1 << (FAST_BITS-s); - for (j=0; j < m; ++j) { - h->fast[c+j] = (uint8) i; - } - } - } - return 1; -} - -static void grow_buffer_unsafe(jpeg *j) -{ - do { - int b = j->nomore ? 0 : get8(&j->s); - if (b == 0xff) { - int c = get8(&j->s); - if (c != 0) { - j->marker = (unsigned char) c; - j->nomore = 1; - return; - } - } - j->code_buffer |= b << (24 - j->code_bits); - j->code_bits += 8; - } while (j->code_bits <= 24); -} - -// (1 << n) - 1 -static uint32 bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; - -// decode a jpeg huffman value from the bitstream -__forceinline static int decode(jpeg *j, huffman *h) -{ - unsigned int temp; - int c,k; - - if (j->code_bits < 16) grow_buffer_unsafe(j); - - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - k = h->fast[c]; - if (k < 255) { - int s = h->size[k]; - if (s > j->code_bits) - return -1; - j->code_buffer <<= s; - j->code_bits -= s; - return h->values[k]; - } - - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. - temp = j->code_buffer >> 16; - for (k=FAST_BITS+1 ; ; ++k) - if (temp < h->maxcode[k]) - break; - if (k == 17) { - // error! code not found - j->code_bits -= 16; - return -1; - } - - if (k > j->code_bits) - return -1; - - // convert the huffman code to the symbol id - c = ((j->code_buffer >> (32 - k)) & bmask[k]) + h->delta[k]; - assert((((j->code_buffer) >> (32 - h->size[c])) & bmask[h->size[c]]) == h->code[c]); - - // convert the id to a symbol - j->code_bits -= k; - j->code_buffer <<= k; - return h->values[c]; -} - -// combined JPEG 'receive' and JPEG 'extend', since baseline -// always extends everything it receives. -__forceinline static int extend_receive(jpeg *j, int n) -{ - unsigned int m = 1 << (n-1); - unsigned int k; - if (j->code_bits < n) grow_buffer_unsafe(j); - - #if 1 - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~bmask[n]; - k &= bmask[n]; - j->code_bits -= n; - #else - k = (j->code_buffer >> (32 - n)) & bmask[n]; - j->code_bits -= n; - j->code_buffer <<= n; - #endif - // the following test is probably a random branch that won't - // predict well. I tried to table accelerate it but failed. - // maybe it's compiling as a conditional move? - if (k < m) - return (-1 << n) + k + 1; - else - return k; -} - -// given a value that's at position X in the zigzag stream, -// where does it appear in the 8x8 matrix coded as row-major? -static uint8 dezigzag[64+15] = -{ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63 -}; - -// decode one 64-entry block-- -static int decode_block(jpeg *j, short data[64], huffman *hdc, huffman *hac, int b) -{ - int diff,dc,k; - int t = decode(j, hdc); - if (t < 0) return e("bad huffman code","Corrupt JPEG"); - - // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); - - diff = t ? extend_receive(j, t) : 0; - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) dc; - - // decode AC components, see JPEG spec - k = 1; - do { - int r,s; - int rs = decode(j, hac); - if (rs < 0) return e("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (rs != 0xf0) break; // end block - k += 16; - } else { - k += r; - // decode into unzigzag'd location - data[dezigzag[k++]] = (short) extend_receive(j,s); - } - } while (k < 64); - return 1; -} - -// take a -128..127 value and clamp it and convert to 0..255 -__forceinline static uint8 clamp(int x) -{ - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; - } - return (uint8) x; -} - -#define f2f(x) (int) (((x) * 4096 + 0.5)) -#define fsh(x) ((x) << 12) - -// derived from jidctint -- DCT_ISLOW -#define IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ - int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ - p2 = s2; \ - p3 = s6; \ - p1 = (p2+p3) * f2f(0.5411961f); \ - t2 = p1 + p3*f2f(-1.847759065f); \ - t3 = p1 + p2*f2f( 0.765366865f); \ - p2 = s0; \ - p3 = s4; \ - t0 = fsh(p2+p3); \ - t1 = fsh(p2-p3); \ - x0 = t0+t3; \ - x3 = t0-t3; \ - x1 = t1+t2; \ - x2 = t1-t2; \ - t0 = s7; \ - t1 = s5; \ - t2 = s3; \ - t3 = s1; \ - p3 = t0+t2; \ - p4 = t1+t3; \ - p1 = t0+t3; \ - p2 = t1+t2; \ - p5 = (p3+p4)*f2f( 1.175875602f); \ - t0 = t0*f2f( 0.298631336f); \ - t1 = t1*f2f( 2.053119869f); \ - t2 = t2*f2f( 3.072711026f); \ - t3 = t3*f2f( 1.501321110f); \ - p1 = p5 + p1*f2f(-0.899976223f); \ - p2 = p5 + p2*f2f(-2.562915447f); \ - p3 = p3*f2f(-1.961570560f); \ - p4 = p4*f2f(-0.390180644f); \ - t3 += p1+p4; \ - t2 += p2+p3; \ - t1 += p2+p4; \ - t0 += p1+p3; - -#ifdef STBI_SIMD -typedef unsigned short stbi_dequantize_t; -#else -typedef uint8 stbi_dequantize_t; -#endif - -// .344 seconds on 3*anemones.jpg -static void idct_block(uint8 *out, int out_stride, short data[64], stbi_dequantize_t *dequantize) -{ - int i,val[64],*v=val; - stbi_dequantize_t *dq = dequantize; - uint8 *o; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d,++dq, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0] * dq[0] << 2; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - IDCT_1D(d[ 0]*dq[ 0],d[ 8]*dq[ 8],d[16]*dq[16],d[24]*dq[24], - d[32]*dq[32],d[40]*dq[40],d[48]*dq[48],d[56]*dq[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - // so we want to round that, which means adding 0.5 * 1<<17, - // aka 65536. Also, we'll end up with -128 to 127 that we want - // to encode as 0..255 by adding 128, so we'll add that before the shift - x0 += 65536 + (128<<17); - x1 += 65536 + (128<<17); - x2 += 65536 + (128<<17); - x3 += 65536 + (128<<17); - // tried computing the shifts into temps, or'ing the temps to see - // if any were out of range, but that was slower - o[0] = clamp((x0+t3) >> 17); - o[7] = clamp((x0-t3) >> 17); - o[1] = clamp((x1+t2) >> 17); - o[6] = clamp((x1-t2) >> 17); - o[2] = clamp((x2+t1) >> 17); - o[5] = clamp((x2-t1) >> 17); - o[3] = clamp((x3+t0) >> 17); - o[4] = clamp((x3-t0) >> 17); - } -} - -#ifdef STBI_SIMD -static stbi_idct_8x8 stbi_idct_installed = idct_block; - -extern void stbi_install_idct(stbi_idct_8x8 func) -{ - stbi_idct_installed = func; -} -#endif - -#define MARKER_none 0xff -// if there's a pending marker from the entropy stream, return that -// otherwise, fetch from the stream and get a marker. if there's no -// marker, return 0xff, which is never a valid marker value -static uint8 get_marker(jpeg *j) -{ - uint8 x; - if (j->marker != MARKER_none) { x = j->marker; j->marker = MARKER_none; return x; } - x = get8u(&j->s); - if (x != 0xff) return MARKER_none; - while (x == 0xff) - x = get8u(&j->s); - return x; -} - -// in each scan, we'll have scan_n components, and the order -// of the components is specified by order[] -#define RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) - -// after a restart interval, reset the entropy decoder and -// the dc prediction -static void reset(jpeg *j) -{ - j->code_bits = 0; - j->code_buffer = 0; - j->nomore = 0; - j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; - j->marker = MARKER_none; - j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels -} - -static int parse_entropy_coded_data(jpeg *z) -{ - reset(z); - if (z->scan_n == 1) { - int i,j; - #ifdef STBI_SIMD - __declspec(align(16)) - #endif - short data[64]; - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - if (!decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+z->img_comp[n].ha, n)) return 0; - #ifdef STBI_SIMD - stbi_idct_installed(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data, z->dequant2[z->img_comp[n].tq]); - #else - idct_block(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data, z->dequant[z->img_comp[n].tq]); - #endif - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!RESTART(z->marker)) return 1; - reset(z); - } - } - } - } else { // interleaved! - int i,j,k,x,y; - short data[64]; - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x)*8; - int y2 = (j*z->img_comp[n].v + y)*8; - if (!decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+z->img_comp[n].ha, n)) return 0; - #ifdef STBI_SIMD - stbi_idct_installed(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data, z->dequant2[z->img_comp[n].tq]); - #else - idct_block(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data, z->dequant[z->img_comp[n].tq]); - #endif - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!RESTART(z->marker)) return 1; - reset(z); - } - } - } - } - return 1; -} - -static int process_marker(jpeg *z, int m) -{ - int L; - switch (m) { - case MARKER_none: // no marker found - return e("expected marker","Corrupt JPEG"); - - case 0xC2: // SOF - progressive - return e("progressive jpeg","JPEG format not supported (progressive)"); - - case 0xDD: // DRI - specify restart interval - if (get16(&z->s) != 4) return e("bad DRI len","Corrupt JPEG"); - z->restart_interval = get16(&z->s); - return 1; - - case 0xDB: // DQT - define quantization table - L = get16(&z->s)-2; - while (L > 0) { - int q = get8(&z->s); - int p = q >> 4; - int t = q & 15,i; - if (p != 0) return e("bad DQT type","Corrupt JPEG"); - if (t > 3) return e("bad DQT table","Corrupt JPEG"); - for (i=0; i < 64; ++i) - z->dequant[t][dezigzag[i]] = get8u(&z->s); - #ifdef STBI_SIMD - for (i=0; i < 64; ++i) - z->dequant2[t][i] = z->dequant[t][i]; - #endif - L -= 65; - } - return L==0; - - case 0xC4: // DHT - define huffman table - L = get16(&z->s)-2; - while (L > 0) { - uint8 *v; - int sizes[16],i,m=0; - int q = get8(&z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return e("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { - sizes[i] = get8(&z->s); - m += sizes[i]; - } - L -= 17; - if (tc == 0) { - if (!build_huffman(z->huff_dc+th, sizes)) return 0; - v = z->huff_dc[th].values; - } else { - if (!build_huffman(z->huff_ac+th, sizes)) return 0; - v = z->huff_ac[th].values; - } - for (i=0; i < m; ++i) - v[i] = get8u(&z->s); - L -= m; - } - return L==0; - } - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - skip(&z->s, get16(&z->s)-2); - return 1; - } - return 0; -} - -// after we see SOS -static int process_scan_header(jpeg *z) -{ - int i; - int Ls = get16(&z->s); - z->scan_n = get8(&z->s); - if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s.img_n) return e("bad SOS component count","Corrupt JPEG"); - if (Ls != 6+2*z->scan_n) return e("bad SOS len","Corrupt JPEG"); - for (i=0; i < z->scan_n; ++i) { - int id = get8(&z->s), which; - int q = get8(&z->s); - for (which = 0; which < z->s.img_n; ++which) - if (z->img_comp[which].id == id) - break; - if (which == z->s.img_n) return 0; - z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return e("bad DC huff","Corrupt JPEG"); - z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return e("bad AC huff","Corrupt JPEG"); - z->order[i] = which; - } - if (get8(&z->s) != 0) return e("bad SOS","Corrupt JPEG"); - get8(&z->s); // should be 63, but might be 0 - if (get8(&z->s) != 0) return e("bad SOS","Corrupt JPEG"); - - return 1; -} - -static int process_frame_header(jpeg *z, int scan) -{ - stbi *s = &z->s; - int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = get16(s); if (Lf < 11) return e("bad SOF len","Corrupt JPEG"); // JPEG - p = get8(s); if (p != 8) return e("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = get16(s); if (s->img_y == 0) return e("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = get16(s); if (s->img_x == 0) return e("0 width","Corrupt JPEG"); // JPEG requires - c = get8(s); - if (c != 3 && c != 1) return e("bad component count","Corrupt JPEG"); // JFIF requires - s->img_n = c; - for (i=0; i < c; ++i) { - z->img_comp[i].data = NULL; - z->img_comp[i].linebuf = NULL; - } - - if (Lf != 8+3*s->img_n) return e("bad SOF len","Corrupt JPEG"); - - for (i=0; i < s->img_n; ++i) { - z->img_comp[i].id = get8(s); - if (z->img_comp[i].id != i+1) // JFIF requires - if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! - return e("bad component ID","Corrupt JPEG"); - q = get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return e("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return e("bad V","Corrupt JPEG"); - z->img_comp[i].tq = get8(s); if (z->img_comp[i].tq > 3) return e("bad TQ","Corrupt JPEG"); - } - - if (scan != SCAN_load) return 1; - - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return e("too large", "Image too large to decode"); - - for (i=0; i < s->img_n; ++i) { - if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; - if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; - } - - // compute interleaved mcu info - z->img_h_max = h_max; - z->img_v_max = v_max; - z->img_mcu_w = h_max * 8; - z->img_mcu_h = v_max * 8; - z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; - z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; - - for (i=0; i < s->img_n; ++i) { - // number of effective pixels (e.g. for non-interleaved MCU) - z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; - z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; - // to simplify generation, we'll allocate enough memory to decode - // the bogus oversized data from using interleaved MCUs and their - // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't - // discard the extra data until colorspace conversion - z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; - z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; - z->img_comp[i].raw_data = malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); - if (z->img_comp[i].raw_data == NULL) { - for(--i; i >= 0; --i) { - free(z->img_comp[i].raw_data); - z->img_comp[i].data = NULL; - } - return e("outofmem", "Out of memory"); - } - // align blocks for installable-idct using mmx/sse - z->img_comp[i].data = (uint8*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); - z->img_comp[i].linebuf = NULL; - } - - return 1; -} - -// use comparisons since in some cases we handle more than one case (e.g. SOF) -#define DNL(x) ((x) == 0xdc) -#define SOI(x) ((x) == 0xd8) -#define EOI(x) ((x) == 0xd9) -#define SOF(x) ((x) == 0xc0 || (x) == 0xc1) -#define SOS(x) ((x) == 0xda) - -static int decode_jpeg_header(jpeg *z, int scan) -{ - int m; - z->marker = MARKER_none; // initialize cached marker to empty - m = get_marker(z); - if (!SOI(m)) return e("no SOI","Corrupt JPEG"); - if (scan == SCAN_type) return 1; - m = get_marker(z); - while (!SOF(m)) { - if (!process_marker(z,m)) return 0; - m = get_marker(z); - while (m == MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan - if (at_eof(&z->s)) return e("no SOF", "Corrupt JPEG"); - m = get_marker(z); - } - } - if (!process_frame_header(z, scan)) return 0; - return 1; -} - -static int decode_jpeg_image(jpeg *j) -{ - int m; - j->restart_interval = 0; - if (!decode_jpeg_header(j, SCAN_load)) return 0; - m = get_marker(j); - while (!EOI(m)) { - if (SOS(m)) { - if (!process_scan_header(j)) return 0; - if (!parse_entropy_coded_data(j)) return 0; - if (j->marker == MARKER_none ) { - // handle 0s at the end of image data from IP Kamera 9060 - while (!at_eof(&j->s)) { - int x = get8(&j->s); - if (x == 255) { - j->marker = get8u(&j->s); - break; - } else if (x != 0) { - return 0; - } - } - // if we reach eof without hitting a marker, get_marker() below will fail and we'll eventually return 0 - } - } else { - if (!process_marker(j, m)) return 0; - } - m = get_marker(j); - } - return 1; -} - -// static jfif-centered resampling (across block boundaries) - -typedef uint8 *(*resample_row_func)(uint8 *out, uint8 *in0, uint8 *in1, - int w, int hs); - -#define div4(x) ((uint8) ((x) >> 2)) - -static uint8 *resample_row_1(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - STBI_NOTUSED(out); - STBI_NOTUSED(in_far); - STBI_NOTUSED(w); - STBI_NOTUSED(hs); - return in_near; -} - -static uint8* resample_row_v_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // need to generate two samples vertically for every one in input - int i; - STBI_NOTUSED(hs); - for (i=0; i < w; ++i) - out[i] = div4(3*in_near[i] + in_far[i] + 2); - return out; -} - -static uint8* resample_row_h_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // need to generate two samples horizontally for every one in input - int i; - uint8 *input = in_near; - - if (w == 1) { - // if only one sample, can't do any interpolation - out[0] = out[1] = input[0]; - return out; - } - - out[0] = input[0]; - out[1] = div4(input[0]*3 + input[1] + 2); - for (i=1; i < w-1; ++i) { - int n = 3*input[i]+2; - out[i*2+0] = div4(n+input[i-1]); - out[i*2+1] = div4(n+input[i+1]); - } - out[i*2+0] = div4(input[w-2]*3 + input[w-1] + 2); - out[i*2+1] = input[w-1]; - - STBI_NOTUSED(in_far); - STBI_NOTUSED(hs); - - return out; -} - -#define div16(x) ((uint8) ((x) >> 4)) - -static uint8 *resample_row_hv_2(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i,t0,t1; - if (w == 1) { - out[0] = out[1] = div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - out[0] = div4(t1+2); - for (i=1; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = div16(3*t0 + t1 + 8); - out[i*2 ] = div16(3*t1 + t0 + 8); - } - out[w*2-1] = div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} - -static uint8 *resample_row_generic(uint8 *out, uint8 *in_near, uint8 *in_far, int w, int hs) -{ - // resample with nearest-neighbor - int i,j; - in_far = in_far; - for (i=0; i < w; ++i) - for (j=0; j < hs; ++j) - out[i*hs+j] = in_near[i]; - return out; -} - -#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) - -// 0.38 seconds on 3*anemones.jpg (0.25 with processor = Pro) -// VC6 without processor=Pro is generating multiple LEAs per multiply! -static void YCbCr_to_RGB_row(uint8 *out, const uint8 *y, const uint8 *pcb, const uint8 *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 16) + 32768; // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr*float2fixed(1.40200f); - g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); - b = y_fixed + cb*float2fixed(1.77200f); - r >>= 16; - g >>= 16; - b >>= 16; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (uint8)r; - out[1] = (uint8)g; - out[2] = (uint8)b; - out[3] = 255; - out += step; - } -} - -#ifdef STBI_SIMD -static stbi_YCbCr_to_RGB_run stbi_YCbCr_installed = YCbCr_to_RGB_row; - -void stbi_install_YCbCr_to_RGB(stbi_YCbCr_to_RGB_run func) -{ - stbi_YCbCr_installed = func; -} -#endif - - -// clean up the temporary component buffers -static void cleanup_jpeg(jpeg *j) -{ - int i; - for (i=0; i < j->s.img_n; ++i) { - if (j->img_comp[i].data) { - free(j->img_comp[i].raw_data); - j->img_comp[i].data = NULL; - } - if (j->img_comp[i].linebuf) { - free(j->img_comp[i].linebuf); - j->img_comp[i].linebuf = NULL; - } - } -} - -typedef struct -{ - resample_row_func resample; - uint8 *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on -} stbi_resample; - -static uint8 *load_jpeg_image(jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) -{ - int n, decode_n; - // validate req_comp - if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); - z->s.img_n = 0; - - // load a jpeg image from whichever source - if (!decode_jpeg_image(z)) { cleanup_jpeg(z); return NULL; } - - // determine actual number of components to generate - n = req_comp ? req_comp : z->s.img_n; - - if (z->s.img_n == 3 && n < 3) - decode_n = 1; - else - decode_n = z->s.img_n; - - // resample and color-convert - { - int k; - uint i,j; - uint8 *output; - uint8 *coutput[4]; - - stbi_resample res_comp[4]; - - for (k=0; k < decode_n; ++k) { - stbi_resample *r = &res_comp[k]; - - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 - z->img_comp[k].linebuf = (uint8 *) malloc(z->s.img_x + 3); - if (!z->img_comp[k].linebuf) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); } - - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s.img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; - - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = resample_row_hv_2; - else r->resample = resample_row_generic; - } - - // can't error after this so, this is safe - output = (uint8 *) malloc(n * z->s.img_x * z->s.img_y + 1); - if (!output) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); } - - // now go ahead and resample - for (j=0; j < z->s.img_y; ++j) { - uint8 *out = output + n * z->s.img_x * j; - for (k=0; k < decode_n; ++k) { - stbi_resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); - coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { - r->ystep = 0; - r->line0 = r->line1; - if (++r->ypos < z->img_comp[k].y) - r->line1 += z->img_comp[k].w2; - } - } - if (n >= 3) { - uint8 *y = coutput[0]; - if (z->s.img_n == 3) { - #ifdef STBI_SIMD - stbi_YCbCr_installed(out, y, coutput[1], coutput[2], z->s.img_x, n); - #else - YCbCr_to_RGB_row(out, y, coutput[1], coutput[2], z->s.img_x, n); - #endif - } else - for (i=0; i < z->s.img_x; ++i) { - out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 - out += n; - } - } else { - uint8 *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s.img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s.img_x; ++i) *out++ = y[i], *out++ = 255; - } - } - cleanup_jpeg(z); - *out_x = z->s.img_x; - *out_y = z->s.img_y; - if (comp) *comp = z->s.img_n; // report original components, not output - return output; - } -} - -#ifndef STBI_NO_STDIO -unsigned char *stbi_jpeg_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - jpeg j; - start_file(&j.s, f); - return load_jpeg_image(&j, x,y,comp,req_comp); -} - -unsigned char *stbi_jpeg_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_jpeg_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return data; -} -#endif - -unsigned char *stbi_jpeg_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - #ifdef STBI_SMALL_STACK - unsigned char *result; - jpeg *j = (jpeg *) malloc(sizeof(*j)); - start_mem(&j->s, buffer, len); - result = load_jpeg_image(j,x,y,comp,req_comp); - free(j); - return result; - #else - jpeg j; - start_mem(&j.s, buffer,len); - return load_jpeg_image(&j, x,y,comp,req_comp); - #endif -} - -static int stbi_jpeg_info_raw(jpeg *j, int *x, int *y, int *comp) -{ - if (!decode_jpeg_header(j, SCAN_header)) - return 0; - if (x) *x = j->s.img_x; - if (y) *y = j->s.img_y; - if (comp) *comp = j->s.img_n; - return 1; -} - -#ifndef STBI_NO_STDIO -int stbi_jpeg_test_file(FILE *f) -{ - int n,r; - jpeg j; - n = ftell(f); - start_file(&j.s, f); - r = decode_jpeg_header(&j, SCAN_type); - fseek(f,n,SEEK_SET); - return r; -} - -int stbi_jpeg_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - jpeg j; - long n = ftell(f); - int res; - start_file(&j.s, f); - res = stbi_jpeg_info_raw(&j, x, y, comp); - fseek(f, n, SEEK_SET); - return res; -} - -int stbi_jpeg_info(char const *filename, int *x, int *y, int *comp) -{ - FILE *f = fopen(filename, "rb"); - int result; - if (!f) return e("can't fopen", "Unable to open file"); - result = stbi_jpeg_info_from_file(f, x, y, comp); - fclose(f); - return result; -} -#endif - -int stbi_jpeg_test_memory(stbi_uc const *buffer, int len) -{ - jpeg j; - start_mem(&j.s, buffer,len); - return decode_jpeg_header(&j, SCAN_type); -} - -int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - jpeg j; - start_mem(&j.s, buffer, len); - return stbi_jpeg_info_raw(&j, x, y, comp); -} - -#ifndef STBI_NO_STDIO -extern int stbi_jpeg_info (char const *filename, int *x, int *y, int *comp); -extern int stbi_jpeg_info_from_file (FILE *f, int *x, int *y, int *comp); -#endif -extern int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); - -// public domain zlib decode v0.2 Sean Barrett 2006-11-18 -// simple implementation -// - all input must be provided in an upfront buffer -// - all output is written to a single output buffer (can malloc/realloc) -// performance -// - fast huffman - -// fast-way is faster to check than jpeg huffman, but slow way is slower -#define ZFAST_BITS 9 // accelerate all cases in default tables -#define ZFAST_MASK ((1 << ZFAST_BITS) - 1) - -// zlib-style huffman encoding -// (jpegs packs from left, zlib from right, so can't share code) -typedef struct -{ - uint16 fast[1 << ZFAST_BITS]; - uint16 firstcode[16]; - int maxcode[17]; - uint16 firstsymbol[16]; - uint8 size[288]; - uint16 value[288]; -} zhuffman; - -__forceinline static int bitreverse16(int n) -{ - n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); - n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); - n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); - n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); - return n; -} - -__forceinline static int bit_reverse(int v, int bits) -{ - assert(bits <= 16); - // to bit reverse n bits, reverse 16 and shift - // e.g. 11 bits, bit reverse and shift away 5 - return bitreverse16(v) >> (16-bits); -} - -static int zbuild_huffman(zhuffman *z, uint8 *sizelist, int num) -{ - int i,k=0; - int code, next_code[16], sizes[17]; - - // DEFLATE spec for generating codes - memset(sizes, 0, sizeof(sizes)); - memset(z->fast, 255, sizeof(z->fast)); - for (i=0; i < num; ++i) - ++sizes[sizelist[i]]; - sizes[0] = 0; - for (i=1; i < 16; ++i) - assert(sizes[i] <= (1 << i)); - code = 0; - for (i=1; i < 16; ++i) { - next_code[i] = code; - z->firstcode[i] = (uint16) code; - z->firstsymbol[i] = (uint16) k; - code = (code + sizes[i]); - if (sizes[i]) - if (code-1 >= (1 << i)) return e("bad codelengths","Corrupt JPEG"); - z->maxcode[i] = code << (16-i); // preshift for inner loop - code <<= 1; - k += sizes[i]; - } - z->maxcode[16] = 0x10000; // sentinel - for (i=0; i < num; ++i) { - int s = sizelist[i]; - if (s) { - int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; - z->size[c] = (uint8)s; - z->value[c] = (uint16)i; - if (s <= ZFAST_BITS) { - int k = bit_reverse(next_code[s],s); - while (k < (1 << ZFAST_BITS)) { - z->fast[k] = (uint16) c; - k += (1 << s); - } - } - ++next_code[s]; - } - } - return 1; -} - -// zlib-from-memory implementation for PNG reading -// because PNG allows splitting the zlib stream arbitrarily, -// and it's annoying structurally to have PNG call ZLIB call PNG, -// we require PNG read all the IDATs and combine them into a single -// memory buffer - -typedef struct -{ - uint8 *zbuffer, *zbuffer_end; - int num_bits; - uint32 code_buffer; - - char *zout; - char *zout_start; - char *zout_end; - int z_expandable; - - zhuffman z_length, z_distance; -} zbuf; - -__forceinline static int zget8(zbuf *z) -{ - if (z->zbuffer >= z->zbuffer_end) return 0; - return *z->zbuffer++; -} - -static void fill_bits(zbuf *z) -{ - do { - assert(z->code_buffer < (1U << z->num_bits)); - z->code_buffer |= zget8(z) << z->num_bits; - z->num_bits += 8; - } while (z->num_bits <= 24); -} - -__forceinline static unsigned int zreceive(zbuf *z, int n) -{ - unsigned int k; - if (z->num_bits < n) fill_bits(z); - k = z->code_buffer & ((1 << n) - 1); - z->code_buffer >>= n; - z->num_bits -= n; - return k; -} - -__forceinline static int zhuffman_decode(zbuf *a, zhuffman *z) -{ - int b,s,k; - if (a->num_bits < 16) fill_bits(a); - b = z->fast[a->code_buffer & ZFAST_MASK]; - if (b < 0xffff) { - s = z->size[b]; - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; - } - - // not resolved by fast table, so compute it the slow way - // use jpeg approach, which requires MSbits at top - k = bit_reverse(a->code_buffer, 16); - for (s=ZFAST_BITS+1; ; ++s) - if (k < z->maxcode[s]) - break; - if (s == 16) return -1; // invalid code! - // code size is s, so: - b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; - assert(z->size[b] == s); - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; -} - -static int expand(zbuf *z, int n) // need to make room for n bytes -{ - char *q; - int cur, limit; - if (!z->z_expandable) return e("output buffer limit","Corrupt PNG"); - cur = (int) (z->zout - z->zout_start); - limit = (int) (z->zout_end - z->zout_start); - while (cur + n > limit) - limit *= 2; - q = (char *) realloc(z->zout_start, limit); - if (q == NULL) return e("outofmem", "Out of memory"); - z->zout_start = q; - z->zout = q + cur; - z->zout_end = q + limit; - return 1; -} - -static int length_base[31] = { - 3,4,5,6,7,8,9,10,11,13, - 15,17,19,23,27,31,35,43,51,59, - 67,83,99,115,131,163,195,227,258,0,0 }; - -static int length_extra[31]= -{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; - -static int dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, -257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; - -static int dist_extra[32] = -{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static int parse_huffman_block(zbuf *a) -{ - for(;;) { - int z = zhuffman_decode(a, &a->z_length); - if (z < 256) { - if (z < 0) return e("bad huffman code","Corrupt PNG"); // error in huffman codes - if (a->zout >= a->zout_end) if (!expand(a, 1)) return 0; - *a->zout++ = (char) z; - } else { - uint8 *p; - int len,dist; - if (z == 256) return 1; - z -= 257; - len = length_base[z]; - if (length_extra[z]) len += zreceive(a, length_extra[z]); - z = zhuffman_decode(a, &a->z_distance); - if (z < 0) return e("bad huffman code","Corrupt PNG"); - dist = dist_base[z]; - if (dist_extra[z]) dist += zreceive(a, dist_extra[z]); - if (a->zout - a->zout_start < dist) return e("bad dist","Corrupt PNG"); - if (a->zout + len > a->zout_end) if (!expand(a, len)) return 0; - p = (uint8 *) (a->zout - dist); - while (len--) - *a->zout++ = *p++; - } - } -} - -static int compute_huffman_codes(zbuf *a) -{ - static uint8 length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; - zhuffman z_codelength; - uint8 lencodes[286+32+137];//padding for maximum single op - uint8 codelength_sizes[19]; - int i,n; - - int hlit = zreceive(a,5) + 257; - int hdist = zreceive(a,5) + 1; - int hclen = zreceive(a,4) + 4; - - memset(codelength_sizes, 0, sizeof(codelength_sizes)); - for (i=0; i < hclen; ++i) { - int s = zreceive(a,3); - codelength_sizes[length_dezigzag[i]] = (uint8) s; - } - if (!zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; - - n = 0; - while (n < hlit + hdist) { - int c = zhuffman_decode(a, &z_codelength); - assert(c >= 0 && c < 19); - if (c < 16) - lencodes[n++] = (uint8) c; - else if (c == 16) { - c = zreceive(a,2)+3; - memset(lencodes+n, lencodes[n-1], c); - n += c; - } else if (c == 17) { - c = zreceive(a,3)+3; - memset(lencodes+n, 0, c); - n += c; - } else { - assert(c == 18); - c = zreceive(a,7)+11; - memset(lencodes+n, 0, c); - n += c; - } - } - if (n != hlit+hdist) return e("bad codelengths","Corrupt PNG"); - if (!zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; - if (!zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; - return 1; -} - -static int parse_uncompressed_block(zbuf *a) -{ - uint8 header[4]; - int len,nlen,k; - if (a->num_bits & 7) - zreceive(a, a->num_bits & 7); // discard - // drain the bit-packed data into header - k = 0; - while (a->num_bits > 0) { - header[k++] = (uint8) (a->code_buffer & 255); // wtf this warns? - a->code_buffer >>= 8; - a->num_bits -= 8; - } - assert(a->num_bits == 0); - // now fill header the normal way - while (k < 4) - header[k++] = (uint8) zget8(a); - len = header[1] * 256 + header[0]; - nlen = header[3] * 256 + header[2]; - if (nlen != (len ^ 0xffff)) return e("zlib corrupt","Corrupt PNG"); - if (a->zbuffer + len > a->zbuffer_end) return e("read past buffer","Corrupt PNG"); - if (a->zout + len > a->zout_end) - if (!expand(a, len)) return 0; - memcpy(a->zout, a->zbuffer, len); - a->zbuffer += len; - a->zout += len; - return 1; -} - -static int parse_zlib_header(zbuf *a) -{ - int cmf = zget8(a); - int cm = cmf & 15; - /* int cinfo = cmf >> 4; */ - int flg = zget8(a); - if ((cmf*256+flg) % 31 != 0) return e("bad zlib header","Corrupt PNG"); // zlib spec - if (flg & 32) return e("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png - if (cm != 8) return e("bad compression","Corrupt PNG"); // DEFLATE required for png - // window = 1 << (8 + cinfo)... but who cares, we fully buffer output - return 1; -} - -// @TODO: should statically initialize these for optimal thread safety -static uint8 default_length[288], default_distance[32]; -static void init_defaults(void) -{ - int i; // use <= to match clearly with spec - for (i=0; i <= 143; ++i) default_length[i] = 8; - for ( ; i <= 255; ++i) default_length[i] = 9; - for ( ; i <= 279; ++i) default_length[i] = 7; - for ( ; i <= 287; ++i) default_length[i] = 8; - - for (i=0; i <= 31; ++i) default_distance[i] = 5; -} - -int stbi_png_partial; // a quick hack to only allow decoding some of a PNG... I should implement real streaming support instead -static int parse_zlib(zbuf *a, int parse_header) -{ - int final, type; - if (parse_header) - if (!parse_zlib_header(a)) return 0; - a->num_bits = 0; - a->code_buffer = 0; - do { - final = zreceive(a,1); - type = zreceive(a,2); - if (type == 0) { - if (!parse_uncompressed_block(a)) return 0; - } else if (type == 3) { - return 0; - } else { - if (type == 1) { - // use fixed code lengths - if (!default_distance[31]) init_defaults(); - if (!zbuild_huffman(&a->z_length , default_length , 288)) return 0; - if (!zbuild_huffman(&a->z_distance, default_distance, 32)) return 0; - } else { - if (!compute_huffman_codes(a)) return 0; - } - if (!parse_huffman_block(a)) return 0; - } - if (stbi_png_partial && a->zout - a->zout_start > 65536) - break; - } while (!final); - return 1; -} - -static int do_zlib(zbuf *a, char *obuf, int olen, int exp, int parse_header) -{ - a->zout_start = obuf; - a->zout = obuf; - a->zout_end = obuf + olen; - a->z_expandable = exp; - - return parse_zlib(a, parse_header); -} - -char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) -{ - zbuf a; - char *p = (char *) malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (uint8 *) buffer; - a.zbuffer_end = (uint8 *) buffer + len; - if (do_zlib(&a, p, initial_size, 1, 1)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - free(a.zout_start); - return NULL; - } -} - -char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) -{ - return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); -} - -char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) -{ - zbuf a; - char *p = (char *) malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (uint8 *) buffer; - a.zbuffer_end = (uint8 *) buffer + len; - if (do_zlib(&a, p, initial_size, 1, parse_header)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - free(a.zout_start); - return NULL; - } -} - -int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) -{ - zbuf a; - a.zbuffer = (uint8 *) ibuffer; - a.zbuffer_end = (uint8 *) ibuffer + ilen; - if (do_zlib(&a, obuffer, olen, 0, 1)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) -{ - zbuf a; - char *p = (char *) malloc(16384); - if (p == NULL) return NULL; - a.zbuffer = (uint8 *) buffer; - a.zbuffer_end = (uint8 *) buffer+len; - if (do_zlib(&a, p, 16384, 1, 0)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - free(a.zout_start); - return NULL; - } -} - -int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) -{ - zbuf a; - a.zbuffer = (uint8 *) ibuffer; - a.zbuffer_end = (uint8 *) ibuffer + ilen; - if (do_zlib(&a, obuffer, olen, 0, 0)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 -// simple implementation -// - only 8-bit samples -// - no CRC checking -// - allocates lots of intermediate memory -// - avoids problem of streaming data between subsystems -// - avoids explicit window management -// performance -// - uses stb_zlib, a PD zlib implementation with fast huffman decoding - - -typedef struct -{ - uint32 length; - uint32 type; -} chunk; - -#define PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) - -static chunk get_chunk_header(stbi *s) -{ - chunk c; - c.length = get32(s); - c.type = get32(s); - return c; -} - -static int check_png_header(stbi *s) -{ - static uint8 png_sig[8] = { 137,80,78,71,13,10,26,10 }; - int i; - for (i=0; i < 8; ++i) - if (get8(s) != png_sig[i]) return e("bad png sig","Not a PNG"); - return 1; -} - -typedef struct -{ - stbi s; - uint8 *idata, *expanded, *out; -} png; - - -enum { - F_none=0, F_sub=1, F_up=2, F_avg=3, F_paeth=4, - F_avg_first, F_paeth_first -}; - -static uint8 first_row_filter[5] = -{ - F_none, F_sub, F_none, F_avg_first, F_paeth_first -}; - -static int paeth(int a, int b, int c) -{ - int p = a + b - c; - int pa = abs(p-a); - int pb = abs(p-b); - int pc = abs(p-c); - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; -} - -// create the png data from post-deflated data -static int create_png_image_raw(png *a, uint8 *raw, uint32 raw_len, int out_n, uint32 x, uint32 y) -{ - stbi *s = &a->s; - uint32 i,j,stride = x*out_n; - int k; - int img_n = s->img_n; // copy it into a local for later - assert(out_n == s->img_n || out_n == s->img_n+1); - if (stbi_png_partial) y = 1; - a->out = (uint8 *) malloc(x * y * out_n); - if (!a->out) return e("outofmem", "Out of memory"); - if (!stbi_png_partial) { - if (s->img_x == x && s->img_y == y) { - if (raw_len != (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG"); - } else { // interlaced: - if (raw_len < (img_n * x + 1) * y) return e("not enough pixels","Corrupt PNG"); - } - } - for (j=0; j < y; ++j) { - uint8 *cur = a->out + stride*j; - uint8 *prior = cur - stride; - int filter = *raw++; - if (filter > 4) return e("invalid filter","Corrupt PNG"); - // if first row, use special filter that doesn't sample previous row - if (j == 0) filter = first_row_filter[filter]; - // handle first pixel explicitly - for (k=0; k < img_n; ++k) { - switch (filter) { - case F_none : cur[k] = raw[k]; break; - case F_sub : cur[k] = raw[k]; break; - case F_up : cur[k] = raw[k] + prior[k]; break; - case F_avg : cur[k] = raw[k] + (prior[k]>>1); break; - case F_paeth : cur[k] = (uint8) (raw[k] + paeth(0,prior[k],0)); break; - case F_avg_first : cur[k] = raw[k]; break; - case F_paeth_first: cur[k] = raw[k]; break; - } - } - if (img_n != out_n) cur[img_n] = 255; - raw += img_n; - cur += out_n; - prior += out_n; - // this is a little gross, so that we don't switch per-pixel or per-component - if (img_n == out_n) { - #define CASE(f) \ - case f: \ - for (i=x-1; i >= 1; --i, raw+=img_n,cur+=img_n,prior+=img_n) \ - for (k=0; k < img_n; ++k) - switch (filter) { - CASE(F_none) cur[k] = raw[k]; break; - CASE(F_sub) cur[k] = raw[k] + cur[k-img_n]; break; - CASE(F_up) cur[k] = raw[k] + prior[k]; break; - CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break; - CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break; - CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1); break; - CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break; - } - #undef CASE - } else { - assert(img_n+1 == out_n); - #define CASE(f) \ - case f: \ - for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ - for (k=0; k < img_n; ++k) - switch (filter) { - CASE(F_none) cur[k] = raw[k]; break; - CASE(F_sub) cur[k] = raw[k] + cur[k-out_n]; break; - CASE(F_up) cur[k] = raw[k] + prior[k]; break; - CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break; - CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; - CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1); break; - CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break; - } - #undef CASE - } - } - return 1; -} - -static int create_png_image(png *a, uint8 *raw, uint32 raw_len, int out_n, int interlaced) -{ - uint8 *final; - int p; - int save; - if (!interlaced) - return create_png_image_raw(a, raw, raw_len, out_n, a->s.img_x, a->s.img_y); - save = stbi_png_partial; - stbi_png_partial = 0; - - // de-interlacing - final = (uint8 *) malloc(a->s.img_x * a->s.img_y * out_n); - for (p=0; p < 7; ++p) { - int xorig[] = { 0,4,0,2,0,1,0 }; - int yorig[] = { 0,0,4,0,2,0,1 }; - int xspc[] = { 8,8,4,4,2,2,1 }; - int yspc[] = { 8,8,8,4,4,2,2 }; - int i,j,x,y; - // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 - x = (a->s.img_x - xorig[p] + xspc[p]-1) / xspc[p]; - y = (a->s.img_y - yorig[p] + yspc[p]-1) / yspc[p]; - if (x && y) { - if (!create_png_image_raw(a, raw, raw_len, out_n, x, y)) { - free(final); - return 0; - } - for (j=0; j < y; ++j) - for (i=0; i < x; ++i) - memcpy(final + (j*yspc[p]+yorig[p])*a->s.img_x*out_n + (i*xspc[p]+xorig[p])*out_n, - a->out + (j*x+i)*out_n, out_n); - free(a->out); - raw += (x*out_n+1)*y; - raw_len -= (x*out_n+1)*y; - } - } - a->out = final; - - stbi_png_partial = save; - return 1; -} - -static int compute_transparency(png *z, uint8 tc[3], int out_n) -{ - stbi *s = &z->s; - uint32 i, pixel_count = s->img_x * s->img_y; - uint8 *p = z->out; - - // compute color-based transparency, assuming we've - // already got 255 as the alpha value in the output - assert(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i=0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 255); - p += 2; - } - } else { - for (i=0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int expand_palette(png *a, uint8 *palette, int len, int pal_img_n) -{ - uint32 i, pixel_count = a->s.img_x * a->s.img_y; - uint8 *p, *temp_out, *orig = a->out; - - p = (uint8 *) malloc(pixel_count * pal_img_n); - if (p == NULL) return e("outofmem", "Out of memory"); - - // between here and free(out) below, exitting would leak - temp_out = p; - - if (pal_img_n == 3) { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p += 3; - } - } else { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p[3] = palette[n+3]; - p += 4; - } - } - free(a->out); - a->out = temp_out; - - STBI_NOTUSED(len); - - return 1; -} - -static int stbi_unpremultiply_on_load = 0; -static int stbi_de_iphone_flag = 0; - -void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) -{ - stbi_unpremultiply_on_load = flag_true_if_should_unpremultiply; -} -void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) -{ - stbi_de_iphone_flag = flag_true_if_should_convert; -} - -static void stbi_de_iphone(png *z) -{ - stbi *s = &z->s; - uint32 i, pixel_count = s->img_x * s->img_y; - uint8 *p = z->out; - - if (s->img_out_n == 3) { // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - uint8 t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 3; - } - } else { - assert(s->img_out_n == 4); - if (stbi_unpremultiply_on_load) { - // convert bgr to rgb and unpremultiply - for (i=0; i < pixel_count; ++i) { - uint8 a = p[3]; - uint8 t = p[0]; - if (a) { - p[0] = p[2] * 255 / a; - p[1] = p[1] * 255 / a; - p[2] = t * 255 / a; - } else { - p[0] = p[2]; - p[2] = t; - } - p += 4; - } - } else { - // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - uint8 t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 4; - } - } - } -} - -static int parse_png_file(png *z, int scan, int req_comp) -{ - uint8 palette[1024], pal_img_n=0; - uint8 has_trans=0, tc[3]; - uint32 ioff=0, idata_limit=0, i, pal_len=0; - int first=1,k,interlace=0, iphone=0; - stbi *s = &z->s; - - if (!check_png_header(s)) return 0; - - if (scan == SCAN_type) return 1; - - for (;;) { - chunk c = get_chunk_header(s); - switch (c.type) { - case PNG_TYPE('C','g','B','I'): - iphone = stbi_de_iphone_flag; - skip(s, c.length); - break; - case PNG_TYPE('I','H','D','R'): { - int depth,color,comp,filter; - if (!first) return e("multiple IHDR","Corrupt PNG"); - first = 0; - if (c.length != 13) return e("bad IHDR len","Corrupt PNG"); - s->img_x = get32(s); if (s->img_x > (1 << 24)) return e("too large","Very large image (corrupt?)"); - s->img_y = get32(s); if (s->img_y > (1 << 24)) return e("too large","Very large image (corrupt?)"); - depth = get8(s); if (depth != 8) return e("8bit only","PNG not supported: 8-bit only"); - color = get8(s); if (color > 6) return e("bad ctype","Corrupt PNG"); - if (color == 3) pal_img_n = 3; else if (color & 1) return e("bad ctype","Corrupt PNG"); - comp = get8(s); if (comp) return e("bad comp method","Corrupt PNG"); - filter= get8(s); if (filter) return e("bad filter method","Corrupt PNG"); - interlace = get8(s); if (interlace>1) return e("bad interlace method","Corrupt PNG"); - if (!s->img_x || !s->img_y) return e("0-pixel image","Corrupt PNG"); - if (!pal_img_n) { - s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return e("too large", "Image too large to decode"); - if (scan == SCAN_header) return 1; - } else { - // if paletted, then pal_n is our final components, and - // img_n is # components to decompress/filter. - s->img_n = 1; - if ((1 << 30) / s->img_x / 4 < s->img_y) return e("too large","Corrupt PNG"); - // if SCAN_header, have to scan to see if we have a tRNS - } - break; - } - - case PNG_TYPE('P','L','T','E'): { - if (first) return e("first not IHDR", "Corrupt PNG"); - if (c.length > 256*3) return e("invalid PLTE","Corrupt PNG"); - pal_len = c.length / 3; - if (pal_len * 3 != c.length) return e("invalid PLTE","Corrupt PNG"); - for (i=0; i < pal_len; ++i) { - palette[i*4+0] = get8u(s); - palette[i*4+1] = get8u(s); - palette[i*4+2] = get8u(s); - palette[i*4+3] = 255; - } - break; - } - - case PNG_TYPE('t','R','N','S'): { - if (first) return e("first not IHDR", "Corrupt PNG"); - if (z->idata) return e("tRNS after IDAT","Corrupt PNG"); - if (pal_img_n) { - if (scan == SCAN_header) { s->img_n = 4; return 1; } - if (pal_len == 0) return e("tRNS before PLTE","Corrupt PNG"); - if (c.length > pal_len) return e("bad tRNS len","Corrupt PNG"); - pal_img_n = 4; - for (i=0; i < c.length; ++i) - palette[i*4+3] = get8u(s); - } else { - if (!(s->img_n & 1)) return e("tRNS with alpha","Corrupt PNG"); - if (c.length != (uint32) s->img_n*2) return e("bad tRNS len","Corrupt PNG"); - has_trans = 1; - for (k=0; k < s->img_n; ++k) - tc[k] = (uint8) get16(s); // non 8-bit images will be larger - } - break; - } - - case PNG_TYPE('I','D','A','T'): { - if (first) return e("first not IHDR", "Corrupt PNG"); - if (pal_img_n && !pal_len) return e("no PLTE","Corrupt PNG"); - if (scan == SCAN_header) { s->img_n = pal_img_n; return 1; } - if (ioff + c.length > idata_limit) { - uint8 *p; - if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; - while (ioff + c.length > idata_limit) - idata_limit *= 2; - p = (uint8 *) realloc(z->idata, idata_limit); if (p == NULL) return e("outofmem", "Out of memory"); - z->idata = p; - } - if (!getn(s, z->idata+ioff,c.length)) return e("outofdata","Corrupt PNG"); - ioff += c.length; - break; - } - - case PNG_TYPE('I','E','N','D'): { - uint32 raw_len; - if (first) return e("first not IHDR", "Corrupt PNG"); - if (scan != SCAN_load) return 1; - if (z->idata == NULL) return e("no IDAT","Corrupt PNG"); - z->expanded = (uint8 *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, 16384, (int *) &raw_len, !iphone); - if (z->expanded == NULL) return 0; // zlib should set error - free(z->idata); z->idata = NULL; - if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) - s->img_out_n = s->img_n+1; - else - s->img_out_n = s->img_n; - if (!create_png_image(z, z->expanded, raw_len, s->img_out_n, interlace)) return 0; - if (has_trans) - if (!compute_transparency(z, tc, s->img_out_n)) return 0; - if (iphone && s->img_out_n > 2) - stbi_de_iphone(z); - if (pal_img_n) { - // pal_img_n == 3 or 4 - s->img_n = pal_img_n; // record the actual colors we had - s->img_out_n = pal_img_n; - if (req_comp >= 3) s->img_out_n = req_comp; - if (!expand_palette(z, palette, pal_len, s->img_out_n)) - return 0; - } - free(z->expanded); z->expanded = NULL; - return 1; - } - - default: - // if critical, fail - if (first) return e("first not IHDR", "Corrupt PNG"); - if ((c.type & (1 << 29)) == 0) { - #ifndef STBI_NO_FAILURE_STRINGS - // not threadsafe - static char invalid_chunk[] = "XXXX chunk not known"; - invalid_chunk[0] = (uint8) (c.type >> 24); - invalid_chunk[1] = (uint8) (c.type >> 16); - invalid_chunk[2] = (uint8) (c.type >> 8); - invalid_chunk[3] = (uint8) (c.type >> 0); - #endif - return e(invalid_chunk, "PNG not supported: unknown chunk type"); - } - skip(s, c.length); - break; - } - // end of chunk, read and skip CRC - get32(s); - } -} - -static unsigned char *do_png(png *p, int *x, int *y, int *n, int req_comp) -{ - unsigned char *result=NULL; - p->expanded = NULL; - p->idata = NULL; - p->out = NULL; - if (req_comp < 0 || req_comp > 4) return epuc("bad req_comp", "Internal error"); - if (parse_png_file(p, SCAN_load, req_comp)) { - result = p->out; - p->out = NULL; - if (req_comp && req_comp != p->s.img_out_n) { - result = convert_format(result, p->s.img_out_n, req_comp, p->s.img_x, p->s.img_y); - p->s.img_out_n = req_comp; - if (result == NULL) return result; - } - *x = p->s.img_x; - *y = p->s.img_y; - if (n) *n = p->s.img_n; - } - free(p->out); p->out = NULL; - free(p->expanded); p->expanded = NULL; - free(p->idata); p->idata = NULL; - - return result; -} - -#ifndef STBI_NO_STDIO -unsigned char *stbi_png_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - png p; - start_file(&p.s, f); - return do_png(&p, x,y,comp,req_comp); -} - -unsigned char *stbi_png_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_png_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return data; -} -#endif - -unsigned char *stbi_png_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - png p; - start_mem(&p.s, buffer,len); - return do_png(&p, x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -int stbi_png_test_file(FILE *f) -{ - png p; - int n,r; - n = ftell(f); - start_file(&p.s, f); - r = parse_png_file(&p, SCAN_type,STBI_default); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_png_test_memory(stbi_uc const *buffer, int len) -{ - png p; - start_mem(&p.s, buffer, len); - return parse_png_file(&p, SCAN_type,STBI_default); -} - -static int stbi_png_info_raw(png *p, int *x, int *y, int *comp) -{ - if (!parse_png_file(p, SCAN_header, 0)) - return 0; - if (x) *x = p->s.img_x; - if (y) *y = p->s.img_y; - if (comp) *comp = p->s.img_n; - return 1; -} - -#ifndef STBI_NO_STDIO -int stbi_png_info (char const *filename, int *x, int *y, int *comp) -{ - int res; - FILE *f = fopen(filename, "rb"); - if (!f) return 0; - res = stbi_png_info_from_file(f, x, y, comp); - fclose(f); - return res; -} - -int stbi_png_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - png p; - int res; - long n = ftell(f); - start_file(&p.s, f); - res = stbi_png_info_raw(&p, x, y, comp); - fseek(f, n, SEEK_SET); - return res; -} -#endif // !STBI_NO_STDIO - -int stbi_png_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - png p; - start_mem(&p.s, buffer, len); - return stbi_png_info_raw(&p, x, y, comp); -} - -// Microsoft/Windows BMP image - -static int bmp_test(stbi *s) -{ - int sz; - if (get8(s) != 'B') return 0; - if (get8(s) != 'M') return 0; - get32le(s); // discard filesize - get16le(s); // discard reserved - get16le(s); // discard reserved - get32le(s); // discard data offset - sz = get32le(s); - if (sz == 12 || sz == 40 || sz == 56 || sz == 108) return 1; - return 0; -} - -#ifndef STBI_NO_STDIO -int stbi_bmp_test_file (FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s,f); - r = bmp_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_bmp_test_memory (stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return bmp_test(&s); -} - -// returns 0..31 for the highest set bit -static int high_bit(unsigned int z) -{ - int n=0; - if (z == 0) return -1; - if (z >= 0x10000) n += 16, z >>= 16; - if (z >= 0x00100) n += 8, z >>= 8; - if (z >= 0x00010) n += 4, z >>= 4; - if (z >= 0x00004) n += 2, z >>= 2; - if (z >= 0x00002) n += 1, z >>= 1; - return n; -} - -static int bitcount(unsigned int a) -{ - a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 - a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 - a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits - a = (a + (a >> 8)); // max 16 per 8 bits - a = (a + (a >> 16)); // max 32 per 8 bits - return a & 0xff; -} - -static int shiftsigned(int v, int shift, int bits) -{ - int result; - int z=0; - - if (shift < 0) v <<= -shift; - else v >>= shift; - result = v; - - z = bits; - while (z < 8) { - result += v >> z; - z += bits; - } - return result; -} - -static stbi_uc *bmp_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - uint8 *out; - unsigned int mr=0,mg=0,mb=0,ma=0, fake_a=0; - stbi_uc pal[256][4]; - int psize=0,i,j,compress=0,width; - int bpp, flip_vertically, pad, target, offset, hsz; - if (get8(s) != 'B' || get8(s) != 'M') return epuc("not BMP", "Corrupt BMP"); - get32le(s); // discard filesize - get16le(s); // discard reserved - get16le(s); // discard reserved - offset = get32le(s); - hsz = get32le(s); - if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108) return epuc("unknown BMP", "BMP type not supported: unknown"); - if (hsz == 12) { - s->img_x = get16le(s); - s->img_y = get16le(s); - } else { - s->img_x = get32le(s); - s->img_y = get32le(s); - } - if (get16le(s) != 1) return epuc("bad BMP", "bad BMP"); - bpp = get16le(s); - if (bpp == 1) return epuc("monochrome", "BMP type not supported: 1-bit"); - flip_vertically = ((int) s->img_y) > 0; - s->img_y = abs((int) s->img_y); - if (hsz == 12) { - if (bpp < 24) - psize = (offset - 14 - 24) / 3; - } else { - compress = get32le(s); - if (compress == 1 || compress == 2) return epuc("BMP RLE", "BMP type not supported: RLE"); - get32le(s); // discard sizeof - get32le(s); // discard hres - get32le(s); // discard vres - get32le(s); // discard colorsused - get32le(s); // discard max important - if (hsz == 40 || hsz == 56) { - if (hsz == 56) { - get32le(s); - get32le(s); - get32le(s); - get32le(s); - } - if (bpp == 16 || bpp == 32) { - mr = mg = mb = 0; - if (compress == 0) { - if (bpp == 32) { - mr = 0xffu << 16; - mg = 0xffu << 8; - mb = 0xffu << 0; - ma = 0xffu << 24; - fake_a = 1; // @TODO: check for cases like alpha value is all 0 and switch it to 255 - } else { - mr = 31u << 10; - mg = 31u << 5; - mb = 31u << 0; - } - } else if (compress == 3) { - mr = get32le(s); - mg = get32le(s); - mb = get32le(s); - // not documented, but generated by photoshop and handled by mspaint - if (mr == mg && mg == mb) { - // ?!?!? - return epuc("bad BMP", "bad BMP"); - } - } else - return epuc("bad BMP", "bad BMP"); - } - } else { - assert(hsz == 108); - mr = get32le(s); - mg = get32le(s); - mb = get32le(s); - ma = get32le(s); - get32le(s); // discard color space - for (i=0; i < 12; ++i) - get32le(s); // discard color space parameters - } - if (bpp < 16) - psize = (offset - 14 - hsz) >> 2; - } - s->img_n = ma ? 4 : 3; - if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 - target = req_comp; - else - target = s->img_n; // if they want monochrome, we'll post-convert - out = (stbi_uc *) malloc(target * s->img_x * s->img_y); - if (!out) return epuc("outofmem", "Out of memory"); - if (bpp < 16) { - int z=0; - if (psize == 0 || psize > 256) { free(out); return epuc("invalid", "Corrupt BMP"); } - for (i=0; i < psize; ++i) { - pal[i][2] = get8u(s); - pal[i][1] = get8u(s); - pal[i][0] = get8u(s); - if (hsz != 12) get8(s); - pal[i][3] = 255; - } - skip(s, offset - 14 - hsz - psize * (hsz == 12 ? 3 : 4)); - if (bpp == 4) width = (s->img_x + 1) >> 1; - else if (bpp == 8) width = s->img_x; - else { free(out); return epuc("bad bpp", "Corrupt BMP"); } - pad = (-width)&3; - for (j=0; j < (int) s->img_y; ++j) { - for (i=0; i < (int) s->img_x; i += 2) { - int v=get8(s),v2=0; - if (bpp == 4) { - v2 = v & 15; - v >>= 4; - } - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - v = (bpp == 8) ? get8(s) : v2; - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - } - skip(s, pad); - } - } else { - int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; - int z = 0; - int easy=0; - skip(s, offset - 14 - hsz); - if (bpp == 24) width = 3 * s->img_x; - else if (bpp == 16) width = 2*s->img_x; - else /* bpp = 32 and pad = 0 */ width=0; - pad = (-width) & 3; - if (bpp == 24) { - easy = 1; - } else if (bpp == 32) { - if (mb == 0xff && mg == 0xff00 && mr == 0xff000000 && ma == 0xff000000) - easy = 2; - } - if (!easy) { - if (!mr || !mg || !mb) return epuc("bad masks", "Corrupt BMP"); - // right shift amt to put high bit in position #7 - rshift = high_bit(mr)-7; rcount = bitcount(mr); - gshift = high_bit(mg)-7; gcount = bitcount(mr); - bshift = high_bit(mb)-7; bcount = bitcount(mr); - ashift = high_bit(ma)-7; acount = bitcount(mr); - } - for (j=0; j < (int) s->img_y; ++j) { - if (easy) { - for (i=0; i < (int) s->img_x; ++i) { - int a; - out[z+2] = get8u(s); - out[z+1] = get8u(s); - out[z+0] = get8u(s); - z += 3; - a = (easy == 2 ? get8(s) : 255); - if (target == 4) out[z++] = (uint8) a; - } - } else { - for (i=0; i < (int) s->img_x; ++i) { - uint32 v = (bpp == 16 ? get16le(s) : get32le(s)); - int a; - out[z++] = (uint8) shiftsigned(v & mr, rshift, rcount); - out[z++] = (uint8) shiftsigned(v & mg, gshift, gcount); - out[z++] = (uint8) shiftsigned(v & mb, bshift, bcount); - a = (ma ? shiftsigned(v & ma, ashift, acount) : 255); - if (target == 4) out[z++] = (uint8) a; - } - } - skip(s, pad); - } - } - if (flip_vertically) { - stbi_uc t; - for (j=0; j < (int) s->img_y>>1; ++j) { - stbi_uc *p1 = out + j *s->img_x*target; - stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; - for (i=0; i < (int) s->img_x*target; ++i) { - t = p1[i], p1[i] = p2[i], p2[i] = t; - } - } - } - - if (req_comp && req_comp != target) { - out = convert_format(out, target, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // convert_format frees input on failure - } - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = target; - return out; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_bmp_load (char const *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_bmp_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_bmp_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s, f); - return bmp_load(&s, x,y,comp,req_comp); -} -#endif - -stbi_uc *stbi_bmp_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s, buffer, len); - return bmp_load(&s, x,y,comp,req_comp); -} - -// Targa Truevision - TGA -// by Jonathan Dummer - -static int tga_info(stbi *s, int *x, int *y, int *comp) -{ - int tga_w, tga_h, tga_comp; - int sz; - get8u(s); // discard Offset - sz = get8u(s); // color type - if( sz > 1 ) return 0; // only RGB or indexed allowed - sz = get8u(s); // image type - // only RGB or grey allowed, +/- RLE - if ((sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11)) return 0; - get16le(s); // discard palette start - get16le(s); // discard palette length - get8(s); // discard bits per palette color entry - get16le(s); // discard x origin - get16le(s); // discard y origin - tga_w = get16le(s); - if( tga_w < 1 ) return 0; // test width - tga_h = get16le(s); - if( tga_h < 1 ) return 0; // test height - sz = get8(s); // bits per pixel - // only RGB or RGBA or grey allowed - if ((sz != 8) && (sz != 16) && (sz != 24) && (sz != 32)) return 0; - tga_comp = sz; - if (x) *x = tga_w; - if (y) *y = tga_h; - if (comp) *comp = tga_comp / 8; - return 1; // seems to have passed everything -} - -#ifndef STBI_NO_STDIO -int stbi_tga_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - stbi s; - int r; - long n = ftell(f); - start_file(&s, f); - r = tga_info(&s, x, y, comp); - fseek(f, n, SEEK_SET); - return r; -} -#endif - -int stbi_tga_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - stbi s; - start_mem(&s, buffer, len); - return tga_info(&s, x, y, comp); -} - -static int tga_test(stbi *s) -{ - int sz; - get8u(s); // discard Offset - sz = get8u(s); // color type - if ( sz > 1 ) return 0; // only RGB or indexed allowed - sz = get8u(s); // image type - if ( (sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) && (sz != 11) ) return 0; // only RGB or grey allowed, +/- RLE - get16(s); // discard palette start - get16(s); // discard palette length - get8(s); // discard bits per palette color entry - get16(s); // discard x origin - get16(s); // discard y origin - if ( get16(s) < 1 ) return 0; // test width - if ( get16(s) < 1 ) return 0; // test height - sz = get8(s); // bits per pixel - if ( (sz != 8) && (sz != 16) && (sz != 24) && (sz != 32) ) return 0; // only RGB or RGBA or grey allowed - return 1; // seems to have passed everything -} - -#ifndef STBI_NO_STDIO -int stbi_tga_test_file (FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s, f); - r = tga_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_tga_test_memory (stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return tga_test(&s); -} - -static stbi_uc *tga_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - // read in the TGA header stuff - int tga_offset = get8u(s); - int tga_indexed = get8u(s); - int tga_image_type = get8u(s); - int tga_is_RLE = 0; - int tga_palette_start = get16le(s); - int tga_palette_len = get16le(s); - int tga_palette_bits = get8u(s); - int tga_x_origin = get16le(s); - int tga_y_origin = get16le(s); - int tga_width = get16le(s); - int tga_height = get16le(s); - int tga_bits_per_pixel = get8u(s); - int tga_inverted = get8u(s); - // image data - unsigned char *tga_data; - unsigned char *tga_palette = NULL; - int i, j; - unsigned char raw_data[4]; - unsigned char trans_data[4]; - int RLE_count = 0; - int RLE_repeating = 0; - int read_next_pixel = 1; - - // do a tiny bit of precessing - if ( tga_image_type >= 8 ) - { - tga_image_type -= 8; - tga_is_RLE = 1; - } - /* int tga_alpha_bits = tga_inverted & 15; */ - tga_inverted = 1 - ((tga_inverted >> 5) & 1); - - // error check - if ( //(tga_indexed) || - (tga_width < 1) || (tga_height < 1) || - (tga_image_type < 1) || (tga_image_type > 3) || - ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16) && - (tga_bits_per_pixel != 24) && (tga_bits_per_pixel != 32)) - ) - { - return NULL; - } - - // If I'm paletted, then I'll use the number of bits from the palette - if ( tga_indexed ) - { - tga_bits_per_pixel = tga_palette_bits; - } - - // tga info - *x = tga_width; - *y = tga_height; - if ( (req_comp < 1) || (req_comp > 4) ) - { - // just use whatever the file was - req_comp = tga_bits_per_pixel / 8; - *comp = req_comp; - } else - { - // force a new number of components - *comp = tga_bits_per_pixel/8; - } - tga_data = (unsigned char*)malloc( tga_width * tga_height * req_comp ); - - // skip to the data's starting position (offset usually = 0) - skip(s, tga_offset ); - // do I need to load a palette? - if ( tga_indexed ) - { - // any data to skip? (offset usually = 0) - skip(s, tga_palette_start ); - // load the palette - tga_palette = (unsigned char*)malloc( tga_palette_len * tga_palette_bits / 8 ); - if (!getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 )) - return NULL; - } - // load the data - trans_data[0] = trans_data[1] = trans_data[2] = trans_data[3] = 0; - for (i=0; i < tga_width * tga_height; ++i) - { - // if I'm in RLE mode, do I need to get a RLE chunk? - if ( tga_is_RLE ) - { - if ( RLE_count == 0 ) - { - // yep, get the next byte as a RLE command - int RLE_cmd = get8u(s); - RLE_count = 1 + (RLE_cmd & 127); - RLE_repeating = RLE_cmd >> 7; - read_next_pixel = 1; - } else if ( !RLE_repeating ) - { - read_next_pixel = 1; - } - } else - { - read_next_pixel = 1; - } - // OK, if I need to read a pixel, do it now - if ( read_next_pixel ) - { - // load however much data we did have - if ( tga_indexed ) - { - // read in 1 byte, then perform the lookup - int pal_idx = get8u(s); - if ( pal_idx >= tga_palette_len ) - { - // invalid index - pal_idx = 0; - } - pal_idx *= tga_bits_per_pixel / 8; - for (j = 0; j*8 < tga_bits_per_pixel; ++j) - { - raw_data[j] = tga_palette[pal_idx+j]; - } - } else - { - // read in the data raw - for (j = 0; j*8 < tga_bits_per_pixel; ++j) - { - raw_data[j] = get8u(s); - } - } - // convert raw to the intermediate format - switch (tga_bits_per_pixel) - { - case 8: - // Luminous => RGBA - trans_data[0] = raw_data[0]; - trans_data[1] = raw_data[0]; - trans_data[2] = raw_data[0]; - trans_data[3] = 255; - break; - case 16: - // Luminous,Alpha => RGBA - trans_data[0] = raw_data[0]; - trans_data[1] = raw_data[0]; - trans_data[2] = raw_data[0]; - trans_data[3] = raw_data[1]; - break; - case 24: - // BGR => RGBA - trans_data[0] = raw_data[2]; - trans_data[1] = raw_data[1]; - trans_data[2] = raw_data[0]; - trans_data[3] = 255; - break; - case 32: - // BGRA => RGBA - trans_data[0] = raw_data[2]; - trans_data[1] = raw_data[1]; - trans_data[2] = raw_data[0]; - trans_data[3] = raw_data[3]; - break; - } - // clear the reading flag for the next pixel - read_next_pixel = 0; - } // end of reading a pixel - // convert to final format - switch (req_comp) - { - case 1: - // RGBA => Luminance - tga_data[i*req_comp+0] = compute_y(trans_data[0],trans_data[1],trans_data[2]); - break; - case 2: - // RGBA => Luminance,Alpha - tga_data[i*req_comp+0] = compute_y(trans_data[0],trans_data[1],trans_data[2]); - tga_data[i*req_comp+1] = trans_data[3]; - break; - case 3: - // RGBA => RGB - tga_data[i*req_comp+0] = trans_data[0]; - tga_data[i*req_comp+1] = trans_data[1]; - tga_data[i*req_comp+2] = trans_data[2]; - break; - case 4: - // RGBA => RGBA - tga_data[i*req_comp+0] = trans_data[0]; - tga_data[i*req_comp+1] = trans_data[1]; - tga_data[i*req_comp+2] = trans_data[2]; - tga_data[i*req_comp+3] = trans_data[3]; - break; - } - // in case we're in RLE mode, keep counting down - --RLE_count; - } - // do I need to invert the image? - if ( tga_inverted ) - { - for (j = 0; j*2 < tga_height; ++j) - { - int index1 = j * tga_width * req_comp; - int index2 = (tga_height - 1 - j) * tga_width * req_comp; - for (i = tga_width * req_comp; i > 0; --i) - { - unsigned char temp = tga_data[index1]; - tga_data[index1] = tga_data[index2]; - tga_data[index2] = temp; - ++index1; - ++index2; - } - } - } - // clear my palette, if I had one - if ( tga_palette != NULL ) - { - free( tga_palette ); - } - // the things I do to get rid of an error message, and yet keep - // Microsoft's C compilers happy... [8^( - tga_palette_start = tga_palette_len = tga_palette_bits = - tga_x_origin = tga_y_origin = 0; - // OK, done - return tga_data; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_tga_load (char const *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_tga_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_tga_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s, f); - return tga_load(&s, x,y,comp,req_comp); -} -#endif - -stbi_uc *stbi_tga_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s, buffer, len); - return tga_load(&s, x,y,comp,req_comp); -} - - -// ************************************************************************************************* -// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB - -static int psd_test(stbi *s) -{ - if (get32(s) != 0x38425053) return 0; // "8BPS" - else return 1; -} - -#ifndef STBI_NO_STDIO -int stbi_psd_test_file(FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s, f); - r = psd_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_psd_test_memory(stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return psd_test(&s); -} - -static stbi_uc *psd_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - int pixelCount; - int channelCount, compression; - int channel, i, count, len; - int w,h; - uint8 *out; - - // Check identifier - if (get32(s) != 0x38425053) // "8BPS" - return epuc("not PSD", "Corrupt PSD image"); - - // Check file type version. - if (get16(s) != 1) - return epuc("wrong version", "Unsupported version of PSD image"); - - // Skip 6 reserved bytes. - skip(s, 6 ); - - // Read the number of channels (R, G, B, A, etc). - channelCount = get16(s); - if (channelCount < 0 || channelCount > 16) - return epuc("wrong channel count", "Unsupported number of channels in PSD image"); - - // Read the rows and columns of the image. - h = get32(s); - w = get32(s); - - // Make sure the depth is 8 bits. - if (get16(s) != 8) - return epuc("unsupported bit depth", "PSD bit depth is not 8 bit"); - - // Make sure the color mode is RGB. - // Valid options are: - // 0: Bitmap - // 1: Grayscale - // 2: Indexed color - // 3: RGB color - // 4: CMYK color - // 7: Multichannel - // 8: Duotone - // 9: Lab color - if (get16(s) != 3) - return epuc("wrong color format", "PSD is not in RGB color format"); - - // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) - skip(s,get32(s) ); - - // Skip the image resources. (resolution, pen tool paths, etc) - skip(s, get32(s) ); - - // Skip the reserved data. - skip(s, get32(s) ); - - // Find out if the data is compressed. - // Known values: - // 0: no compression - // 1: RLE compressed - compression = get16(s); - if (compression > 1) - return epuc("bad compression", "PSD has an unknown compression format"); - - // Create the destination image. - out = (stbi_uc *) malloc(4 * w*h); - if (!out) return epuc("outofmem", "Out of memory"); - pixelCount = w*h; - - // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); - - // Finally, the image data. - if (compression) { - // RLE as used by .PSD and .TIFF - // Loop until you get the number of unpacked bytes you are expecting: - // Read the next source byte into n. - // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. - // Else if n is 128, noop. - // Endloop - - // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, - // which we're going to just skip. - skip(s, h * channelCount * 2 ); - - // Read the RLE data by channel. - for (channel = 0; channel < 4; channel++) { - uint8 *p; - - p = out+channel; - if (channel >= channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++) *p = (channel == 3 ? 255 : 0), p += 4; - } else { - // Read the RLE data. - count = 0; - while (count < pixelCount) { - len = get8(s); - if (len == 128) { - // No-op. - } else if (len < 128) { - // Copy next len+1 bytes literally. - len++; - count += len; - while (len) { - *p = get8u(s); - p += 4; - len--; - } - } else if (len > 128) { - uint8 val; - // Next -len+1 bytes in the dest are replicated from next source byte. - // (Interpret len as a negative 8-bit int.) - len ^= 0x0FF; - len += 2; - val = get8u(s); - count += len; - while (len) { - *p = val; - p += 4; - len--; - } - } - } - } - } - - } else { - // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit value for each pixel in the image. - - // Read the data by channel. - for (channel = 0; channel < 4; channel++) { - uint8 *p; - - p = out + channel; - if (channel > channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++) *p = channel == 3 ? 255 : 0, p += 4; - } else { - // Read the data. - for (i = 0; i < pixelCount; i++) - *p = get8u(s), p += 4; - } - } - } - - if (req_comp && req_comp != 4) { - out = convert_format(out, 4, req_comp, w, h); - if (out == NULL) return out; // convert_format frees input on failure - } - - if (comp) *comp = channelCount; - *y = h; - *x = w; - - return out; -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_psd_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_psd_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_psd_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s, f); - return psd_load(&s, x,y,comp,req_comp); -} -#endif - -stbi_uc *stbi_psd_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s, buffer, len); - return psd_load(&s, x,y,comp,req_comp); -} - -// ************************************************************************************************* -// Softimage PIC loader -// by Tom Seddon -// -// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format -// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ - -static int pic_is4(stbi *s,const char *str) -{ - int i; - for (i=0; i<4; ++i) - if (get8(s) != (stbi_uc)str[i]) - return 0; - - return 1; -} - -static int pic_test(stbi *s) -{ - int i; - - if (!pic_is4(s,"\x53\x80\xF6\x34")) - return 0; - - for(i=0;i<84;++i) - get8(s); - - if (!pic_is4(s,"PICT")) - return 0; - - return 1; -} - -typedef struct -{ - stbi_uc size,type,channel; -} pic_packet_t; - -static stbi_uc *pic_readval(stbi *s, int channel, stbi_uc *dest) -{ - int mask=0x80, i; - - for (i=0; i<4; ++i, mask>>=1) { - if (channel & mask) { - if (at_eof(s)) return epuc("bad file","PIC file too short"); - dest[i]=get8u(s); - } - } - - return dest; -} - -static void pic_copyval(int channel,stbi_uc *dest,const stbi_uc *src) -{ - int mask=0x80,i; - - for (i=0;i<4; ++i, mask>>=1) - if (channel&mask) - dest[i]=src[i]; -} - -static stbi_uc *pic_load2(stbi *s,int width,int height,int *comp, stbi_uc *result) -{ - int act_comp=0,num_packets=0,y,chained; - pic_packet_t packets[10]; - - // this will (should...) cater for even some bizarre stuff like having data - // for the same channel in multiple packets. - do { - pic_packet_t *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return epuc("bad format","too many packets"); - - packet = &packets[num_packets++]; - - chained = get8(s); - packet->size = get8u(s); - packet->type = get8u(s); - packet->channel = get8u(s); - - act_comp |= packet->channel; - - if (at_eof(s)) return epuc("bad file","file too short (reading packets)"); - if (packet->size != 8) return epuc("bad format","packet isn't 8bpp"); - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? - - for(y=0; ytype) { - default: - return epuc("bad format","packet has bad compression type"); - - case 0: {//uncompressed - int x; - - for(x=0;xchannel,dest)) - return 0; - break; - } - - case 1://Pure RLE - { - int left=width, i; - - while (left>0) { - stbi_uc count,value[4]; - - count=get8u(s); - if (at_eof(s)) return epuc("bad file","file too short (pure read count)"); - - if (count > left) - count = (uint8) left; - - if (!pic_readval(s,packet->channel,value)) return 0; - - for(i=0; ichannel,dest,value); - left -= count; - } - } - break; - - case 2: {//Mixed RLE - int left=width; - while (left>0) { - int count = get8(s), i; - if (at_eof(s)) return epuc("bad file","file too short (mixed read count)"); - - if (count >= 128) { // Repeated - stbi_uc value[4]; - int i; - - if (count==128) - count = get16(s); - else - count -= 127; - if (count > left) - return epuc("bad file","scanline overrun"); - - if (!pic_readval(s,packet->channel,value)) - return 0; - - for(i=0;ichannel,dest,value); - } else { // Raw - ++count; - if (count>left) return epuc("bad file","scanline overrun"); - - for(i=0;ichannel,dest)) - return 0; - } - left-=count; - } - break; - } - } - } - } - - return result; -} - -static stbi_uc *pic_load(stbi *s,int *px,int *py,int *comp,int req_comp) -{ - stbi_uc *result; - int i, x,y; - - for (i=0; i<92; ++i) - get8(s); - - x = get16(s); - y = get16(s); - if (at_eof(s)) return epuc("bad file","file too short (pic header)"); - if ((1 << 28) / x < y) return epuc("too large", "Image too large to decode"); - - get32(s); //skip `ratio' - get16(s); //skip `fields' - get16(s); //skip `pad' - - // intermediate buffer is RGBA - result = (stbi_uc *) malloc(x*y*4); - memset(result, 0xff, x*y*4); - - if (!pic_load2(s,x,y,comp, result)) { - free(result); - result=0; - } - *px = x; - *py = y; - if (req_comp == 0) req_comp = *comp; - result=convert_format(result,4,req_comp,x,y); - - return result; -} - -int stbi_pic_test_memory(stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s,buffer,len); - return pic_test(&s); -} - -stbi_uc *stbi_pic_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s,buffer,len); - return pic_load(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -int stbi_pic_test_file(FILE *f) -{ - int result; - long l = ftell(f); - stbi s; - start_file(&s,f); - result = pic_test(&s); - fseek(f,l,SEEK_SET); - return result; -} - -stbi_uc *stbi_pic_load(char const *filename,int *x, int *y, int *comp, int req_comp) -{ - stbi_uc *result; - FILE *f=fopen(filename,"rb"); - if (!f) return 0; - result = stbi_pic_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -stbi_uc *stbi_pic_load_from_file(FILE *f,int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s,f); - return pic_load(&s,x,y,comp,req_comp); -} -#endif - -// ************************************************************************************************* -// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb -typedef struct stbi_gif_lzw_struct { - int16 prefix; - uint8 first; - uint8 suffix; -} stbi_gif_lzw; - -typedef struct stbi_gif_struct -{ - int w,h; - stbi_uc *out; // output buffer (always 4 components) - int flags, bgindex, ratio, transparent, eflags; - uint8 pal[256][4]; - uint8 lpal[256][4]; - stbi_gif_lzw codes[4096]; - uint8 *color_table; - int parse, step; - int lflags; - int start_x, start_y; - int max_x, max_y; - int cur_x, cur_y; - int line_size; -} stbi_gif; - -static int gif_test(stbi *s) -{ - int sz; - if (get8(s) != 'G' || get8(s) != 'I' || get8(s) != 'F' || get8(s) != '8') return 0; - sz = get8(s); - if (sz != '9' && sz != '7') return 0; - if (get8(s) != 'a') return 0; - return 1; -} - -#ifndef STBI_NO_STDIO -int stbi_gif_test_file (FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s,f); - r = gif_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -int stbi_gif_test_memory (stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return gif_test(&s); -} - -static void stbi_gif_parse_colortable(stbi *s, uint8 pal[256][4], int num_entries, int transp) -{ - int i; - for (i=0; i < num_entries; ++i) { - pal[i][2] = get8u(s); - pal[i][1] = get8u(s); - pal[i][0] = get8u(s); - pal[i][3] = transp ? 0 : 255; - } -} - -static int stbi_gif_header(stbi *s, stbi_gif *g, int *comp, int is_info) -{ - uint8 version; - if (get8(s) != 'G' || get8(s) != 'I' || get8(s) != 'F' || get8(s) != '8') - return e("not GIF", "Corrupt GIF"); - - version = get8u(s); - if (version != '7' && version != '9') return e("not GIF", "Corrupt GIF"); - if (get8(s) != 'a') return e("not GIF", "Corrupt GIF"); - - failure_reason = ""; - g->w = get16le(s); - g->h = get16le(s); - g->flags = get8(s); - g->bgindex = get8(s); - g->ratio = get8(s); - g->transparent = -1; - - if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments - - if (is_info) return 1; - - if (g->flags & 0x80) - stbi_gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); - - return 1; -} - -static int stbi_gif_info_raw(stbi *s, int *x, int *y, int *comp) -{ - stbi_gif g; - if (!stbi_gif_header(s, &g, comp, 1)) return 0; - if (x) *x = g.w; - if (y) *y = g.h; - return 1; -} - -static void stbi_out_gif_code(stbi_gif *g, uint16 code) -{ - uint8 *p, *c; - - // recurse to decode the prefixes, since the linked-list is backwards, - // and working backwards through an interleaved image would be nasty - if (g->codes[code].prefix >= 0) - stbi_out_gif_code(g, g->codes[code].prefix); - - if (g->cur_y >= g->max_y) return; - - p = &g->out[g->cur_x + g->cur_y]; - c = &g->color_table[g->codes[code].suffix * 4]; - - if (c[3] >= 128) { - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = c[3]; - } - g->cur_x += 4; - - if (g->cur_x >= g->max_x) { - g->cur_x = g->start_x; - g->cur_y += g->step; - - while (g->cur_y >= g->max_y && g->parse > 0) { - g->step = (1 << g->parse) * g->line_size; - g->cur_y = g->start_y + (g->step >> 1); - --g->parse; - } - } -} - -static uint8 *stbi_process_gif_raster(stbi *s, stbi_gif *g) -{ - uint8 lzw_cs; - int32 len, code; - uint32 first; - int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; - stbi_gif_lzw *p; - - lzw_cs = get8u(s); - clear = 1 << lzw_cs; - first = 1; - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - bits = 0; - valid_bits = 0; - for (code = 0; code < clear; code++) { - g->codes[code].prefix = -1; - g->codes[code].first = (uint8) code; - g->codes[code].suffix = (uint8) code; - } - - // support no starting clear code - avail = clear+2; - oldcode = -1; - - len = 0; - for(;;) { - if (valid_bits < codesize) { - if (len == 0) { - len = get8(s); // start new block - if (len == 0) - return g->out; - } - --len; - bits |= (int32) get8(s) << valid_bits; - valid_bits += 8; - } else { - int32 code = bits & codemask; - bits >>= codesize; - valid_bits -= codesize; - // @OPTIMIZE: is there some way we can accelerate the non-clear path? - if (code == clear) { // clear code - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - avail = clear + 2; - oldcode = -1; - first = 0; - } else if (code == clear + 1) { // end of stream code - skip(s, len); - while ((len = get8(s)) > 0) - skip(s,len); - return g->out; - } else if (code <= avail) { - if (first) return epuc("no clear code", "Corrupt GIF"); - - if (oldcode >= 0) { - p = &g->codes[avail++]; - if (avail > 4096) return epuc("too many codes", "Corrupt GIF"); - p->prefix = (int16) oldcode; - p->first = g->codes[oldcode].first; - p->suffix = (code == avail) ? p->first : g->codes[code].first; - } else if (code == avail) - return epuc("illegal code in raster", "Corrupt GIF"); - - stbi_out_gif_code(g, (uint16) code); - - if ((avail & codemask) == 0 && avail <= 0x0FFF) { - codesize++; - codemask = (1 << codesize) - 1; - } - - oldcode = code; - } else { - return epuc("illegal code in raster", "Corrupt GIF"); - } - } - } -} - -static void stbi_fill_gif_background(stbi_gif *g) -{ - int i; - uint8 *c = g->pal[g->bgindex]; - // @OPTIMIZE: write a dword at a time - for (i = 0; i < g->w * g->h * 4; i += 4) { - uint8 *p = &g->out[i]; - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = c[3]; - } -} - -// this function is designed to support animated gifs, although stb_image doesn't support it -static uint8 *stbi_gif_load_next(stbi *s, stbi_gif *g, int *comp, int req_comp) -{ - int i; - uint8 *old_out = 0; - - if (g->out == 0) { - if (!stbi_gif_header(s, g, comp,0)) return 0; // failure_reason set by stbi_gif_header - g->out = (uint8 *) malloc(4 * g->w * g->h); - if (g->out == 0) return epuc("outofmem", "Out of memory"); - stbi_fill_gif_background(g); - } else { - // animated-gif-only path - if (((g->eflags & 0x1C) >> 2) == 3) { - old_out = g->out; - g->out = (uint8 *) malloc(4 * g->w * g->h); - if (g->out == 0) return epuc("outofmem", "Out of memory"); - memcpy(g->out, old_out, g->w*g->h*4); - } - } - - for (;;) { - switch (get8(s)) { - case 0x2C: /* Image Descriptor */ - { - int32 x, y, w, h; - uint8 *o; - - x = get16le(s); - y = get16le(s); - w = get16le(s); - h = get16le(s); - if (((x + w) > (g->w)) || ((y + h) > (g->h))) - return epuc("bad Image Descriptor", "Corrupt GIF"); - - g->line_size = g->w * 4; - g->start_x = x * 4; - g->start_y = y * g->line_size; - g->max_x = g->start_x + w * 4; - g->max_y = g->start_y + h * g->line_size; - g->cur_x = g->start_x; - g->cur_y = g->start_y; - - g->lflags = get8(s); - - if (g->lflags & 0x40) { - g->step = 8 * g->line_size; // first interlaced spacing - g->parse = 3; - } else { - g->step = g->line_size; - g->parse = 0; - } - - if (g->lflags & 0x80) { - stbi_gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); - g->color_table = (uint8 *) g->lpal; - } else if (g->flags & 0x80) { - for (i=0; i < 256; ++i) // @OPTIMIZE: reset only the previous transparent - g->pal[i][3] = 255; - if (g->transparent >= 0 && (g->eflags & 0x01)) - g->pal[g->transparent][3] = 0; - g->color_table = (uint8 *) g->pal; - } else - return epuc("missing color table", "Corrupt GIF"); - - o = stbi_process_gif_raster(s, g); - if (o == NULL) return NULL; - - if (req_comp && req_comp != 4) - o = convert_format(o, 4, req_comp, g->w, g->h); - return o; - } - - case 0x21: // Comment Extension. - { - int len; - if (get8(s) == 0xF9) { // Graphic Control Extension. - len = get8(s); - if (len == 4) { - g->eflags = get8(s); - get16le(s); // delay - g->transparent = get8(s); - } else { - skip(s, len); - break; - } - } - while ((len = get8(s)) != 0) - skip(s, len); - break; - } - - case 0x3B: // gif stream termination code - return (uint8 *) 1; - - default: - return epuc("unknown code", "Corrupt GIF"); - } - } -} - -#ifndef STBI_NO_STDIO -stbi_uc *stbi_gif_load (char const *filename, int *x, int *y, int *comp, int req_comp) -{ - uint8 *data; - FILE *f = fopen(filename, "rb"); - if (!f) return NULL; - data = stbi_gif_load_from_file(f, x,y,comp,req_comp); - fclose(f); - return data; -} - -stbi_uc *stbi_gif_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp) -{ - uint8 *u = 0; - stbi s; - stbi_gif g={0}; - start_file(&s, f); - - u = stbi_gif_load_next(&s, &g, comp, req_comp); - if (u == (void *) 1) u = 0; // end of animated gif marker - if (u) { - *x = g.w; - *y = g.h; - } - - return u; -} -#endif - -stbi_uc *stbi_gif_load_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - uint8 *u = 0; - stbi s; - stbi_gif g={0}; - start_mem(&s, buffer, len); - u = stbi_gif_load_next(&s, &g, comp, req_comp); - if (u == (void *) 1) u = 0; // end of animated gif marker - if (u) { - *x = g.w; - *y = g.h; - } - return u; -} - -#ifndef STBI_NO_STDIO -int stbi_gif_info (char const *filename, int *x, int *y, int *comp) -{ - int res; - FILE *f = fopen(filename, "rb"); - if (!f) return 0; - res = stbi_gif_info_from_file(f, x, y, comp); - fclose(f); - return res; -} - -int stbi_gif_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - stbi s; - int res; - long n = ftell(f); - start_file(&s, f); - res = stbi_gif_info_raw(&s, x, y, comp); - fseek(f, n, SEEK_SET); - return res; -} -#endif // !STBI_NO_STDIO - -int stbi_gif_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - stbi s; - start_mem(&s, buffer, len); - return stbi_gif_info_raw(&s, x, y, comp); -} - - - - -// ************************************************************************************************* -// Radiance RGBE HDR loader -// originally by Nicolas Schulz -#ifndef STBI_NO_HDR -static int hdr_test(stbi *s) -{ - const char *signature = "#?RADIANCE\n"; - int i; - for (i=0; signature[i]; ++i) - if (get8(s) != signature[i]) - return 0; - return 1; -} - -int stbi_hdr_test_memory(stbi_uc const *buffer, int len) -{ - stbi s; - start_mem(&s, buffer, len); - return hdr_test(&s); -} - -#ifndef STBI_NO_STDIO -int stbi_hdr_test_file(FILE *f) -{ - stbi s; - int r,n = ftell(f); - start_file(&s, f); - r = hdr_test(&s); - fseek(f,n,SEEK_SET); - return r; -} -#endif - -#define HDR_BUFLEN 1024 -static char *hdr_gettoken(stbi *z, char *buffer) -{ - int len=0; - char c = '\0'; - - c = (char) get8(z); - - while (!at_eof(z) && c != '\n') { - buffer[len++] = c; - if (len == HDR_BUFLEN-1) { - // flush to end of line - while (!at_eof(z) && get8(z) != '\n') - ; - break; - } - c = (char) get8(z); - } - - buffer[len] = 0; - return buffer; -} - -static void hdr_convert(float *output, stbi_uc *input, int req_comp) -{ - if ( input[3] != 0 ) { - float f1; - // Exponent - f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); - if (req_comp <= 2) - output[0] = (input[0] + input[1] + input[2]) * f1 / 3; - else { - output[0] = input[0] * f1; - output[1] = input[1] * f1; - output[2] = input[2] * f1; - } - if (req_comp == 2) output[1] = 1; - if (req_comp == 4) output[3] = 1; - } else { - switch (req_comp) { - case 4: output[3] = 1; /* fallthrough */ - case 3: output[0] = output[1] = output[2] = 0; - break; - case 2: output[1] = 1; /* fallthrough */ - case 1: output[0] = 0; - break; - } - } -} - - -static float *hdr_load(stbi *s, int *x, int *y, int *comp, int req_comp) -{ - char buffer[HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - float *hdr_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - - - // Check identifier - if (strcmp(hdr_gettoken(s,buffer), "#?RADIANCE") != 0) - return epf("not HDR", "Corrupt HDR image"); - - // Parse header - for(;;) { - token = hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return epf("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return epf("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = strtol(token, NULL, 10); - - *x = width; - *y = height; - - *comp = 3; - if (req_comp == 0) req_comp = 3; - - // Read data - hdr_data = (float *) malloc(height * width * req_comp * sizeof(float)); - - // Load image data - // image data is stored as some number of sca - if ( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - stbi_uc rgbe[4]; - main_decode_loop: - getn(s, rgbe, 4); - hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); - } - } - } else { - // Read RLE-encoded data - scanline = NULL; - - for (j = 0; j < height; ++j) { - c1 = get8(s); - c2 = get8(s); - len = get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - uint8 rgbe[4]; - rgbe[0] = (uint8) c1; - rgbe[1] = (uint8) c2; - rgbe[2] = (uint8) len; - rgbe[3] = (uint8) get8u(s); - hdr_convert(hdr_data, rgbe, req_comp); - i = 1; - j = 0; - free(scanline); - goto main_decode_loop; // yes, this makes no sense - } - len <<= 8; - len |= get8(s); - if (len != width) { free(hdr_data); free(scanline); return epf("invalid decoded scanline length", "corrupt HDR"); } - if (scanline == NULL) scanline = (stbi_uc *) malloc(width * 4); - - for (k = 0; k < 4; ++k) { - i = 0; - while (i < width) { - count = get8u(s); - if (count > 128) { - // Run - value = get8u(s); - count -= 128; - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = get8u(s); - } - } - } - for (i=0; i < width; ++i) - hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); - } - free(scanline); - } - - return hdr_data; -} - -#ifndef STBI_NO_STDIO -float *stbi_hdr_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_file(&s,f); - return hdr_load(&s,x,y,comp,req_comp); -} -#endif - -float *stbi_hdr_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi s; - start_mem(&s,buffer, len); - return hdr_load(&s,x,y,comp,req_comp); -} - -#endif // STBI_NO_HDR - - -#ifndef STBI_NO_STDIO -int stbi_info(char const *filename, int *x, int *y, int *comp) -{ - FILE *f = fopen(filename, "rb"); - int result; - if (!f) return e("can't fopen", "Unable to open file"); - result = stbi_info_from_file(f, x, y, comp); - fclose(f); - return result; -} - -int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - if (stbi_jpeg_info_from_file(f, x, y, comp)) - return 1; - if (stbi_png_info_from_file(f, x, y, comp)) - return 1; - if (stbi_gif_info_from_file(f, x, y, comp)) - return 1; - // @TODO: stbi_bmp_info_from_file - // @TODO: stbi_psd_info_from_file - #ifndef STBI_NO_HDR - // @TODO: stbi_hdr_info_from_file - #endif - // test tga last because it's a crappy test! - if (stbi_tga_info_from_file(f, x, y, comp)) - return 1; - return e("unknown image type", "Image not of any known type, or corrupt"); -} -#endif // !STBI_NO_STDIO - -int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - if (stbi_jpeg_info_from_memory(buffer, len, x, y, comp)) - return 1; - if (stbi_png_info_from_memory(buffer, len, x, y, comp)) - return 1; - if (stbi_gif_info_from_memory(buffer, len, x, y, comp)) - return 1; - // @TODO: stbi_bmp_info_from_memory - // @TODO: stbi_psd_info_from_memory - #ifndef STBI_NO_HDR - // @TODO: stbi_hdr_info_from_memory - #endif - // test tga last because it's a crappy test! - if (stbi_tga_info_from_memory(buffer, len, x, y, comp)) - return 1; - return e("unknown image type", "Image not of any known type, or corrupt"); -} - -#endif // STBI_HEADER_FILE_ONLY - -/* - revision history: - 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville - 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) - 1.27 (2010-08-01) - cast-to-uint8 to fix warnings - 1.26 (2010-07-24) - fix bug in file buffering for PNG reported by SpartanJ - 1.25 (2010-07-17) - refix trans_data warning (Won Chun) - 1.24 (2010-07-12) - perf improvements reading from files on platforms with lock-heavy fgetc() - minor perf improvements for jpeg - deprecated type-specific functions so we'll get feedback if they're needed - attempt to fix trans_data warning (Won Chun) - 1.23 fixed bug in iPhone support - 1.22 (2010-07-10) - removed image *writing* support - removed image *writing* support - stbi_info support from Jetro Lauha - GIF support from Jean-Marc Lienher - iPhone PNG-extensions from James Brown - warning-fixes from Nicolas Schulz and Janez Zemva (i.e. Janez (U+017D)emva) - 1.21 fix use of 'uint8' in header (reported by jon blow) - 1.20 added support for Softimage PIC, by Tom Seddon - 1.19 bug in interlaced PNG corruption check (found by ryg) - 1.18 2008-08-02 - fix a threading bug (local mutable static) - 1.17 support interlaced PNG - 1.16 major bugfix - convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug - header-file-only version (#define STBI_HEADER_FILE_ONLY before including) - 1.13 threadsafe - 1.12 const qualifiers in the API - 1.11 Support installable IDCT, colorspace conversion routines - 1.10 Fixes for 64-bit (don't use "unsigned long") - optimized upsampling by Fabian "ryg" Giesen - 1.09 Fix format-conversion for PSD code (bad global variables!) - 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz - 1.07 attempt to fix C++ warning/errors again - 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi_bmp_load() and stbi_tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) - 0.97 jpeg errors on too large a file; also catch another malloc failure - 0.96 fix detection of invalid v value - particleman@mollyrocket forum - 0.95 during header scan, seek to markers in case of padding - 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same - 0.93 handle jpegtran output; verbose errors - 0.92 read 4,8,16,24,32-bit BMP files of several formats - 0.91 output 24-bit Windows 3.0 BMP files - 0.90 fix a few more warnings; bump version number to approach 1.0 - 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd - 0.60 fix compiling as c++ - 0.59 fix warnings: merge Dave Moore's -Wall fixes - 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less - than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen - 0.55 fix bug: restart_interval not initialized to 0 - 0.54 allow NULL for 'int *comp' - 0.53 fix bug in png 3->4; speedup png decoding - 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments - 0.51 obey req_comp requests, 1-component jpegs return as 1-component, - on 'test' only check type, not whether we support this variant -*/ +/* stb_image - v2.25 - public domain image loader - http://nothings.org/stb + no warranty implied; use at your own risk + + Do this: + #define STB_IMAGE_IMPLEMENTATION + before you include this file in *one* C or C++ file to create the implementation. + + // i.e. it should look like this: + #include ... + #include ... + #include ... + #define STB_IMAGE_IMPLEMENTATION + #include "stb_image.h" + + You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. + And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free + + + QUICK NOTES: + Primarily of interest to game developers and other people who can + avoid problematic images and only need the trivial interface + + JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) + PNG 1/2/4/8/16-bit-per-channel + + TGA (not sure what subset, if a subset) + BMP non-1bpp, non-RLE + PSD (composited view only, no extra channels, 8/16 bit-per-channel) + + GIF (*comp always reports as 4-channel) + HDR (radiance rgbE format) + PIC (Softimage PIC) + PNM (PPM and PGM binary only) + + Animated GIF still needs a proper API, but here's one way to do it: + http://gist.github.com/urraka/685d9a6340b26b830d49 + + - decode from memory or through FILE (define STBI_NO_STDIO to remove code) + - decode from arbitrary I/O callbacks + - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) + + Full documentation under "DOCUMENTATION" below. + + +LICENSE + + See end of file for license information. + +RECENT REVISION HISTORY: + + 2.25 (2020-02-02) fix warnings + 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically + 2.23 (2019-08-11) fix clang static analysis warning + 2.22 (2019-03-04) gif fixes, fix warnings + 2.21 (2019-02-25) fix typo in comment + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs + 2.19 (2018-02-11) fix warning + 2.18 (2018-01-30) fix warnings + 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings + 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes + 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs + 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes + 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes + 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 + RGB-format JPEG; remove white matting in PSD; + allocate large structures on the stack; + correct channel count for PNG & BMP + 2.10 (2016-01-22) avoid warning introduced in 2.09 + 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED + + See end of file for full revision history. + + + ============================ Contributors ========================= + + Image formats Extensions, features + Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) + Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) + Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) + Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) + Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) + Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) + Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) + github:urraka (animated gif) Junggon Kim (PNM comments) + Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) + socks-the-fox (16-bit PNG) + Jeremy Sawicki (handle all ImageNet JPGs) + Optimizations & bugfixes Mikhail Morozov (1-bit BMP) + Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) + Arseny Kapoulkine + John-Mark Allen + Carmelo J Fdez-Aguera + + Bug & warning fixes + Marc LeBlanc David Woo Guillaume George Martins Mozeiko + Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan + Dave Moore Roy Eltham Hayaki Saito Nathan Reed + Won Chun Luke Graham Johan Duparc Nick Verigakis + the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh + Janez Zemva John Bartholomew Michal Cichon github:romigrou + Jonathan Blow Ken Hamada Tero Hanninen github:svdijk + Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar + Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex + Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 + Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw + Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus + Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo + Christian Floisand Kevin Schmidt JR Smith github:darealshinji + Brad Weinberger Matvey Cherevko github:Michaelangel007 + Blazej Dariusz Roszkowski Alexander Veselov +*/ + +#ifndef STBI_INCLUDE_STB_IMAGE_H +#define STBI_INCLUDE_STB_IMAGE_H + +// DOCUMENTATION +// +// Limitations: +// - no 12-bit-per-channel JPEG +// - no JPEGs with arithmetic coding +// - GIF always returns *comp=4 +// +// Basic usage (see HDR discussion below for HDR usage): +// int x,y,n; +// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); +// // ... process data if not NULL ... +// // ... x = width, y = height, n = # 8-bit components per pixel ... +// // ... replace '0' with '1'..'4' to force that many components per pixel +// // ... but 'n' will always be the number that it would have been if you said 0 +// stbi_image_free(data) +// +// Standard parameters: +// int *x -- outputs image width in pixels +// int *y -- outputs image height in pixels +// int *channels_in_file -- outputs # of image components in image file +// int desired_channels -- if non-zero, # of image components requested in result +// +// The return value from an image loader is an 'unsigned char *' which points +// to the pixel data, or NULL on an allocation failure or if the image is +// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, +// with each pixel consisting of N interleaved 8-bit components; the first +// pixel pointed to is top-left-most in the image. There is no padding between +// image scanlines or between pixels, regardless of format. The number of +// components N is 'desired_channels' if desired_channels is non-zero, or +// *channels_in_file otherwise. If desired_channels is non-zero, +// *channels_in_file has the number of components that _would_ have been +// output otherwise. E.g. if you set desired_channels to 4, you will always +// get RGBA output, but you can check *channels_in_file to see if it's trivially +// opaque because e.g. there were only 3 channels in the source image. +// +// An output image with N components has the following components interleaved +// in this order in each pixel: +// +// N=#comp components +// 1 grey +// 2 grey, alpha +// 3 red, green, blue +// 4 red, green, blue, alpha +// +// If image loading fails for any reason, the return value will be NULL, +// and *x, *y, *channels_in_file will be unchanged. The function +// stbi_failure_reason() can be queried for an extremely brief, end-user +// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS +// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly +// more user-friendly ones. +// +// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. +// +// =========================================================================== +// +// UNICODE: +// +// If compiling for Windows and you wish to use Unicode filenames, compile +// with +// #define STBI_WINDOWS_UTF8 +// and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert +// Windows wchar_t filenames to utf8. +// +// =========================================================================== +// +// Philosophy +// +// stb libraries are designed with the following priorities: +// +// 1. easy to use +// 2. easy to maintain +// 3. good performance +// +// Sometimes I let "good performance" creep up in priority over "easy to maintain", +// and for best performance I may provide less-easy-to-use APIs that give higher +// performance, in addition to the easy-to-use ones. Nevertheless, it's important +// to keep in mind that from the standpoint of you, a client of this library, +// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. +// +// Some secondary priorities arise directly from the first two, some of which +// provide more explicit reasons why performance can't be emphasized. +// +// - Portable ("ease of use") +// - Small source code footprint ("easy to maintain") +// - No dependencies ("ease of use") +// +// =========================================================================== +// +// I/O callbacks +// +// I/O callbacks allow you to read from arbitrary sources, like packaged +// files or some other source. Data read from callbacks are processed +// through a small internal buffer (currently 128 bytes) to try to reduce +// overhead. +// +// The three functions you must define are "read" (reads some bytes of data), +// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). +// +// =========================================================================== +// +// SIMD support +// +// The JPEG decoder will try to automatically use SIMD kernels on x86 when +// supported by the compiler. For ARM Neon support, you must explicitly +// request it. +// +// (The old do-it-yourself SIMD API is no longer supported in the current +// code.) +// +// On x86, SSE2 will automatically be used when available based on a run-time +// test; if not, the generic C versions are used as a fall-back. On ARM targets, +// the typical path is to have separate builds for NEON and non-NEON devices +// (at least this is true for iOS and Android). Therefore, the NEON support is +// toggled by a build flag: define STBI_NEON to get NEON loops. +// +// If for some reason you do not want to use any of SIMD code, or if +// you have issues compiling it, you can disable it entirely by +// defining STBI_NO_SIMD. +// +// =========================================================================== +// +// HDR image support (disable by defining STBI_NO_HDR) +// +// stb_image supports loading HDR images in general, and currently the Radiance +// .HDR file format specifically. You can still load any file through the existing +// interface; if you attempt to load an HDR file, it will be automatically remapped +// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; +// both of these constants can be reconfigured through this interface: +// +// stbi_hdr_to_ldr_gamma(2.2f); +// stbi_hdr_to_ldr_scale(1.0f); +// +// (note, do not use _inverse_ constants; stbi_image will invert them +// appropriately). +// +// Additionally, there is a new, parallel interface for loading files as +// (linear) floats to preserve the full dynamic range: +// +// float *data = stbi_loadf(filename, &x, &y, &n, 0); +// +// If you load LDR images through this interface, those images will +// be promoted to floating point values, run through the inverse of +// constants corresponding to the above: +// +// stbi_ldr_to_hdr_scale(1.0f); +// stbi_ldr_to_hdr_gamma(2.2f); +// +// Finally, given a filename (or an open file or memory block--see header +// file for details) containing image data, you can query for the "most +// appropriate" interface to use (that is, whether the image is HDR or +// not), using: +// +// stbi_is_hdr(char *filename); +// +// =========================================================================== +// +// iPhone PNG support: +// +// By default we convert iphone-formatted PNGs back to RGB, even though +// they are internally encoded differently. You can disable this conversion +// by calling stbi_convert_iphone_png_to_rgb(0), in which case +// you will always just get the native iphone "format" through (which +// is BGR stored in RGB). +// +// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per +// pixel to remove any premultiplied alpha *only* if the image file explicitly +// says there's premultiplied data (currently only happens in iPhone images, +// and only if iPhone convert-to-rgb processing is on). +// +// =========================================================================== +// +// ADDITIONAL CONFIGURATION +// +// - You can suppress implementation of any of the decoders to reduce +// your code footprint by #defining one or more of the following +// symbols before creating the implementation. +// +// STBI_NO_JPEG +// STBI_NO_PNG +// STBI_NO_BMP +// STBI_NO_PSD +// STBI_NO_TGA +// STBI_NO_GIF +// STBI_NO_HDR +// STBI_NO_PIC +// STBI_NO_PNM (.ppm and .pgm) +// +// - You can request *only* certain decoders and suppress all other ones +// (this will be more forward-compatible, as addition of new decoders +// doesn't require you to disable them explicitly): +// +// STBI_ONLY_JPEG +// STBI_ONLY_PNG +// STBI_ONLY_BMP +// STBI_ONLY_PSD +// STBI_ONLY_TGA +// STBI_ONLY_GIF +// STBI_ONLY_HDR +// STBI_ONLY_PIC +// STBI_ONLY_PNM (.ppm and .pgm) +// +// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still +// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB +// + + +#ifndef STBI_NO_STDIO +#include +#endif // STBI_NO_STDIO + +#define STBI_VERSION 1 + +enum +{ + STBI_default = 0, // only used for desired_channels + + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 +}; + +#include +typedef unsigned char stbi_uc; +typedef unsigned short stbi_us; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef STBIDEF +#ifdef STB_IMAGE_STATIC +#define STBIDEF static +#else +#define STBIDEF extern +#endif +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// PRIMARY API - works on images of any type +// + +// +// load image by filename, open file, or memory buffer +// + +typedef struct +{ + int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read + void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative + int (*eof) (void *user); // returns nonzero if we are at end of file/data +} stbi_io_callbacks; + +//////////////////////////////////// +// +// 8-bits-per-channel interface +// + +STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO +STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +// for stbi_load_from_file, file pointer is left pointing immediately after image +#endif + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +#endif + +#ifdef STBI_WINDOWS_UTF8 +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); +#endif + +//////////////////////////////////// +// +// 16-bits-per-channel interface +// + +STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO +STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +#endif + +//////////////////////////////////// +// +// float-per-channel interface +// +#ifndef STBI_NO_LINEAR + STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); + + #ifndef STBI_NO_STDIO + STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); + #endif +#endif + +#ifndef STBI_NO_HDR + STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); + STBIDEF void stbi_hdr_to_ldr_scale(float scale); +#endif // STBI_NO_HDR + +#ifndef STBI_NO_LINEAR + STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); + STBIDEF void stbi_ldr_to_hdr_scale(float scale); +#endif // STBI_NO_LINEAR + +// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr (char const *filename); +STBIDEF int stbi_is_hdr_from_file(FILE *f); +#endif // STBI_NO_STDIO + + +// get a VERY brief reason for failure +// on most compilers (and ALL modern mainstream compilers) this is threadsafe +STBIDEF const char *stbi_failure_reason (void); + +// free the loaded image -- this is just free() +STBIDEF void stbi_image_free (void *retval_from_stbi_load); + +// get image dimensions & components without fully decoding +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit (char const *filename); +STBIDEF int stbi_is_16_bit_from_file(FILE *f); +#endif + + + +// for image formats that explicitly notate that they have premultiplied alpha, +// we just return the colors as stored in the file. set this flag to force +// unpremultiplication. results are undefined if the unpremultiply overflow. +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); + +// indicate whether we should process iphone images back to canonical format, +// or just pass them through "as-is" +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); + +// flip the image vertically, so the first pixel in the output array is the bottom left +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); + +// as above, but only applies to images loaded on the thread that calls the function +// this function is only available if your compiler supports thread-local variables; +// calling it will fail to link if your compiler doesn't +STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); + +// ZLIB client - used by PNG, available for other purposes + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); +STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + +STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + + +#ifdef __cplusplus +} +#endif + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBI_INCLUDE_STB_IMAGE_H + +#ifdef STB_IMAGE_IMPLEMENTATION + +#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ + || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ + || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ + || defined(STBI_ONLY_ZLIB) + #ifndef STBI_ONLY_JPEG + #define STBI_NO_JPEG + #endif + #ifndef STBI_ONLY_PNG + #define STBI_NO_PNG + #endif + #ifndef STBI_ONLY_BMP + #define STBI_NO_BMP + #endif + #ifndef STBI_ONLY_PSD + #define STBI_NO_PSD + #endif + #ifndef STBI_ONLY_TGA + #define STBI_NO_TGA + #endif + #ifndef STBI_ONLY_GIF + #define STBI_NO_GIF + #endif + #ifndef STBI_ONLY_HDR + #define STBI_NO_HDR + #endif + #ifndef STBI_ONLY_PIC + #define STBI_NO_PIC + #endif + #ifndef STBI_ONLY_PNM + #define STBI_NO_PNM + #endif +#endif + +#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) +#define STBI_NO_ZLIB +#endif + + +#include +#include // ptrdiff_t on osx +#include +#include +#include + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +#include // ldexp, pow +#endif + +#ifndef STBI_NO_STDIO +#include +#endif + +#ifndef STBI_ASSERT +#include +#define STBI_ASSERT(x) assert(x) +#endif + +#ifdef __cplusplus +#define STBI_EXTERN extern "C" +#else +#define STBI_EXTERN extern +#endif + + +#ifndef _MSC_VER + #ifdef __cplusplus + #define stbi_inline inline + #else + #define stbi_inline + #endif +#else + #define stbi_inline __forceinline +#endif + +#ifndef STBI_NO_THREAD_LOCALS + #if defined(__cplusplus) && __cplusplus >= 201103L + #define STBI_THREAD_LOCAL thread_local + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define STBI_THREAD_LOCAL _Thread_local + #elif defined(__GNUC__) + #define STBI_THREAD_LOCAL __thread + #elif defined(_MSC_VER) + #define STBI_THREAD_LOCAL __declspec(thread) +#endif +#endif + +#ifdef _MSC_VER +typedef unsigned short stbi__uint16; +typedef signed short stbi__int16; +typedef unsigned int stbi__uint32; +typedef signed int stbi__int32; +#else +#include +typedef uint16_t stbi__uint16; +typedef int16_t stbi__int16; +typedef uint32_t stbi__uint32; +typedef int32_t stbi__int32; +#endif + +// should produce compiler error if size is wrong +typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBI_NOTUSED(v) (void)(v) +#else +#define STBI_NOTUSED(v) (void)sizeof(v) +#endif + +#ifdef _MSC_VER +#define STBI_HAS_LROTL +#endif + +#ifdef STBI_HAS_LROTL + #define stbi_lrot(x,y) _lrotl(x,y) +#else + #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) +#endif + +#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) +// ok +#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) +// ok +#else +#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." +#endif + +#ifndef STBI_MALLOC +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p,newsz) realloc(p,newsz) +#define STBI_FREE(p) free(p) +#endif + +#ifndef STBI_REALLOC_SIZED +#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) +#endif + +// x86/x64 detection +#if defined(__x86_64__) || defined(_M_X64) +#define STBI__X64_TARGET +#elif defined(__i386) || defined(_M_IX86) +#define STBI__X86_TARGET +#endif + +#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +// gcc doesn't support sse2 intrinsics unless you compile with -msse2, +// which in turn means it gets to use SSE2 everywhere. This is unfortunate, +// but previous attempts to provide the SSE2 functions with runtime +// detection caused numerous issues. The way architecture extensions are +// exposed in GCC/Clang is, sadly, not really suited for one-file libs. +// New behavior: if compiled with -msse2, we use SSE2 without any +// detection; if not, we don't use it at all. +#define STBI_NO_SIMD +#endif + +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +// +// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the +// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. +// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not +// simultaneously enabling "-mstackrealign". +// +// See https://github.com/nothings/stb/issues/81 for more information. +// +// So default to no SSE2 on 32-bit MinGW. If you've read this far and added +// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. +#define STBI_NO_SIMD +#endif + +#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) +#define STBI_SSE2 +#include + +#ifdef _MSC_VER + +#if _MSC_VER >= 1400 // not VC6 +#include // __cpuid +static int stbi__cpuid3(void) +{ + int info[4]; + __cpuid(info,1); + return info[3]; +} +#else +static int stbi__cpuid3(void) +{ + int res; + __asm { + mov eax,1 + cpuid + mov res,edx + } + return res; +} +#endif + +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name + +#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) +static int stbi__sse2_available(void) +{ + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; +} +#endif + +#else // assume GCC-style if not VC++ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) + +#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) +static int stbi__sse2_available(void) +{ + // If we're even attempting to compile this on GCC/Clang, that means + // -msse2 is on, which means the compiler is allowed to use SSE2 + // instructions at will, and so are we. + return 1; +} +#endif + +#endif +#endif + +// ARM NEON +#if defined(STBI_NO_SIMD) && defined(STBI_NEON) +#undef STBI_NEON +#endif + +#ifdef STBI_NEON +#include +// assume GCC or Clang on ARM targets +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +#ifndef STBI_SIMD_ALIGN +#define STBI_SIMD_ALIGN(type, name) type name +#endif + +/////////////////////////////////////////////// +// +// stbi__context struct and start_xxx functions + +// stbi__context structure is our basic context used by all images, so it +// contains all the IO context, plus some basic image information +typedef struct +{ + stbi__uint32 img_x, img_y; + int img_n, img_out_n; + + stbi_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + stbi_uc buffer_start[128]; + + stbi_uc *img_buffer, *img_buffer_end; + stbi_uc *img_buffer_original, *img_buffer_original_end; +} stbi__context; + + +static void stbi__refill_buffer(stbi__context *s); + +// initialize a memory-decode context +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) +{ + s->io.read = NULL; + s->read_from_callbacks = 0; + s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; + s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; +} + +// initialize a callback-based context +static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) +{ + s->io = *c; + s->io_user_data = user; + s->buflen = sizeof(s->buffer_start); + s->read_from_callbacks = 1; + s->img_buffer_original = s->buffer_start; + stbi__refill_buffer(s); + s->img_buffer_original_end = s->img_buffer_end; +} + +#ifndef STBI_NO_STDIO + +static int stbi__stdio_read(void *user, char *data, int size) +{ + return (int) fread(data,1,size,(FILE*) user); +} + +static void stbi__stdio_skip(void *user, int n) +{ + fseek((FILE*) user, n, SEEK_CUR); +} + +static int stbi__stdio_eof(void *user) +{ + return feof((FILE*) user); +} + +static stbi_io_callbacks stbi__stdio_callbacks = +{ + stbi__stdio_read, + stbi__stdio_skip, + stbi__stdio_eof, +}; + +static void stbi__start_file(stbi__context *s, FILE *f) +{ + stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); +} + +//static void stop_file(stbi__context *s) { } + +#endif // !STBI_NO_STDIO + +static void stbi__rewind(stbi__context *s) +{ + // conceptually rewind SHOULD rewind to the beginning of the stream, + // but we just rewind to the beginning of the initial buffer, because + // we only use it after doing 'test', which only ever looks at at most 92 bytes + s->img_buffer = s->img_buffer_original; + s->img_buffer_end = s->img_buffer_original_end; +} + +enum +{ + STBI_ORDER_RGB, + STBI_ORDER_BGR +}; + +typedef struct +{ + int bits_per_channel; + int num_channels; + int channel_order; +} stbi__result_info; + +#ifndef STBI_NO_JPEG +static int stbi__jpeg_test(stbi__context *s); +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNG +static int stbi__png_test(stbi__context *s); +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__png_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_BMP +static int stbi__bmp_test(stbi__context *s); +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_TGA +static int stbi__tga_test(stbi__context *s); +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s); +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__psd_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_HDR +static int stbi__hdr_test(stbi__context *s); +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_test(stbi__context *s); +static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_GIF +static int stbi__gif_test(stbi__context *s); +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNM +static int stbi__pnm_test(stbi__context *s); +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +static +#ifdef STBI_THREAD_LOCAL +STBI_THREAD_LOCAL +#endif +const char *stbi__g_failure_reason; + +STBIDEF const char *stbi_failure_reason(void) +{ + return stbi__g_failure_reason; +} + +#ifndef STBI_NO_FAILURE_STRINGS +static int stbi__err(const char *str) +{ + stbi__g_failure_reason = str; + return 0; +} +#endif + +static void *stbi__malloc(size_t size) +{ + return STBI_MALLOC(size); +} + +// stb_image uses ints pervasively, including for offset calculations. +// therefore the largest decoded image size we can support with the +// current code, even on 64-bit targets, is INT_MAX. this is not a +// significant limitation for the intended use case. +// +// we do, however, need to make sure our size calculations don't +// overflow. hence a few helper functions for size calculations that +// multiply integers together, making sure that they're non-negative +// and no overflow occurs. + +// return 1 if the sum is valid, 0 on overflow. +// negative terms are considered invalid. +static int stbi__addsizes_valid(int a, int b) +{ + if (b < 0) return 0; + // now 0 <= b <= INT_MAX, hence also + // 0 <= INT_MAX - b <= INTMAX. + // And "a + b <= INT_MAX" (which might overflow) is the + // same as a <= INT_MAX - b (no overflow) + return a <= INT_MAX - b; +} + +// returns 1 if the product is valid, 0 on overflow. +// negative factors are considered invalid. +static int stbi__mul2sizes_valid(int a, int b) +{ + if (a < 0 || b < 0) return 0; + if (b == 0) return 1; // mul-by-0 is always safe + // portable way to check for no overflows in a*b + return a <= INT_MAX/b; +} + +#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) +// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow +static int stbi__mad2sizes_valid(int a, int b, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); +} +#endif + +// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow +static int stbi__mad3sizes_valid(int a, int b, int c, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && + stbi__addsizes_valid(a*b*c, add); +} + +// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && + stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); +} +#endif + +#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) +// mallocs with size overflow checking +static void *stbi__malloc_mad2(int a, int b, int add) +{ + if (!stbi__mad2sizes_valid(a, b, add)) return NULL; + return stbi__malloc(a*b + add); +} +#endif + +static void *stbi__malloc_mad3(int a, int b, int c, int add) +{ + if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; + return stbi__malloc(a*b*c + add); +} + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) +{ + if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; + return stbi__malloc(a*b*c*d + add); +} +#endif + +// stbi__err - error +// stbi__errpf - error returning pointer to float +// stbi__errpuc - error returning pointer to unsigned char + +#ifdef STBI_NO_FAILURE_STRINGS + #define stbi__err(x,y) 0 +#elif defined(STBI_FAILURE_USERMSG) + #define stbi__err(x,y) stbi__err(y) +#else + #define stbi__err(x,y) stbi__err(x) +#endif + +#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) +#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) + +STBIDEF void stbi_image_free(void *retval_from_stbi_load) +{ + STBI_FREE(retval_from_stbi_load); +} + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +#endif + +#ifndef STBI_NO_HDR +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); +#endif + +static int stbi__vertically_flip_on_load_global = 0; + +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) +{ + stbi__vertically_flip_on_load_global = flag_true_if_should_flip; +} + +#ifndef STBI_THREAD_LOCAL +#define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global +#else +static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; + +STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) +{ + stbi__vertically_flip_on_load_local = flag_true_if_should_flip; + stbi__vertically_flip_on_load_set = 1; +} + +#define stbi__vertically_flip_on_load (stbi__vertically_flip_on_load_set \ + ? stbi__vertically_flip_on_load_local \ + : stbi__vertically_flip_on_load_global) +#endif // STBI_THREAD_LOCAL + +static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +{ + memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields + ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed + ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order + ri->num_channels = 0; + + #ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_PNG + if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_BMP + if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_GIF + if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_PSD + if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); + #else + STBI_NOTUSED(bpc); + #endif + #ifndef STBI_NO_PIC + if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_PNM + if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); + #endif + + #ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); + return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } + #endif + + #ifndef STBI_NO_TGA + // test tga last because it's a crappy test! + if (stbi__tga_test(s)) + return stbi__tga_load(s,x,y,comp,req_comp, ri); + #endif + + return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); +} + +static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) +{ + int i; + int img_len = w * h * channels; + stbi_uc *reduced; + + reduced = (stbi_uc *) stbi__malloc(img_len); + if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling + + STBI_FREE(orig); + return reduced; +} + +static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) +{ + int i; + int img_len = w * h * channels; + stbi__uint16 *enlarged; + + enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); + if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff + + STBI_FREE(orig); + return enlarged; +} + +static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) +{ + int row; + size_t bytes_per_row = (size_t)w * bytes_per_pixel; + stbi_uc temp[2048]; + stbi_uc *bytes = (stbi_uc *)image; + + for (row = 0; row < (h>>1); row++) { + stbi_uc *row0 = bytes + row*bytes_per_row; + stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; + // swap row0 with row1 + size_t bytes_left = bytes_per_row; + while (bytes_left) { + size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); + memcpy(temp, row0, bytes_copy); + memcpy(row0, row1, bytes_copy); + memcpy(row1, temp, bytes_copy); + row0 += bytes_copy; + row1 += bytes_copy; + bytes_left -= bytes_copy; + } + } +} + +#ifndef STBI_NO_GIF +static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) +{ + int slice; + int slice_size = w * h * bytes_per_pixel; + + stbi_uc *bytes = (stbi_uc *)image; + for (slice = 0; slice < z; ++slice) { + stbi__vertical_flip(bytes, w, h, bytes_per_pixel); + bytes += slice_size; + } +} +#endif + +static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); + + if (result == NULL) + return NULL; + + if (ri.bits_per_channel != 8) { + STBI_ASSERT(ri.bits_per_channel == 16); + result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 8; + } + + // @TODO: move stbi__convert_format to here + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); + } + + return (unsigned char *) result; +} + +static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); + + if (result == NULL) + return NULL; + + if (ri.bits_per_channel != 16) { + STBI_ASSERT(ri.bits_per_channel == 8); + result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 16; + } + + // @TODO: move stbi__convert_format16 to here + // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); + } + + return (stbi__uint16 *) result; +} + +#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) +{ + if (stbi__vertically_flip_on_load && result != NULL) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); + } +} +#endif + +#ifndef STBI_NO_STDIO + +#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) +STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); +STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); +#endif + +#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) +{ + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); +} +#endif + +static FILE *stbi__fopen(char const *filename, char const *mode) +{ + FILE *f; +#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) + return 0; + + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) + return 0; + +#if _MSC_VER >= 1400 + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; +#else + f = _wfopen(wFilename, wMode); +#endif + +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f=0; +#else + f = fopen(filename, mode); +#endif + return f; +} + + +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + unsigned char *result; + if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_file(&s,f); + result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__uint16 *result; + stbi__context s; + stbi__start_file(&s,f); + result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + stbi__uint16 *result; + if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file_16(f,x,y,comp,req_comp); + fclose(f); + return result; +} + + +#endif //!STBI_NO_STDIO + +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); +} + +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); +} + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); +} + +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); +} + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_mem(&s,buffer,len); + + result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); + if (stbi__vertically_flip_on_load) { + stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); + } + + return result; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; + #ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + stbi__result_info ri; + float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); + if (hdr_data) + stbi__float_postprocess(hdr_data,x,y,comp,req_comp); + return hdr_data; + } + #endif + data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); + if (data) + return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); +} + +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} + +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} + +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + float *result; + FILE *f = stbi__fopen(filename, "rb"); + if (!f) return stbi__errpf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_file(&s,f); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} +#endif // !STBI_NO_STDIO + +#endif // !STBI_NO_LINEAR + +// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is +// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always +// reports false! + +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(buffer); + STBI_NOTUSED(len); + return 0; + #endif +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr (char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result=0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; +} + +STBIDEF int stbi_is_hdr_from_file(FILE *f) +{ + #ifndef STBI_NO_HDR + long pos = ftell(f); + int res; + stbi__context s; + stbi__start_file(&s,f); + res = stbi__hdr_test(&s); + fseek(f, pos, SEEK_SET); + return res; + #else + STBI_NOTUSED(f); + return 0; + #endif +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(clbk); + STBI_NOTUSED(user); + return 0; + #endif +} + +#ifndef STBI_NO_LINEAR +static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; + +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +#endif + +static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; + +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } +STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } + + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +enum +{ + STBI__SCAN_load=0, + STBI__SCAN_type, + STBI__SCAN_header +}; + +static void stbi__refill_buffer(stbi__context *s) +{ + int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start+1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +stbi_inline static stbi_uc stbi__get8(stbi__context *s) +{ + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +stbi_inline static int stbi__at_eof(stbi__context *s) +{ + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) return 1; + } + + return s->img_buffer >= s->img_buffer_end; +} +#endif + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) +// nothing +#else +static void stbi__skip(stbi__context *s, int n) +{ + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) +// nothing +#else +static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) +{ + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; + + memcpy(buffer, s->img_buffer, blen); + + count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); + res = (count == (n-blen)); + s->img_buffer = s->img_buffer_end; + return res; + } + } + + if (s->img_buffer+n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } else + return 0; +} +#endif + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) +// nothing +#else +static int stbi__get16be(stbi__context *s) +{ + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) +// nothing +#else +static stbi__uint32 stbi__get32be(stbi__context *s) +{ + stbi__uint32 z = stbi__get16be(s); + return (z << 16) + stbi__get16be(s); +} +#endif + +#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) +// nothing +#else +static int stbi__get16le(stbi__context *s) +{ + int z = stbi__get8(s); + return z + (stbi__get8(s) << 8); +} +#endif + +#ifndef STBI_NO_BMP +static stbi__uint32 stbi__get32le(stbi__context *s) +{ + stbi__uint32 z = stbi__get16le(s); + return z + (stbi__get16le(s) << 16); +} +#endif + +#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +////////////////////////////////////////////////////////////////////////////// +// +// generic converter from built-in img_n to req_comp +// individual types do this automatically as much as possible (e.g. jpeg +// does all cases internally since it needs to colorspace convert anyway, +// and it never has alpha, so very few cases ). png can automatically +// interleave an alpha=255 channel, but falls back to this for other cases +// +// assume data buffer is malloced, so malloc a new one and free that one +// only failure mode is malloc failing + +static stbi_uc stbi__compute_y(int r, int g, int b) +{ + return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i,j; + unsigned char *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); + if (good == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + + for (j=0; j < (int) y; ++j) { + unsigned char *src = data + j * x * img_n ; + unsigned char *dest = good + j * x * req_comp; + + #define STBI__COMBO(a,b) ((a)*8+(b)) + #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; + STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; + STBI__CASE(2,1) { dest[0]=src[0]; } break; + STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; + STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; + STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; + STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; + STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; + STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; + STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; + default: STBI_ASSERT(0); + } + #undef STBI__CASE + } + + STBI_FREE(data); + return good; +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) +// nothing +#else +static stbi__uint16 stbi__compute_y_16(int r, int g, int b) +{ + return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) +// nothing +#else +static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i,j; + stbi__uint16 *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); + if (good == NULL) { + STBI_FREE(data); + return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); + } + + for (j=0; j < (int) y; ++j) { + stbi__uint16 *src = data + j * x * img_n ; + stbi__uint16 *dest = good + j * x * req_comp; + + #define STBI__COMBO(a,b) ((a)*8+(b)) + #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; + STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; + STBI__CASE(2,1) { dest[0]=src[0]; } break; + STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; + STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; + STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; + STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; + STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; + STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; + STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; + default: STBI_ASSERT(0); + } + #undef STBI__CASE + } + + STBI_FREE(data); + return good; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) +{ + int i,k,n; + float *output; + if (!data) return NULL; + output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); + if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); + } + } + if (n < comp) { + for (i=0; i < x*y; ++i) { + output[i*comp + n] = data[i*comp + n]/255.0f; + } + } + STBI_FREE(data); + return output; +} +#endif + +#ifndef STBI_NO_HDR +#define stbi__float2int(x) ((int) (x)) +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) +{ + int i,k,n; + stbi_uc *output; + if (!data) return NULL; + output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); + if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc) stbi__float2int(z); + } + if (k < comp) { + float z = data[i*comp+k] * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc) stbi__float2int(z); + } + } + STBI_FREE(data); + return output; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder +// +// simple implementation +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - some SIMD kernels for common paths on targets with SSE2/NEON +// - uses a lot of intermediate memory, could cache poorly + +#ifndef STBI_NO_JPEG + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct +{ + stbi_uc fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + stbi__uint16 code[256]; + stbi_uc values[256]; + stbi_uc size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} stbi__huffman; + +typedef struct +{ + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + stbi__uint16 dequant[4][64]; + stbi__int16 fast_ac[4][1 << FAST_BITS]; + +// sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + +// definition of jpeg image component + struct + { + int id; + int h,v; + int tq; + int hd,ha; + int dc_pred; + + int x,y,w2,h2; + stbi_uc *data; + void *raw_data, *raw_coeff; + stbi_uc *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; + + stbi__uint32 code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop + + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; + int jfif; + int app14_color_transform; // Adobe APP14 tag + int rgb; + + int scan_n, order[4]; + int restart_interval, todo; + +// kernels + void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); + void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); + stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); +} stbi__jpeg; + +static int stbi__build_huffman(stbi__huffman *h, int *count) +{ + int i,j,k=0; + unsigned int code; + // build size list for each symbol (from JPEG spec) + for (i=0; i < 16; ++i) + for (j=0; j < count[i]; ++j) + h->size[k++] = (stbi_uc) (i+1); + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for(j=1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (stbi__uint16) (code++); + if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16-j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i=0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS-s); + int m = 1 << (FAST_BITS-s); + for (j=0; j < m; ++j) { + h->fast[c+j] = (stbi_uc) i; + } + } + } + return 1; +} + +// build a table that decodes both magnitude and value of small ACs in +// one go. +static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) +{ + int i; + for (i=0; i < (1 << FAST_BITS); ++i) { + stbi_uc fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) k += (~0U << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); + } + } + } +} + +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) +{ + do { + unsigned int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes + if (c != 0) { + j->marker = (unsigned char) c; + j->nomore = 1; + return; + } + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); +} + +// (1 << n) - 1 +static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; + +// decode a jpeg huffman value from the bitstream +stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) +{ + unsigned int temp; + int c,k; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) + return -1; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k=FAST_BITS+1 ; ; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } + + if (k > j->code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; +} + +// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); + + sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB + k = stbi_lrot(j->code_buffer, n); + STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & ~sgn); +} + +// get some unsigned bits +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +{ + unsigned int k; + if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) +{ + unsigned int k; + if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static const stbi_uc stbi__jpeg_dezigzag[64+15] = +{ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63 +}; + +// decode one 64-entry block-- +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) +{ + int diff,dc,k; + int t; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data,0,64*sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short) (dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) * dequant[zig]); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) break; // end block + k += 16; + } else { + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); + } + } + } while (k < 64); + return 1; +} + +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +{ + int diff,dc; + int t; + if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + if (j->succ_high == 0) { + // first scan for DC coefficient, must be first + memset(data,0,64*sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + diff = t ? stbi__extend_receive(j, t) : 0; + + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short) (dc << j->succ_low); + } else { + // refinement scan for DC coefficient + if (stbi__jpeg_get_bit(j)) + data[0] += (short) (1 << j->succ_low); + } + return 1; +} + +// @OPTIMIZE: store non-zigzagged during the decode passes, +// and only de-zigzag when dequantizing +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) +{ + int k; + if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } + + k = j->spec_start; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) << shift); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) << shift); + } + } + } while (k <= j->spec_end); + } else { + // refinement scan for these AC coefficients + + short bit = (short) (1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + } else { + k = j->spec_start; + do { + int r,s; + int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } else { + if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } + + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } else { + if (r == 0) { + *p = (short) s; + break; + } + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; +} + +// take a -128..127 value and stbi__clamp it and convert to 0..255 +stbi_inline static stbi_uc stbi__clamp(int x) +{ + // trick to use a single test to catch both cases + if ((unsigned int) x > 255) { + if (x < 0) return 0; + if (x > 255) return 255; + } + return (stbi_uc) x; +} + +#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) * 4096) + +// derived from jidctint -- DCT_ISLOW +#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ + int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2+p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3*stbi__f2f(-1.847759065f); \ + t3 = p1 + p2*stbi__f2f( 0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2+p3); \ + t1 = stbi__fsh(p2-p3); \ + x0 = t0+t3; \ + x3 = t0-t3; \ + x1 = t1+t2; \ + x2 = t1-t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0+t2; \ + p4 = t1+t3; \ + p1 = t0+t3; \ + p2 = t1+t2; \ + p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ + t0 = t0*stbi__f2f( 0.298631336f); \ + t1 = t1*stbi__f2f( 2.053119869f); \ + t2 = t2*stbi__f2f( 3.072711026f); \ + t3 = t3*stbi__f2f( 1.501321110f); \ + p1 = p5 + p1*stbi__f2f(-0.899976223f); \ + p2 = p5 + p2*stbi__f2f(-2.562915447f); \ + p3 = p3*stbi__f2f(-1.961570560f); \ + p4 = p4*stbi__f2f(-0.390180644f); \ + t3 += p1+p4; \ + t2 += p2+p3; \ + t1 += p2+p4; \ + t0 += p1+p3; + +static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) +{ + int i,val[64],*v=val; + stbi_uc *o; + short *d = data; + + // columns + for (i=0; i < 8; ++i,++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 + && d[40]==0 && d[48]==0 && d[56]==0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0]*4; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; x1 += 512; x2 += 512; x3 += 512; + v[ 0] = (x0+t3) >> 10; + v[56] = (x0-t3) >> 10; + v[ 8] = (x1+t2) >> 10; + v[48] = (x1-t2) >> 10; + v[16] = (x2+t1) >> 10; + v[40] = (x2-t1) >> 10; + v[24] = (x3+t0) >> 10; + v[32] = (x3-t0) >> 10; + } + } + + for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128<<17); + x1 += 65536 + (128<<17); + x2 += 65536 + (128<<17); + x3 += 65536 + (128<<17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0+t3) >> 17); + o[7] = stbi__clamp((x0-t3) >> 17); + o[1] = stbi__clamp((x1+t2) >> 17); + o[6] = stbi__clamp((x1-t2) >> 17); + o[2] = stbi__clamp((x2+t1) >> 17); + o[5] = stbi__clamp((x2-t1) >> 17); + o[3] = stbi__clamp((x3+t0) >> 17); + o[4] = stbi__clamp((x3-t0) >> 17); + } +} + +#ifdef STBI_SSE2 +// sse2 integer IDCT. not the fastest possible implementation but it +// produces bit-identical results to the generic C version so it's +// fully "transparent". +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + // This is constructed to match our regular (generic) integer IDCT exactly. + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + + // dot product constant: even elems=x, odd elems=y + #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) + + // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) + // out(1) = c1[even]*x + c1[odd]*y + #define dct_rot(out0,out1, x,y,c0,c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + + // out = in << 12 (in 16-bit, out 32-bit) + #define dct_widen(out, in) \ + __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) + + // wide add + #define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) + + // wide sub + #define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + + // butterfly a/b, add bias, then shift by "s" and pack + #define dct_bfly32o(out0, out1, a,b,bias,s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + + // 8-bit interleave step (for transposes) + #define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + + // 16-bit interleave step (for transposes) + #define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + + #define dct_pass(bias,shift) \ + { \ + /* even part */ \ + dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ + dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0,row7, x0,x7,bias,shift); \ + dct_bfly32o(row1,row6, x1,x6,bias,shift); \ + dct_bfly32o(row2,row5, x2,x5,bias,shift); \ + dct_bfly32o(row3,row4, x3,x4,bias,shift); \ + } + + __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); + __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); + __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); + __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); + __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); + + // rounding biases in column/row passes, see stbi__idct_block for explanation. + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); + + // load + row0 = _mm_load_si128((const __m128i *) (data + 0*8)); + row1 = _mm_load_si128((const __m128i *) (data + 1*8)); + row2 = _mm_load_si128((const __m128i *) (data + 2*8)); + row3 = _mm_load_si128((const __m128i *) (data + 3*8)); + row4 = _mm_load_si128((const __m128i *) (data + 4*8)); + row5 = _mm_load_si128((const __m128i *) (data + 5*8)); + row6 = _mm_load_si128((const __m128i *) (data + 6*8)); + row7 = _mm_load_si128((const __m128i *) (data + 7*8)); + + // column pass + dct_pass(bias_0, 10); + + { + // 16bit 8x8 transpose pass 1 + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + // transpose pass 2 + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + // transpose pass 3 + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + // row pass + dct_pass(bias_1, 17); + + { + // pack + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *) out, p0); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p2); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p1); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p3); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); + } + +#undef dct_const +#undef dct_rot +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_interleave8 +#undef dct_interleave16 +#undef dct_pass +} + +#endif // STBI_SSE2 + +#ifdef STBI_NEON + +// NEON integer IDCT. should produce bit-identical +// results to the generic C version. +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) + +// wide add +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) + +// wide sub +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) + +// butterfly a/b, then shift using "shiftop" by "s" and pack +#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ + { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } + +#define dct_pass(shiftop, shift) \ + { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ + dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ + dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ + dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ + } + + // load + row0 = vld1q_s16(data + 0*8); + row1 = vld1q_s16(data + 1*8); + row2 = vld1q_s16(data + 2*8); + row3 = vld1q_s16(data + 3*8); + row4 = vld1q_s16(data + 4*8); + row5 = vld1q_s16(data + 5*8); + row6 = vld1q_s16(data + 6*8); + row7 = vld1q_s16(data + 7*8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { +// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. +// whether compilers actually get this is another story, sadly. +#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } +#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); + +#undef dct_trn16 +#undef dct_trn32 +#undef dct_trn64 + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + // pack and round + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + // again, these can translate into one instruction, but often don't. +#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } +#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } + + // sadly can't use interleaved stores here since we only write + // 8 bytes to each scan line! + + // 8x8 8-bit transpose pass 1 + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + // pass 2 + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + // pass 3 + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + // store + vst1_u8(out, p0); out += out_stride; + vst1_u8(out, p1); out += out_stride; + vst1_u8(out, p2); out += out_stride; + vst1_u8(out, p3); out += out_stride; + vst1_u8(out, p4); out += out_stride; + vst1_u8(out, p5); out += out_stride; + vst1_u8(out, p6); out += out_stride; + vst1_u8(out, p7); + +#undef dct_trn8_8 +#undef dct_trn8_16 +#undef dct_trn8_32 + } + +#undef dct_long_mul +#undef dct_long_mac +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_pass +} + +#endif // STBI_NEON + +#define STBI__MARKER_none 0xff +// if there's a pending marker from the entropy stream, return that +// otherwise, fetch from the stream and get a marker. if there's no +// marker, return 0xff, which is never a valid marker value +static stbi_uc stbi__get_marker(stbi__jpeg *j) +{ + stbi_uc x; + if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } + x = stbi__get8(j->s); + if (x != 0xff) return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); // consume repeated 0xff fill bytes + return x; +} + +// in each scan, we'll have scan_n components, and the order +// of the components is specified by order[] +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// after a restart interval, stbi__jpeg_reset the entropy decoder and +// the dc prediction +static void stbi__jpeg_reset(stbi__jpeg *j) +{ + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) +{ + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i,j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + STBI_SIMD_ALIGN(short, data[64]); + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x)*8; + int y2 = (j*z->img_comp[n].v + y)*8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } else { + if (z->scan_n == 1) { + int i,j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x); + int y2 = (j*z->img_comp[n].v + y); + short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } +} + +static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) +{ + int i; + for (i=0; i < 64; ++i) + data[i] *= dequant[i]; +} + +static void stbi__jpeg_finish(stbi__jpeg *z) +{ + if (z->progressive) { + // dequantize and idct the data + int i,j,n; + for (n=0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + } + } + } + } +} + +static int stbi__process_marker(stbi__jpeg *z, int m) +{ + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker","Corrupt JPEG"); + + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; + + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s)-2; + while (L > 0) { + int q = stbi__get8(z->s); + int p = q >> 4, sixteen = (p != 0); + int t = q & 15,i; + if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); + if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); + + for (i=0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); + L -= (sixteen ? 129 : 65); + } + return L==0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s)-2; + while (L > 0) { + stbi_uc *v; + int sizes[16],i,n=0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); + for (i=0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; + v = z->huff_dc[th].values; + } else { + if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; + v = z->huff_ac[th].values; + } + for (i=0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L==0; + } + + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + L = stbi__get16be(z->s); + if (L < 2) { + if (m == 0xFE) + return stbi__err("bad COM len","Corrupt JPEG"); + else + return stbi__err("bad APP len","Corrupt JPEG"); + } + L -= 2; + + if (m == 0xE0 && L >= 5) { // JFIF APP0 segment + static const unsigned char tag[5] = {'J','F','I','F','\0'}; + int ok = 1; + int i; + for (i=0; i < 5; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 5; + if (ok) + z->jfif = 1; + } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment + static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; + int ok = 1; + int i; + for (i=0; i < 6; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 6; + if (ok) { + stbi__get8(z->s); // version + stbi__get16be(z->s); // flags0 + stbi__get16be(z->s); // flags1 + z->app14_color_transform = stbi__get8(z->s); // color transform + L -= 6; + } + } + + stbi__skip(z->s, L); + return 1; + } + + return stbi__err("unknown marker","Corrupt JPEG"); +} + +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) +{ + int i; + int Ls = stbi__get16be(z->s); + z->scan_n = stbi__get8(z->s); + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); + if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); + for (i=0; i < z->scan_n; ++i) { + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) return 0; // no match + z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); + z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); + z->order[i] = which; + } + + { + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } else { + if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); + z->spec_end = 63; + } + } + + return 1; +} + +static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) +{ + int i; + for (i=0; i < ncomp; ++i) { + if (z->img_comp[i].raw_data) { + STBI_FREE(z->img_comp[i].raw_data); + z->img_comp[i].raw_data = NULL; + z->img_comp[i].data = NULL; + } + if (z->img_comp[i].raw_coeff) { + STBI_FREE(z->img_comp[i].raw_coeff); + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].coeff = 0; + } + if (z->img_comp[i].linebuf) { + STBI_FREE(z->img_comp[i].linebuf); + z->img_comp[i].linebuf = NULL; + } + } + return why; +} + +static int stbi__process_frame_header(stbi__jpeg *z, int scan) +{ + stbi__context *s = z->s; + int Lf,p,i,q, h_max=1,v_max=1,c; + Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG + p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG + s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires + c = stbi__get8(s); + if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); + s->img_n = c; + for (i=0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } + + if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); + + z->rgb = 0; + for (i=0; i < s->img_n; ++i) { + static const unsigned char rgb[3] = { 'R', 'G', 'B' }; + z->img_comp[i].id = stbi__get8(s); + if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) + ++z->rgb; + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); + z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); + } + + if (scan != STBI__SCAN_load) return 1; + + if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); + + for (i=0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + // these sizes can't be more than 17 bits + z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; + + for (i=0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + // + // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) + // so these muls can't overflow with 32-bit ints (which we require) + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].linebuf = NULL; + z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); + if (z->img_comp[i].raw_data == NULL) + return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); + // align blocks for idct using mmx/sse + z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); + if (z->progressive) { + // w2, h2 are multiples of 8 (see above) + z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; + z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; + z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); + if (z->img_comp[i].raw_coeff == NULL) + return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); + z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); + } + } + + return 1; +} + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) +{ + int m; + z->jfif = 0; + z->app14_color_transform = -1; // valid values are 0,1,2 + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); + if (scan == STBI__SCAN_type) return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z,m)) return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); + m = stbi__get_marker(z); + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) return 0; + return 1; +} + +// decode image to YCbCr format +static int stbi__decode_jpeg_image(stbi__jpeg *j) +{ + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) return 0; + if (!stbi__parse_entropy_coded_data(j)) return 0; + if (j->marker == STBI__MARKER_none ) { + // handle 0s at the end of image data from IP Kamera 9060 + while (!stbi__at_eof(j->s)) { + int x = stbi__get8(j->s); + if (x == 255) { + j->marker = stbi__get8(j->s); + break; + } + } + // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 + } + } else if (stbi__DNL(m)) { + int Ld = stbi__get16be(j->s); + stbi__uint32 NL = stbi__get16be(j->s); + if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); + if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); + } else { + if (!stbi__process_marker(j, m)) return 0; + } + m = stbi__get_marker(j); + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; +} + +// static jfif-centered resampling (across block boundaries) + +typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, + int w, int hs); + +#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) + +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i=0; i < w; ++i) + out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); + return out; +} + +static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples horizontally for every one in input + int i; + stbi_uc *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0]*3 + input[1] + 2); + for (i=1; i < w-1; ++i) { + int n = 3*input[i]+2; + out[i*2+0] = stbi__div4(n+input[i-1]); + out[i*2+1] = stbi__div4(n+input[i+1]); + } + out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); + out[i*2+1] = input[w-1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) + +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i,t0,t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + out[0] = stbi__div4(t1+2); + for (i=1; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i=0,t0,t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + // process groups of 8 pixels for as long as we can. + // note we can't handle the last pixel in a row in this loop + // because we need to handle the filter boundary conditions. + for (; i < ((w-1) & ~7); i += 8) { +#if defined(STBI_SSE2) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + // interleave even and odd pixels, then undo scaling. + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + // pack and write output + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *) (out + i*2), outv); +#elif defined(STBI_NEON) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + // undo scaling and round, then store with even/odd phases interleaved + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i*2, o); +#endif + + // "previous" value for next iter + t1 = 3*in_near[i+7] + in_far[i+7]; + } + + t0 = t1; + t1 = 3*in_near[i] + in_far[i]; + out[i*2] = stbi__div16(3*t1 + t0 + 8); + + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} +#endif + +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // resample with nearest-neighbor + int i,j; + STBI_NOTUSED(in_far); + for (i=0; i < w; ++i) + for (j=0; j < hs; ++j) + out[i*hs+j] = in_near[i]; + return out; +} + +// this is a reduced-precision calculation of YCbCr-to-RGB introduced +// to make sure the code produces the same results in both SIMD and scalar +#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* stbi__float2fixed(1.40200f); + g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) +{ + int i = 0; + +#ifdef STBI_SSE2 + // step == 3 is pretty ugly on the final interleave, and i'm not convinced + // it's useful in practice (you wouldn't use it for textures, for example). + // so just accelerate step == 4 case. + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); + __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); + __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); + __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); + __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); + __m128i xw = _mm_set1_epi16(255); // alpha channel + + for (; i+7 < count; i += 8) { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *) (out + 0), o0); + _mm_storeu_si128((__m128i *) (out + 16), o1); + out += 32; + } + } +#endif + +#ifdef STBI_NEON + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); + int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); + int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); + int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); + + for (; i+7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8*4; + } + } +#endif + + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* stbi__float2fixed(1.40200f); + g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#endif + +// set up the kernels +static void stbi__setup_jpeg(stbi__jpeg *j) +{ + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + +#ifdef STBI_SSE2 + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } +#endif + +#ifdef STBI_NEON + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; +#endif +} + +// clean up the temporary component buffers +static void stbi__cleanup_jpeg(stbi__jpeg *j) +{ + stbi__free_jpeg_components(j, j->s->img_n, 0); +} + +typedef struct +{ + resample_row_func resample; + stbi_uc *line0,*line1; + int hs,vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on +} stbi__resample; + +// fast 0..255 * 0..255 => 0..255 rounded multiplication +static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) +{ + unsigned int t = x*y + 128; + return (stbi_uc) ((t + (t >>8)) >> 8); +} + +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +{ + int n, decode_n, is_rgb; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; + + is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); + + if (z->s->img_n == 3 && n < 3 && !is_rgb) + decode_n = 1; + else + decode_n = z->s->img_n; + + // resample and color-convert + { + int k; + unsigned int i,j; + stbi_uc *output; + stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; + + stbi__resample res_comp[4]; + + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs-1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; + else r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); + if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + // now go ahead and resample + for (j=0; j < z->s->img_y; ++j) { + stbi_uc *out = output + n * z->s->img_x * j; + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = r->resample(z->img_comp[k].linebuf, + y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, + r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + stbi_uc *y = coutput[0]; + if (z->s->img_n == 3) { + if (is_rgb) { + for (i=0; i < z->s->img_x; ++i) { + out[0] = y[i]; + out[1] = coutput[1][i]; + out[2] = coutput[2][i]; + out[3] = 255; + out += n; + } + } else { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } else if (z->s->img_n == 4) { + if (z->app14_color_transform == 0) { // CMYK + for (i=0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(coutput[0][i], m); + out[1] = stbi__blinn_8x8(coutput[1][i], m); + out[2] = stbi__blinn_8x8(coutput[2][i], m); + out[3] = 255; + out += n; + } + } else if (z->app14_color_transform == 2) { // YCCK + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + for (i=0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(255 - out[0], m); + out[1] = stbi__blinn_8x8(255 - out[1], m); + out[2] = stbi__blinn_8x8(255 - out[2], m); + out += n; + } + } else { // YCbCr + alpha? Ignore the fourth channel for now + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } else + for (i=0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } else { + if (is_rgb) { + if (n == 1) + for (i=0; i < z->s->img_x; ++i) + *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + else { + for (i=0; i < z->s->img_x; ++i, out += 2) { + out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + out[1] = 255; + } + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { + for (i=0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); + stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); + stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); + out[0] = stbi__compute_y(r, g, b); + out[1] = 255; + out += n; + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { + for (i=0; i < z->s->img_x; ++i) { + out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); + out[1] = 255; + out += n; + } + } else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; + else + for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } + } + } + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output + return output; + } +} + +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + unsigned char* result; + stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); + STBI_NOTUSED(ri); + j->s = s; + stbi__setup_jpeg(j); + result = load_jpeg_image(j, x,y,comp,req_comp); + STBI_FREE(j); + return result; +} + +static int stbi__jpeg_test(stbi__context *s) +{ + int r; + stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); + j->s = s; + stbi__setup_jpeg(j); + r = stbi__decode_jpeg_header(j, STBI__SCAN_type); + stbi__rewind(s); + STBI_FREE(j); + return r; +} + +static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) +{ + if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { + stbi__rewind( j->s ); + return 0; + } + if (x) *x = j->s->img_x; + if (y) *y = j->s->img_y; + if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; + return 1; +} + +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) +{ + int result; + stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); + j->s = s; + result = stbi__jpeg_info_raw(j, x, y, comp); + STBI_FREE(j); + return result; +} +#endif + +// public domain zlib decode v0.2 Sean Barrett 2006-11-18 +// simple implementation +// - all input must be provided in an upfront buffer +// - all output is written to a single output buffer (can malloc/realloc) +// performance +// - fast huffman + +#ifndef STBI_NO_ZLIB + +// fast-way is faster to check than jpeg huffman, but slow way is slower +#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables +#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) + +// zlib-style huffman encoding +// (jpegs packs from left, zlib from right, so can't share code) +typedef struct +{ + stbi__uint16 fast[1 << STBI__ZFAST_BITS]; + stbi__uint16 firstcode[16]; + int maxcode[17]; + stbi__uint16 firstsymbol[16]; + stbi_uc size[288]; + stbi__uint16 value[288]; +} stbi__zhuffman; + +stbi_inline static int stbi__bitreverse16(int n) +{ + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); + return n; +} + +stbi_inline static int stbi__bit_reverse(int v, int bits) +{ + STBI_ASSERT(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return stbi__bitreverse16(v) >> (16-bits); +} + +static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) +{ + int i,k=0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 0, sizeof(z->fast)); + for (i=0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i=1; i < 16; ++i) + if (sizes[i] > (1 << i)) + return stbi__err("bad sizes", "Corrupt PNG"); + code = 0; + for (i=1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (stbi__uint16) code; + z->firstsymbol[i] = (stbi__uint16) k; + code = (code + sizes[i]); + if (sizes[i]) + if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); + z->maxcode[i] = code << (16-i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i=0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); + z->size [c] = (stbi_uc ) s; + z->value[c] = (stbi__uint16) i; + if (s <= STBI__ZFAST_BITS) { + int j = stbi__bit_reverse(next_code[s],s); + while (j < (1 << STBI__ZFAST_BITS)) { + z->fast[j] = fastv; + j += (1 << s); + } + } + ++next_code[s]; + } + } + return 1; +} + +// zlib-from-memory implementation for PNG reading +// because PNG allows splitting the zlib stream arbitrarily, +// and it's annoying structurally to have PNG call ZLIB call PNG, +// we require PNG read all the IDATs and combine them into a single +// memory buffer + +typedef struct +{ + stbi_uc *zbuffer, *zbuffer_end; + int num_bits; + stbi__uint32 code_buffer; + + char *zout; + char *zout_start; + char *zout_end; + int z_expandable; + + stbi__zhuffman z_length, z_distance; +} stbi__zbuf; + +stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) +{ + if (z->zbuffer >= z->zbuffer_end) return 0; + return *z->zbuffer++; +} + +static void stbi__fill_bits(stbi__zbuf *z) +{ + do { + STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); + z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; + z->num_bits += 8; + } while (z->num_bits <= 24); +} + +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) +{ + unsigned int k; + if (z->num_bits < n) stbi__fill_bits(z); + k = z->code_buffer & ((1 << n) - 1); + z->code_buffer >>= n; + z->num_bits -= n; + return k; +} + +static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b,s,k; + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = stbi__bit_reverse(a->code_buffer, 16); + for (s=STBI__ZFAST_BITS+1; ; ++s) + if (k < z->maxcode[s]) + break; + if (s == 16) return -1; // invalid code! + // code size is s, so: + b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; + STBI_ASSERT(z->size[b] == s); + a->code_buffer >>= s; + a->num_bits -= s; + return z->value[b]; +} + +stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b,s; + if (a->num_bits < 16) stbi__fill_bits(a); + b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; + if (b) { + s = b >> 9; + a->code_buffer >>= s; + a->num_bits -= s; + return b & 511; + } + return stbi__zhuffman_decode_slowpath(a, z); +} + +static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes +{ + char *q; + int cur, limit, old_limit; + z->zout = zout; + if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); + cur = (int) (z->zout - z->zout_start); + limit = old_limit = (int) (z->zout_end - z->zout_start); + while (cur + n > limit) + limit *= 2; + q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); + STBI_NOTUSED(old_limit); + if (q == NULL) return stbi__err("outofmem", "Out of memory"); + z->zout_start = q; + z->zout = q + cur; + z->zout_end = q + limit; + return 1; +} + +static const int stbi__zlength_base[31] = { + 3,4,5,6,7,8,9,10,11,13, + 15,17,19,23,27,31,35,43,51,59, + 67,83,99,115,131,163,195,227,258,0,0 }; + +static const int stbi__zlength_extra[31]= +{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + +static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, +257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; + +static const int stbi__zdist_extra[32] = +{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +static int stbi__parse_huffman_block(stbi__zbuf *a) +{ + char *zout = a->zout; + for(;;) { + int z = stbi__zhuffman_decode(a, &a->z_length); + if (z < 256) { + if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes + if (zout >= a->zout_end) { + if (!stbi__zexpand(a, zout, 1)) return 0; + zout = a->zout; + } + *zout++ = (char) z; + } else { + stbi_uc *p; + int len,dist; + if (z == 256) { + a->zout = zout; + return 1; + } + z -= 257; + len = stbi__zlength_base[z]; + if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); + z = stbi__zhuffman_decode(a, &a->z_distance); + if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); + dist = stbi__zdist_base[z]; + if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); + if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); + if (zout + len > a->zout_end) { + if (!stbi__zexpand(a, zout, len)) return 0; + zout = a->zout; + } + p = (stbi_uc *) (zout - dist); + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + if (len) { do *zout++ = v; while (--len); } + } else { + if (len) { do *zout++ = *p++; while (--len); } + } + } + } +} + +static int stbi__compute_huffman_codes(stbi__zbuf *a) +{ + static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + stbi__zhuffman z_codelength; + stbi_uc lencodes[286+32+137];//padding for maximum single op + stbi_uc codelength_sizes[19]; + int i,n; + + int hlit = stbi__zreceive(a,5) + 257; + int hdist = stbi__zreceive(a,5) + 1; + int hclen = stbi__zreceive(a,4) + 4; + int ntot = hlit + hdist; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i=0; i < hclen; ++i) { + int s = stbi__zreceive(a,3); + codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; + } + if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; + + n = 0; + while (n < ntot) { + int c = stbi__zhuffman_decode(a, &z_codelength); + if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); + if (c < 16) + lencodes[n++] = (stbi_uc) c; + else { + stbi_uc fill = 0; + if (c == 16) { + c = stbi__zreceive(a,2)+3; + if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); + fill = lencodes[n-1]; + } else if (c == 17) + c = stbi__zreceive(a,3)+3; + else { + STBI_ASSERT(c == 18); + c = stbi__zreceive(a,7)+11; + } + if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); + memset(lencodes+n, fill, c); + n += c; + } + } + if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); + if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; + return 1; +} + +static int stbi__parse_uncompressed_block(stbi__zbuf *a) +{ + stbi_uc header[4]; + int len,nlen,k; + if (a->num_bits & 7) + stbi__zreceive(a, a->num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (a->num_bits > 0) { + header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check + a->code_buffer >>= 8; + a->num_bits -= 8; + } + STBI_ASSERT(a->num_bits == 0); + // now fill header the normal way + while (k < 4) + header[k++] = stbi__zget8(a); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); + if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); + if (a->zout + len > a->zout_end) + if (!stbi__zexpand(a, a->zout, len)) return 0; + memcpy(a->zout, a->zbuffer, len); + a->zbuffer += len; + a->zout += len; + return 1; +} + +static int stbi__parse_zlib_header(stbi__zbuf *a) +{ + int cmf = stbi__zget8(a); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = stbi__zget8(a); + if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec + if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +static const stbi_uc stbi__zdefault_length[288] = +{ + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 +}; +static const stbi_uc stbi__zdefault_distance[32] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 +}; +/* +Init algorithm: +{ + int i; // use <= to match clearly with spec + for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; + for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; + for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; + for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; + + for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; +} +*/ + +static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) +{ + int final, type; + if (parse_header) + if (!stbi__parse_zlib_header(a)) return 0; + a->num_bits = 0; + a->code_buffer = 0; + do { + final = stbi__zreceive(a,1); + type = stbi__zreceive(a,2); + if (type == 0) { + if (!stbi__parse_uncompressed_block(a)) return 0; + } else if (type == 3) { + return 0; + } else { + if (type == 1) { + // use fixed code lengths + if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; + } else { + if (!stbi__compute_huffman_codes(a)) return 0; + } + if (!stbi__parse_huffman_block(a)) return 0; + } + } while (!final); + return 1; +} + +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) +{ + a->zout_start = obuf; + a->zout = obuf; + a->zout_end = obuf + olen; + a->z_expandable = exp; + + return stbi__parse_zlib(a, parse_header); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) +{ + return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *) ibuffer; + a.zbuffer_end = (stbi_uc *) ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) + return (int) (a.zout - a.zout_start); + else + return -1; +} + +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(16384); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer+len; + if (stbi__do_zlib(&a, p, 16384, 1, 0)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *) ibuffer; + a.zbuffer_end = (stbi_uc *) ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) + return (int) (a.zout - a.zout_start); + else + return -1; +} +#endif + +// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 +// simple implementation +// - only 8-bit samples +// - no CRC checking +// - allocates lots of intermediate memory +// - avoids problem of streaming data between subsystems +// - avoids explicit window management +// performance +// - uses stb_zlib, a PD zlib implementation with fast huffman decoding + +#ifndef STBI_NO_PNG +typedef struct +{ + stbi__uint32 length; + stbi__uint32 type; +} stbi__pngchunk; + +static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) +{ + stbi__pngchunk c; + c.length = stbi__get32be(s); + c.type = stbi__get32be(s); + return c; +} + +static int stbi__check_png_header(stbi__context *s) +{ + static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; + int i; + for (i=0; i < 8; ++i) + if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); + return 1; +} + +typedef struct +{ + stbi__context *s; + stbi_uc *idata, *expanded, *out; + int depth; +} stbi__png; + + +enum { + STBI__F_none=0, + STBI__F_sub=1, + STBI__F_up=2, + STBI__F_avg=3, + STBI__F_paeth=4, + // synthetic filters used for first scanline to avoid needing a dummy row of 0s + STBI__F_avg_first, + STBI__F_paeth_first +}; + +static stbi_uc first_row_filter[5] = +{ + STBI__F_none, + STBI__F_sub, + STBI__F_none, + STBI__F_avg_first, + STBI__F_paeth_first +}; + +static int stbi__paeth(int a, int b, int c) +{ + int p = a + b - c; + int pa = abs(p-a); + int pb = abs(p-b); + int pc = abs(p-c); + if (pa <= pb && pa <= pc) return a; + if (pb <= pc) return b; + return c; +} + +static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; + +// create the png data from post-deflated data +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) +{ + int bytes = (depth == 16? 2 : 1); + stbi__context *s = a->s; + stbi__uint32 i,j,stride = x*out_n*bytes; + stbi__uint32 img_len, img_width_bytes; + int k; + int img_n = s->img_n; // copy it into a local for later + + int output_bytes = out_n*bytes; + int filter_bytes = img_n*bytes; + int width = x; + + STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); + a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into + if (!a->out) return stbi__err("outofmem", "Out of memory"); + + if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); + img_width_bytes = (((img_n * x * depth) + 7) >> 3); + img_len = (img_width_bytes + 1) * y; + + // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, + // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), + // so just check for raw_len < img_len always. + if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); + + for (j=0; j < y; ++j) { + stbi_uc *cur = a->out + stride*j; + stbi_uc *prior; + int filter = *raw++; + + if (filter > 4) + return stbi__err("invalid filter","Corrupt PNG"); + + if (depth < 8) { + STBI_ASSERT(img_width_bytes <= x); + cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place + filter_bytes = 1; + width = img_width_bytes; + } + prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above + + // if first row, use special filter that doesn't sample previous row + if (j == 0) filter = first_row_filter[filter]; + + // handle first byte explicitly + for (k=0; k < filter_bytes; ++k) { + switch (filter) { + case STBI__F_none : cur[k] = raw[k]; break; + case STBI__F_sub : cur[k] = raw[k]; break; + case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; + case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; + case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; + case STBI__F_avg_first : cur[k] = raw[k]; break; + case STBI__F_paeth_first: cur[k] = raw[k]; break; + } + } + + if (depth == 8) { + if (img_n != out_n) + cur[img_n] = 255; // first pixel + raw += img_n; + cur += out_n; + prior += out_n; + } else if (depth == 16) { + if (img_n != out_n) { + cur[filter_bytes] = 255; // first pixel top byte + cur[filter_bytes+1] = 255; // first pixel bottom byte + } + raw += filter_bytes; + cur += output_bytes; + prior += output_bytes; + } else { + raw += 1; + cur += 1; + prior += 1; + } + + // this is a little gross, so that we don't switch per-pixel or per-component + if (depth < 8 || img_n == out_n) { + int nk = (width - 1)*filter_bytes; + #define STBI__CASE(f) \ + case f: \ + for (k=0; k < nk; ++k) + switch (filter) { + // "none" filter turns into a memcpy here; make that explicit. + case STBI__F_none: memcpy(cur, raw, nk); break; + STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; + STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; + STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; + STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; + STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; + STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; + } + #undef STBI__CASE + raw += nk; + } else { + STBI_ASSERT(img_n+1 == out_n); + #define STBI__CASE(f) \ + case f: \ + for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ + for (k=0; k < filter_bytes; ++k) + switch (filter) { + STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; + STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; + STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; + STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; + STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; + STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; + STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; + } + #undef STBI__CASE + + // the loop above sets the high byte of the pixels' alpha, but for + // 16 bit png files we also need the low byte set. we'll do that here. + if (depth == 16) { + cur = a->out + stride*j; // start at the beginning of the row again + for (i=0; i < x; ++i,cur+=output_bytes) { + cur[filter_bytes+1] = 255; + } + } + } + } + + // we make a separate pass to expand bits to pixels; for performance, + // this could run two scanlines behind the above code, so it won't + // intefere with filtering but will still be in the cache. + if (depth < 8) { + for (j=0; j < y; ++j) { + stbi_uc *cur = a->out + stride*j; + stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; + // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit + // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop + stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range + + // note that the final byte might overshoot and write more data than desired. + // we can allocate enough data that this never writes out of memory, but it + // could also overwrite the next scanline. can it overwrite non-empty data + // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. + // so we need to explicitly clamp the final ones + + if (depth == 4) { + for (k=x*img_n; k >= 2; k-=2, ++in) { + *cur++ = scale * ((*in >> 4) ); + *cur++ = scale * ((*in ) & 0x0f); + } + if (k > 0) *cur++ = scale * ((*in >> 4) ); + } else if (depth == 2) { + for (k=x*img_n; k >= 4; k-=4, ++in) { + *cur++ = scale * ((*in >> 6) ); + *cur++ = scale * ((*in >> 4) & 0x03); + *cur++ = scale * ((*in >> 2) & 0x03); + *cur++ = scale * ((*in ) & 0x03); + } + if (k > 0) *cur++ = scale * ((*in >> 6) ); + if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); + if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); + } else if (depth == 1) { + for (k=x*img_n; k >= 8; k-=8, ++in) { + *cur++ = scale * ((*in >> 7) ); + *cur++ = scale * ((*in >> 6) & 0x01); + *cur++ = scale * ((*in >> 5) & 0x01); + *cur++ = scale * ((*in >> 4) & 0x01); + *cur++ = scale * ((*in >> 3) & 0x01); + *cur++ = scale * ((*in >> 2) & 0x01); + *cur++ = scale * ((*in >> 1) & 0x01); + *cur++ = scale * ((*in ) & 0x01); + } + if (k > 0) *cur++ = scale * ((*in >> 7) ); + if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); + if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); + if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); + if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); + if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); + if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); + } + if (img_n != out_n) { + int q; + // insert alpha = 255 + cur = a->out + stride*j; + if (img_n == 1) { + for (q=x-1; q >= 0; --q) { + cur[q*2+1] = 255; + cur[q*2+0] = cur[q]; + } + } else { + STBI_ASSERT(img_n == 3); + for (q=x-1; q >= 0; --q) { + cur[q*4+3] = 255; + cur[q*4+2] = cur[q*3+2]; + cur[q*4+1] = cur[q*3+1]; + cur[q*4+0] = cur[q*3+0]; + } + } + } + } + } else if (depth == 16) { + // force the image data from big-endian to platform-native. + // this is done in a separate pass due to the decoding relying + // on the data being untouched, but could probably be done + // per-line during decode if care is taken. + stbi_uc *cur = a->out; + stbi__uint16 *cur16 = (stbi__uint16*)cur; + + for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { + *cur16 = (cur[0] << 8) | cur[1]; + } + } + + return 1; +} + +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) +{ + int bytes = (depth == 16 ? 2 : 1); + int out_bytes = out_n * bytes; + stbi_uc *final; + int p; + if (!interlaced) + return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); + + // de-interlacing + final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); + for (p=0; p < 7; ++p) { + int xorig[] = { 0,4,0,2,0,1,0 }; + int yorig[] = { 0,0,4,0,2,0,1 }; + int xspc[] = { 8,8,4,4,2,2,1 }; + int yspc[] = { 8,8,8,4,4,2,2 }; + int i,j,x,y; + // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 + x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; + y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; + if (x && y) { + stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; + if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { + STBI_FREE(final); + return 0; + } + for (j=0; j < y; ++j) { + for (i=0; i < x; ++i) { + int out_y = j*yspc[p]+yorig[p]; + int out_x = i*xspc[p]+xorig[p]; + memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, + a->out + (j*x+i)*out_bytes, out_bytes); + } + } + STBI_FREE(a->out); + image_data += img_len; + image_data_len -= img_len; + } + } + a->out = final; + + return 1; +} + +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i=0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } else { + for (i=0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi__uint16 *p = (stbi__uint16*) z->out; + + // compute color-based transparency, assuming we've + // already got 65535 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 65535); + p += 2; + } + } else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) +{ + stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; + stbi_uc *p, *temp_out, *orig = a->out; + + p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); + if (p == NULL) return stbi__err("outofmem", "Out of memory"); + + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p += 3; + } + } else { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p[3] = palette[n+3]; + p += 4; + } + } + STBI_FREE(a->out); + a->out = temp_out; + + STBI_NOTUSED(len); + + return 1; +} + +static int stbi__unpremultiply_on_load = 0; +static int stbi__de_iphone_flag = 0; + +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) +{ + stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) +{ + stbi__de_iphone_flag = flag_true_if_should_convert; +} + +static void stbi__de_iphone(stbi__png *z) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + if (s->img_out_n == 3) { // convert bgr to rgb + for (i=0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 3; + } + } else { + STBI_ASSERT(s->img_out_n == 4); + if (stbi__unpremultiply_on_load) { + // convert bgr to rgb and unpremultiply + for (i=0; i < pixel_count; ++i) { + stbi_uc a = p[3]; + stbi_uc t = p[0]; + if (a) { + stbi_uc half = a / 2; + p[0] = (p[2] * 255 + half) / a; + p[1] = (p[1] * 255 + half) / a; + p[2] = ( t * 255 + half) / a; + } else { + p[0] = p[2]; + p[2] = t; + } + p += 4; + } + } else { + // convert bgr to rgb + for (i=0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 4; + } + } + } +} + +#define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) + +static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) +{ + stbi_uc palette[1024], pal_img_n=0; + stbi_uc has_trans=0, tc[3]={0}; + stbi__uint16 tc16[3]; + stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; + int first=1,k,interlace=0, color=0, is_iphone=0; + stbi__context *s = z->s; + + z->expanded = NULL; + z->idata = NULL; + z->out = NULL; + + if (!stbi__check_png_header(s)) return 0; + + if (scan == STBI__SCAN_type) return 1; + + for (;;) { + stbi__pngchunk c = stbi__get_chunk_header(s); + switch (c.type) { + case STBI__PNG_TYPE('C','g','B','I'): + is_iphone = 1; + stbi__skip(s, c.length); + break; + case STBI__PNG_TYPE('I','H','D','R'): { + int comp,filter; + if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); + first = 0; + if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); + s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); + s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); + z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); + color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); + if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); + if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); + comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); + filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); + interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); + if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); + if (!pal_img_n) { + s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + if (scan == STBI__SCAN_header) return 1; + } else { + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + s->img_n = 1; + if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); + // if SCAN_header, have to scan to see if we have a tRNS + } + break; + } + + case STBI__PNG_TYPE('P','L','T','E'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); + for (i=0; i < pal_len; ++i) { + palette[i*4+0] = stbi__get8(s); + palette[i*4+1] = stbi__get8(s); + palette[i*4+2] = stbi__get8(s); + palette[i*4+3] = 255; + } + break; + } + + case STBI__PNG_TYPE('t','R','N','S'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); + if (pal_img_n) { + if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } + if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); + if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); + pal_img_n = 4; + for (i=0; i < c.length; ++i) + palette[i*4+3] = stbi__get8(s); + } else { + if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); + if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); + has_trans = 1; + if (z->depth == 16) { + for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is + } else { + for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger + } + } + break; + } + + case STBI__PNG_TYPE('I','D','A','T'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); + if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } + if ((int)(ioff + c.length) < (int)ioff) return 0; + if (ioff + c.length > idata_limit) { + stbi__uint32 idata_limit_old = idata_limit; + stbi_uc *p; + if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + STBI_NOTUSED(idata_limit_old); + p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); + z->idata = p; + } + if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); + ioff += c.length; + break; + } + + case STBI__PNG_TYPE('I','E','N','D'): { + stbi__uint32 raw_len, bpl; + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (scan != STBI__SCAN_load) return 1; + if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); + // initial guess for decoded data size to avoid unnecessary reallocs + bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component + raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; + z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); + if (z->expanded == NULL) return 0; // zlib should set error + STBI_FREE(z->idata); z->idata = NULL; + if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) + s->img_out_n = s->img_n+1; + else + s->img_out_n = s->img_n; + if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; + if (has_trans) { + if (z->depth == 16) { + if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; + } else { + if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; + } + } + if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) + stbi__de_iphone(z); + if (pal_img_n) { + // pal_img_n == 3 or 4 + s->img_n = pal_img_n; // record the actual colors we had + s->img_out_n = pal_img_n; + if (req_comp >= 3) s->img_out_n = req_comp; + if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) + return 0; + } else if (has_trans) { + // non-paletted image with tRNS -> source image has (constant) alpha + ++s->img_n; + } + STBI_FREE(z->expanded); z->expanded = NULL; + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + return 1; + } + + default: + // if critical, fail + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if ((c.type & (1 << 29)) == 0) { + #ifndef STBI_NO_FAILURE_STRINGS + // not threadsafe + static char invalid_chunk[] = "XXXX PNG chunk not known"; + invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); + invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); + invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); + invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); + #endif + return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); + } + stbi__skip(s, c.length); + break; + } + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + } +} + +static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) +{ + void *result=NULL; + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { + if (p->depth < 8) + ri->bits_per_channel = 8; + else + ri->bits_per_channel = p->depth; + result = p->out; + p->out = NULL; + if (req_comp && req_comp != p->s->img_out_n) { + if (ri->bits_per_channel == 8) + result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + else + result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + p->s->img_out_n = req_comp; + if (result == NULL) return result; + } + *x = p->s->img_x; + *y = p->s->img_y; + if (n) *n = p->s->img_n; + } + STBI_FREE(p->out); p->out = NULL; + STBI_FREE(p->expanded); p->expanded = NULL; + STBI_FREE(p->idata); p->idata = NULL; + + return result; +} + +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi__png p; + p.s = s; + return stbi__do_png(&p, x,y,comp,req_comp, ri); +} + +static int stbi__png_test(stbi__context *s) +{ + int r; + r = stbi__check_png_header(s); + stbi__rewind(s); + return r; +} + +static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) +{ + if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { + stbi__rewind( p->s ); + return 0; + } + if (x) *x = p->s->img_x; + if (y) *y = p->s->img_y; + if (comp) *comp = p->s->img_n; + return 1; +} + +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__png p; + p.s = s; + return stbi__png_info_raw(&p, x, y, comp); +} + +static int stbi__png_is16(stbi__context *s) +{ + stbi__png p; + p.s = s; + if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) + return 0; + if (p.depth != 16) { + stbi__rewind(p.s); + return 0; + } + return 1; +} +#endif + +// Microsoft/Windows BMP image + +#ifndef STBI_NO_BMP +static int stbi__bmp_test_raw(stbi__context *s) +{ + int r; + int sz; + if (stbi__get8(s) != 'B') return 0; + if (stbi__get8(s) != 'M') return 0; + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + stbi__get32le(s); // discard data offset + sz = stbi__get32le(s); + r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); + return r; +} + +static int stbi__bmp_test(stbi__context *s) +{ + int r = stbi__bmp_test_raw(s); + stbi__rewind(s); + return r; +} + + +// returns 0..31 for the highest set bit +static int stbi__high_bit(unsigned int z) +{ + int n=0; + if (z == 0) return -1; + if (z >= 0x10000) { n += 16; z >>= 16; } + if (z >= 0x00100) { n += 8; z >>= 8; } + if (z >= 0x00010) { n += 4; z >>= 4; } + if (z >= 0x00004) { n += 2; z >>= 2; } + if (z >= 0x00002) { n += 1;/* >>= 1;*/ } + return n; +} + +static int stbi__bitcount(unsigned int a) +{ + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; +} + +// extract an arbitrarily-aligned N-bit value (N=bits) +// from v, and then make it 8-bits long and fractionally +// extend it to full full range. +static int stbi__shiftsigned(unsigned int v, int shift, int bits) +{ + static unsigned int mul_table[9] = { + 0, + 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, + 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, + }; + static unsigned int shift_table[9] = { + 0, 0,0,1,0,2,4,6,0, + }; + if (shift < 0) + v <<= -shift; + else + v >>= shift; + STBI_ASSERT(v < 256); + v >>= (8-bits); + STBI_ASSERT(bits >= 0 && bits <= 8); + return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; +} + +typedef struct +{ + int bpp, offset, hsz; + unsigned int mr,mg,mb,ma, all_a; + int extra_read; +} stbi__bmp_data; + +static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) +{ + int hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + info->offset = stbi__get32le(s); + info->hsz = hsz = stbi__get32le(s); + info->mr = info->mg = info->mb = info->ma = 0; + info->extra_read = 14; + + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); + if (hsz == 12) { + s->img_x = stbi__get16le(s); + s->img_y = stbi__get16le(s); + } else { + s->img_x = stbi__get32le(s); + s->img_y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); + info->bpp = stbi__get16le(s); + if (hsz != 12) { + int compress = stbi__get32le(s); + if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); + stbi__get32le(s); // discard sizeof + stbi__get32le(s); // discard hres + stbi__get32le(s); // discard vres + stbi__get32le(s); // discard colorsused + stbi__get32le(s); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + } + if (info->bpp == 16 || info->bpp == 32) { + if (compress == 0) { + if (info->bpp == 32) { + info->mr = 0xffu << 16; + info->mg = 0xffu << 8; + info->mb = 0xffu << 0; + info->ma = 0xffu << 24; + info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 + } else { + info->mr = 31u << 10; + info->mg = 31u << 5; + info->mb = 31u << 0; + } + } else if (compress == 3) { + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->extra_read += 12; + // not documented, but generated by photoshop and handled by mspaint + if (info->mr == info->mg && info->mg == info->mb) { + // ?!?!? + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else { + int i; + if (hsz != 108 && hsz != 124) + return stbi__errpuc("bad BMP", "bad BMP"); + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->ma = stbi__get32le(s); + stbi__get32le(s); // discard color space + for (i=0; i < 12; ++i) + stbi__get32le(s); // discard color space parameters + if (hsz == 124) { + stbi__get32le(s); // discard rendering intent + stbi__get32le(s); // discard offset of profile data + stbi__get32le(s); // discard size of profile data + stbi__get32le(s); // discard reserved + } + } + } + return (void *) 1; +} + + +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *out; + unsigned int mr=0,mg=0,mb=0,ma=0, all_a; + stbi_uc pal[256][4]; + int psize=0,i,j,width; + int flip_vertically, pad, target; + stbi__bmp_data info; + STBI_NOTUSED(ri); + + info.all_a = 255; + if (stbi__bmp_parse_header(s, &info) == NULL) + return NULL; // error code already set + + flip_vertically = ((int) s->img_y) > 0; + s->img_y = abs((int) s->img_y); + + mr = info.mr; + mg = info.mg; + mb = info.mb; + ma = info.ma; + all_a = info.all_a; + + if (info.hsz == 12) { + if (info.bpp < 24) + psize = (info.offset - info.extra_read - 24) / 3; + } else { + if (info.bpp < 16) + psize = (info.offset - info.extra_read - info.hsz) >> 2; + } + if (psize == 0) { + STBI_ASSERT(info.offset == (s->img_buffer - s->buffer_start)); + } + + if (info.bpp == 24 && ma == 0xff000000) + s->img_n = 3; + else + s->img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = s->img_n; // if they want monochrome, we'll post-convert + + // sanity-check size + if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "Corrupt BMP"); + + out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + if (info.bpp < 16) { + int z=0; + if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } + for (i=0; i < psize; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + if (info.hsz != 12) stbi__get8(s); + pal[i][3] = 255; + } + stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); + if (info.bpp == 1) width = (s->img_x + 7) >> 3; + else if (info.bpp == 4) width = (s->img_x + 1) >> 1; + else if (info.bpp == 8) width = s->img_x; + else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } + pad = (-width)&3; + if (info.bpp == 1) { + for (j=0; j < (int) s->img_y; ++j) { + int bit_offset = 7, v = stbi__get8(s); + for (i=0; i < (int) s->img_x; ++i) { + int color = (v>>bit_offset)&0x1; + out[z++] = pal[color][0]; + out[z++] = pal[color][1]; + out[z++] = pal[color][2]; + if (target == 4) out[z++] = 255; + if (i+1 == (int) s->img_x) break; + if((--bit_offset) < 0) { + bit_offset = 7; + v = stbi__get8(s); + } + } + stbi__skip(s, pad); + } + } else { + for (j=0; j < (int) s->img_y; ++j) { + for (i=0; i < (int) s->img_x; i += 2) { + int v=stbi__get8(s),v2=0; + if (info.bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + if (i+1 == (int) s->img_x) break; + v = (info.bpp == 8) ? stbi__get8(s) : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + } + stbi__skip(s, pad); + } + } + } else { + int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; + int z = 0; + int easy=0; + stbi__skip(s, info.offset - info.extra_read - info.hsz); + if (info.bpp == 24) width = 3 * s->img_x; + else if (info.bpp == 16) width = 2*s->img_x; + else /* bpp = 32 and pad = 0 */ width=0; + pad = (-width) & 3; + if (info.bpp == 24) { + easy = 1; + } else if (info.bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } + // right shift amt to put high bit in position #7 + rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); + gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); + bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); + ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); + } + for (j=0; j < (int) s->img_y; ++j) { + if (easy) { + for (i=0; i < (int) s->img_x; ++i) { + unsigned char a; + out[z+2] = stbi__get8(s); + out[z+1] = stbi__get8(s); + out[z+0] = stbi__get8(s); + z += 3; + a = (easy == 2 ? stbi__get8(s) : 255); + all_a |= a; + if (target == 4) out[z++] = a; + } + } else { + int bpp = info.bpp; + for (i=0; i < (int) s->img_x; ++i) { + stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); + unsigned int a; + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); + a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); + all_a |= a; + if (target == 4) out[z++] = STBI__BYTECAST(a); + } + } + stbi__skip(s, pad); + } + } + + // if alpha channel is all 0s, replace with all 255s + if (target == 4 && all_a == 0) + for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) + out[i] = 255; + + if (flip_vertically) { + stbi_uc t; + for (j=0; j < (int) s->img_y>>1; ++j) { + stbi_uc *p1 = out + j *s->img_x*target; + stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; + for (i=0; i < (int) s->img_x*target; ++i) { + t = p1[i]; p1[i] = p2[i]; p2[i] = t; + } + } + } + + if (req_comp && req_comp != target) { + out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + return out; +} +#endif + +// Targa Truevision - TGA +// by Jonathan Dummer +#ifndef STBI_NO_TGA +// returns STBI_rgb or whatever, 0 on error +static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) +{ + // only RGB or RGBA (incl. 16bit) or grey allowed + if (is_rgb16) *is_rgb16 = 0; + switch(bits_per_pixel) { + case 8: return STBI_grey; + case 16: if(is_grey) return STBI_grey_alpha; + // fallthrough + case 15: if(is_rgb16) *is_rgb16 = 1; + return STBI_rgb; + case 24: // fallthrough + case 32: return bits_per_pixel/8; + default: return 0; + } +} + +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) +{ + int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; + int sz, tga_colormap_type; + stbi__get8(s); // discard Offset + tga_colormap_type = stbi__get8(s); // colormap type + if( tga_colormap_type > 1 ) { + stbi__rewind(s); + return 0; // only RGB or indexed allowed + } + tga_image_type = stbi__get8(s); // image type + if ( tga_colormap_type == 1 ) { // colormapped (paletted) image + if (tga_image_type != 1 && tga_image_type != 9) { + stbi__rewind(s); + return 0; + } + stbi__skip(s,4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { + stbi__rewind(s); + return 0; + } + stbi__skip(s,4); // skip image x and y origin + tga_colormap_bpp = sz; + } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE + if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { + stbi__rewind(s); + return 0; // only RGB or grey allowed, +/- RLE + } + stbi__skip(s,9); // skip colormap specification and image x/y origin + tga_colormap_bpp = 0; + } + tga_w = stbi__get16le(s); + if( tga_w < 1 ) { + stbi__rewind(s); + return 0; // test width + } + tga_h = stbi__get16le(s); + if( tga_h < 1 ) { + stbi__rewind(s); + return 0; // test height + } + tga_bits_per_pixel = stbi__get8(s); // bits per pixel + stbi__get8(s); // ignore alpha bits + if (tga_colormap_bpp != 0) { + if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { + // when using a colormap, tga_bits_per_pixel is the size of the indexes + // I don't think anything but 8 or 16bit indexes makes sense + stbi__rewind(s); + return 0; + } + tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); + } else { + tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); + } + if(!tga_comp) { + stbi__rewind(s); + return 0; + } + if (x) *x = tga_w; + if (y) *y = tga_h; + if (comp) *comp = tga_comp; + return 1; // seems to have passed everything +} + +static int stbi__tga_test(stbi__context *s) +{ + int res = 0; + int sz, tga_color_type; + stbi__get8(s); // discard Offset + tga_color_type = stbi__get8(s); // color type + if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed + sz = stbi__get8(s); // image type + if ( tga_color_type == 1 ) { // colormapped (paletted) image + if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 + stbi__skip(s,4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; + stbi__skip(s,4); // skip image x and y origin + } else { // "normal" image w/o colormap + if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE + stbi__skip(s,9); // skip colormap specification and image x/y origin + } + if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width + if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height + sz = stbi__get8(s); // bits per pixel + if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index + if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; + + res = 1; // if we got this far, everything's good and we can return 1 instead of 0 + +errorEnd: + stbi__rewind(s); + return res; +} + +// read 16bit value and convert to 24bit RGB +static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) +{ + stbi__uint16 px = (stbi__uint16)stbi__get16le(s); + stbi__uint16 fiveBitMask = 31; + // we have 3 channels with 5bits each + int r = (px >> 10) & fiveBitMask; + int g = (px >> 5) & fiveBitMask; + int b = px & fiveBitMask; + // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later + out[0] = (stbi_uc)((r * 255)/31); + out[1] = (stbi_uc)((g * 255)/31); + out[2] = (stbi_uc)((b * 255)/31); + + // some people claim that the most significant bit might be used for alpha + // (possibly if an alpha-bit is set in the "image descriptor byte") + // but that only made 16bit test images completely translucent.. + // so let's treat all 15 and 16bit TGAs as RGB with no alpha. +} + +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + // read in the TGA header stuff + int tga_offset = stbi__get8(s); + int tga_indexed = stbi__get8(s); + int tga_image_type = stbi__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = stbi__get16le(s); + int tga_palette_len = stbi__get16le(s); + int tga_palette_bits = stbi__get8(s); + int tga_x_origin = stbi__get16le(s); + int tga_y_origin = stbi__get16le(s); + int tga_width = stbi__get16le(s); + int tga_height = stbi__get16le(s); + int tga_bits_per_pixel = stbi__get8(s); + int tga_comp, tga_rgb16=0; + int tga_inverted = stbi__get8(s); + // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4] = {0}; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + STBI_NOTUSED(ri); + STBI_NOTUSED(tga_x_origin); // @TODO + STBI_NOTUSED(tga_y_origin); // @TODO + + // do a tiny bit of precessing + if ( tga_image_type >= 8 ) + { + tga_image_type -= 8; + tga_is_RLE = 1; + } + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // If I'm paletted, then I'll use the number of bits from the palette + if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); + else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); + + if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency + return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); + + // tga info + *x = tga_width; + *y = tga_height; + if (comp) *comp = tga_comp; + + if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) + return stbi__errpuc("too large", "Corrupt TGA"); + + tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); + if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); + + // skip to the data's starting position (offset usually = 0) + stbi__skip(s, tga_offset ); + + if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { + for (i=0; i < tga_height; ++i) { + int row = tga_inverted ? tga_height -i - 1 : i; + stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; + stbi__getn(s, tga_row, tga_width * tga_comp); + } + } else { + // do I need to load a palette? + if ( tga_indexed) + { + // any data to skip? (offset usually = 0) + stbi__skip(s, tga_palette_start ); + // load the palette + tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); + if (!tga_palette) { + STBI_FREE(tga_data); + return stbi__errpuc("outofmem", "Out of memory"); + } + if (tga_rgb16) { + stbi_uc *pal_entry = tga_palette; + STBI_ASSERT(tga_comp == STBI_rgb); + for (i=0; i < tga_palette_len; ++i) { + stbi__tga_read_rgb16(s, pal_entry); + pal_entry += tga_comp; + } + } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { + STBI_FREE(tga_data); + STBI_FREE(tga_palette); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + } + // load the data + for (i=0; i < tga_width * tga_height; ++i) + { + // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? + if ( tga_is_RLE ) + { + if ( RLE_count == 0 ) + { + // yep, get the next byte as a RLE command + int RLE_cmd = stbi__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } else if ( !RLE_repeating ) + { + read_next_pixel = 1; + } + } else + { + read_next_pixel = 1; + } + // OK, if I need to read a pixel, do it now + if ( read_next_pixel ) + { + // load however much data we did have + if ( tga_indexed ) + { + // read in index, then perform the lookup + int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); + if ( pal_idx >= tga_palette_len ) { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_comp; + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = tga_palette[pal_idx+j]; + } + } else if(tga_rgb16) { + STBI_ASSERT(tga_comp == STBI_rgb); + stbi__tga_read_rgb16(s, raw_data); + } else { + // read in the data raw + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = stbi__get8(s); + } + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel + + // copy data + for (j = 0; j < tga_comp; ++j) + tga_data[i*tga_comp+j] = raw_data[j]; + + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if ( tga_inverted ) + { + for (j = 0; j*2 < tga_height; ++j) + { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) + { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + // clear my palette, if I had one + if ( tga_palette != NULL ) + { + STBI_FREE( tga_palette ); + } + } + + // swap RGB - if the source data was RGB16, it already is in the right order + if (tga_comp >= 3 && !tga_rgb16) + { + unsigned char* tga_pixel = tga_data; + for (i=0; i < tga_width * tga_height; ++i) + { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } + + // convert to target component count + if (req_comp && req_comp != tga_comp) + tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = + tga_x_origin = tga_y_origin = 0; + STBI_NOTUSED(tga_palette_start); + // OK, done + return tga_data; +} +#endif + +// ************************************************************************************************* +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s) +{ + int r = (stbi__get32be(s) == 0x38425053); + stbi__rewind(s); + return r; +} + +static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) +{ + int count, nleft, len; + + count = 0; + while ((nleft = pixelCount - count) > 0) { + len = stbi__get8(s); + if (len == 128) { + // No-op. + } else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + if (len > nleft) return 0; // corrupt data + count += len; + while (len) { + *p = stbi__get8(s); + p += 4; + len--; + } + } else if (len > 128) { + stbi_uc val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len = 257 - len; + if (len > nleft) return 0; // corrupt data + val = stbi__get8(s); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + + return 1; +} + +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +{ + int pixelCount; + int channelCount, compression; + int channel, i; + int bitdepth; + int w,h; + stbi_uc *out; + STBI_NOTUSED(ri); + + // Check identifier + if (stbi__get32be(s) != 0x38425053) // "8BPS" + return stbi__errpuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (stbi__get16be(s) != 1) + return stbi__errpuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + stbi__skip(s, 6 ); + + // Read the number of channels (R, G, B, A, etc). + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) + return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = stbi__get32be(s); + w = stbi__get32be(s); + + // Make sure the depth is 8 bits. + bitdepth = stbi__get16be(s); + if (bitdepth != 8 && bitdepth != 16) + return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (stbi__get16be(s) != 3) + return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) + stbi__skip(s,stbi__get32be(s) ); + + // Skip the image resources. (resolution, pen tool paths, etc) + stbi__skip(s, stbi__get32be(s) ); + + // Skip the reserved data. + stbi__skip(s, stbi__get32be(s) ); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = stbi__get16be(s); + if (compression > 1) + return stbi__errpuc("bad compression", "PSD has an unknown compression format"); + + // Check size + if (!stbi__mad3sizes_valid(4, w, h, 0)) + return stbi__errpuc("too large", "Corrupt PSD"); + + // Create the destination image. + + if (!compression && bitdepth == 16 && bpc == 16) { + out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); + ri->bits_per_channel = 16; + } else + out = (stbi_uc *) stbi__malloc(4 * w*h); + + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + pixelCount = w*h; + + // Initialize the data to zero. + //memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + // Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, + // which we're going to just skip. + stbi__skip(s, h * channelCount * 2 ); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out+channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++, p += 4) + *p = (channel == 3 ? 255 : 0); + } else { + // Read the RLE data. + if (!stbi__psd_decode_rle(s, p, pixelCount)) { + STBI_FREE(out); + return stbi__errpuc("corrupt", "bad RLE data"); + } + } + } + + } else { + // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) + // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + if (channel >= channelCount) { + // Fill this channel with default data. + if (bitdepth == 16 && bpc == 16) { + stbi__uint16 *q = ((stbi__uint16 *) out) + channel; + stbi__uint16 val = channel == 3 ? 65535 : 0; + for (i = 0; i < pixelCount; i++, q += 4) + *q = val; + } else { + stbi_uc *p = out+channel; + stbi_uc val = channel == 3 ? 255 : 0; + for (i = 0; i < pixelCount; i++, p += 4) + *p = val; + } + } else { + if (ri->bits_per_channel == 16) { // output bpc + stbi__uint16 *q = ((stbi__uint16 *) out) + channel; + for (i = 0; i < pixelCount; i++, q += 4) + *q = (stbi__uint16) stbi__get16be(s); + } else { + stbi_uc *p = out+channel; + if (bitdepth == 16) { // input bpc + for (i = 0; i < pixelCount; i++, p += 4) + *p = (stbi_uc) (stbi__get16be(s) >> 8); + } else { + for (i = 0; i < pixelCount; i++, p += 4) + *p = stbi__get8(s); + } + } + } + } + } + + // remove weird white matte from PSD + if (channelCount >= 4) { + if (ri->bits_per_channel == 16) { + for (i=0; i < w*h; ++i) { + stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; + if (pixel[3] != 0 && pixel[3] != 65535) { + float a = pixel[3] / 65535.0f; + float ra = 1.0f / a; + float inv_a = 65535.0f * (1 - ra); + pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); + pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); + pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); + } + } + } else { + for (i=0; i < w*h; ++i) { + unsigned char *pixel = out + 4*i; + if (pixel[3] != 0 && pixel[3] != 255) { + float a = pixel[3] / 255.0f; + float ra = 1.0f / a; + float inv_a = 255.0f * (1 - ra); + pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); + pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); + pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); + } + } + } + } + + // convert to desired output format + if (req_comp && req_comp != 4) { + if (ri->bits_per_channel == 16) + out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); + else + out = stbi__convert_format(out, 4, req_comp, w, h); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + if (comp) *comp = 4; + *y = h; + *x = w; + + return out; +} +#endif + +// ************************************************************************************************* +// Softimage PIC loader +// by Tom Seddon +// +// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format +// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ + +#ifndef STBI_NO_PIC +static int stbi__pic_is4(stbi__context *s,const char *str) +{ + int i; + for (i=0; i<4; ++i) + if (stbi__get8(s) != (stbi_uc)str[i]) + return 0; + + return 1; +} + +static int stbi__pic_test_core(stbi__context *s) +{ + int i; + + if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) + return 0; + + for(i=0;i<84;++i) + stbi__get8(s); + + if (!stbi__pic_is4(s,"PICT")) + return 0; + + return 1; +} + +typedef struct +{ + stbi_uc size,type,channel; +} stbi__pic_packet; + +static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) +{ + int mask=0x80, i; + + for (i=0; i<4; ++i, mask>>=1) { + if (channel & mask) { + if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); + dest[i]=stbi__get8(s); + } + } + + return dest; +} + +static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) +{ + int mask=0x80,i; + + for (i=0;i<4; ++i, mask>>=1) + if (channel&mask) + dest[i]=src[i]; +} + +static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) +{ + int act_comp=0,num_packets=0,y,chained; + stbi__pic_packet packets[10]; + + // this will (should...) cater for even some bizarre stuff like having data + // for the same channel in multiple packets. + do { + stbi__pic_packet *packet; + + if (num_packets==sizeof(packets)/sizeof(packets[0])) + return stbi__errpuc("bad format","too many packets"); + + packet = &packets[num_packets++]; + + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + + act_comp |= packet->channel; + + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); + if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? + + for(y=0; ytype) { + default: + return stbi__errpuc("bad format","packet has bad compression type"); + + case 0: {//uncompressed + int x; + + for(x=0;xchannel,dest)) + return 0; + break; + } + + case 1://Pure RLE + { + int left=width, i; + + while (left>0) { + stbi_uc count,value[4]; + + count=stbi__get8(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); + + if (count > left) + count = (stbi_uc) left; + + if (!stbi__readval(s,packet->channel,value)) return 0; + + for(i=0; ichannel,dest,value); + left -= count; + } + } + break; + + case 2: {//Mixed RLE + int left=width; + while (left>0) { + int count = stbi__get8(s), i; + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); + + if (count >= 128) { // Repeated + stbi_uc value[4]; + + if (count==128) + count = stbi__get16be(s); + else + count -= 127; + if (count > left) + return stbi__errpuc("bad file","scanline overrun"); + + if (!stbi__readval(s,packet->channel,value)) + return 0; + + for(i=0;ichannel,dest,value); + } else { // Raw + ++count; + if (count>left) return stbi__errpuc("bad file","scanline overrun"); + + for(i=0;ichannel,dest)) + return 0; + } + left-=count; + } + break; + } + } + } + } + + return result; +} + +static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) +{ + stbi_uc *result; + int i, x,y, internal_comp; + STBI_NOTUSED(ri); + + if (!comp) comp = &internal_comp; + + for (i=0; i<92; ++i) + stbi__get8(s); + + x = stbi__get16be(s); + y = stbi__get16be(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); + if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); + + stbi__get32be(s); //skip `ratio' + stbi__get16be(s); //skip `fields' + stbi__get16be(s); //skip `pad' + + // intermediate buffer is RGBA + result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); + memset(result, 0xff, x*y*4); + + if (!stbi__pic_load_core(s,x,y,comp, result)) { + STBI_FREE(result); + result=0; + } + *px = x; + *py = y; + if (req_comp == 0) req_comp = *comp; + result=stbi__convert_format(result,4,req_comp,x,y); + + return result; +} + +static int stbi__pic_test(stbi__context *s) +{ + int r = stbi__pic_test_core(s); + stbi__rewind(s); + return r; +} +#endif + +// ************************************************************************************************* +// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb + +#ifndef STBI_NO_GIF +typedef struct +{ + stbi__int16 prefix; + stbi_uc first; + stbi_uc suffix; +} stbi__gif_lzw; + +typedef struct +{ + int w,h; + stbi_uc *out; // output buffer (always 4 components) + stbi_uc *background; // The current "background" as far as a gif is concerned + stbi_uc *history; + int flags, bgindex, ratio, transparent, eflags; + stbi_uc pal[256][4]; + stbi_uc lpal[256][4]; + stbi__gif_lzw codes[8192]; + stbi_uc *color_table; + int parse, step; + int lflags; + int start_x, start_y; + int max_x, max_y; + int cur_x, cur_y; + int line_size; + int delay; +} stbi__gif; + +static int stbi__gif_test_raw(stbi__context *s) +{ + int sz; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; + sz = stbi__get8(s); + if (sz != '9' && sz != '7') return 0; + if (stbi__get8(s) != 'a') return 0; + return 1; +} + +static int stbi__gif_test(stbi__context *s) +{ + int r = stbi__gif_test_raw(s); + stbi__rewind(s); + return r; +} + +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) +{ + int i; + for (i=0; i < num_entries; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + pal[i][3] = transp == i ? 0 : 255; + } +} + +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) +{ + stbi_uc version; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') + return stbi__err("not GIF", "Corrupt GIF"); + + version = stbi__get8(s); + if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); + if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); + + stbi__g_failure_reason = ""; + g->w = stbi__get16le(s); + g->h = stbi__get16le(s); + g->flags = stbi__get8(s); + g->bgindex = stbi__get8(s); + g->ratio = stbi__get8(s); + g->transparent = -1; + + if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments + + if (is_info) return 1; + + if (g->flags & 0x80) + stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); + + return 1; +} + +static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); + if (!stbi__gif_header(s, g, comp, 1)) { + STBI_FREE(g); + stbi__rewind( s ); + return 0; + } + if (x) *x = g->w; + if (y) *y = g->h; + STBI_FREE(g); + return 1; +} + +static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) +{ + stbi_uc *p, *c; + int idx; + + // recurse to decode the prefixes, since the linked-list is backwards, + // and working backwards through an interleaved image would be nasty + if (g->codes[code].prefix >= 0) + stbi__out_gif_code(g, g->codes[code].prefix); + + if (g->cur_y >= g->max_y) return; + + idx = g->cur_x + g->cur_y; + p = &g->out[idx]; + g->history[idx / 4] = 1; + + c = &g->color_table[g->codes[code].suffix * 4]; + if (c[3] > 128) { // don't render transparent pixels; + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = c[3]; + } + g->cur_x += 4; + + if (g->cur_x >= g->max_x) { + g->cur_x = g->start_x; + g->cur_y += g->step; + + while (g->cur_y >= g->max_y && g->parse > 0) { + g->step = (1 << g->parse) * g->line_size; + g->cur_y = g->start_y + (g->step >> 1); + --g->parse; + } + } +} + +static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) +{ + stbi_uc lzw_cs; + stbi__int32 len, init_code; + stbi__uint32 first; + stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; + stbi__gif_lzw *p; + + lzw_cs = stbi__get8(s); + if (lzw_cs > 12) return NULL; + clear = 1 << lzw_cs; + first = 1; + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + bits = 0; + valid_bits = 0; + for (init_code = 0; init_code < clear; init_code++) { + g->codes[init_code].prefix = -1; + g->codes[init_code].first = (stbi_uc) init_code; + g->codes[init_code].suffix = (stbi_uc) init_code; + } + + // support no starting clear code + avail = clear+2; + oldcode = -1; + + len = 0; + for(;;) { + if (valid_bits < codesize) { + if (len == 0) { + len = stbi__get8(s); // start new block + if (len == 0) + return g->out; + } + --len; + bits |= (stbi__int32) stbi__get8(s) << valid_bits; + valid_bits += 8; + } else { + stbi__int32 code = bits & codemask; + bits >>= codesize; + valid_bits -= codesize; + // @OPTIMIZE: is there some way we can accelerate the non-clear path? + if (code == clear) { // clear code + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + first = 0; + } else if (code == clear + 1) { // end of stream code + stbi__skip(s, len); + while ((len = stbi__get8(s)) > 0) + stbi__skip(s,len); + return g->out; + } else if (code <= avail) { + if (first) { + return stbi__errpuc("no clear code", "Corrupt GIF"); + } + + if (oldcode >= 0) { + p = &g->codes[avail++]; + if (avail > 8192) { + return stbi__errpuc("too many codes", "Corrupt GIF"); + } + + p->prefix = (stbi__int16) oldcode; + p->first = g->codes[oldcode].first; + p->suffix = (code == avail) ? p->first : g->codes[code].first; + } else if (code == avail) + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + + stbi__out_gif_code(g, (stbi__uint16) code); + + if ((avail & codemask) == 0 && avail <= 0x0FFF) { + codesize++; + codemask = (1 << codesize) - 1; + } + + oldcode = code; + } else { + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + } + } + } +} + +// this function is designed to support animated gifs, although stb_image doesn't support it +// two back is the image from two frames ago, used for a very specific disposal format +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) +{ + int dispose; + int first_frame; + int pi; + int pcount; + STBI_NOTUSED(req_comp); + + // on first frame, any non-written pixels get the background colour (non-transparent) + first_frame = 0; + if (g->out == 0) { + if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header + if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) + return stbi__errpuc("too large", "GIF image is too large"); + pcount = g->w * g->h; + g->out = (stbi_uc *) stbi__malloc(4 * pcount); + g->background = (stbi_uc *) stbi__malloc(4 * pcount); + g->history = (stbi_uc *) stbi__malloc(pcount); + if (!g->out || !g->background || !g->history) + return stbi__errpuc("outofmem", "Out of memory"); + + // image is treated as "transparent" at the start - ie, nothing overwrites the current background; + // background colour is only used for pixels that are not rendered first frame, after that "background" + // color refers to the color that was there the previous frame. + memset(g->out, 0x00, 4 * pcount); + memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) + memset(g->history, 0x00, pcount); // pixels that were affected previous frame + first_frame = 1; + } else { + // second frame - how do we dispoase of the previous one? + dispose = (g->eflags & 0x1C) >> 2; + pcount = g->w * g->h; + + if ((dispose == 3) && (two_back == 0)) { + dispose = 2; // if I don't have an image to revert back to, default to the old background + } + + if (dispose == 3) { // use previous graphic + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); + } + } + } else if (dispose == 2) { + // restore what was changed last frame to background before that frame; + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); + } + } + } else { + // This is a non-disposal case eithe way, so just + // leave the pixels as is, and they will become the new background + // 1: do not dispose + // 0: not specified. + } + + // background is what out is after the undoing of the previou frame; + memcpy( g->background, g->out, 4 * g->w * g->h ); + } + + // clear my history; + memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame + + for (;;) { + int tag = stbi__get8(s); + switch (tag) { + case 0x2C: /* Image Descriptor */ + { + stbi__int32 x, y, w, h; + stbi_uc *o; + + x = stbi__get16le(s); + y = stbi__get16le(s); + w = stbi__get16le(s); + h = stbi__get16le(s); + if (((x + w) > (g->w)) || ((y + h) > (g->h))) + return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); + + g->line_size = g->w * 4; + g->start_x = x * 4; + g->start_y = y * g->line_size; + g->max_x = g->start_x + w * 4; + g->max_y = g->start_y + h * g->line_size; + g->cur_x = g->start_x; + g->cur_y = g->start_y; + + // if the width of the specified rectangle is 0, that means + // we may not see *any* pixels or the image is malformed; + // to make sure this is caught, move the current y down to + // max_y (which is what out_gif_code checks). + if (w == 0) + g->cur_y = g->max_y; + + g->lflags = stbi__get8(s); + + if (g->lflags & 0x40) { + g->step = 8 * g->line_size; // first interlaced spacing + g->parse = 3; + } else { + g->step = g->line_size; + g->parse = 0; + } + + if (g->lflags & 0x80) { + stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); + g->color_table = (stbi_uc *) g->lpal; + } else if (g->flags & 0x80) { + g->color_table = (stbi_uc *) g->pal; + } else + return stbi__errpuc("missing color table", "Corrupt GIF"); + + o = stbi__process_gif_raster(s, g); + if (!o) return NULL; + + // if this was the first frame, + pcount = g->w * g->h; + if (first_frame && (g->bgindex > 0)) { + // if first frame, any pixel not drawn to gets the background color + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi] == 0) { + g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; + memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); + } + } + } + + return o; + } + + case 0x21: // Comment Extension. + { + int len; + int ext = stbi__get8(s); + if (ext == 0xF9) { // Graphic Control Extension. + len = stbi__get8(s); + if (len == 4) { + g->eflags = stbi__get8(s); + g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. + + // unset old transparent + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 255; + } + if (g->eflags & 0x01) { + g->transparent = stbi__get8(s); + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 0; + } + } else { + // don't need transparent + stbi__skip(s, 1); + g->transparent = -1; + } + } else { + stbi__skip(s, len); + break; + } + } + while ((len = stbi__get8(s)) != 0) { + stbi__skip(s, len); + } + break; + } + + case 0x3B: // gif stream termination code + return (stbi_uc *) s; // using '1' causes warning on some compilers + + default: + return stbi__errpuc("unknown code", "Corrupt GIF"); + } + } +} + +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +{ + if (stbi__gif_test(s)) { + int layers = 0; + stbi_uc *u = 0; + stbi_uc *out = 0; + stbi_uc *two_back = 0; + stbi__gif g; + int stride; + memset(&g, 0, sizeof(g)); + if (delays) { + *delays = 0; + } + + do { + u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); + if (u == (stbi_uc *) s) u = 0; // end of animated gif marker + + if (u) { + *x = g.w; + *y = g.h; + ++layers; + stride = g.w * g.h * 4; + + if (out) { + void *tmp = (stbi_uc*) STBI_REALLOC( out, layers * stride ); + if (NULL == tmp) { + STBI_FREE(g.out); + STBI_FREE(g.history); + STBI_FREE(g.background); + return stbi__errpuc("outofmem", "Out of memory"); + } + else + out = (stbi_uc*) tmp; + if (delays) { + *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); + } + } else { + out = (stbi_uc*)stbi__malloc( layers * stride ); + if (delays) { + *delays = (int*) stbi__malloc( layers * sizeof(int) ); + } + } + memcpy( out + ((layers - 1) * stride), u, stride ); + if (layers >= 2) { + two_back = out - 2 * stride; + } + + if (delays) { + (*delays)[layers - 1U] = g.delay; + } + } + } while (u != 0); + + // free temp buffer; + STBI_FREE(g.out); + STBI_FREE(g.history); + STBI_FREE(g.background); + + // do the final conversion after loading everything; + if (req_comp && req_comp != 4) + out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); + + *z = layers; + return out; + } else { + return stbi__errpuc("not GIF", "Image was not as a gif type."); + } +} + +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *u = 0; + stbi__gif g; + memset(&g, 0, sizeof(g)); + STBI_NOTUSED(ri); + + u = stbi__gif_load_next(s, &g, comp, req_comp, 0); + if (u == (stbi_uc *) s) u = 0; // end of animated gif marker + if (u) { + *x = g.w; + *y = g.h; + + // moved conversion to after successful load so that the same + // can be done for multiple frames. + if (req_comp && req_comp != 4) + u = stbi__convert_format(u, 4, req_comp, g.w, g.h); + } else if (g.out) { + // if there was an error and we allocated an image buffer, free it! + STBI_FREE(g.out); + } + + // free buffers needed for multiple frame loading; + STBI_FREE(g.history); + STBI_FREE(g.background); + + return u; +} + +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) +{ + return stbi__gif_info_raw(s,x,y,comp); +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR loader +// originally by Nicolas Schulz +#ifndef STBI_NO_HDR +static int stbi__hdr_test_core(stbi__context *s, const char *signature) +{ + int i; + for (i=0; signature[i]; ++i) + if (stbi__get8(s) != signature[i]) + return 0; + stbi__rewind(s); + return 1; +} + +static int stbi__hdr_test(stbi__context* s) +{ + int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); + stbi__rewind(s); + if(!r) { + r = stbi__hdr_test_core(s, "#?RGBE\n"); + stbi__rewind(s); + } + return r; +} + +#define STBI__HDR_BUFLEN 1024 +static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) +{ + int len=0; + char c = '\0'; + + c = (char) stbi__get8(z); + + while (!stbi__at_eof(z) && c != '\n') { + buffer[len++] = c; + if (len == STBI__HDR_BUFLEN-1) { + // flush to end of line + while (!stbi__at_eof(z) && stbi__get8(z) != '\n') + ; + break; + } + c = (char) stbi__get8(z); + } + + buffer[len] = 0; + return buffer; +} + +static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) +{ + if ( input[3] != 0 ) { + float f1; + // Exponent + f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) output[1] = 1; + if (req_comp == 4) output[3] = 1; + } else { + switch (req_comp) { + case 4: output[3] = 1; /* fallthrough */ + case 3: output[0] = output[1] = output[2] = 0; + break; + case 2: output[1] = 1; /* fallthrough */ + case 1: output[0] = 0; + break; + } + } +} + +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1,c2, z; + const char *headerToken; + STBI_NOTUSED(ri); + + // Check identifier + headerToken = stbi__hdr_gettoken(s,buffer); + if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) + return stbi__errpf("not HDR", "Corrupt HDR image"); + + // Parse header + for(;;) { + token = stbi__hdr_gettoken(s,buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = stbi__hdr_gettoken(s,buffer); + if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = (int) strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = (int) strtol(token, NULL, 10); + + *x = width; + *y = height; + + if (comp) *comp = 3; + if (req_comp == 0) req_comp = 3; + + if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) + return stbi__errpf("too large", "HDR image is too large"); + + // Read data + hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); + if (!hdr_data) + return stbi__errpf("outofmem", "Out of memory"); + + // Load image data + // image data is stored as some number of sca + if ( width < 8 || width >= 32768) { + // Read flat data + for (j=0; j < height; ++j) { + for (i=0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + stbi__getn(s, rgbe, 4); + stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); + } + } + } else { + // Read RLE-encoded data + scanline = NULL; + + for (j = 0; j < height; ++j) { + c1 = stbi__get8(s); + c2 = stbi__get8(s); + len = stbi__get8(s); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a decoded + // pixel (note this can't be a valid pixel--one of RGB must be >= 128) + stbi_uc rgbe[4]; + rgbe[0] = (stbi_uc) c1; + rgbe[1] = (stbi_uc) c2; + rgbe[2] = (stbi_uc) len; + rgbe[3] = (stbi_uc) stbi__get8(s); + stbi__hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + STBI_FREE(scanline); + goto main_decode_loop; // yes, this makes no sense + } + len <<= 8; + len |= stbi__get8(s); + if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } + if (scanline == NULL) { + scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); + if (!scanline) { + STBI_FREE(hdr_data); + return stbi__errpf("outofmem", "Out of memory"); + } + } + + for (k = 0; k < 4; ++k) { + int nleft; + i = 0; + while ((nleft = width - i) > 0) { + count = stbi__get8(s); + if (count > 128) { + // Run + value = stbi__get8(s); + count -= 128; + if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } else { + // Dump + if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = stbi__get8(s); + } + } + } + for (i=0; i < width; ++i) + stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); + } + if (scanline) + STBI_FREE(scanline); + } + + return hdr_data; +} + +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int dummy; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + if (stbi__hdr_test(s) == 0) { + stbi__rewind( s ); + return 0; + } + + for(;;) { + token = stbi__hdr_gettoken(s,buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) { + stbi__rewind( s ); + return 0; + } + token = stbi__hdr_gettoken(s,buffer); + if (strncmp(token, "-Y ", 3)) { + stbi__rewind( s ); + return 0; + } + token += 3; + *y = (int) strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) { + stbi__rewind( s ); + return 0; + } + token += 3; + *x = (int) strtol(token, NULL, 10); + *comp = 3; + return 1; +} +#endif // STBI_NO_HDR + +#ifndef STBI_NO_BMP +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) +{ + void *p; + stbi__bmp_data info; + + info.all_a = 255; + p = stbi__bmp_parse_header(s, &info); + stbi__rewind( s ); + if (p == NULL) + return 0; + if (x) *x = s->img_x; + if (y) *y = s->img_y; + if (comp) { + if (info.bpp == 24 && info.ma == 0xff000000) + *comp = 3; + else + *comp = info.ma ? 4 : 3; + } + return 1; +} +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) +{ + int channelCount, dummy, depth; + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind( s ); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind( s ); + return 0; + } + *y = stbi__get32be(s); + *x = stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 8 && depth != 16) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 3) { + stbi__rewind( s ); + return 0; + } + *comp = 4; + return 1; +} + +static int stbi__psd_is16(stbi__context *s) +{ + int channelCount, depth; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind( s ); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind( s ); + return 0; + } + (void) stbi__get32be(s); + (void) stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 16) { + stbi__rewind( s ); + return 0; + } + return 1; +} +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) +{ + int act_comp=0,num_packets=0,chained,dummy; + stbi__pic_packet packets[10]; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 88); + + *x = stbi__get16be(s); + *y = stbi__get16be(s); + if (stbi__at_eof(s)) { + stbi__rewind( s); + return 0; + } + if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { + stbi__rewind( s ); + return 0; + } + + stbi__skip(s, 8); + + do { + stbi__pic_packet *packet; + + if (num_packets==sizeof(packets)/sizeof(packets[0])) + return 0; + + packet = &packets[num_packets++]; + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + act_comp |= packet->channel; + + if (stbi__at_eof(s)) { + stbi__rewind( s ); + return 0; + } + if (packet->size != 8) { + stbi__rewind( s ); + return 0; + } + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); + + return 1; +} +#endif + +// ************************************************************************************************* +// Portable Gray Map and Portable Pixel Map loader +// by Ken Miller +// +// PGM: http://netpbm.sourceforge.net/doc/pgm.html +// PPM: http://netpbm.sourceforge.net/doc/ppm.html +// +// Known limitations: +// Does not support comments in the header section +// Does not support ASCII image data (formats P2 and P3) +// Does not support 16-bit-per-channel + +#ifndef STBI_NO_PNM + +static int stbi__pnm_test(stbi__context *s) +{ + char p, t; + p = (char) stbi__get8(s); + t = (char) stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind( s ); + return 0; + } + return 1; +} + +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *out; + STBI_NOTUSED(ri); + + if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) + return 0; + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + + if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "PNM too large"); + + out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + stbi__getn(s, out, s->img_n * s->img_x * s->img_y); + + if (req_comp && req_comp != s->img_n) { + out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + return out; +} + +static int stbi__pnm_isspace(char c) +{ + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; +} + +static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) +{ + for (;;) { + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char) stbi__get8(s); + + if (stbi__at_eof(s) || *c != '#') + break; + + while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) + *c = (char) stbi__get8(s); + } +} + +static int stbi__pnm_isdigit(char c) +{ + return c >= '0' && c <= '9'; +} + +static int stbi__pnm_getinteger(stbi__context *s, char *c) +{ + int value = 0; + + while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { + value = value*10 + (*c - '0'); + *c = (char) stbi__get8(s); + } + + return value; +} + +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) +{ + int maxv, dummy; + char c, p, t; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + stbi__rewind(s); + + // Get identifier + p = (char) stbi__get8(s); + t = (char) stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + + *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm + + c = (char) stbi__get8(s); + stbi__pnm_skip_whitespace(s, &c); + + *x = stbi__pnm_getinteger(s, &c); // read width + stbi__pnm_skip_whitespace(s, &c); + + *y = stbi__pnm_getinteger(s, &c); // read height + stbi__pnm_skip_whitespace(s, &c); + + maxv = stbi__pnm_getinteger(s, &c); // read max value + + if (maxv > 255) + return stbi__err("max value > 255", "PPM image not 8-bit"); + else + return 1; +} +#endif + +static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) +{ + #ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNG + if (stbi__png_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_GIF + if (stbi__gif_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_BMP + if (stbi__bmp_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PSD + if (stbi__psd_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PIC + if (stbi__pic_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNM + if (stbi__pnm_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_HDR + if (stbi__hdr_info(s, x, y, comp)) return 1; + #endif + + // test tga last because it's a crappy test! + #ifndef STBI_NO_TGA + if (stbi__tga_info(s, x, y, comp)) + return 1; + #endif + return stbi__err("unknown image type", "Image not of any known type, or corrupt"); +} + +static int stbi__is_16_main(stbi__context *s) +{ + #ifndef STBI_NO_PNG + if (stbi__png_is16(s)) return 1; + #endif + + #ifndef STBI_NO_PSD + if (stbi__psd_is16(s)) return 1; + #endif + + return 0; +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_info_from_file(f, x, y, comp); + fclose(f); + return result; +} + +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__info_main(&s,x,y,comp); + fseek(f,pos,SEEK_SET); + return r; +} + +STBIDEF int stbi_is_16_bit(char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_is_16_bit_from_file(f); + fclose(f); + return result; +} + +STBIDEF int stbi_is_16_bit_from_file(FILE *f) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__is_16_main(&s); + fseek(f,pos,SEEK_SET); + return r; +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__info_main(&s,x,y,comp); +} + +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); + return stbi__info_main(&s,x,y,comp); +} + +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__is_16_main(&s); +} + +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); + return stbi__is_16_main(&s); +} + +#endif // STB_IMAGE_IMPLEMENTATION + +/* + revision history: + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs + 2.19 (2018-02-11) fix warning + 2.18 (2018-01-30) fix warnings + 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug + 1-bit BMP + *_is_16_bit api + avoid warnings + 2.16 (2017-07-23) all functions have 16-bit variants; + STBI_NO_STDIO works again; + compilation fixes; + fix rounding in unpremultiply; + optimize vertical flip; + disable raw_len validation; + documentation fixes + 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; + warning fixes; disable run-time SSE detection on gcc; + uniform handling of optional "return" values; + thread-safe initialization of zlib tables + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs + 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now + 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes + 2.11 (2016-04-02) allocate large structures on the stack + remove white matting for transparent PSD + fix reported channel count for PNG & BMP + re-enable SSE2 in non-gcc 64-bit + support RGB-formatted JPEG + read 16-bit PNGs (only as 8-bit) + 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED + 2.09 (2016-01-16) allow comments in PNM files + 16-bit-per-pixel TGA (not bit-per-component) + info() for TGA could break due to .hdr handling + info() for BMP to shares code instead of sloppy parse + can use STBI_REALLOC_SIZED if allocator doesn't support realloc + code cleanup + 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA + 2.07 (2015-09-13) fix compiler warnings + partial animated GIF support + limited 16-bpc PSD support + #ifdef unused functions + bug with < 92 byte PIC,PNM,HDR,TGA + 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value + 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning + 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit + 2.03 (2015-04-12) extra corruption checking (mmozeiko) + stbi_set_flip_vertically_on_load (nguillemot) + fix NEON support; fix mingw support + 2.02 (2015-01-19) fix incorrect assert, fix warning + 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 + 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG + 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) + progressive JPEG (stb) + PGM/PPM support (Ken Miller) + STBI_MALLOC,STBI_REALLOC,STBI_FREE + GIF bugfix -- seemingly never worked + STBI_NO_*, STBI_ONLY_* + 1.48 (2014-12-14) fix incorrectly-named assert() + 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) + optimize PNG (ryg) + fix bug in interlaced PNG with user-specified channel count (stb) + 1.46 (2014-08-26) + fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG + 1.45 (2014-08-16) + fix MSVC-ARM internal compiler error by wrapping malloc + 1.44 (2014-08-07) + various warning fixes from Ronny Chevalier + 1.43 (2014-07-15) + fix MSVC-only compiler problem in code changed in 1.42 + 1.42 (2014-07-09) + don't define _CRT_SECURE_NO_WARNINGS (affects user code) + fixes to stbi__cleanup_jpeg path + added STBI_ASSERT to avoid requiring assert.h + 1.41 (2014-06-25) + fix search&replace from 1.36 that messed up comments/error messages + 1.40 (2014-06-22) + fix gcc struct-initialization warning + 1.39 (2014-06-15) + fix to TGA optimization when req_comp != number of components in TGA; + fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) + add support for BMP version 5 (more ignored fields) + 1.38 (2014-06-06) + suppress MSVC warnings on integer casts truncating values + fix accidental rename of 'skip' field of I/O + 1.37 (2014-06-04) + remove duplicate typedef + 1.36 (2014-06-03) + convert to header file single-file library + if de-iphone isn't set, load iphone images color-swapped instead of returning NULL + 1.35 (2014-05-27) + various warnings + fix broken STBI_SIMD path + fix bug where stbi_load_from_file no longer left file pointer in correct place + fix broken non-easy path for 32-bit BMP (possibly never used) + TGA optimization by Arseny Kapoulkine + 1.34 (unknown) + use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case + 1.33 (2011-07-14) + make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements + 1.32 (2011-07-13) + support for "info" function for all supported filetypes (SpartanJ) + 1.31 (2011-06-20) + a few more leak fixes, bug in PNG handling (SpartanJ) + 1.30 (2011-06-11) + added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) + removed deprecated format-specific test/load functions + removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway + error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) + fix inefficiency in decoding 32-bit BMP (David Woo) + 1.29 (2010-08-16) + various warning fixes from Aurelien Pocheville + 1.28 (2010-08-01) + fix bug in GIF palette transparency (SpartanJ) + 1.27 (2010-08-01) + cast-to-stbi_uc to fix warnings + 1.26 (2010-07-24) + fix bug in file buffering for PNG reported by SpartanJ + 1.25 (2010-07-17) + refix trans_data warning (Won Chun) + 1.24 (2010-07-12) + perf improvements reading from files on platforms with lock-heavy fgetc() + minor perf improvements for jpeg + deprecated type-specific functions so we'll get feedback if they're needed + attempt to fix trans_data warning (Won Chun) + 1.23 fixed bug in iPhone support + 1.22 (2010-07-10) + removed image *writing* support + stbi_info support from Jetro Lauha + GIF support from Jean-Marc Lienher + iPhone PNG-extensions from James Brown + warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) + 1.21 fix use of 'stbi_uc' in header (reported by jon blow) + 1.20 added support for Softimage PIC, by Tom Seddon + 1.19 bug in interlaced PNG corruption check (found by ryg) + 1.18 (2008-08-02) + fix a threading bug (local mutable static) + 1.17 support interlaced PNG + 1.16 major bugfix - stbi__convert_format converted one too many pixels + 1.15 initialize some fields for thread safety + 1.14 fix threadsafe conversion bug + header-file-only version (#define STBI_HEADER_FILE_ONLY before including) + 1.13 threadsafe + 1.12 const qualifiers in the API + 1.11 Support installable IDCT, colorspace conversion routines + 1.10 Fixes for 64-bit (don't use "unsigned long") + optimized upsampling by Fabian "ryg" Giesen + 1.09 Fix format-conversion for PSD code (bad global variables!) + 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz + 1.07 attempt to fix C++ warning/errors again + 1.06 attempt to fix C++ warning/errors again + 1.05 fix TGA loading to return correct *comp and use good luminance calc + 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free + 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR + 1.02 support for (subset of) HDR files, float interface for preferred access to them + 1.01 fix bug: possible bug in handling right-side up bmps... not sure + fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all + 1.00 interface to zlib that skips zlib header + 0.99 correct handling of alpha in palette + 0.98 TGA loader by lonesock; dynamically add loaders (untested) + 0.97 jpeg errors on too large a file; also catch another malloc failure + 0.96 fix detection of invalid v value - particleman@mollyrocket forum + 0.95 during header scan, seek to markers in case of padding + 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same + 0.93 handle jpegtran output; verbose errors + 0.92 read 4,8,16,24,32-bit BMP files of several formats + 0.91 output 24-bit Windows 3.0 BMP files + 0.90 fix a few more warnings; bump version number to approach 1.0 + 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd + 0.60 fix compiling as c++ + 0.59 fix warnings: merge Dave Moore's -Wall fixes + 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian + 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available + 0.56 fix bug: zlib uncompressed mode len vs. nlen + 0.55 fix bug: restart_interval not initialized to 0 + 0.54 allow NULL for 'int *comp' + 0.53 fix bug in png 3->4; speedup png decoding + 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments + 0.51 obey req_comp requests, 1-component jpegs return as 1-component, + on 'test' only check type, not whether we support this variant + 0.50 (2006-11-19) + first released version +*/ + + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/extern/stb/stb_image_resize.h b/extern/stb/stb_image_resize.h new file mode 100644 index 00000000..42a8efb1 --- /dev/null +++ b/extern/stb/stb_image_resize.h @@ -0,0 +1,2631 @@ +/* stb_image_resize - v0.96 - public domain image resizing + by Jorge L Rodriguez (@VinoBS) - 2014 + http://github.com/nothings/stb + + Written with emphasis on usability, portability, and efficiency. (No + SIMD or threads, so it be easily outperformed by libs that use those.) + Only scaling and translation is supported, no rotations or shears. + Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation. + + COMPILING & LINKING + In one C/C++ file that #includes this file, do this: + #define STB_IMAGE_RESIZE_IMPLEMENTATION + before the #include. That will create the implementation in that file. + + QUICKSTART + stbir_resize_uint8( input_pixels , in_w , in_h , 0, + output_pixels, out_w, out_h, 0, num_channels) + stbir_resize_float(...) + stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0, + output_pixels, out_w, out_h, 0, + num_channels , alpha_chan , 0) + stbir_resize_uint8_srgb_edgemode( + input_pixels , in_w , in_h , 0, + output_pixels, out_w, out_h, 0, + num_channels , alpha_chan , 0, STBIR_EDGE_CLAMP) + // WRAP/REFLECT/ZERO + + FULL API + See the "header file" section of the source for API documentation. + + ADDITIONAL DOCUMENTATION + + SRGB & FLOATING POINT REPRESENTATION + The sRGB functions presume IEEE floating point. If you do not have + IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use + a slower implementation. + + MEMORY ALLOCATION + The resize functions here perform a single memory allocation using + malloc. To control the memory allocation, before the #include that + triggers the implementation, do: + + #define STBIR_MALLOC(size,context) ... + #define STBIR_FREE(ptr,context) ... + + Each resize function makes exactly one call to malloc/free, so to use + temp memory, store the temp memory in the context and return that. + + ASSERT + Define STBIR_ASSERT(boolval) to override assert() and not use assert.h + + OPTIMIZATION + Define STBIR_SATURATE_INT to compute clamp values in-range using + integer operations instead of float operations. This may be faster + on some platforms. + + DEFAULT FILTERS + For functions which don't provide explicit control over what filters + to use, you can change the compile-time defaults with + + #define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_something + #define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_something + + See stbir_filter in the header-file section for the list of filters. + + NEW FILTERS + A number of 1D filter kernels are used. For a list of + supported filters see the stbir_filter enum. To add a new filter, + write a filter function and add it to stbir__filter_info_table. + + PROGRESS + For interactive use with slow resize operations, you can install + a progress-report callback: + + #define STBIR_PROGRESS_REPORT(val) some_func(val) + + The parameter val is a float which goes from 0 to 1 as progress is made. + + For example: + + static void my_progress_report(float progress); + #define STBIR_PROGRESS_REPORT(val) my_progress_report(val) + + #define STB_IMAGE_RESIZE_IMPLEMENTATION + #include "stb_image_resize.h" + + static void my_progress_report(float progress) + { + printf("Progress: %f%%\n", progress*100); + } + + MAX CHANNELS + If your image has more than 64 channels, define STBIR_MAX_CHANNELS + to the max you'll have. + + ALPHA CHANNEL + Most of the resizing functions provide the ability to control how + the alpha channel of an image is processed. The important things + to know about this: + + 1. The best mathematically-behaved version of alpha to use is + called "premultiplied alpha", in which the other color channels + have had the alpha value multiplied in. If you use premultiplied + alpha, linear filtering (such as image resampling done by this + library, or performed in texture units on GPUs) does the "right + thing". While premultiplied alpha is standard in the movie CGI + industry, it is still uncommon in the videogame/real-time world. + + If you linearly filter non-premultiplied alpha, strange effects + occur. (For example, the 50/50 average of 99% transparent bright green + and 1% transparent black produces 50% transparent dark green when + non-premultiplied, whereas premultiplied it produces 50% + transparent near-black. The former introduces green energy + that doesn't exist in the source image.) + + 2. Artists should not edit premultiplied-alpha images; artists + want non-premultiplied alpha images. Thus, art tools generally output + non-premultiplied alpha images. + + 3. You will get best results in most cases by converting images + to premultiplied alpha before processing them mathematically. + + 4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the + resizer does not do anything special for the alpha channel; + it is resampled identically to other channels. This produces + the correct results for premultiplied-alpha images, but produces + less-than-ideal results for non-premultiplied-alpha images. + + 5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, + then the resizer weights the contribution of input pixels + based on their alpha values, or, equivalently, it multiplies + the alpha value into the color channels, resamples, then divides + by the resultant alpha value. Input pixels which have alpha=0 do + not contribute at all to output pixels unless _all_ of the input + pixels affecting that output pixel have alpha=0, in which case + the result for that pixel is the same as it would be without + STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for + input images in integer formats. For input images in float format, + input pixels with alpha=0 have no effect, and output pixels + which have alpha=0 will be 0 in all channels. (For float images, + you can manually achieve the same result by adding a tiny epsilon + value to the alpha channel of every image, and then subtracting + or clamping it at the end.) + + 6. You can suppress the behavior described in #5 and make + all-0-alpha pixels have 0 in all channels by #defining + STBIR_NO_ALPHA_EPSILON. + + 7. You can separately control whether the alpha channel is + interpreted as linear or affected by the colorspace. By default + it is linear; you almost never want to apply the colorspace. + (For example, graphics hardware does not apply sRGB conversion + to the alpha channel.) + + CONTRIBUTORS + Jorge L Rodriguez: Implementation + Sean Barrett: API design, optimizations + Aras Pranckevicius: bugfix + Nathan Reed: warning fixes + + REVISIONS + 0.97 (2020-02-02) fixed warning + 0.96 (2019-03-04) fixed warnings + 0.95 (2017-07-23) fixed warnings + 0.94 (2017-03-18) fixed warnings + 0.93 (2017-03-03) fixed bug with certain combinations of heights + 0.92 (2017-01-02) fix integer overflow on large (>2GB) images + 0.91 (2016-04-02) fix warnings; fix handling of subpixel regions + 0.90 (2014-09-17) first released version + + LICENSE + See end of file for license information. + + TODO + Don't decode all of the image data when only processing a partial tile + Don't use full-width decode buffers when only processing a partial tile + When processing wide images, break processing into tiles so data fits in L1 cache + Installable filters? + Resize that respects alpha test coverage + (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage: + https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp ) +*/ + +#ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H +#define STBIR_INCLUDE_STB_IMAGE_RESIZE_H + +#ifdef _MSC_VER +typedef unsigned char stbir_uint8; +typedef unsigned short stbir_uint16; +typedef unsigned int stbir_uint32; +#else +#include +typedef uint8_t stbir_uint8; +typedef uint16_t stbir_uint16; +typedef uint32_t stbir_uint32; +#endif + +#ifndef STBIRDEF +#ifdef STB_IMAGE_RESIZE_STATIC +#define STBIRDEF static +#else +#ifdef __cplusplus +#define STBIRDEF extern "C" +#else +#define STBIRDEF extern +#endif +#endif +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// Easy-to-use API: +// +// * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4) +// * input_w is input image width (x-axis), input_h is input image height (y-axis) +// * stride is the offset between successive rows of image data in memory, in bytes. you can +// specify 0 to mean packed continuously in memory +// * alpha channel is treated identically to other channels. +// * colorspace is linear or sRGB as specified by function name +// * returned result is 1 for success or 0 in case of an error. +// #define STBIR_ASSERT() to trigger an assert on parameter validation errors. +// * Memory required grows approximately linearly with input and output size, but with +// discontinuities at input_w == output_w and input_h == output_h. +// * These functions use a "default" resampling filter defined at compile time. To change the filter, +// you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE +// and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API. + +STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels); + +STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels); + + +// The following functions interpret image data as gamma-corrected sRGB. +// Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel, +// or otherwise provide the index of the alpha channel. Flags value +// of 0 will probably do the right thing if you're not sure what +// the flags mean. + +#define STBIR_ALPHA_CHANNEL_NONE -1 + +// Set this flag if your texture has premultiplied alpha. Otherwise, stbir will +// use alpha-weighted resampling (effectively premultiplying, resampling, +// then unpremultiplying). +#define STBIR_FLAG_ALPHA_PREMULTIPLIED (1 << 0) +// The specified alpha channel should be handled as gamma-corrected value even +// when doing sRGB operations. +#define STBIR_FLAG_ALPHA_USES_COLORSPACE (1 << 1) + +STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags); + + +typedef enum +{ + STBIR_EDGE_CLAMP = 1, + STBIR_EDGE_REFLECT = 2, + STBIR_EDGE_WRAP = 3, + STBIR_EDGE_ZERO = 4, +} stbir_edge; + +// This function adds the ability to specify how requests to sample off the edge of the image are handled. +STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode); + +////////////////////////////////////////////////////////////////////////////// +// +// Medium-complexity API +// +// This extends the easy-to-use API as follows: +// +// * Alpha-channel can be processed separately +// * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE +// * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT) +// * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED) +// * Filter can be selected explicitly +// * uint16 image type +// * sRGB colorspace available for all types +// * context parameter for passing to STBIR_MALLOC + +typedef enum +{ + STBIR_FILTER_DEFAULT = 0, // use same filter type that easy-to-use API chooses + STBIR_FILTER_BOX = 1, // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios + STBIR_FILTER_TRIANGLE = 2, // On upsampling, produces same results as bilinear texture filtering + STBIR_FILTER_CUBICBSPLINE = 3, // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque + STBIR_FILTER_CATMULLROM = 4, // An interpolating cubic spline + STBIR_FILTER_MITCHELL = 5, // Mitchell-Netrevalli filter with B=1/3, C=1/3 +} stbir_filter; + +typedef enum +{ + STBIR_COLORSPACE_LINEAR, + STBIR_COLORSPACE_SRGB, + + STBIR_MAX_COLORSPACES, +} stbir_colorspace; + +// The following functions are all identical except for the type of the image data + +STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context); + +STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context); + +STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context); + + + +////////////////////////////////////////////////////////////////////////////// +// +// Full-complexity API +// +// This extends the medium API as follows: +// +// * uint32 image type +// * not typesafe +// * separate filter types for each axis +// * separate edge modes for each axis +// * can specify scale explicitly for subpixel correctness +// * can specify image source tile using texture coordinates + +typedef enum +{ + STBIR_TYPE_UINT8 , + STBIR_TYPE_UINT16, + STBIR_TYPE_UINT32, + STBIR_TYPE_FLOAT , + + STBIR_MAX_TYPES +} stbir_datatype; + +STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context); + +STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float x_scale, float y_scale, + float x_offset, float y_offset); + +STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float s0, float t0, float s1, float t1); +// (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use. + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H + + + + + +#ifdef STB_IMAGE_RESIZE_IMPLEMENTATION + +#ifndef STBIR_ASSERT +#include +#define STBIR_ASSERT(x) assert(x) +#endif + +// For memset +#include + +#include + +#ifndef STBIR_MALLOC +#include +// use comma operator to evaluate c, to avoid "unused parameter" warnings +#define STBIR_MALLOC(size,c) ((void)(c), malloc(size)) +#define STBIR_FREE(ptr,c) ((void)(c), free(ptr)) +#endif + +#ifndef _MSC_VER +#ifdef __cplusplus +#define stbir__inline inline +#else +#define stbir__inline +#endif +#else +#define stbir__inline __forceinline +#endif + + +// should produce compiler error if size is wrong +typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBIR__NOTUSED(v) (void)(v) +#else +#define STBIR__NOTUSED(v) (void)sizeof(v) +#endif + +#define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0])) + +#ifndef STBIR_DEFAULT_FILTER_UPSAMPLE +#define STBIR_DEFAULT_FILTER_UPSAMPLE STBIR_FILTER_CATMULLROM +#endif + +#ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE +#define STBIR_DEFAULT_FILTER_DOWNSAMPLE STBIR_FILTER_MITCHELL +#endif + +#ifndef STBIR_PROGRESS_REPORT +#define STBIR_PROGRESS_REPORT(float_0_to_1) +#endif + +#ifndef STBIR_MAX_CHANNELS +#define STBIR_MAX_CHANNELS 64 +#endif + +#if STBIR_MAX_CHANNELS > 65536 +#error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536." +// because we store the indices in 16-bit variables +#endif + +// This value is added to alpha just before premultiplication to avoid +// zeroing out color values. It is equivalent to 2^-80. If you don't want +// that behavior (it may interfere if you have floating point images with +// very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to +// disable it. +#ifndef STBIR_ALPHA_EPSILON +#define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20)) +#endif + + + +#ifdef _MSC_VER +#define STBIR__UNUSED_PARAM(v) (void)(v) +#else +#define STBIR__UNUSED_PARAM(v) (void)sizeof(v) +#endif + +// must match stbir_datatype +static unsigned char stbir__type_size[] = { + 1, // STBIR_TYPE_UINT8 + 2, // STBIR_TYPE_UINT16 + 4, // STBIR_TYPE_UINT32 + 4, // STBIR_TYPE_FLOAT +}; + +// Kernel function centered at 0 +typedef float (stbir__kernel_fn)(float x, float scale); +typedef float (stbir__support_fn)(float scale); + +typedef struct +{ + stbir__kernel_fn* kernel; + stbir__support_fn* support; +} stbir__filter_info; + +// When upsampling, the contributors are which source pixels contribute. +// When downsampling, the contributors are which destination pixels are contributed to. +typedef struct +{ + int n0; // First contributing pixel + int n1; // Last contributing pixel +} stbir__contributors; + +typedef struct +{ + const void* input_data; + int input_w; + int input_h; + int input_stride_bytes; + + void* output_data; + int output_w; + int output_h; + int output_stride_bytes; + + float s0, t0, s1, t1; + + float horizontal_shift; // Units: output pixels + float vertical_shift; // Units: output pixels + float horizontal_scale; + float vertical_scale; + + int channels; + int alpha_channel; + stbir_uint32 flags; + stbir_datatype type; + stbir_filter horizontal_filter; + stbir_filter vertical_filter; + stbir_edge edge_horizontal; + stbir_edge edge_vertical; + stbir_colorspace colorspace; + + stbir__contributors* horizontal_contributors; + float* horizontal_coefficients; + + stbir__contributors* vertical_contributors; + float* vertical_coefficients; + + int decode_buffer_pixels; + float* decode_buffer; + + float* horizontal_buffer; + + // cache these because ceil/floor are inexplicably showing up in profile + int horizontal_coefficient_width; + int vertical_coefficient_width; + int horizontal_filter_pixel_width; + int vertical_filter_pixel_width; + int horizontal_filter_pixel_margin; + int vertical_filter_pixel_margin; + int horizontal_num_contributors; + int vertical_num_contributors; + + int ring_buffer_length_bytes; // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter) + int ring_buffer_num_entries; // Total number of entries in the ring buffer. + int ring_buffer_first_scanline; + int ring_buffer_last_scanline; + int ring_buffer_begin_index; // first_scanline is at this index in the ring buffer + float* ring_buffer; + + float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds. + + int horizontal_contributors_size; + int horizontal_coefficients_size; + int vertical_contributors_size; + int vertical_coefficients_size; + int decode_buffer_size; + int horizontal_buffer_size; + int ring_buffer_size; + int encode_buffer_size; +} stbir__info; + + +static const float stbir__max_uint8_as_float = 255.0f; +static const float stbir__max_uint16_as_float = 65535.0f; +static const double stbir__max_uint32_as_float = 4294967295.0; + + +static stbir__inline int stbir__min(int a, int b) +{ + return a < b ? a : b; +} + +static stbir__inline float stbir__saturate(float x) +{ + if (x < 0) + return 0; + + if (x > 1) + return 1; + + return x; +} + +#ifdef STBIR_SATURATE_INT +static stbir__inline stbir_uint8 stbir__saturate8(int x) +{ + if ((unsigned int) x <= 255) + return x; + + if (x < 0) + return 0; + + return 255; +} + +static stbir__inline stbir_uint16 stbir__saturate16(int x) +{ + if ((unsigned int) x <= 65535) + return x; + + if (x < 0) + return 0; + + return 65535; +} +#endif + +static float stbir__srgb_uchar_to_linear_float[256] = { + 0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f, + 0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f, + 0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f, + 0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f, + 0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f, + 0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f, + 0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f, + 0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f, + 0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f, + 0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f, + 0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f, + 0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f, + 0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f, + 0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f, + 0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f, + 0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f, + 0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f, + 0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f, + 0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f, + 0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f, + 0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f, + 0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f, + 0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f, + 0.982251f, 0.991102f, 1.0f +}; + +static float stbir__srgb_to_linear(float f) +{ + if (f <= 0.04045f) + return f / 12.92f; + else + return (float)pow((f + 0.055f) / 1.055f, 2.4f); +} + +static float stbir__linear_to_srgb(float f) +{ + if (f <= 0.0031308f) + return f * 12.92f; + else + return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f; +} + +#ifndef STBIR_NON_IEEE_FLOAT +// From https://gist.github.com/rygorous/2203834 + +typedef union +{ + stbir_uint32 u; + float f; +} stbir__FP32; + +static const stbir_uint32 fp32_to_srgb8_tab4[104] = { + 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, + 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, + 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, + 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, + 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, + 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, + 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, + 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, + 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, + 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, + 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, + 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, + 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, +}; + +static stbir_uint8 stbir__linear_to_srgb_uchar(float in) +{ + static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps + static const stbir__FP32 minval = { (127-13) << 23 }; + stbir_uint32 tab,bias,scale,t; + stbir__FP32 f; + + // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. + // The tests are carefully written so that NaNs map to 0, same as in the reference + // implementation. + if (!(in > minval.f)) // written this way to catch NaNs + in = minval.f; + if (in > almostone.f) + in = almostone.f; + + // Do the table lookup and unpack bias, scale + f.f = in; + tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20]; + bias = (tab >> 16) << 9; + scale = tab & 0xffff; + + // Grab next-highest mantissa bits and perform linear interpolation + t = (f.u >> 12) & 0xff; + return (unsigned char) ((bias + scale*t) >> 16); +} + +#else +// sRGB transition values, scaled by 1<<28 +static int stbir__srgb_offset_to_linear_scaled[256] = +{ + 0, 40738, 122216, 203693, 285170, 366648, 448125, 529603, + 611080, 692557, 774035, 855852, 942009, 1033024, 1128971, 1229926, + 1335959, 1447142, 1563542, 1685229, 1812268, 1944725, 2082664, 2226148, + 2375238, 2529996, 2690481, 2856753, 3028870, 3206888, 3390865, 3580856, + 3776916, 3979100, 4187460, 4402049, 4622919, 4850123, 5083710, 5323731, + 5570236, 5823273, 6082892, 6349140, 6622065, 6901714, 7188133, 7481369, + 7781466, 8088471, 8402427, 8723380, 9051372, 9386448, 9728650, 10078021, + 10434603, 10798439, 11169569, 11548036, 11933879, 12327139, 12727857, 13136073, + 13551826, 13975156, 14406100, 14844697, 15290987, 15745007, 16206795, 16676389, + 17153826, 17639142, 18132374, 18633560, 19142734, 19659934, 20185196, 20718552, + 21260042, 21809696, 22367554, 22933648, 23508010, 24090680, 24681686, 25281066, + 25888850, 26505076, 27129772, 27762974, 28404716, 29055026, 29713942, 30381490, + 31057708, 31742624, 32436272, 33138682, 33849884, 34569912, 35298800, 36036568, + 36783260, 37538896, 38303512, 39077136, 39859796, 40651528, 41452360, 42262316, + 43081432, 43909732, 44747252, 45594016, 46450052, 47315392, 48190064, 49074096, + 49967516, 50870356, 51782636, 52704392, 53635648, 54576432, 55526772, 56486700, + 57456236, 58435408, 59424248, 60422780, 61431036, 62449032, 63476804, 64514376, + 65561776, 66619028, 67686160, 68763192, 69850160, 70947088, 72053992, 73170912, + 74297864, 75434880, 76581976, 77739184, 78906536, 80084040, 81271736, 82469648, + 83677792, 84896192, 86124888, 87363888, 88613232, 89872928, 91143016, 92423512, + 93714432, 95015816, 96327688, 97650056, 98982952, 100326408, 101680440, 103045072, + 104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544, + 115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832, + 127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528, + 140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968, + 154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184, + 168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992, + 183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968, + 199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480, + 215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656, + 232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464, + 250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664, +}; + +static stbir_uint8 stbir__linear_to_srgb_uchar(float f) +{ + int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp + int v = 0; + int i; + + // Refine the guess with a short binary search. + i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + i = v + 1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i; + + return (stbir_uint8) v; +} +#endif + +static float stbir__filter_trapezoid(float x, float scale) +{ + float halfscale = scale / 2; + float t = 0.5f + halfscale; + STBIR_ASSERT(scale <= 1); + + x = (float)fabs(x); + + if (x >= t) + return 0; + else + { + float r = 0.5f - halfscale; + if (x <= r) + return 1; + else + return (t - x) / scale; + } +} + +static float stbir__support_trapezoid(float scale) +{ + STBIR_ASSERT(scale <= 1); + return 0.5f + scale / 2; +} + +static float stbir__filter_triangle(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x <= 1.0f) + return 1 - x; + else + return 0; +} + +static float stbir__filter_cubic(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x < 1.0f) + return (4 + x*x*(3*x - 6))/6; + else if (x < 2.0f) + return (8 + x*(-12 + x*(6 - x)))/6; + + return (0.0f); +} + +static float stbir__filter_catmullrom(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x < 1.0f) + return 1 - x*x*(2.5f - 1.5f*x); + else if (x < 2.0f) + return 2 - x*(4 + x*(0.5f*x - 2.5f)); + + return (0.0f); +} + +static float stbir__filter_mitchell(float x, float s) +{ + STBIR__UNUSED_PARAM(s); + + x = (float)fabs(x); + + if (x < 1.0f) + return (16 + x*x*(21 * x - 36))/18; + else if (x < 2.0f) + return (32 + x*(-60 + x*(36 - 7*x)))/18; + + return (0.0f); +} + +static float stbir__support_zero(float s) +{ + STBIR__UNUSED_PARAM(s); + return 0; +} + +static float stbir__support_one(float s) +{ + STBIR__UNUSED_PARAM(s); + return 1; +} + +static float stbir__support_two(float s) +{ + STBIR__UNUSED_PARAM(s); + return 2; +} + +static stbir__filter_info stbir__filter_info_table[] = { + { NULL, stbir__support_zero }, + { stbir__filter_trapezoid, stbir__support_trapezoid }, + { stbir__filter_triangle, stbir__support_one }, + { stbir__filter_cubic, stbir__support_two }, + { stbir__filter_catmullrom, stbir__support_two }, + { stbir__filter_mitchell, stbir__support_two }, +}; + +stbir__inline static int stbir__use_upsampling(float ratio) +{ + return ratio > 1; +} + +stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info) +{ + return stbir__use_upsampling(stbir_info->horizontal_scale); +} + +stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info) +{ + return stbir__use_upsampling(stbir_info->vertical_scale); +} + +// This is the maximum number of input samples that can affect an output sample +// with the given filter +static int stbir__get_filter_pixel_width(stbir_filter filter, float scale) +{ + STBIR_ASSERT(filter != 0); + STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); + + if (stbir__use_upsampling(scale)) + return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2); + else + return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale); +} + +// This is how much to expand buffers to account for filters seeking outside +// the image boundaries. +static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale) +{ + return stbir__get_filter_pixel_width(filter, scale) / 2; +} + +static int stbir__get_coefficient_width(stbir_filter filter, float scale) +{ + if (stbir__use_upsampling(scale)) + return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2); + else + return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2); +} + +static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size) +{ + if (stbir__use_upsampling(scale)) + return output_size; + else + return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2); +} + +static int stbir__get_total_horizontal_coefficients(stbir__info* info) +{ + return info->horizontal_num_contributors + * stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); +} + +static int stbir__get_total_vertical_coefficients(stbir__info* info) +{ + return info->vertical_num_contributors + * stbir__get_coefficient_width (info->vertical_filter, info->vertical_scale); +} + +static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n) +{ + return &contributors[n]; +} + +// For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample, +// if you change it here change it there too. +static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c) +{ + int width = stbir__get_coefficient_width(filter, scale); + return &coefficients[width*n + c]; +} + +static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max) +{ + switch (edge) + { + case STBIR_EDGE_ZERO: + return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later + + case STBIR_EDGE_CLAMP: + if (n < 0) + return 0; + + if (n >= max) + return max - 1; + + return n; // NOTREACHED + + case STBIR_EDGE_REFLECT: + { + if (n < 0) + { + if (n < max) + return -n; + else + return max - 1; + } + + if (n >= max) + { + int max2 = max * 2; + if (n >= max2) + return 0; + else + return max2 - n - 1; + } + + return n; // NOTREACHED + } + + case STBIR_EDGE_WRAP: + if (n >= 0) + return (n % max); + else + { + int m = (-n) % max; + + if (m != 0) + m = max - m; + + return (m); + } + // NOTREACHED + + default: + STBIR_ASSERT(!"Unimplemented edge type"); + return 0; + } +} + +stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max) +{ + // avoid per-pixel switch + if (n >= 0 && n < max) + return n; + return stbir__edge_wrap_slow(edge, n, max); +} + +// What input pixels contribute to this output pixel? +static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out) +{ + float out_pixel_center = (float)n + 0.5f; + float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius; + float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius; + + float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio; + float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio; + + *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio; + *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5)); + *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5)); +} + +// What output pixels does this input pixel contribute to? +static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in) +{ + float in_pixel_center = (float)n + 0.5f; + float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius; + float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius; + + float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift; + float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift; + + *out_center_of_in = in_pixel_center * scale_ratio - out_shift; + *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5)); + *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5)); +} + +static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group) +{ + int i; + float total_filter = 0; + float filter_scale; + + STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. + + contributor->n0 = in_first_pixel; + contributor->n1 = in_last_pixel; + + STBIR_ASSERT(contributor->n1 >= contributor->n0); + + for (i = 0; i <= in_last_pixel - in_first_pixel; i++) + { + float in_pixel_center = (float)(i + in_first_pixel) + 0.5f; + coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale); + + // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.) + if (i == 0 && !coefficient_group[i]) + { + contributor->n0 = ++in_first_pixel; + i--; + continue; + } + + total_filter += coefficient_group[i]; + } + + STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0); + + STBIR_ASSERT(total_filter > 0.9); + STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off. + + // Make sure the sum of all coefficients is 1. + filter_scale = 1 / total_filter; + + for (i = 0; i <= in_last_pixel - in_first_pixel; i++) + coefficient_group[i] *= filter_scale; + + for (i = in_last_pixel - in_first_pixel; i >= 0; i--) + { + if (coefficient_group[i]) + break; + + // This line has no weight. We can skip it. + contributor->n1 = contributor->n0 + i - 1; + } +} + +static void stbir__calculate_coefficients_downsample(stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group) +{ + int i; + + STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical. + + contributor->n0 = out_first_pixel; + contributor->n1 = out_last_pixel; + + STBIR_ASSERT(contributor->n1 >= contributor->n0); + + for (i = 0; i <= out_last_pixel - out_first_pixel; i++) + { + float out_pixel_center = (float)(i + out_first_pixel) + 0.5f; + float x = out_pixel_center - out_center_of_in; + coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio; + } + + STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0); + + for (i = out_last_pixel - out_first_pixel; i >= 0; i--) + { + if (coefficient_group[i]) + break; + + // This line has no weight. We can skip it. + contributor->n1 = contributor->n0 + i - 1; + } +} + +static void stbir__normalize_downsample_coefficients(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, int input_size, int output_size) +{ + int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); + int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio); + int i, j; + int skip; + + for (i = 0; i < output_size; i++) + { + float scale; + float total = 0; + + for (j = 0; j < num_contributors; j++) + { + if (i >= contributors[j].n0 && i <= contributors[j].n1) + { + float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0); + total += coefficient; + } + else if (i < contributors[j].n0) + break; + } + + STBIR_ASSERT(total > 0.9f); + STBIR_ASSERT(total < 1.1f); + + scale = 1 / total; + + for (j = 0; j < num_contributors; j++) + { + if (i >= contributors[j].n0 && i <= contributors[j].n1) + *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale; + else if (i < contributors[j].n0) + break; + } + } + + // Optimize: Skip zero coefficients and contributions outside of image bounds. + // Do this after normalizing because normalization depends on the n0/n1 values. + for (j = 0; j < num_contributors; j++) + { + int range, max, width; + + skip = 0; + while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0) + skip++; + + contributors[j].n0 += skip; + + while (contributors[j].n0 < 0) + { + contributors[j].n0++; + skip++; + } + + range = contributors[j].n1 - contributors[j].n0 + 1; + max = stbir__min(num_coefficients, range); + + width = stbir__get_coefficient_width(filter, scale_ratio); + for (i = 0; i < max; i++) + { + if (i + skip >= width) + break; + + *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip); + } + + continue; + } + + // Using min to avoid writing into invalid pixels. + for (i = 0; i < num_contributors; i++) + contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1); +} + +// Each scan line uses the same kernel values so we should calculate the kernel +// values once and then we can use them for every scan line. +static void stbir__calculate_filters(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size) +{ + int n; + int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size); + + if (stbir__use_upsampling(scale_ratio)) + { + float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio; + + // Looping through out pixels + for (n = 0; n < total_contributors; n++) + { + float in_center_of_out; // Center of the current out pixel in the in pixel space + int in_first_pixel, in_last_pixel; + + stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out); + + stbir__calculate_coefficients_upsample(filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); + } + } + else + { + float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio; + + // Looping through in pixels + for (n = 0; n < total_contributors; n++) + { + float out_center_of_in; // Center of the current out pixel in the in pixel space + int out_first_pixel, out_last_pixel; + int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio); + + stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in); + + stbir__calculate_coefficients_downsample(filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0)); + } + + stbir__normalize_downsample_coefficients(contributors, coefficients, filter, scale_ratio, input_size, output_size); + } +} + +static float* stbir__get_decode_buffer(stbir__info* stbir_info) +{ + // The 0 index of the decode buffer starts after the margin. This makes + // it okay to use negative indexes on the decode buffer. + return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels]; +} + +#define STBIR__DECODE(type, colorspace) ((int)(type) * (STBIR_MAX_COLORSPACES) + (int)(colorspace)) + +static void stbir__decode_scanline(stbir__info* stbir_info, int n) +{ + int c; + int channels = stbir_info->channels; + int alpha_channel = stbir_info->alpha_channel; + int type = stbir_info->type; + int colorspace = stbir_info->colorspace; + int input_w = stbir_info->input_w; + size_t input_stride_bytes = stbir_info->input_stride_bytes; + float* decode_buffer = stbir__get_decode_buffer(stbir_info); + stbir_edge edge_horizontal = stbir_info->edge_horizontal; + stbir_edge edge_vertical = stbir_info->edge_vertical; + size_t in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes; + const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset; + int max_x = input_w + stbir_info->horizontal_filter_pixel_margin; + int decode = STBIR__DECODE(type, colorspace); + + int x = -stbir_info->horizontal_filter_pixel_margin; + + // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input, + // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO + if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h)) + { + for (; x < max_x; x++) + for (c = 0; c < channels; c++) + decode_buffer[x*channels + c] = 0; + return; + } + + switch (decode) + { + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / stbir__max_uint8_as_float; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]]; + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint8_as_float; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float); + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint16_as_float; + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float); + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float)); + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint32_as_float); + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c]; + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): + for (; x < max_x; x++) + { + int decode_pixel_index = x * channels; + int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels; + for (c = 0; c < channels; c++) + decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]); + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel]; + } + + break; + + default: + STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); + break; + } + + if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED)) + { + for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++) + { + int decode_pixel_index = x * channels; + + // If the alpha value is 0 it will clobber the color values. Make sure it's not. + float alpha = decode_buffer[decode_pixel_index + alpha_channel]; +#ifndef STBIR_NO_ALPHA_EPSILON + if (stbir_info->type != STBIR_TYPE_FLOAT) { + alpha += STBIR_ALPHA_EPSILON; + decode_buffer[decode_pixel_index + alpha_channel] = alpha; + } +#endif + for (c = 0; c < channels; c++) + { + if (c == alpha_channel) + continue; + + decode_buffer[decode_pixel_index + c] *= alpha; + } + } + } + + if (edge_horizontal == STBIR_EDGE_ZERO) + { + for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++) + { + for (c = 0; c < channels; c++) + decode_buffer[x*channels + c] = 0; + } + for (x = input_w; x < max_x; x++) + { + for (c = 0; c < channels; c++) + decode_buffer[x*channels + c] = 0; + } + } +} + +static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length) +{ + return &ring_buffer[index * ring_buffer_length]; +} + +static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n) +{ + int ring_buffer_index; + float* ring_buffer; + + stbir_info->ring_buffer_last_scanline = n; + + if (stbir_info->ring_buffer_begin_index < 0) + { + ring_buffer_index = stbir_info->ring_buffer_begin_index = 0; + stbir_info->ring_buffer_first_scanline = n; + } + else + { + ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline)) % stbir_info->ring_buffer_num_entries; + STBIR_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index); + } + + ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float)); + memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes); + + return ring_buffer; +} + + +static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, float* output_buffer) +{ + int x, k; + int output_w = stbir_info->output_w; + int channels = stbir_info->channels; + float* decode_buffer = stbir__get_decode_buffer(stbir_info); + stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; + float* horizontal_coefficients = stbir_info->horizontal_coefficients; + int coefficient_width = stbir_info->horizontal_coefficient_width; + + for (x = 0; x < output_w; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int out_pixel_index = x * channels; + int coefficient_group = coefficient_width * x; + int coefficient_counter = 0; + + STBIR_ASSERT(n1 >= n0); + STBIR_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin); + STBIR_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin); + STBIR_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); + STBIR_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin); + + switch (channels) { + case 1: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 1; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + } + break; + case 2: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 2; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + } + break; + case 3: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 3; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + } + break; + case 4: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * 4; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; + } + break; + default: + for (k = n0; k <= n1; k++) + { + int in_pixel_index = k * channels; + float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++]; + int c; + STBIR_ASSERT(coefficient != 0); + for (c = 0; c < channels; c++) + output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; + } + break; + } + } +} + +static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, float* output_buffer) +{ + int x, k; + int input_w = stbir_info->input_w; + int channels = stbir_info->channels; + float* decode_buffer = stbir__get_decode_buffer(stbir_info); + stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors; + float* horizontal_coefficients = stbir_info->horizontal_coefficients; + int coefficient_width = stbir_info->horizontal_coefficient_width; + int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin; + int max_x = input_w + filter_pixel_margin * 2; + + STBIR_ASSERT(!stbir__use_width_upsampling(stbir_info)); + + switch (channels) { + case 1: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 1; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 1; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + } + } + break; + + case 2: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 2; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 2; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + } + } + break; + + case 3: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 3; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 3; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + } + } + break; + + case 4: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * 4; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int out_pixel_index = k * 4; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR_ASSERT(coefficient != 0); + output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient; + output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient; + output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient; + output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient; + } + } + break; + + default: + for (x = 0; x < max_x; x++) + { + int n0 = horizontal_contributors[x].n0; + int n1 = horizontal_contributors[x].n1; + + int in_x = x - filter_pixel_margin; + int in_pixel_index = in_x * channels; + int max_n = n1; + int coefficient_group = coefficient_width * x; + + for (k = n0; k <= max_n; k++) + { + int c; + int out_pixel_index = k * channels; + float coefficient = horizontal_coefficients[coefficient_group + k - n0]; + STBIR_ASSERT(coefficient != 0); + for (c = 0; c < channels; c++) + output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient; + } + } + break; + } +} + +static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n) +{ + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, n); + + // Now resample it into the ring buffer. + if (stbir__use_width_upsampling(stbir_info)) + stbir__resample_horizontal_upsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); + else + stbir__resample_horizontal_downsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n)); + + // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling. +} + +static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n) +{ + // Decode the nth scanline from the source image into the decode buffer. + stbir__decode_scanline(stbir_info, n); + + memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float)); + + // Now resample it into the horizontal buffer. + if (stbir__use_width_upsampling(stbir_info)) + stbir__resample_horizontal_upsample(stbir_info, stbir_info->horizontal_buffer); + else + stbir__resample_horizontal_downsample(stbir_info, stbir_info->horizontal_buffer); + + // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers. +} + +// Get the specified scan line from the ring buffer. +static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_num_entries, int ring_buffer_length) +{ + int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_num_entries; + return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length); +} + + +static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode) +{ + int x; + int n; + int num_nonalpha; + stbir_uint16 nonalpha[STBIR_MAX_CHANNELS]; + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) + { + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + float alpha = encode_buffer[pixel_index + alpha_channel]; + float reciprocal_alpha = alpha ? 1.0f / alpha : 0; + + // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb + for (n = 0; n < channels; n++) + if (n != alpha_channel) + encode_buffer[pixel_index + n] *= reciprocal_alpha; + + // We added in a small epsilon to prevent the color channel from being deleted with zero alpha. + // Because we only add it for integer types, it will automatically be discarded on integer + // conversion, so we don't need to subtract it back out (which would be problematic for + // numeric precision reasons). + } + } + + // build a table of all channels that need colorspace correction, so + // we don't perform colorspace correction on channels that don't need it. + for (x = 0, num_nonalpha = 0; x < channels; ++x) + { + if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) + { + nonalpha[num_nonalpha++] = (stbir_uint16)x; + } + } + + #define STBIR__ROUND_INT(f) ((int) ((f)+0.5)) + #define STBIR__ROUND_UINT(f) ((stbir_uint32) ((f)+0.5)) + + #ifdef STBIR__SATURATE_INT + #define STBIR__ENCODE_LINEAR8(f) stbir__saturate8 (STBIR__ROUND_INT((f) * stbir__max_uint8_as_float )) + #define STBIR__ENCODE_LINEAR16(f) stbir__saturate16(STBIR__ROUND_INT((f) * stbir__max_uint16_as_float)) + #else + #define STBIR__ENCODE_LINEAR8(f) (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint8_as_float ) + #define STBIR__ENCODE_LINEAR16(f) (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint16_as_float) + #endif + + switch (decode) + { + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]); + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]); + } + + if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]); + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]); + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * stbir__max_uint16_as_float); + } + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]); + } + + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * stbir__max_uint32_as_float); + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * stbir__max_uint32_as_float); + } + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * stbir__max_uint32_as_float); + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < channels; n++) + { + int index = pixel_index + n; + ((float*)output_buffer)[index] = encode_buffer[index]; + } + } + break; + + case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB): + for (x=0; x < num_pixels; ++x) + { + int pixel_index = x*channels; + + for (n = 0; n < num_nonalpha; n++) + { + int index = pixel_index + nonalpha[n]; + ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]); + } + + if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE)) + ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel]; + } + break; + + default: + STBIR_ASSERT(!"Unknown type/colorspace/channels combination."); + break; + } +} + +static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n) +{ + int x, k; + int output_w = stbir_info->output_w; + stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; + float* vertical_coefficients = stbir_info->vertical_coefficients; + int channels = stbir_info->channels; + int alpha_channel = stbir_info->alpha_channel; + int type = stbir_info->type; + int colorspace = stbir_info->colorspace; + int ring_buffer_entries = stbir_info->ring_buffer_num_entries; + void* output_data = stbir_info->output_data; + float* encode_buffer = stbir_info->encode_buffer; + int decode = STBIR__DECODE(type, colorspace); + int coefficient_width = stbir_info->vertical_coefficient_width; + int coefficient_counter; + int contributor = n; + + float* ring_buffer = stbir_info->ring_buffer; + int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; + int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; + int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); + + int n0,n1, output_row_start; + int coefficient_group = coefficient_width * contributor; + + n0 = vertical_contributors[contributor].n0; + n1 = vertical_contributors[contributor].n1; + + output_row_start = n * stbir_info->output_stride_bytes; + + STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); + + memset(encode_buffer, 0, output_w * sizeof(float) * channels); + + // I tried reblocking this for better cache usage of encode_buffer + // (using x_outer, k, x_inner), but it lost speed. -- stb + + coefficient_counter = 0; + switch (channels) { + case 1: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 1; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + } + } + break; + case 2: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 2; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; + } + } + break; + case 3: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 3; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; + encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; + } + } + break; + case 4: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * 4; + encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient; + encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient; + encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient; + encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient; + } + } + break; + default: + for (k = n0; k <= n1; k++) + { + int coefficient_index = coefficient_counter++; + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + for (x = 0; x < output_w; ++x) + { + int in_pixel_index = x * channels; + int c; + for (c = 0; c < channels; c++) + encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient; + } + } + break; + } + stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode); +} + +static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n) +{ + int x, k; + int output_w = stbir_info->output_w; + stbir__contributors* vertical_contributors = stbir_info->vertical_contributors; + float* vertical_coefficients = stbir_info->vertical_coefficients; + int channels = stbir_info->channels; + int ring_buffer_entries = stbir_info->ring_buffer_num_entries; + float* horizontal_buffer = stbir_info->horizontal_buffer; + int coefficient_width = stbir_info->vertical_coefficient_width; + int contributor = n + stbir_info->vertical_filter_pixel_margin; + + float* ring_buffer = stbir_info->ring_buffer; + int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index; + int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline; + int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); + int n0,n1; + + n0 = vertical_contributors[contributor].n0; + n1 = vertical_contributors[contributor].n1; + + STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); + + for (k = n0; k <= n1; k++) + { + int coefficient_index = k - n0; + int coefficient_group = coefficient_width * contributor; + float coefficient = vertical_coefficients[coefficient_group + coefficient_index]; + + float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length); + + switch (channels) { + case 1: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 1; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + } + break; + case 2: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 2; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; + } + break; + case 3: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 3; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; + ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; + } + break; + case 4: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * 4; + ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient; + ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient; + ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient; + ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient; + } + break; + default: + for (x = 0; x < output_w; x++) + { + int in_pixel_index = x * channels; + + int c; + for (c = 0; c < channels; c++) + ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient; + } + break; + } + } +} + +static void stbir__buffer_loop_upsample(stbir__info* stbir_info) +{ + int y; + float scale_ratio = stbir_info->vertical_scale; + float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio; + + STBIR_ASSERT(stbir__use_height_upsampling(stbir_info)); + + for (y = 0; y < stbir_info->output_h; y++) + { + float in_center_of_out = 0; // Center of the current out scanline in the in scanline space + int in_first_scanline = 0, in_last_scanline = 0; + + stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out); + + STBIR_ASSERT(in_last_scanline - in_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); + + if (stbir_info->ring_buffer_begin_index >= 0) + { + // Get rid of whatever we don't need anymore. + while (in_first_scanline > stbir_info->ring_buffer_first_scanline) + { + if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) + { + // We just popped the last scanline off the ring buffer. + // Reset it to the empty state. + stbir_info->ring_buffer_begin_index = -1; + stbir_info->ring_buffer_first_scanline = 0; + stbir_info->ring_buffer_last_scanline = 0; + break; + } + else + { + stbir_info->ring_buffer_first_scanline++; + stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; + } + } + } + + // Load in new ones. + if (stbir_info->ring_buffer_begin_index < 0) + stbir__decode_and_resample_upsample(stbir_info, in_first_scanline); + + while (in_last_scanline > stbir_info->ring_buffer_last_scanline) + stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1); + + // Now all buffers should be ready to write a row of vertical sampling. + stbir__resample_vertical_upsample(stbir_info, y); + + STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h); + } +} + +static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline) +{ + int output_stride_bytes = stbir_info->output_stride_bytes; + int channels = stbir_info->channels; + int alpha_channel = stbir_info->alpha_channel; + int type = stbir_info->type; + int colorspace = stbir_info->colorspace; + int output_w = stbir_info->output_w; + void* output_data = stbir_info->output_data; + int decode = STBIR__DECODE(type, colorspace); + + float* ring_buffer = stbir_info->ring_buffer; + int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float); + + if (stbir_info->ring_buffer_begin_index >= 0) + { + // Get rid of whatever we don't need anymore. + while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline) + { + if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h) + { + int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes; + float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length); + stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode); + STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h); + } + + if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline) + { + // We just popped the last scanline off the ring buffer. + // Reset it to the empty state. + stbir_info->ring_buffer_begin_index = -1; + stbir_info->ring_buffer_first_scanline = 0; + stbir_info->ring_buffer_last_scanline = 0; + break; + } + else + { + stbir_info->ring_buffer_first_scanline++; + stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries; + } + } + } +} + +static void stbir__buffer_loop_downsample(stbir__info* stbir_info) +{ + int y; + float scale_ratio = stbir_info->vertical_scale; + int output_h = stbir_info->output_h; + float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio; + int pixel_margin = stbir_info->vertical_filter_pixel_margin; + int max_y = stbir_info->input_h + pixel_margin; + + STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info)); + + for (y = -pixel_margin; y < max_y; y++) + { + float out_center_of_in; // Center of the current out scanline in the in scanline space + int out_first_scanline, out_last_scanline; + + stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in); + + STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= stbir_info->ring_buffer_num_entries); + + if (out_last_scanline < 0 || out_first_scanline >= output_h) + continue; + + stbir__empty_ring_buffer(stbir_info, out_first_scanline); + + stbir__decode_and_resample_downsample(stbir_info, y); + + // Load in new ones. + if (stbir_info->ring_buffer_begin_index < 0) + stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline); + + while (out_last_scanline > stbir_info->ring_buffer_last_scanline) + stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1); + + // Now the horizontal buffer is ready to write to all ring buffer rows. + stbir__resample_vertical_downsample(stbir_info, y); + } + + stbir__empty_ring_buffer(stbir_info, stbir_info->output_h); +} + +static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels) +{ + info->input_w = input_w; + info->input_h = input_h; + info->output_w = output_w; + info->output_h = output_h; + info->channels = channels; +} + +static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform) +{ + info->s0 = s0; + info->t0 = t0; + info->s1 = s1; + info->t1 = t1; + + if (transform) + { + info->horizontal_scale = transform[0]; + info->vertical_scale = transform[1]; + info->horizontal_shift = transform[2]; + info->vertical_shift = transform[3]; + } + else + { + info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0); + info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0); + + info->horizontal_shift = s0 * info->output_w / (s1 - s0); + info->vertical_shift = t0 * info->output_h / (t1 - t0); + } +} + +static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter) +{ + if (h_filter == 0) + h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; + if (v_filter == 0) + v_filter = stbir__use_upsampling(info->vertical_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE; + info->horizontal_filter = h_filter; + info->vertical_filter = v_filter; +} + +static stbir_uint32 stbir__calculate_memory(stbir__info *info) +{ + int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); + int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale); + + info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w); + info->vertical_num_contributors = stbir__get_contributors(info->vertical_scale , info->vertical_filter , info->input_h, info->output_h); + + // One extra entry because floating point precision problems sometimes cause an extra to be necessary. + info->ring_buffer_num_entries = filter_height + 1; + + info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors); + info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float); + info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors); + info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float); + info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float); + info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float); + info->ring_buffer_size = info->output_w * info->channels * info->ring_buffer_num_entries * sizeof(float); + info->encode_buffer_size = info->output_w * info->channels * sizeof(float); + + STBIR_ASSERT(info->horizontal_filter != 0); + STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late + STBIR_ASSERT(info->vertical_filter != 0); + STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late + + if (stbir__use_height_upsampling(info)) + // The horizontal buffer is for when we're downsampling the height and we + // can't output the result of sampling the decode buffer directly into the + // ring buffers. + info->horizontal_buffer_size = 0; + else + // The encode buffer is to retain precision in the height upsampling method + // and isn't used when height downsampling. + info->encode_buffer_size = 0; + + return info->horizontal_contributors_size + info->horizontal_coefficients_size + + info->vertical_contributors_size + info->vertical_coefficients_size + + info->decode_buffer_size + info->horizontal_buffer_size + + info->ring_buffer_size + info->encode_buffer_size; +} + +static int stbir__resize_allocated(stbir__info *info, + const void* input_data, int input_stride_in_bytes, + void* output_data, int output_stride_in_bytes, + int alpha_channel, stbir_uint32 flags, stbir_datatype type, + stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace, + void* tempmem, size_t tempmem_size_in_bytes) +{ + size_t memory_required = stbir__calculate_memory(info); + + int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type]; + int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type]; + +#ifdef STBIR_DEBUG_OVERWRITE_TEST +#define OVERWRITE_ARRAY_SIZE 8 + unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE]; + unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE]; + unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE]; + unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE]; + + size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type]; + memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); + memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE); + memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE); + memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE); +#endif + + STBIR_ASSERT(info->channels >= 0); + STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS); + + if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS) + return 0; + + STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); + STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); + + if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) + return 0; + if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table)) + return 0; + + if (alpha_channel < 0) + flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED; + + if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) { + STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels); + } + + if (alpha_channel >= info->channels) + return 0; + + STBIR_ASSERT(tempmem); + + if (!tempmem) + return 0; + + STBIR_ASSERT(tempmem_size_in_bytes >= memory_required); + + if (tempmem_size_in_bytes < memory_required) + return 0; + + memset(tempmem, 0, tempmem_size_in_bytes); + + info->input_data = input_data; + info->input_stride_bytes = width_stride_input; + + info->output_data = output_data; + info->output_stride_bytes = width_stride_output; + + info->alpha_channel = alpha_channel; + info->flags = flags; + info->type = type; + info->edge_horizontal = edge_horizontal; + info->edge_vertical = edge_vertical; + info->colorspace = colorspace; + + info->horizontal_coefficient_width = stbir__get_coefficient_width (info->horizontal_filter, info->horizontal_scale); + info->vertical_coefficient_width = stbir__get_coefficient_width (info->vertical_filter , info->vertical_scale ); + info->horizontal_filter_pixel_width = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale); + info->vertical_filter_pixel_width = stbir__get_filter_pixel_width (info->vertical_filter , info->vertical_scale ); + info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale); + info->vertical_filter_pixel_margin = stbir__get_filter_pixel_margin(info->vertical_filter , info->vertical_scale ); + + info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float); + info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2; + +#define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size) + + info->horizontal_contributors = (stbir__contributors *) tempmem; + info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float); + info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors); + info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float); + info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float); + + if (stbir__use_height_upsampling(info)) + { + info->horizontal_buffer = NULL; + info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); + info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float); + + STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); + } + else + { + info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float); + info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float); + info->encode_buffer = NULL; + + STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes); + } + +#undef STBIR__NEXT_MEMPTR + + // This signals that the ring buffer is empty + info->ring_buffer_begin_index = -1; + + stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w); + stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h); + + STBIR_PROGRESS_REPORT(0); + + if (stbir__use_height_upsampling(info)) + stbir__buffer_loop_upsample(info); + else + stbir__buffer_loop_downsample(info); + + STBIR_PROGRESS_REPORT(1); + +#ifdef STBIR_DEBUG_OVERWRITE_TEST + STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); + STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0); + STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0); + STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0); +#endif + + return 1; +} + + +static int stbir__resize_arbitrary( + void *alloc_context, + const void* input_data, int input_w, int input_h, int input_stride_in_bytes, + void* output_data, int output_w, int output_h, int output_stride_in_bytes, + float s0, float t0, float s1, float t1, float *transform, + int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type, + stbir_filter h_filter, stbir_filter v_filter, + stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace) +{ + stbir__info info; + int result; + size_t memory_required; + void* extra_memory; + + stbir__setup(&info, input_w, input_h, output_w, output_h, channels); + stbir__calculate_transform(&info, s0,t0,s1,t1,transform); + stbir__choose_filter(&info, h_filter, v_filter); + memory_required = stbir__calculate_memory(&info); + extra_memory = STBIR_MALLOC(memory_required, alloc_context); + + if (!extra_memory) + return 0; + + result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes, + output_data, output_stride_in_bytes, + alpha_channel, flags, type, + edge_horizontal, edge_vertical, + colorspace, extra_memory, memory_required); + + STBIR_FREE(extra_memory, alloc_context); + + return result; +} + +STBIRDEF int stbir_resize_uint8( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); +} + +STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR); +} + +STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB); +} + +STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode) +{ + return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT, + edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB); +} + +STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter, + edge_wrap_mode, edge_wrap_mode, space); +} + +STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter, + edge_wrap_mode, edge_wrap_mode, space); +} + + +STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + float *output_pixels , int output_w, int output_h, int output_stride_in_bytes, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space, + void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter, + edge_wrap_mode, edge_wrap_mode, space); +} + + +STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, + edge_mode_horizontal, edge_mode_vertical, space); +} + + +STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float x_scale, float y_scale, + float x_offset, float y_offset) +{ + float transform[4]; + transform[0] = x_scale; + transform[1] = y_scale; + transform[2] = x_offset; + transform[3] = y_offset; + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + 0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, + edge_mode_horizontal, edge_mode_vertical, space); +} + +STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes, + void *output_pixels, int output_w, int output_h, int output_stride_in_bytes, + stbir_datatype datatype, + int num_channels, int alpha_channel, int flags, + stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical, + stbir_filter filter_horizontal, stbir_filter filter_vertical, + stbir_colorspace space, void *alloc_context, + float s0, float t0, float s1, float t1) +{ + return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes, + output_pixels, output_w, output_h, output_stride_in_bytes, + s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical, + edge_mode_horizontal, edge_mode_vertical, space); +} + +#endif // STB_IMAGE_RESIZE_IMPLEMENTATION + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/extern/stb/stb_image_write.h b/extern/stb/stb_image_write.h new file mode 100644 index 00000000..cffd473c --- /dev/null +++ b/extern/stb/stb_image_write.h @@ -0,0 +1,1666 @@ +/* stb_image_write - v1.14 - public domain - http://nothings.org/stb + writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 + no warranty implied; use at your own risk + + Before #including, + + #define STB_IMAGE_WRITE_IMPLEMENTATION + + in the file that you want to have the implementation. + + Will probably not work correctly with strict-aliasing optimizations. + +ABOUT: + + This header file is a library for writing images to C stdio or a callback. + + The PNG output is not optimal; it is 20-50% larger than the file + written by a decent optimizing implementation; though providing a custom + zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. + This library is designed for source code compactness and simplicity, + not optimal image file size or run-time performance. + +BUILDING: + + You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. + You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace + malloc,realloc,free. + You can #define STBIW_MEMMOVE() to replace memmove() + You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function + for PNG compression (instead of the builtin one), it must have the following signature: + unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); + The returned data will be freed with STBIW_FREE() (free() by default), + so it must be heap allocated with STBIW_MALLOC() (malloc() by default), + +UNICODE: + + If compiling for Windows and you wish to use Unicode filenames, compile + with + #define STBIW_WINDOWS_UTF8 + and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert + Windows wchar_t filenames to utf8. + +USAGE: + + There are five functions, one for each image file format: + + int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); + int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); + int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); + int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); + int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); + + void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically + + There are also five equivalent functions that use an arbitrary write function. You are + expected to open/close your file-equivalent before and after calling these: + + int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); + int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); + int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); + int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); + int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); + + where the callback is: + void stbi_write_func(void *context, void *data, int size); + + You can configure it with these global variables: + int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE + int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression + int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode + + + You can define STBI_WRITE_NO_STDIO to disable the file variant of these + functions, so the library will not use stdio.h at all. However, this will + also disable HDR writing, because it requires stdio for formatted output. + + Each function returns 0 on failure and non-0 on success. + + The functions create an image file defined by the parameters. The image + is a rectangle of pixels stored from left-to-right, top-to-bottom. + Each pixel contains 'comp' channels of data stored interleaved with 8-bits + per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is + monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. + The *data pointer points to the first byte of the top-left-most pixel. + For PNG, "stride_in_bytes" is the distance in bytes from the first byte of + a row of pixels to the first byte of the next row of pixels. + + PNG creates output files with the same number of components as the input. + The BMP format expands Y to RGB in the file format and does not + output alpha. + + PNG supports writing rectangles of data even when the bytes storing rows of + data are not consecutive in memory (e.g. sub-rectangles of a larger image), + by supplying the stride between the beginning of adjacent rows. The other + formats do not. (Thus you cannot write a native-format BMP through the BMP + writer, both because it is in BGR order and because it may have padding + at the end of the line.) + + PNG allows you to set the deflate compression level by setting the global + variable 'stbi_write_png_compression_level' (it defaults to 8). + + HDR expects linear float data. Since the format is always 32-bit rgb(e) + data, alpha (if provided) is discarded, and for monochrome data it is + replicated across all three channels. + + TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed + data, set the global variable 'stbi_write_tga_with_rle' to 0. + + JPEG does ignore alpha channels in input data; quality is between 1 and 100. + Higher quality looks better but results in a bigger image. + JPEG baseline (no JPEG progressive). + +CREDITS: + + + Sean Barrett - PNG/BMP/TGA + Baldur Karlsson - HDR + Jean-Sebastien Guay - TGA monochrome + Tim Kelsey - misc enhancements + Alan Hickman - TGA RLE + Emmanuel Julien - initial file IO callback implementation + Jon Olick - original jo_jpeg.cpp code + Daniel Gibson - integrate JPEG, allow external zlib + Aarni Koskela - allow choosing PNG filter + + bugfixes: + github:Chribba + Guillaume Chereau + github:jry2 + github:romigrou + Sergio Gonzalez + Jonas Karlsson + Filip Wasil + Thatcher Ulrich + github:poppolopoppo + Patrick Boettcher + github:xeekworx + Cap Petschulat + Simon Rodriguez + Ivan Tikhonov + github:ignotion + Adam Schackart + +LICENSE + + See end of file for license information. + +*/ + +#ifndef INCLUDE_STB_IMAGE_WRITE_H +#define INCLUDE_STB_IMAGE_WRITE_H + +#include + +// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' +#ifndef STBIWDEF +#ifdef STB_IMAGE_WRITE_STATIC +#define STBIWDEF static +#else +#ifdef __cplusplus +#define STBIWDEF extern "C" +#else +#define STBIWDEF extern +#endif +#endif +#endif + +#ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations +extern int stbi_write_tga_with_rle; +extern int stbi_write_png_compression_level; +extern int stbi_write_force_png_filter; +#endif + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); +STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); + +#ifdef STBI_WINDOWS_UTF8 +STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); +#endif +#endif + +typedef void stbi_write_func(void *context, void *data, int size); + +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); + +STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); + +#endif//INCLUDE_STB_IMAGE_WRITE_H + +#ifdef STB_IMAGE_WRITE_IMPLEMENTATION + +#ifdef _WIN32 + #ifndef _CRT_SECURE_NO_WARNINGS + #define _CRT_SECURE_NO_WARNINGS + #endif + #ifndef _CRT_NONSTDC_NO_DEPRECATE + #define _CRT_NONSTDC_NO_DEPRECATE + #endif +#endif + +#ifndef STBI_WRITE_NO_STDIO +#include +#endif // STBI_WRITE_NO_STDIO + +#include +#include +#include +#include + +#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) +// ok +#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) +// ok +#else +#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." +#endif + +#ifndef STBIW_MALLOC +#define STBIW_MALLOC(sz) malloc(sz) +#define STBIW_REALLOC(p,newsz) realloc(p,newsz) +#define STBIW_FREE(p) free(p) +#endif + +#ifndef STBIW_REALLOC_SIZED +#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) +#endif + + +#ifndef STBIW_MEMMOVE +#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) +#endif + + +#ifndef STBIW_ASSERT +#include +#define STBIW_ASSERT(x) assert(x) +#endif + +#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) + +#ifdef STB_IMAGE_WRITE_STATIC +static int stbi_write_png_compression_level = 8; +static int stbi_write_tga_with_rle = 1; +static int stbi_write_force_png_filter = -1; +#else +int stbi_write_png_compression_level = 8; +int stbi_write_tga_with_rle = 1; +int stbi_write_force_png_filter = -1; +#endif + +static int stbi__flip_vertically_on_write = 0; + +STBIWDEF void stbi_flip_vertically_on_write(int flag) +{ + stbi__flip_vertically_on_write = flag; +} + +typedef struct +{ + stbi_write_func *func; + void *context; +} stbi__write_context; + +// initialize a callback-based context +static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) +{ + s->func = c; + s->context = context; +} + +#ifndef STBI_WRITE_NO_STDIO + +static void stbi__stdio_write(void *context, void *data, int size) +{ + fwrite(data,1,size,(FILE*) context); +} + +#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) +#ifdef __cplusplus +#define STBIW_EXTERN extern "C" +#else +#define STBIW_EXTERN extern +#endif +STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); +STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); + +STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) +{ + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); +} +#endif + +static FILE *stbiw__fopen(char const *filename, char const *mode) +{ + FILE *f; +#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) + return 0; + + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) + return 0; + +#if _MSC_VER >= 1400 + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; +#else + f = _wfopen(wFilename, wMode); +#endif + +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f=0; +#else + f = fopen(filename, mode); +#endif + return f; +} + +static int stbi__start_write_file(stbi__write_context *s, const char *filename) +{ + FILE *f = stbiw__fopen(filename, "wb"); + stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); + return f != NULL; +} + +static void stbi__end_write_file(stbi__write_context *s) +{ + fclose((FILE *)s->context); +} + +#endif // !STBI_WRITE_NO_STDIO + +typedef unsigned int stbiw_uint32; +typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; + +static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) +{ + while (*fmt) { + switch (*fmt++) { + case ' ': break; + case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); + s->func(s->context,&x,1); + break; } + case '2': { int x = va_arg(v,int); + unsigned char b[2]; + b[0] = STBIW_UCHAR(x); + b[1] = STBIW_UCHAR(x>>8); + s->func(s->context,b,2); + break; } + case '4': { stbiw_uint32 x = va_arg(v,int); + unsigned char b[4]; + b[0]=STBIW_UCHAR(x); + b[1]=STBIW_UCHAR(x>>8); + b[2]=STBIW_UCHAR(x>>16); + b[3]=STBIW_UCHAR(x>>24); + s->func(s->context,b,4); + break; } + default: + STBIW_ASSERT(0); + return; + } + } +} + +static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) +{ + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); +} + +static void stbiw__putc(stbi__write_context *s, unsigned char c) +{ + s->func(s->context, &c, 1); +} + +static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) +{ + unsigned char arr[3]; + arr[0] = a; arr[1] = b; arr[2] = c; + s->func(s->context, arr, 3); +} + +static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) +{ + unsigned char bg[3] = { 255, 0, 255}, px[3]; + int k; + + if (write_alpha < 0) + s->func(s->context, &d[comp - 1], 1); + + switch (comp) { + case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case + case 1: + if (expand_mono) + stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp + else + s->func(s->context, d, 1); // monochrome TGA + break; + case 4: + if (!write_alpha) { + // composite against pink background + for (k = 0; k < 3; ++k) + px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; + stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); + break; + } + /* FALLTHROUGH */ + case 3: + stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); + break; + } + if (write_alpha > 0) + s->func(s->context, &d[comp - 1], 1); +} + +static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) +{ + stbiw_uint32 zero = 0; + int i,j, j_end; + + if (y <= 0) + return; + + if (stbi__flip_vertically_on_write) + vdir *= -1; + + if (vdir < 0) { + j_end = -1; j = y-1; + } else { + j_end = y; j = 0; + } + + for (; j != j_end; j += vdir) { + for (i=0; i < x; ++i) { + unsigned char *d = (unsigned char *) data + (j*x+i)*comp; + stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); + } + s->func(s->context, &zero, scanline_pad); + } +} + +static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) +{ + if (y < 0 || x < 0) { + return 0; + } else { + va_list v; + va_start(v, fmt); + stbiw__writefv(s, fmt, v); + va_end(v); + stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); + return 1; + } +} + +static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) +{ + int pad = (-x*3) & 3; + return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, + "11 4 22 4" "4 44 22 444444", + 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header + 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header +} + +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_bmp_core(&s, x, y, comp, data); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_bmp_core(&s, x, y, comp, data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif //!STBI_WRITE_NO_STDIO + +static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) +{ + int has_alpha = (comp == 2 || comp == 4); + int colorbytes = has_alpha ? comp-1 : comp; + int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 + + if (y < 0 || x < 0) + return 0; + + if (!stbi_write_tga_with_rle) { + return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, + "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); + } else { + int i,j,k; + int jend, jdir; + + stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); + + if (stbi__flip_vertically_on_write) { + j = 0; + jend = y; + jdir = 1; + } else { + j = y-1; + jend = -1; + jdir = -1; + } + for (; j != jend; j += jdir) { + unsigned char *row = (unsigned char *) data + j * x * comp; + int len; + + for (i = 0; i < x; i += len) { + unsigned char *begin = row + i * comp; + int diff = 1; + len = 1; + + if (i < x - 1) { + ++len; + diff = memcmp(begin, row + (i + 1) * comp, comp); + if (diff) { + const unsigned char *prev = begin; + for (k = i + 2; k < x && len < 128; ++k) { + if (memcmp(prev, row + k * comp, comp)) { + prev += comp; + ++len; + } else { + --len; + break; + } + } + } else { + for (k = i + 2; k < x && len < 128; ++k) { + if (!memcmp(begin, row + k * comp, comp)) { + ++len; + } else { + break; + } + } + } + } + + if (diff) { + unsigned char header = STBIW_UCHAR(len - 1); + s->func(s->context, &header, 1); + for (k = 0; k < len; ++k) { + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); + } + } else { + unsigned char header = STBIW_UCHAR(len - 129); + s->func(s->context, &header, 1); + stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); + } + } + } + } + return 1; +} + +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_tga_core(&s, x, y, comp, (void *) data); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR writer +// by Baldur Karlsson + +#define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) + +static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) +{ + int exponent; + float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); + + if (maxcomp < 1e-32f) { + rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; + } else { + float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; + + rgbe[0] = (unsigned char)(linear[0] * normalize); + rgbe[1] = (unsigned char)(linear[1] * normalize); + rgbe[2] = (unsigned char)(linear[2] * normalize); + rgbe[3] = (unsigned char)(exponent + 128); + } +} + +static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) +{ + unsigned char lengthbyte = STBIW_UCHAR(length+128); + STBIW_ASSERT(length+128 <= 255); + s->func(s->context, &lengthbyte, 1); + s->func(s->context, &databyte, 1); +} + +static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) +{ + unsigned char lengthbyte = STBIW_UCHAR(length); + STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code + s->func(s->context, &lengthbyte, 1); + s->func(s->context, data, length); +} + +static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) +{ + unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; + unsigned char rgbe[4]; + float linear[3]; + int x; + + scanlineheader[2] = (width&0xff00)>>8; + scanlineheader[3] = (width&0x00ff); + + /* skip RLE for images too small or large */ + if (width < 8 || width >= 32768) { + for (x=0; x < width; x++) { + switch (ncomp) { + case 4: /* fallthrough */ + case 3: linear[2] = scanline[x*ncomp + 2]; + linear[1] = scanline[x*ncomp + 1]; + linear[0] = scanline[x*ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + s->func(s->context, rgbe, 4); + } + } else { + int c,r; + /* encode into scratch buffer */ + for (x=0; x < width; x++) { + switch(ncomp) { + case 4: /* fallthrough */ + case 3: linear[2] = scanline[x*ncomp + 2]; + linear[1] = scanline[x*ncomp + 1]; + linear[0] = scanline[x*ncomp + 0]; + break; + default: + linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; + break; + } + stbiw__linear_to_rgbe(rgbe, linear); + scratch[x + width*0] = rgbe[0]; + scratch[x + width*1] = rgbe[1]; + scratch[x + width*2] = rgbe[2]; + scratch[x + width*3] = rgbe[3]; + } + + s->func(s->context, scanlineheader, 4); + + /* RLE each component separately */ + for (c=0; c < 4; c++) { + unsigned char *comp = &scratch[width*c]; + + x = 0; + while (x < width) { + // find first run + r = x; + while (r+2 < width) { + if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) + break; + ++r; + } + if (r+2 >= width) + r = width; + // dump up to first run + while (x < r) { + int len = r-x; + if (len > 128) len = 128; + stbiw__write_dump_data(s, len, &comp[x]); + x += len; + } + // if there's a run, output it + if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd + // find next byte after run + while (r < width && comp[r] == comp[x]) + ++r; + // output run up to r + while (x < r) { + int len = r-x; + if (len > 127) len = 127; + stbiw__write_run_data(s, len, comp[x]); + x += len; + } + } + } + } + } +} + +static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) +{ + if (y <= 0 || x <= 0 || data == NULL) + return 0; + else { + // Each component is stored separately. Allocate scratch space for full output scanline. + unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); + int i, len; + char buffer[128]; + char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; + s->func(s->context, header, sizeof(header)-1); + +#ifdef __STDC_WANT_SECURE_LIB__ + len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); +#else + len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); +#endif + s->func(s->context, buffer, len); + + for(i=0; i < y; i++) + stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); + STBIW_FREE(scratch); + return 1; + } +} + +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_hdr_core(&s, x, y, comp, (float *) data); +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif // STBI_WRITE_NO_STDIO + + +////////////////////////////////////////////////////////////////////////////// +// +// PNG writer +// + +#ifndef STBIW_ZLIB_COMPRESS +// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() +#define stbiw__sbraw(a) ((int *) (void *) (a) - 2) +#define stbiw__sbm(a) stbiw__sbraw(a)[0] +#define stbiw__sbn(a) stbiw__sbraw(a)[1] + +#define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) +#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) +#define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) + +#define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) +#define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) +#define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) + +static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) +{ + int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; + void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); + STBIW_ASSERT(p); + if (p) { + if (!*arr) ((int *) p)[1] = 0; + *arr = (void *) ((int *) p + 2); + stbiw__sbm(*arr) = m; + } + return *arr; +} + +static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) +{ + while (*bitcount >= 8) { + stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); + *bitbuffer >>= 8; + *bitcount -= 8; + } + return data; +} + +static int stbiw__zlib_bitrev(int code, int codebits) +{ + int res=0; + while (codebits--) { + res = (res << 1) | (code & 1); + code >>= 1; + } + return res; +} + +static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) +{ + int i; + for (i=0; i < limit && i < 258; ++i) + if (a[i] != b[i]) break; + return i; +} + +static unsigned int stbiw__zhash(unsigned char *data) +{ + stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + return hash; +} + +#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) +#define stbiw__zlib_add(code,codebits) \ + (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) +#define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) +// default huffman tables +#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) +#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) +#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) +#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) +#define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) +#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) + +#define stbiw__ZHASH 16384 + +#endif // STBIW_ZLIB_COMPRESS + +STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) +{ +#ifdef STBIW_ZLIB_COMPRESS + // user provided a zlib compress implementation, use that + return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); +#else // use builtin + static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; + static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; + static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; + static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; + unsigned int bitbuf=0; + int i,j, bitcount=0; + unsigned char *out = NULL; + unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**)); + if (hash_table == NULL) + return NULL; + if (quality < 5) quality = 5; + + stbiw__sbpush(out, 0x78); // DEFLATE 32K window + stbiw__sbpush(out, 0x5e); // FLEVEL = 1 + stbiw__zlib_add(1,1); // BFINAL = 1 + stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman + + for (i=0; i < stbiw__ZHASH; ++i) + hash_table[i] = NULL; + + i=0; + while (i < data_len-3) { + // hash next 3 bytes of data to be compressed + int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; + unsigned char *bestloc = 0; + unsigned char **hlist = hash_table[h]; + int n = stbiw__sbcount(hlist); + for (j=0; j < n; ++j) { + if (hlist[j]-data > i-32768) { // if entry lies within window + int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); + if (d >= best) { best=d; bestloc=hlist[j]; } + } + } + // when hash table entry is too long, delete half the entries + if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { + STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); + stbiw__sbn(hash_table[h]) = quality; + } + stbiw__sbpush(hash_table[h],data+i); + + if (bestloc) { + // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal + h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); + hlist = hash_table[h]; + n = stbiw__sbcount(hlist); + for (j=0; j < n; ++j) { + if (hlist[j]-data > i-32767) { + int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); + if (e > best) { // if next match is better, bail on current match + bestloc = NULL; + break; + } + } + } + } + + if (bestloc) { + int d = (int) (data+i - bestloc); // distance back + STBIW_ASSERT(d <= 32767 && best <= 258); + for (j=0; best > lengthc[j+1]-1; ++j); + stbiw__zlib_huff(j+257); + if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); + for (j=0; d > distc[j+1]-1; ++j); + stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); + if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); + i += best; + } else { + stbiw__zlib_huffb(data[i]); + ++i; + } + } + // write out final bytes + for (;i < data_len; ++i) + stbiw__zlib_huffb(data[i]); + stbiw__zlib_huff(256); // end of block + // pad with 0 bits to byte boundary + while (bitcount) + stbiw__zlib_add(0,1); + + for (i=0; i < stbiw__ZHASH; ++i) + (void) stbiw__sbfree(hash_table[i]); + STBIW_FREE(hash_table); + + { + // compute adler32 on input + unsigned int s1=1, s2=0; + int blocklen = (int) (data_len % 5552); + j=0; + while (j < data_len) { + for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } + s1 %= 65521; s2 %= 65521; + j += blocklen; + blocklen = 5552; + } + stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(s2)); + stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); + stbiw__sbpush(out, STBIW_UCHAR(s1)); + } + *out_len = stbiw__sbn(out); + // make returned pointer freeable + STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); + return (unsigned char *) stbiw__sbraw(out); +#endif // STBIW_ZLIB_COMPRESS +} + +static unsigned int stbiw__crc32(unsigned char *buffer, int len) +{ +#ifdef STBIW_CRC32 + return STBIW_CRC32(buffer, len); +#else + static unsigned int crc_table[256] = + { + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D + }; + + unsigned int crc = ~0u; + int i; + for (i=0; i < len; ++i) + crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; + return ~crc; +#endif +} + +#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) +#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); +#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) + +static void stbiw__wpcrc(unsigned char **data, int len) +{ + unsigned int crc = stbiw__crc32(*data - len - 4, len+4); + stbiw__wp32(*data, crc); +} + +static unsigned char stbiw__paeth(int a, int b, int c) +{ + int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); + if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); + if (pb <= pc) return STBIW_UCHAR(b); + return STBIW_UCHAR(c); +} + +// @OPTIMIZE: provide an option that always forces left-predict or paeth predict +static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) +{ + static int mapping[] = { 0,1,2,3,4 }; + static int firstmap[] = { 0,1,0,5,6 }; + int *mymap = (y != 0) ? mapping : firstmap; + int i; + int type = mymap[filter_type]; + unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); + int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; + + if (type==0) { + memcpy(line_buffer, z, width*n); + return; + } + + // first loop isn't optimized since it's just one pixel + for (i = 0; i < n; ++i) { + switch (type) { + case 1: line_buffer[i] = z[i]; break; + case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; + case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; + case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; + case 5: line_buffer[i] = z[i]; break; + case 6: line_buffer[i] = z[i]; break; + } + } + switch (type) { + case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; + case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; + case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; + case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; + case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; + case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; + } +} + +STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) +{ + int force_filter = stbi_write_force_png_filter; + int ctype[5] = { -1, 0, 4, 2, 6 }; + unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; + unsigned char *out,*o, *filt, *zlib; + signed char *line_buffer; + int j,zlen; + + if (stride_bytes == 0) + stride_bytes = x * n; + + if (force_filter >= 5) { + force_filter = -1; + } + + filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; + line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } + for (j=0; j < y; ++j) { + int filter_type; + if (force_filter > -1) { + filter_type = force_filter; + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); + } else { // Estimate the best filter by running through all of them: + int best_filter = 0, best_filter_val = 0x7fffffff, est, i; + for (filter_type = 0; filter_type < 5; filter_type++) { + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); + + // Estimate the entropy of the line using this filter; the less, the better. + est = 0; + for (i = 0; i < x*n; ++i) { + est += abs((signed char) line_buffer[i]); + } + if (est < best_filter_val) { + best_filter_val = est; + best_filter = filter_type; + } + } + if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it + stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); + filter_type = best_filter; + } + } + // when we get here, filter_type contains the filter type, and line_buffer contains the data + filt[j*(x*n+1)] = (unsigned char) filter_type; + STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); + } + STBIW_FREE(line_buffer); + zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); + STBIW_FREE(filt); + if (!zlib) return 0; + + // each tag requires 12 bytes of overhead + out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); + if (!out) return 0; + *out_len = 8 + 12+13 + 12+zlen + 12; + + o=out; + STBIW_MEMMOVE(o,sig,8); o+= 8; + stbiw__wp32(o, 13); // header length + stbiw__wptag(o, "IHDR"); + stbiw__wp32(o, x); + stbiw__wp32(o, y); + *o++ = 8; + *o++ = STBIW_UCHAR(ctype[n]); + *o++ = 0; + *o++ = 0; + *o++ = 0; + stbiw__wpcrc(&o,13); + + stbiw__wp32(o, zlen); + stbiw__wptag(o, "IDAT"); + STBIW_MEMMOVE(o, zlib, zlen); + o += zlen; + STBIW_FREE(zlib); + stbiw__wpcrc(&o, zlen); + + stbiw__wp32(o,0); + stbiw__wptag(o, "IEND"); + stbiw__wpcrc(&o,0); + + STBIW_ASSERT(o == out + *out_len); + + return out; +} + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) +{ + FILE *f; + int len; + unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); + if (png == NULL) return 0; + + f = stbiw__fopen(filename, "wb"); + if (!f) { STBIW_FREE(png); return 0; } + fwrite(png, 1, len, f); + fclose(f); + STBIW_FREE(png); + return 1; +} +#endif + +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) +{ + int len; + unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); + if (png == NULL) return 0; + func(context, png, len); + STBIW_FREE(png); + return 1; +} + + +/* *************************************************************************** + * + * JPEG writer + * + * This is based on Jon Olick's jo_jpeg.cpp: + * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html + */ + +static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, + 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; + +static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { + int bitBuf = *bitBufP, bitCnt = *bitCntP; + bitCnt += bs[1]; + bitBuf |= bs[0] << (24 - bitCnt); + while(bitCnt >= 8) { + unsigned char c = (bitBuf >> 16) & 255; + stbiw__putc(s, c); + if(c == 255) { + stbiw__putc(s, 0); + } + bitBuf <<= 8; + bitCnt -= 8; + } + *bitBufP = bitBuf; + *bitCntP = bitCnt; +} + +static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { + float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; + float z1, z2, z3, z4, z5, z11, z13; + + float tmp0 = d0 + d7; + float tmp7 = d0 - d7; + float tmp1 = d1 + d6; + float tmp6 = d1 - d6; + float tmp2 = d2 + d5; + float tmp5 = d2 - d5; + float tmp3 = d3 + d4; + float tmp4 = d3 - d4; + + // Even part + float tmp10 = tmp0 + tmp3; // phase 2 + float tmp13 = tmp0 - tmp3; + float tmp11 = tmp1 + tmp2; + float tmp12 = tmp1 - tmp2; + + d0 = tmp10 + tmp11; // phase 3 + d4 = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * 0.707106781f; // c4 + d2 = tmp13 + z1; // phase 5 + d6 = tmp13 - z1; + + // Odd part + tmp10 = tmp4 + tmp5; // phase 2 + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + // The rotator is modified from fig 4-8 to avoid extra negations. + z5 = (tmp10 - tmp12) * 0.382683433f; // c6 + z2 = tmp10 * 0.541196100f + z5; // c2-c6 + z4 = tmp12 * 1.306562965f + z5; // c2+c6 + z3 = tmp11 * 0.707106781f; // c4 + + z11 = tmp7 + z3; // phase 5 + z13 = tmp7 - z3; + + *d5p = z13 + z2; // phase 6 + *d3p = z13 - z2; + *d1p = z11 + z4; + *d7p = z11 - z4; + + *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; +} + +static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { + int tmp1 = val < 0 ? -val : val; + val = val < 0 ? val-1 : val; + bits[1] = 1; + while(tmp1 >>= 1) { + ++bits[1]; + } + bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { + } + // end0pos = first element in reverse order !=0 + if(end0pos == 0) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + return DU[0]; + } + for(i = 1; i <= end0pos; ++i) { + int startpos = i; + int nrzeroes; + unsigned short bits[2]; + for (; DU[i]==0 && i<=end0pos; ++i) { + } + nrzeroes = i-startpos; + if ( nrzeroes >= 16 ) { + int lng = nrzeroes>>4; + int nrmarker; + for (nrmarker=1; nrmarker <= lng; ++nrmarker) + stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); + nrzeroes &= 15; + } + stbiw__jpg_calcBits(DU[i], bits); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); + stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); + } + if(end0pos != 63) { + stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); + } + return DU[0]; +} + +static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { + // Constants that don't pollute global namespace + static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; + static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; + static const unsigned char std_ac_luminance_values[] = { + 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, + 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, + 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, + 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, + 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, + 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, + 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa + }; + static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; + static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; + static const unsigned char std_ac_chrominance_values[] = { + 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, + 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, + 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, + 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, + 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, + 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa + }; + // Huffman tables + static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; + static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; + static const unsigned short YAC_HT[256][2] = { + {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} + }; + static const unsigned short UVAC_HT[256][2] = { + {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, + {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, + {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} + }; + static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, + 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; + static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, + 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; + static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, + 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; + + int row, col, i, k, subsample; + float fdtbl_Y[64], fdtbl_UV[64]; + unsigned char YTable[64], UVTable[64]; + + if(!data || !width || !height || comp > 4 || comp < 1) { + return 0; + } + + quality = quality ? quality : 90; + subsample = quality <= 90 ? 1 : 0; + quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; + quality = quality < 50 ? 5000 / quality : 200 - quality * 2; + + for(i = 0; i < 64; ++i) { + int uvti, yti = (YQT[i]*quality+50)/100; + YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); + uvti = (UVQT[i]*quality+50)/100; + UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); + } + + for(row = 0, k = 0; row < 8; ++row) { + for(col = 0; col < 8; ++col, ++k) { + fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); + } + } + + // Write Headers + { + static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; + static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; + const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), + 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; + s->func(s->context, (void*)head0, sizeof(head0)); + s->func(s->context, (void*)YTable, sizeof(YTable)); + stbiw__putc(s, 1); + s->func(s->context, UVTable, sizeof(UVTable)); + s->func(s->context, (void*)head1, sizeof(head1)); + s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); + s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); + stbiw__putc(s, 0x10); // HTYACinfo + s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); + s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); + stbiw__putc(s, 1); // HTUDCinfo + s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); + s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); + stbiw__putc(s, 0x11); // HTUACinfo + s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); + s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); + s->func(s->context, (void*)head2, sizeof(head2)); + } + + // Encode 8x8 macroblocks + { + static const unsigned short fillBits[] = {0x7F, 7}; + int DCY=0, DCU=0, DCV=0; + int bitBuf=0, bitCnt=0; + // comp == 2 is grey+alpha (alpha is ignored) + int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; + const unsigned char *dataR = (const unsigned char *)data; + const unsigned char *dataG = dataR + ofsG; + const unsigned char *dataB = dataR + ofsB; + int x, y, pos; + if(subsample) { + for(y = 0; y < height; y += 16) { + for(x = 0; x < width; x += 16) { + float Y[256], U[256], V[256]; + for(row = y, pos = 0; row < y+16; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; + for(col = x; col < x+16; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width-1))*comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; + U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; + V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; + } + } + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); + + // subsample U,V + { + float subU[64], subV[64]; + int yy, xx; + for(yy = 0, pos = 0; yy < 8; ++yy) { + for(xx = 0; xx < 8; ++xx, ++pos) { + int j = yy*32+xx*2; + subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f; + subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f; + } + } + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + } + } else { + for(y = 0; y < height; y += 8) { + for(x = 0; x < width; x += 8) { + float Y[64], U[64], V[64]; + for(row = y, pos = 0; row < y+8; ++row) { + // row >= height => use last input row + int clamped_row = (row < height) ? row : height - 1; + int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; + for(col = x; col < x+8; ++col, ++pos) { + // if col >= width => use pixel from last input column + int p = base_p + ((col < width) ? col : (width-1))*comp; + float r = dataR[p], g = dataG[p], b = dataB[p]; + Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; + U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; + V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; + } + } + + DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + } + + // Do the bit alignment of the EOI marker + stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); + } + + // EOI + stbiw__putc(s, 0xFF); + stbiw__putc(s, 0xD9); + + return 1; +} + +STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) +{ + stbi__write_context s; + stbi__start_write_callbacks(&s, func, context); + return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); +} + + +#ifndef STBI_WRITE_NO_STDIO +STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) +{ + stbi__write_context s; + if (stbi__start_write_file(&s,filename)) { + int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); + stbi__end_write_file(&s); + return r; + } else + return 0; +} +#endif + +#endif // STB_IMAGE_WRITE_IMPLEMENTATION + +/* Revision history + 1.14 (2020-02-02) updated JPEG writer to downsample chroma channels + 1.13 + 1.12 + 1.11 (2019-08-11) + + 1.10 (2019-02-07) + support utf8 filenames in Windows; fix warnings and platform ifdefs + 1.09 (2018-02-11) + fix typo in zlib quality API, improve STB_I_W_STATIC in C++ + 1.08 (2018-01-29) + add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter + 1.07 (2017-07-24) + doc fix + 1.06 (2017-07-23) + writing JPEG (using Jon Olick's code) + 1.05 ??? + 1.04 (2017-03-03) + monochrome BMP expansion + 1.03 ??? + 1.02 (2016-04-02) + avoid allocating large structures on the stack + 1.01 (2016-01-16) + STBIW_REALLOC_SIZED: support allocators with no realloc support + avoid race-condition in crc initialization + minor compile issues + 1.00 (2015-09-14) + installable file IO function + 0.99 (2015-09-13) + warning fixes; TGA rle support + 0.98 (2015-04-08) + added STBIW_MALLOC, STBIW_ASSERT etc + 0.97 (2015-01-18) + fixed HDR asserts, rewrote HDR rle logic + 0.96 (2015-01-17) + add HDR output + fix monochrome BMP + 0.95 (2014-08-17) + add monochrome TGA output + 0.94 (2014-05-31) + rename private functions to avoid conflicts with stb_image.h + 0.93 (2014-05-27) + warning fixes + 0.92 (2010-08-01) + casts to unsigned char to fix warnings + 0.91 (2010-07-17) + first public release + 0.90 first internal release +*/ + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/fixloaderpathsosx b/fixloaderpathsosx new file mode 100755 index 00000000..2a1b0af5 --- /dev/null +++ b/fixloaderpathsosx @@ -0,0 +1,26 @@ +#!/bin/bash +# Path to src directory of checkout +LIBPATH=`pwd`/build/src +cp ${LIBPATH}/**/*.dylib ${LIBPATH}/nvtt/ +# space separated list of libraries +cd ${LIBPATH}/nvtt/ +TARGETS=*.dylib +REPLACE="nvcore nvimage nvmath" +for TARGET in ${TARGETS} ; do +echo "Processing ${TARGET}" +LIBFILE=${LIBPATH}/${TARGET} +TARGETID=`otool -DX ${TARGET}` +NEWTARGETID=@loader_path/${TARGET} +install_name_tool -id ${NEWTARGETID} ${TARGET} || true +install_name_tool -change ${LIBFILE} ${NEWTARGETID} ${TARGET} || true + for T2 in ${TARGETS} ; do + for T3 in ${REPLACE} ; do + echo ${LIBPATH}/${T3}/${T2} @loader_path/${T2} ${TARGET} + install_name_tool -change ${LIBPATH}/${T3}/${T2} @loader_path/${T2} ${TARGET} || true + done + done +done +# Copy the corrected files back +cp ${LIBPATH}/nvtt/libnvmath.dylib ${LIBPATH}/nvmath/libnvmath.dylib +cp ${LIBPATH}/nvtt/libnvimage.dylib ${LIBPATH}/nvimage/libnvimage.dylib +cp ${LIBPATH}/nvtt/libnvcore.dylib ${LIBPATH}/nvcore/libnvcore.dylib diff --git a/project/README b/project/README deleted file mode 100644 index 433c9112..00000000 --- a/project/README +++ /dev/null @@ -1 +0,0 @@ -Most of the development is done on VC12, the remaining projects are often out of date. diff --git a/project/nvtt.code-workspace b/project/nvtt.code-workspace new file mode 100644 index 00000000..1ecfe6af --- /dev/null +++ b/project/nvtt.code-workspace @@ -0,0 +1,15 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": { + "files.exclude": { + "**/build*": true, + "**/.svn": true, + "**/.gitignore": true, + "**/*.user": true, + }, + } +} diff --git a/project/nvtt.sublime-project b/project/nvtt.sublime-project new file mode 100644 index 00000000..043adf1b --- /dev/null +++ b/project/nvtt.sublime-project @@ -0,0 +1,10 @@ +{ + "folders": + [ + { + "path": "..", + "file_exclude_patterns": ["*.user"], + "folder_exclude_patterns": ["build*", ".vscode", ".vc"] + } + ] +} diff --git a/project/vc10/Nvidia.TextureTools/TextureTools.cs b/project/vc10/Nvidia.TextureTools/TextureTools.cs deleted file mode 100644 index 3894da34..00000000 --- a/project/vc10/Nvidia.TextureTools/TextureTools.cs +++ /dev/null @@ -1,534 +0,0 @@ -using System; -using System.Security; -using System.Runtime.InteropServices; - -namespace Nvidia.TextureTools -{ - #region Enums - - #region public enum Format - /// - /// Compression format. - /// - public enum Format - { - // No compression. - RGB, - RGBA = RGB, - - // DX9 formats. - DXT1, - DXT1a, - DXT3, - DXT5, - DXT5n, - - // DX10 formats. - BC1 = DXT1, - BC1a = DXT1a, - BC2 = DXT3, - BC3 = DXT5, - BC3n = DXT5n, - BC4, - BC5, - - DXT1n, // Not supported on CPU yet. - CTX1, // Not supported on CPU yet. - - BC6, - BC7, // Not supported yet. - - DXT1_Luma, - } - #endregion - - #region public enum Quality - /// - /// Quality modes. - /// - public enum Quality - { - Fastest, - Normal, - Production, - Highest, - } - #endregion - - #region public enum WrapMode - /// - /// Wrap modes. - /// - public enum WrapMode - { - Clamp, - Repeat, - Mirror, - } - #endregion - - #region public enum TextureType - /// - /// Texture types. - /// - public enum TextureType - { - Texture2D, - TextureCube, - } - #endregion - - #region public enum InputFormat - /// - /// Input formats. - /// - public enum InputFormat - { - BGRA_8UB - } - #endregion - - #region public enum MipmapFilter - /// - /// Mipmap downsampling filters. - /// - public enum MipmapFilter - { - Box, - Triangle, - Kaiser - } - #endregion - - #region public enum ColorTransform - /// - /// Color transformation. - /// - public enum ColorTransform - { - None, - Linear - } - #endregion - - #region public enum RoundMode - /// - /// Extents rounding mode. - /// - public enum RoundMode - { - None, - ToNextPowerOfTwo, - ToNearestPowerOfTwo, - ToPreviousPowerOfTwo - } - #endregion - - #region public enum AlphaMode - /// - /// Alpha mode. - /// - public enum AlphaMode - { - None, - Transparency, - Premultiplied - } - #endregion - - #region public enum Error - /// - /// Error codes. - /// - public enum Error - { - InvalidInput, - UserInterruption, - UnsupportedFeature, - CudaError, - Unknown, - FileOpen, - FileWrite, - } - #endregion - - #endregion - - #region public class InputOptions - /// - /// Input options. - /// - public class InputOptions - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateInputOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyInputOptions(IntPtr inputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsTextureLayout(IntPtr inputOptions, TextureType type, int w, int h, int d); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttResetInputOptionsTextureLayout(IntPtr inputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttSetInputOptionsMipmapData(IntPtr inputOptions, IntPtr data, int w, int h, int d, int face, int mipmap); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsFormat(IntPtr inputOptions, InputFormat format); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsAlphaMode(IntPtr inputOptions, AlphaMode alphaMode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsGamma(IntPtr inputOptions, float inputGamma, float outputGamma); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsWrapMode(IntPtr inputOptions, WrapMode mode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMipmapFilter(IntPtr inputOptions, MipmapFilter filter); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMipmapGeneration(IntPtr inputOptions, bool generateMipmaps, int maxLevel); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsKaiserParameters(IntPtr inputOptions, float width, float alpha, float stretch); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalMap(IntPtr inputOptions, bool b); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsConvertToNormalMap(IntPtr inputOptions, bool convert); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsHeightEvaluation(IntPtr inputOptions, float redScale, float greenScale, float blueScale, float alphaScale); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalFilter(IntPtr inputOptions, float small, float medium, float big, float large); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalizeMipmaps(IntPtr inputOptions, bool b); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsColorTransform(IntPtr inputOptions, ColorTransform t); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsLinearTransfrom(IntPtr inputOptions, int channel, float w0, float w1, float w2, float w3); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMaxExtents(IntPtr inputOptions, int d); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsRoundMode(IntPtr inputOptions, RoundMode mode); - #endregion - - internal IntPtr options; - - public InputOptions() - { - options = nvttCreateInputOptions(); - } - ~InputOptions() - { - nvttDestroyInputOptions(options); - } - - public void SetTextureLayout(TextureType type, int w, int h, int d) - { - nvttSetInputOptionsTextureLayout(options, type, w, h, d); - } - public void ResetTextureLayout() - { - nvttResetInputOptionsTextureLayout(options); - } - - public void SetMipmapData(IntPtr data, int width, int height, int depth, int face, int mipmap) - { - nvttSetInputOptionsMipmapData(options, data, width, height, depth, face, mipmap); - } - - public void SetFormat(InputFormat format) - { - nvttSetInputOptionsFormat(options, format); - } - - public void SetAlphaMode(AlphaMode alphaMode) - { - nvttSetInputOptionsAlphaMode(options, alphaMode); - } - - public void SetGamma(float inputGamma, float outputGamma) - { - nvttSetInputOptionsGamma(options, inputGamma, outputGamma); - } - - public void SetWrapMode(WrapMode wrapMode) - { - nvttSetInputOptionsWrapMode(options, wrapMode); - } - - public void SetMipmapFilter(MipmapFilter filter) - { - nvttSetInputOptionsMipmapFilter(options, filter); - } - - public void SetMipmapGeneration(bool enabled) - { - nvttSetInputOptionsMipmapGeneration(options, enabled, -1); - } - - public void SetMipmapGeneration(bool enabled, int maxLevel) - { - nvttSetInputOptionsMipmapGeneration(options, enabled, maxLevel); - } - - public void SetKaiserParameters(float width, float alpha, float stretch) - { - nvttSetInputOptionsKaiserParameters(options, width, alpha, stretch); - } - - public void SetNormalMap(bool b) - { - nvttSetInputOptionsNormalMap(options, b); - } - - public void SetConvertToNormalMap(bool convert) - { - nvttSetInputOptionsConvertToNormalMap(options, convert); - } - - public void SetHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale) - { - nvttSetInputOptionsHeightEvaluation(options, redScale, greenScale, blueScale, alphaScale); - } - - public void SetNormalFilter(float small, float medium, float big, float large) - { - nvttSetInputOptionsNormalFilter(options, small, medium, big, large); - } - - public void SetNormalizeMipmaps(bool b) - { - nvttSetInputOptionsNormalizeMipmaps(options, b); - } - - public void SetColorTransform(ColorTransform t) - { - nvttSetInputOptionsColorTransform(options, t); - } - - public void SetLinearTransfrom(int channel, float w0, float w1, float w2, float w3) - { - nvttSetInputOptionsLinearTransfrom(options, channel, w0, w1, w2, w3); - } - - public void SetMaxExtents(int dim) - { - nvttSetInputOptionsMaxExtents(options, dim); - } - - public void SetRoundMode(RoundMode mode) - { - nvttSetInputOptionsRoundMode(options, mode); - } - } - #endregion - - #region public class CompressionOptions - /// - /// Compression options. - /// - public class CompressionOptions - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCompressionOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCompressionOptions(IntPtr compressionOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsFormat(IntPtr compressionOptions, Format format); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsQuality(IntPtr compressionOptions, Quality quality); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsColorWeights(IntPtr compressionOptions, float red, float green, float blue, float alpha); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsPixelFormat(IntPtr compressionOptions, uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsQuantization(IntPtr compressionOptions, bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold); - #endregion - - internal IntPtr options; - - public CompressionOptions() - { - options = nvttCreateCompressionOptions(); - } - ~CompressionOptions() - { - nvttDestroyCompressionOptions(options); - } - - public void SetFormat(Format format) - { - nvttSetCompressionOptionsFormat(options, format); - } - - public void SetQuality(Quality quality) - { - nvttSetCompressionOptionsQuality(options, quality); - } - - public void SetColorWeights(float red, float green, float blue) - { - nvttSetCompressionOptionsColorWeights(options, red, green, blue, 1.0f); - } - - public void SetColorWeights(float red, float green, float blue, float alpha) - { - nvttSetCompressionOptionsColorWeights(options, red, green, blue, alpha); - } - - public void SetPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) - { - nvttSetCompressionOptionsPixelFormat(options, bitcount, rmask, gmask, bmask, amask); - } - - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha) - { - nvttSetCompressionOptionsQuantization(options, colorDithering, alphaDithering, binaryAlpha, 127); - } - - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold) - { - nvttSetCompressionOptionsQuantization(options, colorDithering, alphaDithering, binaryAlpha, alphaThreshold); - } - } - #endregion - - #region public class OutputOptions - /// - /// Output options. - /// - public class OutputOptions - { - #region Delegates - public delegate void ErrorHandler(Error error); - private delegate void WriteDataDelegate(IntPtr data, int size); - private delegate void ImageDelegate(int size, int width, int height, int depth, int face, int miplevel); - #endregion - - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateOutputOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyOutputOptions(IntPtr outputOptions); - - [DllImport("nvtt", CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsFileName(IntPtr outputOptions, string fileName); - - //[DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - //private extern static void nvttSetOutputOptionsErrorHandler(IntPtr outputOptions, ErrorHandler errorHandler); - - private void ErrorCallback(Error error) - { - if (Error != null) Error(error); - } - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsOutputHeader(IntPtr outputOptions, bool b); - - //[DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - //private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, WriteDataDelegate writeData, ImageDelegate image); - - #endregion - - internal IntPtr options; - - public OutputOptions() - { - options = nvttCreateOutputOptions(); - //nvttSetOutputOptionsErrorHandler(options, new ErrorHandler(ErrorCallback)); - } - ~OutputOptions() - { - nvttDestroyOutputOptions(options); - } - - public void SetFileName(string fileName) - { - nvttSetOutputOptionsFileName(options, fileName); - } - - public event ErrorHandler Error; - - public void SetOutputHeader(bool b) - { - nvttSetOutputOptionsOutputHeader(options, b); - } - - // @@ Add OutputHandler interface. - } - #endregion - - #region public static class Compressor - public class Compressor - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCompressor(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCompressor(IntPtr compressor); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttCompress(IntPtr compressor, IntPtr inputOptions, IntPtr compressionOptions, IntPtr outputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static int nvttEstimateSize(IntPtr compressor, IntPtr inputOptions, IntPtr compressionOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private static extern IntPtr nvttErrorString(Error error); - - #endregion - - internal IntPtr compressor; - - public Compressor() - { - compressor = nvttCreateCompressor(); - } - - ~Compressor() - { - nvttDestroyCompressor(compressor); - } - - public bool Compress(InputOptions input, CompressionOptions compression, OutputOptions output) - { - return nvttCompress(compressor, input.options, compression.options, output.options); - } - - public int EstimateSize(InputOptions input, CompressionOptions compression) - { - return nvttEstimateSize(compressor, input.options, compression.options); - } - - public static string ErrorString(Error error) - { - return Marshal.PtrToStringAnsi(nvttErrorString(error)); - } - - } - #endregion - -} // Nvidia.TextureTools namespace diff --git a/project/vc10/bc6-01-eigen-solver.vsp b/project/vc10/bc6-01-eigen-solver.vsp deleted file mode 100644 index df0ec66f..00000000 Binary files a/project/vc10/bc6-01-eigen-solver.vsp and /dev/null differ diff --git a/project/vc10/bc6-02-no-double.vsp b/project/vc10/bc6-02-no-double.vsp deleted file mode 100644 index 933baa4a..00000000 Binary files a/project/vc10/bc6-02-no-double.vsp and /dev/null differ diff --git a/project/vc10/bc6.psess b/project/vc10/bc6.psess deleted file mode 100644 index 1b4f1f02..00000000 --- a/project/vc10/bc6.psess +++ /dev/null @@ -1,105 +0,0 @@ - - - - C:\nvtt\project\vc10\nvtt.sln - Sampling - None - true - true - false - false - Timestamp - Cycles - 10000000 - 10 - 10 - - false - false - - 0 - UnknownDisabled - 0 - - nvcompress - true - mpiexec.exe - true - - - - - - false - 500 - - \Memory\Pages/sec - \PhysicalDisk(_Total)\Avg. Disk Queue Length - \Processor(_Total)\% Processor Time - - - - true - false - - false - - - false - - - - C:\nvtt\project\vc10\Release.x64\bin\nvcompress.exe - 01/01/0001 00:00:00 - true - true - false - false - false - true - false - Executable - C:\nvtt\project\vc10\\Release.x64\bin\nvcompress.exe - C:\nvtt\project\vc10\nvcompress\ - -bc6 -nomips C:\nvtt\data\testsuite\kodak\kodim01.png C:\nvtt\data\testsuite\kodak\kodim01_bc6.dds - IIS - InternetExplorer - true - false - - false - - - false - - {88079E38-83AA-4E8A-B18A-66A78D1B058B}|nvcompress\nvcompress.vcxproj - C:\nvtt\project\vc10\nvcompress\nvcompress.vcxproj - nvcompress - - - - - C:\nvtt\project\vc10\bc6-01-eigen-solver.vsp - - - C:\nvtt\project\vc10\bc6-02-no-double.vsp - - - - - :PB:{88079E38-83AA-4E8A-B18A-66A78D1B058B}|nvcompress\nvcompress.vcxproj - - - - Mark One - Mark Two - Mark Three - Mark Four - Mark Five - Mark Six - Mark Seven - Mark Eight - Mark Nine - Mark Ten - - \ No newline at end of file diff --git a/project/vc10/bc6h/bc6h.vcxproj b/project/vc10/bc6h/bc6h.vcxproj deleted file mode 100755 index 381e8035..00000000 --- a/project/vc10/bc6h/bc6h.vcxproj +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C33787E3-5564-4834-9FE3-A9020455A669} - bc6h - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - X64 - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - MaxSpeed - true - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - Level3 - ProgramDatabase - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - X64 - - - MaxSpeed - true - MultiThreadedDLL - false - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc10/bc7/bc7.vcxproj b/project/vc10/bc7/bc7.vcxproj deleted file mode 100644 index 9d052bf5..00000000 --- a/project/vc10/bc7/bc7.vcxproj +++ /dev/null @@ -1,152 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F974F34B-AF02-4C88-8E1E-85475094EA78} - bc7 - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - X64 - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - MaxSpeed - true - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - Level3 - ProgramDatabase - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - X64 - - - MaxSpeed - true - MultiThreadedDLL - false - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc10/imperativeapi/imperativeapi.vcxproj b/project/vc10/imperativeapi/imperativeapi.vcxproj deleted file mode 100755 index ff499559..00000000 --- a/project/vc10/imperativeapi/imperativeapi.vcxproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {7DCF280E-702B-49F3-84A7-AE7E146384D6} - imperativeapi - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - MachineX86 - - - - - X64 - - - Disabled - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - %(AdditionalLibraryDirectories) - true - MachineX64 - - - - - Full - Default - true - Neither - true - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - Level3 - ProgramDatabase - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - true - true - MachineX86 - - - - - X64 - - - Full - true - true - true - true - MultiThreadedDLL - false - Level3 - ProgramDatabase - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - %(AdditionalLibraryDirectories) - true - true - true - MachineX64 - - - - - - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {1aeb7681-57d8-48ee-813d-5c41cc38b647} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/nvassemble/nvassemble.rc b/project/vc10/nvassemble/nvassemble.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc10/nvassemble/nvassemble.rc and /dev/null differ diff --git a/project/vc10/nvassemble/nvassemble.vcxproj b/project/vc10/nvassemble/nvassemble.vcxproj deleted file mode 100755 index 1186e4b6..00000000 --- a/project/vc10/nvassemble/nvassemble.vcxproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA} - nvassemble - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - true - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - libpng.lib;jpeg.lib;tiff.lib;%(AdditionalDependencies) - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - false - - - MachineX64 - - - - - Full - Default - true - Neither - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - false - - - MachineX86 - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - libpng.lib;jpeg.lib;tiff.lib;%(AdditionalDependencies) - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - false - - - MachineX64 - - - - - - - - - - - - - - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/nvcompress/nvcompress.rc b/project/vc10/nvcompress/nvcompress.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc10/nvcompress/nvcompress.rc and /dev/null differ diff --git a/project/vc10/nvcompress/nvcompress.vcxproj b/project/vc10/nvcompress/nvcompress.vcxproj deleted file mode 100755 index 7de782b7..00000000 --- a/project/vc10/nvcompress/nvcompress.vcxproj +++ /dev/null @@ -1,381 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Debug-CUDA - Win32 - - - Debug-CUDA - x64 - - - Release - Win32 - - - Release - x64 - - - Release-CUDA - Win32 - - - Release-CUDA - x64 - - - - {88079E38-83AA-4E8A-B18A-66A78D1B058B} - nvcompress - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - - - Application - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - - - - - Full - Default - true - Neither - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - - - %(AdditionalLibraryDirectories) - Console - true - true - false - - - MachineX64 - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - ProgramDatabase - - - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - - - - - Full - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - true - true - false - - - MachineX86 - - - - - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - - - %(AdditionalLibraryDirectories) - Console - true - true - UseLinkTimeCodeGeneration - false - - - MachineX64 - - - - - - - - - - - - - - - true - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - {1aeb7681-57d8-48ee-813d-5c41cc38b647} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/nvconfig.h b/project/vc10/nvconfig.h deleted file mode 100644 index 863a1d37..00000000 --- a/project/vc10/nvconfig.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef NV_CONFIG -#define NV_CONFIG - -//#cmakedefine HAVE_UNISTD_H -#define HAVE_STDARG_H -//#cmakedefine HAVE_SIGNAL_H -//#cmakedefine HAVE_EXECINFO_H -#define HAVE_MALLOC_H - -#if defined(_OPENMP) -#define HAVE_OPENMP -#endif - -#define HAVE_STBIMAGE -/*#if !defined(_M_X64) -//#define HAVE_FREEIMAGE -#define HAVE_PNG -#define HAVE_JPEG -#define HAVE_TIFF -#endif*/ - -#endif // NV_CONFIG diff --git a/project/vc10/nvcore/nvcore.vcxproj b/project/vc10/nvcore/nvcore.vcxproj deleted file mode 100644 index d8962b2d..00000000 --- a/project/vc10/nvcore/nvcore.vcxproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - nvcore - Win32Proj - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - Full - Default - true - Neither - true - true - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - ProgramDatabase - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc10/nvddsinfo/nvddsinfo.rc b/project/vc10/nvddsinfo/nvddsinfo.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc10/nvddsinfo/nvddsinfo.rc and /dev/null differ diff --git a/project/vc10/nvddsinfo/nvddsinfo.vcxproj b/project/vc10/nvddsinfo/nvddsinfo.vcxproj deleted file mode 100755 index e8131bfe..00000000 --- a/project/vc10/nvddsinfo/nvddsinfo.vcxproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {841B73C5-C679-4EEF-A50A-7D6106642B49} - nvddsinfo - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - true - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - libpng.lib;jpeg.lib;tiff.lib;%(AdditionalDependencies) - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - false - - - MachineX64 - - - - - Full - Default - true - Neither - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - false - - - MachineX86 - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - libpng.lib;jpeg.lib;tiff.lib;%(AdditionalDependencies) - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - false - - - MachineX64 - - - - - - - - - - - - - - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/nvdecompress/nvdecompress.rc b/project/vc10/nvdecompress/nvdecompress.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc10/nvdecompress/nvdecompress.rc and /dev/null differ diff --git a/project/vc10/nvdecompress/nvdecompress.vcxproj b/project/vc10/nvdecompress/nvdecompress.vcxproj deleted file mode 100755 index e7bff8c0..00000000 --- a/project/vc10/nvdecompress/nvdecompress.vcxproj +++ /dev/null @@ -1,229 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {75A0527D-BFC9-49C3-B46B-CD1A901D5927} - nvdecompress - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - $(GnuWinDir)\lib; $(FreeImageDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - - - - - Full - Default - true - Neither - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - %(AdditionalDependencies) - $(GnuWinDir)\lib; $(FreeImageDir);%(AdditionalLibraryDirectories) - false - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - - - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - true - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/nvimage/nvimage.vcxproj b/project/vc10/nvimage/nvimage.vcxproj deleted file mode 100755 index 389b5236..00000000 --- a/project/vc10/nvimage/nvimage.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4046F392-A18B-4C66-9639-3EABFFF5D531} - nvimage - Win32Proj - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(SolutionDir)\..\..\extern\stb;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(SolutionDir)\..\..\extern\stb;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - Full - Default - true - Neither - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(SolutionDir)\..\..\extern\stb;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(SolutionDir)\..\..\extern\stb;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - ProgramDatabase - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc10/nvimgdiff/nvimgdiff.rc b/project/vc10/nvimgdiff/nvimgdiff.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc10/nvimgdiff/nvimgdiff.rc and /dev/null differ diff --git a/project/vc10/nvimgdiff/nvimgdiff.vcxproj b/project/vc10/nvimgdiff/nvimgdiff.vcxproj deleted file mode 100755 index c472aa1d..00000000 --- a/project/vc10/nvimgdiff/nvimgdiff.vcxproj +++ /dev/null @@ -1,231 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {05A59E8B-EA70-4F22-89E8-E0927BA13064} - nvimgdiff - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - $(GnuWinDir)\lib; $(FreeImageDir);%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - %(AdditionalDependencies) - - - - - Full - Default - true - Neither - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - %(AdditionalDependencies) - $(GnuWinDir)\lib; $(FreeImageDir);%(AdditionalLibraryDirectories) - false - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - - - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - Console - true - true - false - - - MachineX64 - %(AdditionalDependencies) - - - - - - - - - - - - true - - - - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/nvmath/nvmath.vcxproj b/project/vc10/nvmath/nvmath.vcxproj deleted file mode 100755 index b12bc73d..00000000 --- a/project/vc10/nvmath/nvmath.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {50C465FE-B308-42BC-894D-89484482AF06} - nvmath - Win32Proj - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - Full - Default - true - Neither - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - ProgramDatabase - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc10/nvthread/nvthread.vcxproj b/project/vc10/nvthread/nvthread.vcxproj deleted file mode 100755 index ac53891b..00000000 --- a/project/vc10/nvthread/nvthread.vcxproj +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4CFD4876-A026-46C2-AFCF-FB11346E815D} - nvthread - - - - StaticLibrary - true - MultiByte - - - StaticLibrary - true - MultiByte - - - StaticLibrary - false - true - MultiByte - - - StaticLibrary - false - true - MultiByte - - - - - - - - - - - - - - - - - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - $(Configuration)\$(Platform)\ - - - - Level3 - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - true - - - - - Level3 - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - true - - - - - Level3 - MaxSpeed - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - - - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc10/nvtt/nvtt.rc b/project/vc10/nvtt/nvtt.rc deleted file mode 100644 index 089d1e97..00000000 --- a/project/vc10/nvtt/nvtt.rc +++ /dev/null @@ -1,102 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,0,0 - PRODUCTVERSION 2,1,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "NVIDIA Corporation" - VALUE "FileDescription", "NVIDIA Texture Tools Dynamic Link Library" - VALUE "FileVersion", "2, 1, 0, 0" - VALUE "InternalName", "nvtt" - VALUE "LegalCopyright", "Copyright (C) 2007" - VALUE "OriginalFilename", "nvtt.dll" - VALUE "ProductName", "NVIDIA Texture Tools Dynamic Link Library" - VALUE "ProductVersion", "2, 1, 0, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/project/vc10/nvtt/nvtt.vcxproj b/project/vc10/nvtt/nvtt.vcxproj deleted file mode 100755 index 82673cb4..00000000 --- a/project/vc10/nvtt/nvtt.vcxproj +++ /dev/null @@ -1,518 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Debug-CUDA - Win32 - - - Debug-CUDA - x64 - - - Release - Win32 - - - Release - x64 - - - Release-CUDA - Win32 - - - Release-CUDA - x64 - - - - {1AEB7681-57D8-48EE-813D-5C41CC38B647} - nvtt - Win32Proj - - - - DynamicLibrary - NotSet - true - - - DynamicLibrary - NotSet - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - - - DynamicLibrary - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(CUDA_INC_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;HAVE_CUDA;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - cudart.lib;%(AdditionalDependencies) - $(CUDA_PATH)\lib\Win32;%(AdditionalLibraryDirectories) - true - Windows - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX86 - - - Copying header files... - xcopy /y /f /i "$(SolutionDir)\..\..\src\nvtt\nvtt*.h" "$(SolutionDir)\$(Configuration).$(Platform)\include\nvtt\" - - - true - true - -D_DEBUG %(AdditionalOptions) - MDd - RTC1 - ptx - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(CUDA_INC_PATH);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;HAVE_CUDA;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - cudart.lib;%(AdditionalDependencies) - $(CUDA_PATH)\lib\x64;%(AdditionalLibraryDirectories) - true - Windows - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX64 - - - 64 - -D_DEBUG %(AdditionalOptions) - true - true - MDd - RTC1 - ptx - - - - - Full - Default - true - Neither - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(CUDA_INC_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;HAVE_CUDA;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - false - - - Level3 - ProgramDatabase - true - - - cudart.lib;%(AdditionalDependencies) - $(CUDA_PATH)\lib\Win32;%(AdditionalLibraryDirectories) - Windows - true - true - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX86 - true - - - Copying header files... - xcopy /y /f /i "$(SolutionDir)\..\..\src\nvtt\nvtt*.h" "$(SolutionDir)\$(Configuration).$(Platform)\include\nvtt\" - - - O2 - -DNDEBUG %(AdditionalOptions) - ptx - - - - - X64 - - - Full - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;$(CUDA_INC_PATH);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;HAVE_CUDA;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - ProgramDatabase - - - cudart.lib;%(AdditionalDependencies) - $(CUDA_PATH)\lib\x64;%(AdditionalLibraryDirectories) - Windows - true - true - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX64 - true - - - 64 - O2 - -DNDEBUG %(AdditionalOptions) - ptx - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Windows - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX86 - - - Copying header files... - xcopy /y /f /i "$(SolutionDir)\..\..\src\nvtt\nvtt*.h" "$(SolutionDir)\$(Configuration).$(Platform)\include\nvtt\" - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Level3 - ProgramDatabase - - - $(CUDA_LIB_PATH)\..\lib64;%(AdditionalLibraryDirectories) - true - Windows - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX64 - %(AdditionalDependencies) - - - - - Full - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Windows - true - true - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX86 - true - - - Copying header files... - xcopy /y /f /i "$(SolutionDir)\..\..\src\nvtt\nvtt*.h" "$(SolutionDir)\$(Configuration).$(Platform)\include\nvtt\" - - - - - true - true - true - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - ProgramDatabase - - - $(CUDA_LIB_PATH)\..\lib64;%(AdditionalLibraryDirectories) - Windows - true - true - UseLinkTimeCodeGeneration - false - - - $(SolutionDir)\$(Configuration).$(Platform)\lib\$(ProjectName).lib - MachineX64 - %(AdditionalDependencies) - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - true - true - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - false - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - {4cfd4876-a026-46c2-afcf-fb11346e815d} - true - false - false - true - false - - - {ce017322-01fc-4851-9c8b-64e9a8e26c38} - false - - - - - compile - compile - compile - compile - true - true - true - true - - - - - - - \ No newline at end of file diff --git a/project/vc10/nvtt/nvtt.vcxproj.filters b/project/vc10/nvtt/nvtt.vcxproj.filters deleted file mode 100755 index 8dbf23f0..00000000 --- a/project/vc10/nvtt/nvtt.vcxproj.filters +++ /dev/null @@ -1,86 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {18fa5da9-6ed8-4990-880e-ab4234fe2114} - - - - - Resource Files - - - - - Resource Files - - - cuda - - - cuda - - - cuda - - - - - - - - - - - - - - - - - - - - - - - - cuda - - - cuda - - - - - - - - - - - - - - - - - - - - - - - cuda - - - - - cuda - - - \ No newline at end of file diff --git a/project/vc10/nvzoom/nvzoom.rc b/project/vc10/nvzoom/nvzoom.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc10/nvzoom/nvzoom.rc and /dev/null differ diff --git a/project/vc10/nvzoom/nvzoom.vcxproj b/project/vc10/nvzoom/nvzoom.vcxproj deleted file mode 100755 index 656e73c2..00000000 --- a/project/vc10/nvzoom/nvzoom.vcxproj +++ /dev/null @@ -1,222 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {51999D3E-EF22-4BDD-965F-4201034D3DCE} - nvzoom - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - MultiByte - true - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - false - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - X64 - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - true - Console - false - - - MachineX64 - %(AdditionalDependencies) - - - - - Full - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - false - Console - true - true - false - - - MachineX86 - - - - - X64 - - - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NVDXT_SHARED;%(PreprocessorDefinitions) - MultiThreadedDLL - false - - - Level3 - - - ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) - Console - true - true - false - - - MachineX64 - %(AdditionalDependencies) - - - - - - - - - - - - true - - - - - - - - {c33787e3-5564-4834-9fe3-a9020455a669} - - - {f974f34b-af02-4c88-8e1e-85475094ea78} - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/squish/squish.vcxproj b/project/vc10/squish/squish.vcxproj deleted file mode 100755 index d92e74e5..00000000 --- a/project/vc10/squish/squish.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {CE017322-01FC-4851-9C8B-64E9A8E26C38} - squish - Win32Proj - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - - - X64 - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - Full - Default - true - Neither - true - true - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;SQUISH_USE_SSE = 2;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - StreamingSIMDExtensions2 - - - Level3 - ProgramDatabase - true - - - - - X64 - - - Full - true - true - true - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - true - MultiThreadedDLL - false - - - Level3 - ProgramDatabase - - - - - - - - - - - - - - - - - - - - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {50c465fe-b308-42bc-894d-89484482af06} - false - - - - - - \ No newline at end of file diff --git a/project/vc10/testsuite/testsuite.vcxproj b/project/vc10/testsuite/testsuite.vcxproj deleted file mode 100755 index d1c211bf..00000000 --- a/project/vc10/testsuite/testsuite.vcxproj +++ /dev/null @@ -1,361 +0,0 @@ - - - - - Debug-CUDA - Win32 - - - Debug-CUDA - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release-CUDA - Win32 - - - Release-CUDA - x64 - - - Release - Win32 - - - Release - x64 - - - - nvtt-testsuite - {317B694E-B5C1-42A6-956F-FC12B69175A6} - stress - Win32Proj - - - - Application - Unicode - true - - - Application - Unicode - true - - - Application - Unicode - true - - - Application - Unicode - true - - - Application - Unicode - - - Application - Unicode - - - Application - Unicode - - - Application - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - true - true - true - true - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(SolutionDir)\$(Configuration).$(Platform)\bin\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - $(Configuration)\$(Platform)\ - false - false - false - false - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - EditAndContinue - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - MachineX86 - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - - - - - Disabled - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - false - - - - - - - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - - - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - true - true - false - - - MachineX86 - - - - - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - - - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - true - true - false - - - MachineX86 - - - - - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - - - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - true - true - false - - - - - - - $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDLL - StreamingSIMDExtensions2 - - - Level3 - - - true - - - %(AdditionalDependencies) - %(AdditionalLibraryDirectories) - true - Console - true - true - false - - - - - - - - - - {f143d180-d4c4-4037-b3de-be89a21c8d1d} - false - - - {4046f392-a18b-4c66-9639-3eabfff5d531} - false - - - {1aeb7681-57d8-48ee-813d-5c41cc38b647} - false - - - - - - \ No newline at end of file diff --git a/project/vc12/Nvidia.TextureTools.UnitTests/Nvidia.TextureTools.UnitTests.csproj b/project/vc12/Nvidia.TextureTools.UnitTests/Nvidia.TextureTools.UnitTests.csproj new file mode 100644 index 00000000..5e308ce1 --- /dev/null +++ b/project/vc12/Nvidia.TextureTools.UnitTests/Nvidia.TextureTools.UnitTests.csproj @@ -0,0 +1,64 @@ + + + + Debug + AnyCPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA} + Exe + Nvidia.TextureTools.UnitTests + Nvidia.TextureTools.UnitTests + v4.6.1 + + + true + bin\Debug\ + DEBUG; + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\Release\ + true + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + False + True + + + ..\packages\NUnitLite.3.9.0\lib\net45\nunitlite.dll + True + + + + + + + + + {CAB55C39-8FA9-4912-98D9-E52669C8911D} + Nvidia.TextureTools + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/vc12/Nvidia.TextureTools.UnitTests/Test.cs b/project/vc12/Nvidia.TextureTools.UnitTests/Test.cs new file mode 100644 index 00000000..31c7fc34 --- /dev/null +++ b/project/vc12/Nvidia.TextureTools.UnitTests/Test.cs @@ -0,0 +1,150 @@ +using System; +using System.Runtime.InteropServices; +using NUnitLite; +using NUnit.Framework; + +namespace Nvidia.TextureTools.UnitTests +{ + [TestFixture] + public class Test + { + private static int _count; + + // NOTE: This stress test takes around 5 times longer on + // Mac because it seems Mono's GC is that much slower. + + [Test] + [Repeat(200)] + [Parallelizable] + public void StressTest() + { + var count = ++_count; + var seed = unchecked(123456 * count); + Console.WriteLine("StressTest Seed=" + seed); + + TestRandomAllFormats(32, 32, seed); + TestRandomAllFormats(32, 64, seed+1); + TestRandomAllFormats(61, 127, seed+2); + TestRandomAllFormats(1024, 32, seed+3); + TestRandomAllFormats(32, 1024, seed+4); + TestRandomAllFormats(1024, 1024, seed+5); + } + + private void TestRandomAllFormats(int sizeX, int sizeY, int seed) + { + TestRandom(sizeX, sizeY, seed, Format.DXT1, AlphaMode.Premultiplied, Quality.Highest); + TestRandom(sizeX, sizeY, seed+1, Format.DXT1a, AlphaMode.Premultiplied, Quality.Highest); + TestRandom(sizeX, sizeY, seed+2, Format.DXT3, AlphaMode.Premultiplied, Quality.Highest); + TestRandom(sizeX, sizeY, seed+3, Format.DXT5, AlphaMode.Premultiplied, Quality.Highest); + } + + private void TestRandom(int sizeX, int sizeY, int seed, Format format, AlphaMode alphaMode, Quality quality) + { + Console.WriteLine("TestRandom {0} {1}x{2} {3} {4} {5}", seed, sizeX, sizeY, format, alphaMode, quality); + var data = CreateRandomTexture(sizeX, sizeY, seed); + TestCompress(sizeX, sizeY, data, Format.DXT1, AlphaMode.Premultiplied, Quality.Highest); + } + + private static byte[] CreateRandomTexture(int sizeX, int sizeY, int seed) + { + var rand = new Random(seed); + + var data = new byte[sizeX * sizeY * 4]; + for (int i = 0; i < data.Length; i += 4) + { + data[i + 0] = (byte)rand.Next(0, 255); + data[i + 1] = (byte)rand.Next(0, 255); + data[i + 2] = (byte)rand.Next(0, 255); + data[i + 3] = 255; + } + + return data; + } + + private void TestCompress(int sizeX, int sizeY, byte[] data, Format format, AlphaMode alphaMode, Quality quality) + { + var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned); + + try + { + var dataPtr = dataHandle.AddrOfPinnedObject(); + + var inputOptions = new InputOptions(); + inputOptions.SetTextureLayout(TextureType.Texture2D, sizeX, sizeY, 1); + inputOptions.SetMipmapData(dataPtr, sizeX, sizeY, 1, 0, 0); + inputOptions.SetMipmapGeneration(false); + inputOptions.SetGamma(1.0f, 1.0f); + inputOptions.SetAlphaMode(alphaMode); + + var compressionOptions = new CompressionOptions(); + compressionOptions.SetFormat(format); + compressionOptions.SetQuality(quality); + + var dataHelper = new DataHelper(); + + var outputOptions = new OutputOptions(); + outputOptions.SetOutputHeader(false); + outputOptions.SetOutputOptionsOutputHandler(dataHelper.BeginImageInternal, dataHelper.WriteDataInternal, dataHelper.EndImageInternal); + outputOptions.Error += OutputOptionsOnError; + + Collect(); + + var compressor = new Compressor(); + var estsize = compressor.EstimateSize(inputOptions, compressionOptions); + Assert.True(compressor.Compress(inputOptions, compressionOptions, outputOptions)); + + Collect(); + + Assert.AreEqual(estsize, dataHelper.buffer.Length); + } + finally + { + dataHandle.Free(); + } + } + + private void OutputOptionsOnError(Error error) + { + Console.WriteLine("OutputOptionsOnError! " + error); + throw new Exception(); + } + + private static void Collect() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + GC.Collect(); + } + + class DataHelper + { + public byte[] buffer; + int offset; + + public void BeginImageInternal(int size, int width, int height, int depth, int face, int miplevel) + { + Collect(); + buffer = new byte [size]; + offset = 0; + } + + public bool WriteDataInternal(IntPtr data, int length) + { + Collect(); + Marshal.Copy(data, buffer, offset, length); + offset += length; + return true; + } + + public void EndImageInternal() + { + Collect(); + } + } + + public static int Main(String[] args) + { + return new AutoRun().Execute(args); + } + } +} diff --git a/project/vc12/Nvidia.TextureTools.UnitTests/packages.config b/project/vc12/Nvidia.TextureTools.UnitTests/packages.config new file mode 100644 index 00000000..2cebf741 --- /dev/null +++ b/project/vc12/Nvidia.TextureTools.UnitTests/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj b/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj deleted file mode 100644 index e4d8d6fa..00000000 --- a/project/vc12/Nvidia.TextureTools/Nvidia.TextureTools.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - - Debug - AnyCPU - 9.0.21022 - 2.0 - {CAB55C39-8FA9-4912-98D9-E52669C8911D} - Library - Properties - Nvidia.TextureTools - Nvidia.TextureTools - - - 3.5 - - - OnBuildSuccess - v2.0 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc12/Nvidia.TextureTools/Properties/AssemblyInfo.cs b/project/vc12/Nvidia.TextureTools/Properties/AssemblyInfo.cs deleted file mode 100644 index ecd652e8..00000000 --- a/project/vc12/Nvidia.TextureTools/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Nvidia.TextureTools")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("NVIDIA Corporation")] -[assembly: AssemblyProduct("Nvidia.TextureTools")] -[assembly: AssemblyCopyright("Copyright © NVIDIA 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5fa03fb3-b7a3-4ba8-90e7-545929731356")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/project/vc12/bc6-01-eigen-solver.vsp b/project/vc12/bc6-01-eigen-solver.vsp deleted file mode 100644 index df0ec66f..00000000 Binary files a/project/vc12/bc6-01-eigen-solver.vsp and /dev/null differ diff --git a/project/vc12/bc6-02-no-double.vsp b/project/vc12/bc6-02-no-double.vsp deleted file mode 100644 index 933baa4a..00000000 Binary files a/project/vc12/bc6-02-no-double.vsp and /dev/null differ diff --git a/project/vc12/bc6.psess b/project/vc12/bc6.psess deleted file mode 100644 index 1b4f1f02..00000000 --- a/project/vc12/bc6.psess +++ /dev/null @@ -1,105 +0,0 @@ - - - - C:\nvtt\project\vc10\nvtt.sln - Sampling - None - true - true - false - false - Timestamp - Cycles - 10000000 - 10 - 10 - - false - false - - 0 - UnknownDisabled - 0 - - nvcompress - true - mpiexec.exe - true - - - - - - false - 500 - - \Memory\Pages/sec - \PhysicalDisk(_Total)\Avg. Disk Queue Length - \Processor(_Total)\% Processor Time - - - - true - false - - false - - - false - - - - C:\nvtt\project\vc10\Release.x64\bin\nvcompress.exe - 01/01/0001 00:00:00 - true - true - false - false - false - true - false - Executable - C:\nvtt\project\vc10\\Release.x64\bin\nvcompress.exe - C:\nvtt\project\vc10\nvcompress\ - -bc6 -nomips C:\nvtt\data\testsuite\kodak\kodim01.png C:\nvtt\data\testsuite\kodak\kodim01_bc6.dds - IIS - InternetExplorer - true - false - - false - - - false - - {88079E38-83AA-4E8A-B18A-66A78D1B058B}|nvcompress\nvcompress.vcxproj - C:\nvtt\project\vc10\nvcompress\nvcompress.vcxproj - nvcompress - - - - - C:\nvtt\project\vc10\bc6-01-eigen-solver.vsp - - - C:\nvtt\project\vc10\bc6-02-no-double.vsp - - - - - :PB:{88079E38-83AA-4E8A-B18A-66A78D1B058B}|nvcompress\nvcompress.vcxproj - - - - Mark One - Mark Two - Mark Three - Mark Four - Mark Five - Mark Six - Mark Seven - Mark Eight - Mark Nine - Mark Ten - - \ No newline at end of file diff --git a/project/vc12/nvassemble/nvassemble.vcxproj.filters b/project/vc12/nvassemble/nvassemble.vcxproj.filters deleted file mode 100644 index 7cb92e63..00000000 --- a/project/vc12/nvassemble/nvassemble.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/project/vc12/nvassemble/nvidia.ico b/project/vc12/nvassemble/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc12/nvassemble/nvidia.ico and /dev/null differ diff --git a/project/vc12/nvassemble/resource.h b/project/vc12/nvassemble/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc12/nvassemble/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc12/nvcompress/nvcompress.vcxproj.filters b/project/vc12/nvcompress/nvcompress.vcxproj.filters deleted file mode 100644 index 2185cf27..00000000 --- a/project/vc12/nvcompress/nvcompress.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/project/vc12/nvcompress/nvidia.ico b/project/vc12/nvcompress/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc12/nvcompress/nvidia.ico and /dev/null differ diff --git a/project/vc12/nvcompress/resource.h b/project/vc12/nvcompress/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc12/nvcompress/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc12/nvconfig.h b/project/vc12/nvconfig.h deleted file mode 100644 index 863a1d37..00000000 --- a/project/vc12/nvconfig.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef NV_CONFIG -#define NV_CONFIG - -//#cmakedefine HAVE_UNISTD_H -#define HAVE_STDARG_H -//#cmakedefine HAVE_SIGNAL_H -//#cmakedefine HAVE_EXECINFO_H -#define HAVE_MALLOC_H - -#if defined(_OPENMP) -#define HAVE_OPENMP -#endif - -#define HAVE_STBIMAGE -/*#if !defined(_M_X64) -//#define HAVE_FREEIMAGE -#define HAVE_PNG -#define HAVE_JPEG -#define HAVE_TIFF -#endif*/ - -#endif // NV_CONFIG diff --git a/project/vc12/nvddsinfo/nvddsinfo.vcxproj.filters b/project/vc12/nvddsinfo/nvddsinfo.vcxproj.filters deleted file mode 100644 index 8881e204..00000000 --- a/project/vc12/nvddsinfo/nvddsinfo.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/project/vc12/nvddsinfo/nvidia.ico b/project/vc12/nvddsinfo/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc12/nvddsinfo/nvidia.ico and /dev/null differ diff --git a/project/vc12/nvddsinfo/resource.h b/project/vc12/nvddsinfo/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc12/nvddsinfo/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc12/nvdecompress/nvdecompress.vcxproj.filters b/project/vc12/nvdecompress/nvdecompress.vcxproj.filters deleted file mode 100644 index 2d2e7c38..00000000 --- a/project/vc12/nvdecompress/nvdecompress.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/project/vc12/nvdecompress/nvidia.ico b/project/vc12/nvdecompress/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc12/nvdecompress/nvidia.ico and /dev/null differ diff --git a/project/vc12/nvdecompress/resource.h b/project/vc12/nvdecompress/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc12/nvdecompress/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc12/nvimgdiff/nvidia.ico b/project/vc12/nvimgdiff/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc12/nvimgdiff/nvidia.ico and /dev/null differ diff --git a/project/vc12/nvimgdiff/nvimgdiff.vcxproj.filters b/project/vc12/nvimgdiff/nvimgdiff.vcxproj.filters deleted file mode 100644 index b1ae45dd..00000000 --- a/project/vc12/nvimgdiff/nvimgdiff.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/project/vc12/nvimgdiff/resource.h b/project/vc12/nvimgdiff/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc12/nvimgdiff/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc12/nvthread/nvthread.vcxproj.filters b/project/vc12/nvthread/nvthread.vcxproj.filters deleted file mode 100644 index cefe98d1..00000000 --- a/project/vc12/nvthread/nvthread.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc12/nvtt.props b/project/vc12/nvtt.props deleted file mode 100644 index d8451801..00000000 --- a/project/vc12/nvtt.props +++ /dev/null @@ -1,9 +0,0 @@ - - - - - $(SolutionDir)..\..\src - $(SolutionDir)..\..\extern - $(ExternDir)\gnuwin32 - - diff --git a/project/vc12/nvtt/resource.h b/project/vc12/nvtt/resource.h deleted file mode 100644 index 4df7169c..00000000 --- a/project/vc12/nvtt/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvtt.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc12/nvzoom/nvidia.ico b/project/vc12/nvzoom/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc12/nvzoom/nvidia.ico and /dev/null differ diff --git a/project/vc12/nvzoom/nvzoom.vcxproj.filters b/project/vc12/nvzoom/nvzoom.vcxproj.filters deleted file mode 100644 index fff52c9b..00000000 --- a/project/vc12/nvzoom/nvzoom.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/project/vc12/nvzoom/resource.h b/project/vc12/nvzoom/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc12/nvzoom/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc10/Nvidia.TextureTools/Nvidia.TextureTools.csproj b/project/vc2017/Nvidia.TextureTools/Nvidia.TextureTools.csproj similarity index 91% rename from project/vc10/Nvidia.TextureTools/Nvidia.TextureTools.csproj rename to project/vc2017/Nvidia.TextureTools/Nvidia.TextureTools.csproj index e4d8d6fa..0ae8e2d6 100644 --- a/project/vc10/Nvidia.TextureTools/Nvidia.TextureTools.csproj +++ b/project/vc2017/Nvidia.TextureTools/Nvidia.TextureTools.csproj @@ -44,6 +44,11 @@ + + + PreserveNewest + + ImportGroup Label="ExtensionSettings"> @@ -157,6 +158,7 @@ Level3 ProgramDatabase + AdvancedVectorExtensions2 cudart.lib;%(AdditionalDependencies) @@ -197,6 +199,7 @@ Level3 ProgramDatabase + AdvancedVectorExtensions2 cudart.lib;%(AdditionalDependencies) @@ -231,7 +234,7 @@ WIN32;NDEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;HAVE_CUDA;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) true MultiThreadedDLL - StreamingSIMDExtensions2 + AdvancedVectorExtensions2 false @@ -280,6 +283,7 @@ Level3 ProgramDatabase + AdvancedVectorExtensions2 cudart.lib;%(AdditionalDependencies) @@ -314,6 +318,7 @@ Level3 ProgramDatabase true + AdvancedVectorExtensions2 %(AdditionalDependencies) @@ -342,6 +347,7 @@ Level3 ProgramDatabase true + AdvancedVectorExtensions2 $(CUDA_LIB_PATH)\..\lib64;%(AdditionalLibraryDirectories) @@ -369,6 +375,7 @@ Level3 ProgramDatabase true + AdvancedVectorExtensions2 %(AdditionalDependencies) @@ -395,10 +402,11 @@ true $(SolutionDir);$(SolutionDir)\..\..\src;$(SolutionDir)\..\..\extern\poshlib;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;NVTT_EXPORTS;NVTT_SHARED;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) - MultiThreadedDLL + MultiThreaded Level3 ProgramDatabase true + AdvancedVectorExtensions2 $(CUDA_LIB_PATH)\..\lib64;%(AdditionalLibraryDirectories) @@ -420,16 +428,15 @@ - + - @@ -460,19 +467,18 @@ - - + @@ -481,7 +487,6 @@ - diff --git a/project/vc12/nvtt/nvtt.vcxproj.filters b/project/vc2017/nvtt/nvtt.vcxproj.filters similarity index 90% rename from project/vc12/nvtt/nvtt.vcxproj.filters rename to project/vc2017/nvtt/nvtt.vcxproj.filters index 3df42baf..89b9ad43 100644 --- a/project/vc12/nvtt/nvtt.vcxproj.filters +++ b/project/vc2017/nvtt/nvtt.vcxproj.filters @@ -27,7 +27,6 @@ cuda - @@ -46,8 +45,8 @@ - + @@ -56,7 +55,6 @@ cuda - @@ -73,10 +71,9 @@ - - + diff --git a/project/vc2017/nvtt/nvtt.vcxproj.user b/project/vc2017/nvtt/nvtt.vcxproj.user new file mode 100644 index 00000000..2a22e69a --- /dev/null +++ b/project/vc2017/nvtt/nvtt.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/project/vc10/nvtt/resource.h b/project/vc2017/nvtt/resource.h similarity index 100% rename from project/vc10/nvtt/resource.h rename to project/vc2017/nvtt/resource.h diff --git a/project/vc10/nvtt.sln b/project/vc2017/nvtt_monogame.sln similarity index 59% rename from project/vc10/nvtt.sln rename to project/vc2017/nvtt_monogame.sln index 61c75bc6..a530e952 100644 --- a/project/vc10/nvtt.sln +++ b/project/vc2017/nvtt_monogame.sln @@ -1,338 +1,241 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A08D9CB4-C9D8-46EF-A74D-0EAB11FE34C5}" - ProjectSection(SolutionItems) = preProject - bc6.psess = bc6.psess - nvconfig.h = nvconfig.h - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt", "nvtt\nvtt.vcxproj", "{1AEB7681-57D8-48EE-813D-5C41CC38B647}" - ProjectSection(ProjectDependencies) = postProject - {4CFD4876-A026-46C2-AFCF-FB11346E815D} = {4CFD4876-A026-46C2-AFCF-FB11346E815D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcompress", "nvcompress\nvcompress.vcxproj", "{88079E38-83AA-4E8A-B18A-66A78D1B058B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimage", "nvimage\nvimage.vcxproj", "{4046F392-A18B-4C66-9639-3EABFFF5D531}" - ProjectSection(ProjectDependencies) = postProject - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcore", "nvcore\nvcore.vcxproj", "{F143D180-D4C4-4037-B3DE-BE89A21C8D1D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvmath", "nvmath\nvmath.vcxproj", "{50C465FE-B308-42BC-894D-89484482AF06}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "squish\squish.vcxproj", "{CE017322-01FC-4851-9C8B-64E9A8E26C38}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvddsinfo", "nvddsinfo\nvddsinfo.vcxproj", "{841B73C5-C679-4EEF-A50A-7D6106642B49}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvdecompress", "nvdecompress\nvdecompress.vcxproj", "{75A0527D-BFC9-49C3-B46B-CD1A901D5927}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimgdiff", "nvimgdiff\nvimgdiff.vcxproj", "{05A59E8B-EA70-4F22-89E8-E0927BA13064}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvassemble", "nvassemble\nvassemble.vcxproj", "{3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvzoom", "nvzoom\nvzoom.vcxproj", "{51999D3E-EF22-4BDD-965F-4201034D3DCE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nvidia.TextureTools", "Nvidia.TextureTools\Nvidia.TextureTools.csproj", "{CAB55C39-8FA9-4912-98D9-E52669C8911D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt-testsuite", "testsuite\testsuite.vcxproj", "{317B694E-B5C1-42A6-956F-FC12B69175A6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imperativeapi", "imperativeapi\imperativeapi.vcxproj", "{7DCF280E-702B-49F3-84A7-AE7E146384D6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc6h", "bc6h\bc6h.vcxproj", "{C33787E3-5564-4834-9FE3-A9020455A669}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvthread", "nvthread\nvthread.vcxproj", "{4CFD4876-A026-46C2-AFCF-FB11346E815D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc7", "bc7\bc7.vcxproj", "{F974F34B-AF02-4C88-8E1E-85475094EA78}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug-CUDA|Win32 = Debug-CUDA|Win32 - Debug-CUDA|x64 = Debug-CUDA|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - Release-CUDA|Win32 = Release-CUDA|Win32 - Release-CUDA|x64 = Release-CUDA|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.ActiveCfg = Debug|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.Build.0 = Debug|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.ActiveCfg = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.Build.0 = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.ActiveCfg = Release|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.Build.0 = Release|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.ActiveCfg = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.Build.0 = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Win32.ActiveCfg = Debug|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Win32.Build.0 = Debug|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|x64.ActiveCfg = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|x64.Build.0 = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Win32.ActiveCfg = Release|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Win32.Build.0 = Release|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|x64.ActiveCfg = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|x64.Build.0 = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.ActiveCfg = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.Build.0 = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|x64.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.ActiveCfg = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.Build.0 = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.Build.0 = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|Win32.Build.0 = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|x64.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|x64.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.ActiveCfg = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.Build.0 = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|x64.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.ActiveCfg = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.Build.0 = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|Win32.Build.0 = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|x64.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|x64.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.ActiveCfg = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.Build.0 = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|x64.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.ActiveCfg = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.Build.0 = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|Win32.Build.0 = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|x64.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|x64.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.ActiveCfg = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.Build.0 = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|x64.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.ActiveCfg = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.Build.0 = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|Win32.Build.0 = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|x64.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|x64.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Win32.ActiveCfg = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Win32.Build.0 = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|x64.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|x64.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|x64.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Win32.ActiveCfg = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Win32.Build.0 = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|x64.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|x64.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|Win32.Build.0 = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|x64.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|x64.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Win32.ActiveCfg = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Win32.Build.0 = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|x64.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|x64.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|x64.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Win32.ActiveCfg = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Win32.Build.0 = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|x64.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|x64.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|Win32.Build.0 = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|x64.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|x64.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Win32.ActiveCfg = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Win32.Build.0 = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|x64.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|x64.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|x64.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Win32.ActiveCfg = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Win32.Build.0 = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|x64.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|x64.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|Win32.Build.0 = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|x64.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|x64.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Win32.Build.0 = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|x64.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|x64.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|x64.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Win32.ActiveCfg = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Win32.Build.0 = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|x64.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|x64.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|Win32.Build.0 = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|x64.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|x64.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Win32.ActiveCfg = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Win32.Build.0 = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|x64.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|x64.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|x64.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Win32.ActiveCfg = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Win32.Build.0 = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|x64.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|x64.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|Win32.Build.0 = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|x64.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|x64.Build.0 = Release|x64 - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|Win32.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|Win32.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|x64.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|x64.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|Win32.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|Win32.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|x64.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|x64.Build.0 = Release|Any CPU - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|Win32.ActiveCfg = Debug|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|Win32.Build.0 = Debug|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|x64.ActiveCfg = Debug|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|x64.Build.0 = Debug|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|Win32.ActiveCfg = Release|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|Win32.Build.0 = Release|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|x64.ActiveCfg = Release|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|x64.Build.0 = Release|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|Win32.ActiveCfg = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|Win32.Build.0 = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|x64.ActiveCfg = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|x64.Build.0 = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|x64.Build.0 = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|Win32.ActiveCfg = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|Win32.Build.0 = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|x64.ActiveCfg = Release|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|x64.Build.0 = Release|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|Win32.Build.0 = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|x64.ActiveCfg = Release|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|x64.Build.0 = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|Win32.ActiveCfg = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|Win32.Build.0 = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|x64.ActiveCfg = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|x64.Build.0 = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|x64.Build.0 = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|Win32.ActiveCfg = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|Win32.Build.0 = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|x64.ActiveCfg = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|x64.Build.0 = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|Win32.Build.0 = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|x64.ActiveCfg = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|x64.Build.0 = Release|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|Win32.ActiveCfg = Debug|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|Win32.Build.0 = Debug|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|x64.ActiveCfg = Debug|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|x64.Build.0 = Debug|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|x64.Build.0 = Debug|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|Win32.ActiveCfg = Release|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|Win32.Build.0 = Release|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|x64.ActiveCfg = Release|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|x64.Build.0 = Release|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|Win32.Build.0 = Release|Win32 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|x64.ActiveCfg = Release|x64 - {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|x64.Build.0 = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.ActiveCfg = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.Build.0 = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.ActiveCfg = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.Build.0 = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|x64.Build.0 = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|Win32.ActiveCfg = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|Win32.Build.0 = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|x64.ActiveCfg = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|x64.Build.0 = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.Build.0 = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.ActiveCfg = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A08D9CB4-C9D8-46EF-A74D-0EAB11FE34C5}" + ProjectSection(SolutionItems) = preProject + bc6.psess = bc6.psess + nvconfig.h = nvconfig.h + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt", "nvtt\nvtt.vcxproj", "{1AEB7681-57D8-48EE-813D-5C41CC38B647}" + ProjectSection(ProjectDependencies) = postProject + {CE017322-01FC-4851-9C8B-64E9A8E26C38} = {CE017322-01FC-4851-9C8B-64E9A8E26C38} + {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} + {4CFD4876-A026-46C2-AFCF-FB11346E815D} = {4CFD4876-A026-46C2-AFCF-FB11346E815D} + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} + {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} + {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} + {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimage", "nvimage\nvimage.vcxproj", "{4046F392-A18B-4C66-9639-3EABFFF5D531}" + ProjectSection(ProjectDependencies) = postProject + {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} + {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} + {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcore", "nvcore\nvcore.vcxproj", "{F143D180-D4C4-4037-B3DE-BE89A21C8D1D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvmath", "nvmath\nvmath.vcxproj", "{50C465FE-B308-42BC-894D-89484482AF06}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "squish\squish.vcxproj", "{CE017322-01FC-4851-9C8B-64E9A8E26C38}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nvidia.TextureTools", "Nvidia.TextureTools\Nvidia.TextureTools.csproj", "{CAB55C39-8FA9-4912-98D9-E52669C8911D}" + ProjectSection(ProjectDependencies) = postProject + {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imperativeapi", "imperativeapi\imperativeapi.vcxproj", "{7DCF280E-702B-49F3-84A7-AE7E146384D6}" + ProjectSection(ProjectDependencies) = postProject + {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc6h", "bc6h\bc6h.vcxproj", "{C33787E3-5564-4834-9FE3-A9020455A669}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvthread", "nvthread\nvthread.vcxproj", "{4CFD4876-A026-46C2-AFCF-FB11346E815D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc7", "bc7\bc7.vcxproj", "{F974F34B-AF02-4C88-8E1E-85475094EA78}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nvidia.TextureTools.UnitTests", "Nvidia.TextureTools.UnitTests\Nvidia.TextureTools.UnitTests.csproj", "{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Debug-CUDA|Win32 = Debug-CUDA|Win32 + Debug-CUDA|x64 = Debug-CUDA|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + Release-CUDA|Win32 = Release-CUDA|Win32 + Release-CUDA|x64 = Release-CUDA|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.ActiveCfg = Debug|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.Build.0 = Debug|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.ActiveCfg = Debug|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.Build.0 = Debug|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.ActiveCfg = Release|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.Build.0 = Release|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.ActiveCfg = Release|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.Build.0 = Release|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 + {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.ActiveCfg = Debug|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.Build.0 = Debug|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.ActiveCfg = Debug|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.Build.0 = Debug|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|x64.Build.0 = Debug|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.ActiveCfg = Release|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.Build.0 = Release|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.ActiveCfg = Release|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.Build.0 = Release|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|Win32.Build.0 = Release|Win32 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|x64.ActiveCfg = Release|x64 + {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|x64.Build.0 = Release|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.ActiveCfg = Debug|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.Build.0 = Debug|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.ActiveCfg = Debug|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.Build.0 = Debug|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|x64.Build.0 = Debug|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.ActiveCfg = Release|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.Build.0 = Release|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.ActiveCfg = Release|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.Build.0 = Release|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|Win32.Build.0 = Release|Win32 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|x64.ActiveCfg = Release|x64 + {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|x64.Build.0 = Release|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.ActiveCfg = Debug|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.Build.0 = Debug|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.ActiveCfg = Debug|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.Build.0 = Debug|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|x64.Build.0 = Debug|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.ActiveCfg = Release|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.Build.0 = Release|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.ActiveCfg = Release|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.Build.0 = Release|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|Win32.Build.0 = Release|Win32 + {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|x64.ActiveCfg = Release|x64 + {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|x64.Build.0 = Release|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.ActiveCfg = Debug|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.Build.0 = Debug|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.ActiveCfg = Debug|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.Build.0 = Debug|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|x64.Build.0 = Debug|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.ActiveCfg = Release|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.Build.0 = Release|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.ActiveCfg = Release|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.Build.0 = Release|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|Win32.Build.0 = Release|Win32 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|x64.ActiveCfg = Release|x64 + {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|x64.Build.0 = Release|x64 + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.ActiveCfg = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.Build.0 = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.ActiveCfg = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.Build.0 = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|Win32.ActiveCfg = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|Win32.Build.0 = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|x64.ActiveCfg = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|x64.Build.0 = Debug|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.ActiveCfg = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.Build.0 = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.ActiveCfg = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.Build.0 = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|Win32.ActiveCfg = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|Win32.Build.0 = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|x64.ActiveCfg = Release|Any CPU + {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|x64.Build.0 = Release|Any CPU + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|Win32.ActiveCfg = Debug|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|Win32.Build.0 = Debug|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|x64.ActiveCfg = Debug|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|x64.Build.0 = Debug|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|x64.Build.0 = Debug|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|Win32.ActiveCfg = Release|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|Win32.Build.0 = Release|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|x64.ActiveCfg = Release|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|x64.Build.0 = Release|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|Win32.Build.0 = Release|Win32 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|x64.ActiveCfg = Release|x64 + {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|x64.Build.0 = Release|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|Win32.ActiveCfg = Debug|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|Win32.Build.0 = Debug|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|x64.ActiveCfg = Debug|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|x64.Build.0 = Debug|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|x64.Build.0 = Debug|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release|Win32.ActiveCfg = Release|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release|Win32.Build.0 = Release|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release|x64.ActiveCfg = Release|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release|x64.Build.0 = Release|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|Win32.Build.0 = Release|Win32 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|x64.ActiveCfg = Release|x64 + {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|x64.Build.0 = Release|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|Win32.ActiveCfg = Debug|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|Win32.Build.0 = Debug|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|x64.ActiveCfg = Debug|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug|x64.Build.0 = Debug|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Debug-CUDA|x64.Build.0 = Debug|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|Win32.ActiveCfg = Release|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|Win32.Build.0 = Release|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|x64.ActiveCfg = Release|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release|x64.Build.0 = Release|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|Win32.Build.0 = Release|Win32 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|x64.ActiveCfg = Release|x64 + {4CFD4876-A026-46C2-AFCF-FB11346E815D}.Release-CUDA|x64.Build.0 = Release|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.ActiveCfg = Debug|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.Build.0 = Debug|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.ActiveCfg = Debug|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.Build.0 = Debug|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|Win32.Build.0 = Debug|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|x64.ActiveCfg = Debug|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|x64.Build.0 = Debug|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|Win32.ActiveCfg = Release|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|Win32.Build.0 = Release|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|x64.ActiveCfg = Release|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|x64.Build.0 = Release|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.ActiveCfg = Release|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.Build.0 = Release|Win32 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.ActiveCfg = Release|x64 + {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.Build.0 = Release|x64 + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug|Win32.ActiveCfg = Debug|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug|x64.ActiveCfg = Debug|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|Win32.ActiveCfg = Debug|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|x64.ActiveCfg = Debug|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|x64.Build.0 = Debug|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|Win32.ActiveCfg = Release|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|x64.ActiveCfg = Release|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|x64.Build.0 = Release|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release-CUDA|Win32.ActiveCfg = Release|Any CPU + {553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release-CUDA|x64.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/project/vc10/nvzoom/nvidia.ico b/project/vc2017/nvzoom/nvidia.ico similarity index 100% rename from project/vc10/nvzoom/nvidia.ico rename to project/vc2017/nvzoom/nvidia.ico diff --git a/project/vc12/nvzoom/nvzoom.rc b/project/vc2017/nvzoom/nvzoom.rc similarity index 100% rename from project/vc12/nvzoom/nvzoom.rc rename to project/vc2017/nvzoom/nvzoom.rc diff --git a/project/vc12/nvzoom/nvzoom.vcxproj b/project/vc2017/nvzoom/nvzoom.vcxproj similarity index 92% rename from project/vc12/nvzoom/nvzoom.vcxproj rename to project/vc2017/nvzoom/nvzoom.vcxproj index ebd8ce0c..1bb83397 100644 --- a/project/vc12/nvzoom/nvzoom.vcxproj +++ b/project/vc2017/nvzoom/nvzoom.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -22,29 +22,30 @@ {51999D3E-EF22-4BDD-965F-4201034D3DCE} nvzoom Win32Proj + 10.0.18362.0 Application MultiByte true - v120 + v141 Application MultiByte - v120 + v141 Application MultiByte true - v120 + v141 Application MultiByte - v120 + v141 @@ -94,6 +95,7 @@ Level3 EditAndContinue true + AdvancedVectorExtensions2 %(AdditionalDependencies) @@ -122,6 +124,7 @@ Level3 ProgramDatabase true + AdvancedVectorExtensions2 ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) @@ -142,7 +145,7 @@ true MultiThreadedDLL false - StreamingSIMDExtensions2 + AdvancedVectorExtensions2 Level3 @@ -175,6 +178,7 @@ Level3 true + AdvancedVectorExtensions2 ..\..\..\extern\gnuwin32\lib;%(AdditionalLibraryDirectories) diff --git a/project/vc10/nvzoom/nvzoom.vcxproj.filters b/project/vc2017/nvzoom/nvzoom.vcxproj.filters old mode 100755 new mode 100644 similarity index 100% rename from project/vc10/nvzoom/nvzoom.vcxproj.filters rename to project/vc2017/nvzoom/nvzoom.vcxproj.filters diff --git a/project/vc10/nvzoom/resource.h b/project/vc2017/nvzoom/resource.h similarity index 100% rename from project/vc10/nvzoom/resource.h rename to project/vc2017/nvzoom/resource.h diff --git a/project/vc12/squish/squish.vcxproj b/project/vc2017/squish/squish.vcxproj similarity index 91% rename from project/vc12/squish/squish.vcxproj rename to project/vc2017/squish/squish.vcxproj index 64980d5d..862b1568 100644 --- a/project/vc12/squish/squish.vcxproj +++ b/project/vc2017/squish/squish.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -22,29 +22,30 @@ {CE017322-01FC-4851-9C8B-64E9A8E26C38} squish Win32Proj + 10.0.18362.0 StaticLibrary MultiByte true - v120 + v141 StaticLibrary MultiByte - v120 + v141 StaticLibrary MultiByte true - v120 + v141 StaticLibrary MultiByte - v120 + v141 @@ -90,6 +91,7 @@ Level3 EditAndContinue true + AdvancedVectorExtensions2 @@ -108,6 +110,7 @@ Level3 ProgramDatabase true + AdvancedVectorExtensions2 @@ -123,7 +126,7 @@ true MultiThreadedDLL false - StreamingSIMDExtensions2 + AdvancedVectorExtensions2 Level3 @@ -143,13 +146,14 @@ %(AdditionalIncludeDirectories) WIN32;NDEBUG;_LIB;__SSE2__;__SSE__;__MMX__;%(PreprocessorDefinitions) true - MultiThreadedDLL + MultiThreaded false Level3 ProgramDatabase true + AdvancedVectorExtensions2 diff --git a/project/vc12/testsuite/testsuite.vcxproj b/project/vc2017/testsuite/testsuite.vcxproj similarity index 94% rename from project/vc12/testsuite/testsuite.vcxproj rename to project/vc2017/testsuite/testsuite.vcxproj index dbe25ff3..2d305372 100644 --- a/project/vc12/testsuite/testsuite.vcxproj +++ b/project/vc2017/testsuite/testsuite.vcxproj @@ -1,5 +1,5 @@  - + Debug-CUDA @@ -39,51 +39,52 @@ {317B694E-B5C1-42A6-956F-FC12B69175A6} stress Win32Proj + 10.0.18362.0 Application Unicode true - v120 + v141 Application Unicode true - v120 + v141 Application Unicode true - v120 + v141 Application Unicode true - v120 + v141 Application Unicode - v120 + v141 Application Unicode - v120 + v141 Application Unicode - v120 + v141 Application Unicode - v120 + v141 @@ -161,6 +162,7 @@ Level3 EditAndContinue true + AdvancedVectorExtensions2 %(AdditionalDependencies) @@ -209,6 +211,7 @@ Level3 ProgramDatabase true + AdvancedVectorExtensions2 %(AdditionalDependencies) @@ -248,7 +251,7 @@ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreadedDLL - StreamingSIMDExtensions2 + AdvancedVectorExtensions2 Level3 @@ -302,7 +305,7 @@ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreadedDLL - StreamingSIMDExtensions2 + AdvancedVectorExtensions2 Level3 diff --git a/project/vc8/.ignore b/project/vc8/.ignore deleted file mode 100644 index b351d815..00000000 --- a/project/vc8/.ignore +++ /dev/null @@ -1,13 +0,0 @@ -nvtt.suo -nvtt.ncb -release.win32 -debug.win32 -release.x64 -debug.x64 -release (no cuda).win32 -debug (no cuda).win32 -release (no cuda).x64 -debug (no cuda).x64 -Release -Debug -*.icastano.user diff --git a/project/vc8/Nvidia.TextureTools/Nvidia.TextureTools.csproj b/project/vc8/Nvidia.TextureTools/Nvidia.TextureTools.csproj deleted file mode 100644 index 5c5bf25f..00000000 --- a/project/vc8/Nvidia.TextureTools/Nvidia.TextureTools.csproj +++ /dev/null @@ -1,47 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {CAB55C39-8FA9-4912-98D9-E52669C8911D} - Library - Properties - Nvidia.TextureTools - Nvidia.TextureTools - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc8/Nvidia.TextureTools/Properties/AssemblyInfo.cs b/project/vc8/Nvidia.TextureTools/Properties/AssemblyInfo.cs deleted file mode 100644 index ecd652e8..00000000 --- a/project/vc8/Nvidia.TextureTools/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Nvidia.TextureTools")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("NVIDIA Corporation")] -[assembly: AssemblyProduct("Nvidia.TextureTools")] -[assembly: AssemblyCopyright("Copyright © NVIDIA 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5fa03fb3-b7a3-4ba8-90e7-545929731356")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/project/vc8/Nvidia.TextureTools/TextureTools.cs b/project/vc8/Nvidia.TextureTools/TextureTools.cs deleted file mode 100644 index 9b57249d..00000000 --- a/project/vc8/Nvidia.TextureTools/TextureTools.cs +++ /dev/null @@ -1,526 +0,0 @@ -using System; -using System.Security; -using System.Runtime.InteropServices; - -namespace Nvidia.TextureTools -{ - #region Enums - - #region public enum Format - /// - /// Compression format. - /// - public enum Format - { - // No compression. - RGB, - RGBA = RGB, - - // DX9 formats. - DXT1, - DXT1a, - DXT3, - DXT5, - DXT5n, - - // DX10 formats. - BC1 = DXT1, - BC1a = DXT1a, - BC2 = DXT3, - BC3 = DXT5, - BC3n = DXT5n, - BC4, - BC5, - } - #endregion - - #region public enum Quality - /// - /// Quality modes. - /// - public enum Quality - { - Fastest, - Normal, - Production, - Highest, - } - #endregion - - #region public enum WrapMode - /// - /// Wrap modes. - /// - public enum WrapMode - { - Clamp, - Repeat, - Mirror, - } - #endregion - - #region public enum TextureType - /// - /// Texture types. - /// - public enum TextureType - { - Texture2D, - TextureCube, - } - #endregion - - #region public enum InputFormat - /// - /// Input formats. - /// - public enum InputFormat - { - BGRA_8UB - } - #endregion - - #region public enum MipmapFilter - /// - /// Mipmap downsampling filters. - /// - public enum MipmapFilter - { - Box, - Triangle, - Kaiser - } - #endregion - - #region public enum ColorTransform - /// - /// Color transformation. - /// - public enum ColorTransform - { - None, - Linear - } - #endregion - - #region public enum RoundMode - /// - /// Extents rounding mode. - /// - public enum RoundMode - { - None, - ToNextPowerOfTwo, - ToNearestPowerOfTwo, - ToPreviousPowerOfTwo - } - #endregion - - #region public enum AlphaMode - /// - /// Alpha mode. - /// - public enum AlphaMode - { - None, - Transparency, - Premultiplied - } - #endregion - - #region public enum Error - /// - /// Error codes. - /// - public enum Error - { - InvalidInput, - UserInterruption, - UnsupportedFeature, - CudaError, - Unknown, - FileOpen, - FileWrite, - } - #endregion - - #endregion - - #region public class InputOptions - /// - /// Input options. - /// - public class InputOptions - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateInputOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyInputOptions(IntPtr inputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsTextureLayout(IntPtr inputOptions, TextureType type, int w, int h, int d); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttResetInputOptionsTextureLayout(IntPtr inputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttSetInputOptionsMipmapData(IntPtr inputOptions, IntPtr data, int w, int h, int d, int face, int mipmap); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsFormat(IntPtr inputOptions, InputFormat format); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsAlphaMode(IntPtr inputOptions, AlphaMode alphaMode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsGamma(IntPtr inputOptions, float inputGamma, float outputGamma); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsWrapMode(IntPtr inputOptions, WrapMode mode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMipmapFilter(IntPtr inputOptions, MipmapFilter filter); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMipmapGeneration(IntPtr inputOptions, bool generateMipmaps, int maxLevel); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsKaiserParameters(IntPtr inputOptions, float width, float alpha, float stretch); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalMap(IntPtr inputOptions, bool b); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsConvertToNormalMap(IntPtr inputOptions, bool convert); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsHeightEvaluation(IntPtr inputOptions, float redScale, float greenScale, float blueScale, float alphaScale); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalFilter(IntPtr inputOptions, float small, float medium, float big, float large); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalizeMipmaps(IntPtr inputOptions, bool b); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsColorTransform(IntPtr inputOptions, ColorTransform t); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsLinearTransfrom(IntPtr inputOptions, int channel, float w0, float w1, float w2, float w3); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMaxExtents(IntPtr inputOptions, int d); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsRoundMode(IntPtr inputOptions, RoundMode mode); - #endregion - - internal IntPtr options; - - public InputOptions() - { - options = nvttCreateInputOptions(); - } - ~InputOptions() - { - nvttDestroyInputOptions(options); - } - - public void SetTextureLayout(TextureType type, int w, int h, int d) - { - nvttSetInputOptionsTextureLayout(options, type, w, h, d); - } - public void ResetTextureLayout() - { - nvttResetInputOptionsTextureLayout(options); - } - - public void SetMipmapData(IntPtr data, int width, int height, int depth, int face, int mipmap) - { - nvttSetInputOptionsMipmapData(options, data, width, height, depth, face, mipmap); - } - - public void SetFormat(InputFormat format) - { - nvttSetInputOptionsFormat(options, format); - } - - public void SetAlphaMode(AlphaMode alphaMode) - { - nvttSetInputOptionsAlphaMode(options, alphaMode); - } - - public void SetGamma(float inputGamma, float outputGamma) - { - nvttSetInputOptionsGamma(options, inputGamma, outputGamma); - } - - public void SetWrapMode(WrapMode wrapMode) - { - nvttSetInputOptionsWrapMode(options, wrapMode); - } - - public void SetMipmapFilter(MipmapFilter filter) - { - nvttSetInputOptionsMipmapFilter(options, filter); - } - - public void SetMipmapGeneration(bool enabled) - { - nvttSetInputOptionsMipmapGeneration(options, enabled, -1); - } - - public void SetMipmapGeneration(bool enabled, int maxLevel) - { - nvttSetInputOptionsMipmapGeneration(options, enabled, maxLevel); - } - - public void SetKaiserParameters(float width, float alpha, float stretch) - { - nvttSetInputOptionsKaiserParameters(options, width, alpha, stretch); - } - - public void SetNormalMap(bool b) - { - nvttSetInputOptionsNormalMap(options, b); - } - - public void SetConvertToNormalMap(bool convert) - { - nvttSetInputOptionsConvertToNormalMap(options, convert); - } - - public void SetHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale) - { - nvttSetInputOptionsHeightEvaluation(options, redScale, greenScale, blueScale, alphaScale); - } - - public void SetNormalFilter(float small, float medium, float big, float large) - { - nvttSetInputOptionsNormalFilter(options, small, medium, big, large); - } - - public void SetNormalizeMipmaps(bool b) - { - nvttSetInputOptionsNormalizeMipmaps(options, b); - } - - public void SetColorTransform(ColorTransform t) - { - nvttSetInputOptionsColorTransform(options, t); - } - - public void SetLinearTransfrom(int channel, float w0, float w1, float w2, float w3) - { - nvttSetInputOptionsLinearTransfrom(options, channel, w0, w1, w2, w3); - } - - public void SetMaxExtents(int dim) - { - nvttSetInputOptionsMaxExtents(options, dim); - } - - public void SetRoundMode(RoundMode mode) - { - nvttSetInputOptionsRoundMode(options, mode); - } - } - #endregion - - #region public class CompressionOptions - /// - /// Compression options. - /// - public class CompressionOptions - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCompressionOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCompressionOptions(IntPtr compressionOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsFormat(IntPtr compressionOptions, Format format); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsQuality(IntPtr compressionOptions, Quality quality); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsColorWeights(IntPtr compressionOptions, float red, float green, float blue, float alpha); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsPixelFormat(IntPtr compressionOptions, uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsQuantization(IntPtr compressionOptions, bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold); - #endregion - - internal IntPtr options; - - public CompressionOptions() - { - options = nvttCreateCompressionOptions(); - } - ~CompressionOptions() - { - nvttDestroyCompressionOptions(options); - } - - public void SetFormat(Format format) - { - nvttSetCompressionOptionsFormat(options, format); - } - - public void SetQuality(Quality quality) - { - nvttSetCompressionOptionsQuality(options, quality); - } - - public void SetColorWeights(float red, float green, float blue) - { - nvttSetCompressionOptionsColorWeights(options, red, green, blue, 1.0f); - } - - public void SetColorWeights(float red, float green, float blue, float alpha) - { - nvttSetCompressionOptionsColorWeights(options, red, green, blue, alpha); - } - - public void SetPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) - { - nvttSetCompressionOptionsPixelFormat(options, bitcount, rmask, gmask, bmask, amask); - } - - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha) - { - nvttSetCompressionOptionsQuantization(options, colorDithering, alphaDithering, binaryAlpha, 127); - } - - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold) - { - nvttSetCompressionOptionsQuantization(options, colorDithering, alphaDithering, binaryAlpha, alphaThreshold); - } - } - #endregion - - #region public class OutputOptions - /// - /// Output options. - /// - public class OutputOptions - { - #region Delegates - public delegate void ErrorHandler(Error error); - private delegate void WriteDataDelegate(IntPtr data, int size); - private delegate void ImageDelegate(int size, int width, int height, int depth, int face, int miplevel); - #endregion - - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateOutputOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyOutputOptions(IntPtr outputOptions); - - [DllImport("nvtt", CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsFileName(IntPtr outputOptions, string fileName); - - //[DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - //private extern static void nvttSetOutputOptionsErrorHandler(IntPtr outputOptions, ErrorHandler errorHandler); - - private void ErrorCallback(Error error) - { - if (Error != null) Error(error); - } - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsOutputHeader(IntPtr outputOptions, bool b); - - //[DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - //private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, WriteDataDelegate writeData, ImageDelegate image); - - #endregion - - internal IntPtr options; - - public OutputOptions() - { - options = nvttCreateOutputOptions(); - //nvttSetOutputOptionsErrorHandler(options, new ErrorHandler(ErrorCallback)); - } - ~OutputOptions() - { - nvttDestroyOutputOptions(options); - } - - public void SetFileName(string fileName) - { - nvttSetOutputOptionsFileName(options, fileName); - } - - public event ErrorHandler Error; - - public void SetOutputHeader(bool b) - { - nvttSetOutputOptionsOutputHeader(options, b); - } - - // @@ Add OutputHandler interface. - } - #endregion - - #region public static class Compressor - public class Compressor - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCompressor(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCompressor(IntPtr compressor); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttCompress(IntPtr compressor, IntPtr inputOptions, IntPtr compressionOptions, IntPtr outputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static int nvttEstimateSize(IntPtr compressor, IntPtr inputOptions, IntPtr compressionOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private static extern IntPtr nvttErrorString(Error error); - - #endregion - - internal IntPtr compressor; - - public Compressor() - { - compressor = nvttCreateCompressor(); - } - - ~Compressor() - { - nvttDestroyCompressor(compressor); - } - - public bool Compress(InputOptions input, CompressionOptions compression, OutputOptions output) - { - return nvttCompress(compressor, input.options, compression.options, output.options); - } - - public int EstimateSize(InputOptions input, CompressionOptions compression) - { - return nvttEstimateSize(compressor, input.options, compression.options); - } - - public static string ErrorString(Error error) - { - return Marshal.PtrToStringAnsi(nvttErrorString(error)); - } - - } - #endregion - -} // Nvidia.TextureTools namespace diff --git a/project/vc8/PhotoshopExporter/PhotoshopExporter.cpp b/project/vc8/PhotoshopExporter/PhotoshopExporter.cpp deleted file mode 100644 index 30c12c6f..00000000 --- a/project/vc8/PhotoshopExporter/PhotoshopExporter.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -#include "PhotoshopExporter.h" - -#include - -SPBasicSuite * sSPBasic = NULL; - - - -void InitGlobals (Ptr globalPtr) -{ - Globals * globals = (Globals *)globalPtr; - - // Set default values. - globals->queryForParameters = true; -} - - - - -DLLExport MACPASCAL void PluginMain (const short selector, - void *exportParamBlock, - long *data, - short *result) -{ - if (selector == exportSelectorAbout) - { - sSPBasic = ((AboutRecord*)exportParamBlock)->sSPBasic; - //DoAbout((AboutRecordPtr)exportParamBlock); - } - else - { - sSPBasic = ((ExportRecordPtr)exportParamBlock)->sSPBasic; - - // Allocate and initialize globals. - Ptr globalPtr = AllocateGlobals ((uint32)result, (uint32)exportParamBlock, ((ExportRecordPtr)exportParamBlock)->handleProcs, sizeof(Globals), data, InitGlobals); - - if (globalPtr == NULL) - { - *result = memFullErr; - return; - } - - // Get our "globals" variable assigned as a Global Pointer struct with the - // data we've returned: - Globals * globals = (Globals *)globalPtr; - - - //----------------------------------------------------------------------- - // (3) Dispatch selector. - //----------------------------------------------------------------------- - - switch (selector) - { - case exportSelectorPrepare: - // DoPrepare(globals); - break; - case exportSelectorStart: - // DoStart(globals); - break; - case exportSelectorContinue: - // DoContinue(globals); - break; - case exportSelectorFinish: - // DoFinish(globals); - break; - } - - // unlock handle pointing to parameter block and data so it can move - // if memory gets shuffled: - if ((Handle)*data != NULL) - { - PIUnlockHandle((Handle)*data); - } - } -} diff --git a/project/vc8/PhotoshopExporter/PhotoshopExporter.h b/project/vc8/PhotoshopExporter/PhotoshopExporter.h deleted file mode 100644 index 669a6fa2..00000000 --- a/project/vc8/PhotoshopExporter/PhotoshopExporter.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef NV_PHOTOSHOP_EXPORTER_H -#define NV_PHOTOSHOP_EXPORTER_H - -#include // Export Photoshop header file. -#include // SDK Utility library. - -// Photoshop crazyness: -//#define gResult (*(globals->result)) -#define gStuff (globals->exportParamBlock) - - -// This is our structure that we use to pass globals between routines: -struct Globals -{ - short * result; // Must always be first in Globals. - ExportRecord * exportParamBlock; // Must always be second in Globals. - - Boolean queryForParameters; - - // ... - -}; - - - -#endif // NV_PHOTOSHOP_EXPORTER_H diff --git a/project/vc8/PhotoshopExporter/PhotoshopExporter.vcproj b/project/vc8/PhotoshopExporter/PhotoshopExporter.vcproj deleted file mode 100644 index fc911a62..00000000 --- a/project/vc8/PhotoshopExporter/PhotoshopExporter.vcproj +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvassemble/nvassemble.rc b/project/vc8/nvassemble/nvassemble.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc8/nvassemble/nvassemble.rc and /dev/null differ diff --git a/project/vc8/nvassemble/nvassemble.vcproj b/project/vc8/nvassemble/nvassemble.vcproj deleted file mode 100644 index 6b5bc3b0..00000000 --- a/project/vc8/nvassemble/nvassemble.vcproj +++ /dev/null @@ -1,356 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvassemble/nvidia.ico b/project/vc8/nvassemble/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc8/nvassemble/nvidia.ico and /dev/null differ diff --git a/project/vc8/nvassemble/resource.h b/project/vc8/nvassemble/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc8/nvassemble/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/nvcompress/nvcompress.rc b/project/vc8/nvcompress/nvcompress.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc8/nvcompress/nvcompress.rc and /dev/null differ diff --git a/project/vc8/nvcompress/nvcompress.vcproj b/project/vc8/nvcompress/nvcompress.vcproj deleted file mode 100644 index 90c807ad..00000000 --- a/project/vc8/nvcompress/nvcompress.vcproj +++ /dev/null @@ -1,696 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvcompress/nvidia.ico b/project/vc8/nvcompress/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc8/nvcompress/nvidia.ico and /dev/null differ diff --git a/project/vc8/nvcompress/resource.h b/project/vc8/nvcompress/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc8/nvcompress/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/nvconfig.h b/project/vc8/nvconfig.h deleted file mode 100644 index 68948a77..00000000 --- a/project/vc8/nvconfig.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef NV_CONFIG -#define NV_CONFIG - -//#cmakedefine HAVE_UNISTD_H -#define HAVE_STDARG_H -//#cmakedefine HAVE_SIGNAL_H -//#cmakedefine HAVE_EXECINFO_H -#define HAVE_MALLOC_H - -#if !defined(_M_X64) -//#define HAVE_PNG -//#define HAVE_JPEG -//#define HAVE_TIFF -#define HAVE_FREEIMAGE -#endif - -//#define HAVE_ATITC -//#define HAVE_D3DX -//#define HAVE_SQUISH -//#define HAVE_STB - - -#endif // NV_CONFIG diff --git a/project/vc8/nvcore/.ignore b/project/vc8/nvcore/.ignore deleted file mode 100644 index 66b0249d..00000000 --- a/project/vc8/nvcore/.ignore +++ /dev/null @@ -1,3 +0,0 @@ -Debug -Release -*.icastano.user diff --git a/project/vc8/nvcore/nvcore.vcproj b/project/vc8/nvcore/nvcore.vcproj deleted file mode 100644 index 84274fcc..00000000 --- a/project/vc8/nvcore/nvcore.vcproj +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvddsinfo/nvddsinfo.rc b/project/vc8/nvddsinfo/nvddsinfo.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc8/nvddsinfo/nvddsinfo.rc and /dev/null differ diff --git a/project/vc8/nvddsinfo/nvddsinfo.vcproj b/project/vc8/nvddsinfo/nvddsinfo.vcproj deleted file mode 100644 index 32fc39c7..00000000 --- a/project/vc8/nvddsinfo/nvddsinfo.vcproj +++ /dev/null @@ -1,355 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvddsinfo/nvidia.ico b/project/vc8/nvddsinfo/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc8/nvddsinfo/nvidia.ico and /dev/null differ diff --git a/project/vc8/nvddsinfo/resource.h b/project/vc8/nvddsinfo/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc8/nvddsinfo/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/nvdecompress/nvdecompress.rc b/project/vc8/nvdecompress/nvdecompress.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc8/nvdecompress/nvdecompress.rc and /dev/null differ diff --git a/project/vc8/nvdecompress/nvdecompress.vcproj b/project/vc8/nvdecompress/nvdecompress.vcproj deleted file mode 100644 index b02aa7f5..00000000 --- a/project/vc8/nvdecompress/nvdecompress.vcproj +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvdecompress/nvidia.ico b/project/vc8/nvdecompress/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc8/nvdecompress/nvidia.ico and /dev/null differ diff --git a/project/vc8/nvdecompress/resource.h b/project/vc8/nvdecompress/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc8/nvdecompress/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/nvimage/.ignore b/project/vc8/nvimage/.ignore deleted file mode 100644 index 66b0249d..00000000 --- a/project/vc8/nvimage/.ignore +++ /dev/null @@ -1,3 +0,0 @@ -Debug -Release -*.icastano.user diff --git a/project/vc8/nvimage/nvimage.vcproj b/project/vc8/nvimage/nvimage.vcproj deleted file mode 100644 index 30efe0fd..00000000 --- a/project/vc8/nvimage/nvimage.vcproj +++ /dev/null @@ -1,386 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvimgdiff/nvidia.ico b/project/vc8/nvimgdiff/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc8/nvimgdiff/nvidia.ico and /dev/null differ diff --git a/project/vc8/nvimgdiff/nvimgdiff.rc b/project/vc8/nvimgdiff/nvimgdiff.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc8/nvimgdiff/nvimgdiff.rc and /dev/null differ diff --git a/project/vc8/nvimgdiff/nvimgdiff.vcproj b/project/vc8/nvimgdiff/nvimgdiff.vcproj deleted file mode 100644 index 185132c9..00000000 --- a/project/vc8/nvimgdiff/nvimgdiff.vcproj +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvimgdiff/resource.h b/project/vc8/nvimgdiff/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc8/nvimgdiff/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/nvmath/.ignore b/project/vc8/nvmath/.ignore deleted file mode 100644 index 66b0249d..00000000 --- a/project/vc8/nvmath/.ignore +++ /dev/null @@ -1,3 +0,0 @@ -Debug -Release -*.icastano.user diff --git a/project/vc8/nvmath/nvmath.vcproj b/project/vc8/nvmath/nvmath.vcproj deleted file mode 100644 index 43bb1d34..00000000 --- a/project/vc8/nvmath/nvmath.vcproj +++ /dev/null @@ -1,346 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvtt.sln b/project/vc8/nvtt.sln deleted file mode 100644 index baeb9b5e..00000000 --- a/project/vc8/nvtt.sln +++ /dev/null @@ -1,453 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt", "nvtt\nvtt.vcproj", "{1AEB7681-57D8-48EE-813D-5C41CC38B647}" - ProjectSection(ProjectDependencies) = postProject - {CE017322-01FC-4851-9C8B-64E9A8E26C38} = {CE017322-01FC-4851-9C8B-64E9A8E26C38} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcompress", "nvcompress\nvcompress.vcproj", "{88079E38-83AA-4E8A-B18A-66A78D1B058B}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimage", "nvimage\nvimage.vcproj", "{4046F392-A18B-4C66-9639-3EABFFF5D531}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcore", "nvcore\nvcore.vcproj", "{F143D180-D4C4-4037-B3DE-BE89A21C8D1D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvmath", "nvmath\nvmath.vcproj", "{50C465FE-B308-42BC-894D-89484482AF06}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "squish\squish.vcproj", "{CE017322-01FC-4851-9C8B-64E9A8E26C38}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvddsinfo", "nvddsinfo\nvddsinfo.vcproj", "{841B73C5-C679-4EEF-A50A-7D6106642B49}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvdecompress", "nvdecompress\nvdecompress.vcproj", "{75A0527D-BFC9-49C3-B46B-CD1A901D5927}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimgdiff", "nvimgdiff\nvimgdiff.vcproj", "{05A59E8B-EA70-4F22-89E8-E0927BA13064}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvassemble", "nvassemble\nvassemble.vcproj", "{3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvzoom", "nvzoom\nvzoom.vcproj", "{51999D3E-EF22-4BDD-965F-4201034D3DCE}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nvidia.TextureTools", "Nvidia.TextureTools\Nvidia.TextureTools.csproj", "{CAB55C39-8FA9-4912-98D9-E52669C8911D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt-testsuite", "testsuite\testsuite.vcproj", "{4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug (no cuda)|Any CPU = Debug (no cuda)|Any CPU - Debug (no cuda)|Mixed Platforms = Debug (no cuda)|Mixed Platforms - Debug (no cuda)|Win32 = Debug (no cuda)|Win32 - Debug (no cuda)|x64 = Debug (no cuda)|x64 - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release (no cuda)|Any CPU = Release (no cuda)|Any CPU - Release (no cuda)|Mixed Platforms = Release (no cuda)|Mixed Platforms - Release (no cuda)|Win32 = Release (no cuda)|Win32 - Release (no cuda)|x64 = Release (no cuda)|x64 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|Any CPU.ActiveCfg = Debug (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|Win32.ActiveCfg = Debug (no cuda)|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|Win32.Build.0 = Debug (no cuda)|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|x64.ActiveCfg = Debug (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug (no cuda)|x64.Build.0 = Debug (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Any CPU.ActiveCfg = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.ActiveCfg = Debug|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.Build.0 = Debug|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.ActiveCfg = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.Build.0 = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|Any CPU.ActiveCfg = Release (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|Mixed Platforms.Build.0 = Release (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|Win32.ActiveCfg = Release (no cuda)|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|Win32.Build.0 = Release (no cuda)|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|x64.ActiveCfg = Release (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release (no cuda)|x64.Build.0 = Release (no cuda)|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Any CPU.ActiveCfg = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Mixed Platforms.Build.0 = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.ActiveCfg = Release|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.Build.0 = Release|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.ActiveCfg = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.Build.0 = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|Any CPU.ActiveCfg = Debug (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|Win32.ActiveCfg = Debug (no cuda)|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|Win32.Build.0 = Debug (no cuda)|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|x64.ActiveCfg = Debug (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug (no cuda)|x64.Build.0 = Debug (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Any CPU.ActiveCfg = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Win32.ActiveCfg = Debug|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Win32.Build.0 = Debug|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|x64.ActiveCfg = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|x64.Build.0 = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|Any CPU.ActiveCfg = Release (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|Mixed Platforms.Build.0 = Release (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|Win32.ActiveCfg = Release (no cuda)|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|Win32.Build.0 = Release (no cuda)|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|x64.ActiveCfg = Release (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release (no cuda)|x64.Build.0 = Release (no cuda)|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Any CPU.ActiveCfg = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Mixed Platforms.Build.0 = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Win32.ActiveCfg = Release|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Win32.Build.0 = Release|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|x64.ActiveCfg = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|x64.Build.0 = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Any CPU.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.ActiveCfg = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.Build.0 = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release (no cuda)|x64.Build.0 = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Any CPU.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Mixed Platforms.Build.0 = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.ActiveCfg = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.Build.0 = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Any CPU.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.ActiveCfg = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.Build.0 = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release (no cuda)|x64.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Any CPU.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Mixed Platforms.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.ActiveCfg = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.Build.0 = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Any CPU.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.ActiveCfg = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.Build.0 = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release (no cuda)|x64.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Any CPU.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Mixed Platforms.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.ActiveCfg = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.Build.0 = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Any CPU.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.ActiveCfg = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.Build.0 = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release (no cuda)|x64.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Any CPU.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Mixed Platforms.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.ActiveCfg = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.Build.0 = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Any CPU.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Win32.ActiveCfg = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Win32.Build.0 = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|x64.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|x64.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release (no cuda)|x64.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Any CPU.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Mixed Platforms.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Win32.ActiveCfg = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Win32.Build.0 = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|x64.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|x64.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Any CPU.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Win32.ActiveCfg = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Win32.Build.0 = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|x64.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|x64.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release (no cuda)|x64.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Any CPU.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Mixed Platforms.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Win32.ActiveCfg = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Win32.Build.0 = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|x64.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|x64.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Any CPU.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Win32.ActiveCfg = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Win32.Build.0 = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|x64.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|x64.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release (no cuda)|x64.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Any CPU.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Mixed Platforms.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Win32.ActiveCfg = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Win32.Build.0 = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|x64.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|x64.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Any CPU.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Win32.Build.0 = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|x64.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|x64.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release (no cuda)|x64.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Any CPU.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Mixed Platforms.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Win32.ActiveCfg = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Win32.Build.0 = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|x64.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|x64.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|x64.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug (no cuda)|x64.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Any CPU.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Win32.ActiveCfg = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Win32.Build.0 = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|x64.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|x64.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|Any CPU.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|Mixed Platforms.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|x64.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release (no cuda)|x64.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Any CPU.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Mixed Platforms.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Win32.ActiveCfg = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Win32.Build.0 = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|x64.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|x64.Build.0 = Release|x64 - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug (no cuda)|Any CPU.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug (no cuda)|Win32.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug (no cuda)|x64.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release (no cuda)|Any CPU.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release (no cuda)|Any CPU.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release (no cuda)|Mixed Platforms.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release (no cuda)|Win32.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release (no cuda)|x64.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Any CPU.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.ActiveCfg = Release|Any CPU - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug (no cuda)|Any CPU.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug (no cuda)|Mixed Platforms.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug (no cuda)|Mixed Platforms.Build.0 = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug (no cuda)|Win32.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug (no cuda)|Win32.Build.0 = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug (no cuda)|x64.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug|Win32.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug|Win32.Build.0 = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Debug|x64.ActiveCfg = Debug|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release (no cuda)|Any CPU.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release (no cuda)|Mixed Platforms.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release (no cuda)|Mixed Platforms.Build.0 = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release (no cuda)|Win32.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release (no cuda)|Win32.Build.0 = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release (no cuda)|x64.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release|Any CPU.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release|Mixed Platforms.Build.0 = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release|Win32.ActiveCfg = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release|Win32.Build.0 = Release|Win32 - {4B3DF7E1-7541-4351-BEC0-9AEB41BA5D33}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/project/vc8/nvtt.vsprops b/project/vc8/nvtt.vsprops deleted file mode 100644 index 07204cb8..00000000 --- a/project/vc8/nvtt.vsprops +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - diff --git a/project/vc8/nvtt/.ignore b/project/vc8/nvtt/.ignore deleted file mode 100644 index 8c0cc178..00000000 --- a/project/vc8/nvtt/.ignore +++ /dev/null @@ -1,22 +0,0 @@ -Debug -Debug (no cuda) -Release -Release (no cuda) -*.icastano.user -*.gpu -*.ii -*.stub.h -*.stub.c -*.pdb -*.cubin -*.hash -*.cudafe1.cpp -*.cudafe1.c -*.cudafe2.c -*.cu.cpp -*.cu.c -*.fatbin.c -*.ptx -*.linkinfo -*.cpp2.i -*.cpp3.i diff --git a/project/vc8/nvtt/nvtt.rc b/project/vc8/nvtt/nvtt.rc deleted file mode 100644 index 089d1e97..00000000 --- a/project/vc8/nvtt/nvtt.rc +++ /dev/null @@ -1,102 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,0,0 - PRODUCTVERSION 2,1,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "NVIDIA Corporation" - VALUE "FileDescription", "NVIDIA Texture Tools Dynamic Link Library" - VALUE "FileVersion", "2, 1, 0, 0" - VALUE "InternalName", "nvtt" - VALUE "LegalCopyright", "Copyright (C) 2007" - VALUE "OriginalFilename", "nvtt.dll" - VALUE "ProductName", "NVIDIA Texture Tools Dynamic Link Library" - VALUE "ProductVersion", "2, 1, 0, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/project/vc8/nvtt/nvtt.vcproj b/project/vc8/nvtt/nvtt.vcproj deleted file mode 100644 index 57498b9b..00000000 --- a/project/vc8/nvtt/nvtt.vcproj +++ /dev/null @@ -1,981 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvtt/resource.h b/project/vc8/nvtt/resource.h deleted file mode 100644 index 4df7169c..00000000 --- a/project/vc8/nvtt/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvtt.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/nvzoom/nvidia.ico b/project/vc8/nvzoom/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc8/nvzoom/nvidia.ico and /dev/null differ diff --git a/project/vc8/nvzoom/nvzoom.rc b/project/vc8/nvzoom/nvzoom.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc8/nvzoom/nvzoom.rc and /dev/null differ diff --git a/project/vc8/nvzoom/nvzoom.vcproj b/project/vc8/nvzoom/nvzoom.vcproj deleted file mode 100644 index 0711ce2e..00000000 --- a/project/vc8/nvzoom/nvzoom.vcproj +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/nvzoom/resource.h b/project/vc8/nvzoom/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc8/nvzoom/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc8/squish/squish.vcproj b/project/vc8/squish/squish.vcproj deleted file mode 100644 index cd57ab66..00000000 --- a/project/vc8/squish/squish.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc8/testsuite/testsuite.vcproj b/project/vc8/testsuite/testsuite.vcproj deleted file mode 100644 index ee7e00f2..00000000 --- a/project/vc8/testsuite/testsuite.vcproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/.ignore b/project/vc9/.ignore deleted file mode 100644 index b351d815..00000000 --- a/project/vc9/.ignore +++ /dev/null @@ -1,13 +0,0 @@ -nvtt.suo -nvtt.ncb -release.win32 -debug.win32 -release.x64 -debug.x64 -release (no cuda).win32 -debug (no cuda).win32 -release (no cuda).x64 -debug (no cuda).x64 -Release -Debug -*.icastano.user diff --git a/project/vc9/Nvidia.TextureTools/Nvidia.TextureTools.csproj b/project/vc9/Nvidia.TextureTools/Nvidia.TextureTools.csproj deleted file mode 100644 index 8ee960c8..00000000 --- a/project/vc9/Nvidia.TextureTools/Nvidia.TextureTools.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - Debug - AnyCPU - 9.0.21022 - 2.0 - {CAB55C39-8FA9-4912-98D9-E52669C8911D} - Library - Properties - Nvidia.TextureTools - Nvidia.TextureTools - - - 2.0 - - - OnBuildSuccess - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - \ No newline at end of file diff --git a/project/vc9/Nvidia.TextureTools/Properties/AssemblyInfo.cs b/project/vc9/Nvidia.TextureTools/Properties/AssemblyInfo.cs deleted file mode 100644 index ecd652e8..00000000 --- a/project/vc9/Nvidia.TextureTools/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Nvidia.TextureTools")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("NVIDIA Corporation")] -[assembly: AssemblyProduct("Nvidia.TextureTools")] -[assembly: AssemblyCopyright("Copyright © NVIDIA 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5fa03fb3-b7a3-4ba8-90e7-545929731356")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/project/vc9/Nvidia.TextureTools/TextureTools.cs b/project/vc9/Nvidia.TextureTools/TextureTools.cs deleted file mode 100644 index 6ccae1af..00000000 --- a/project/vc9/Nvidia.TextureTools/TextureTools.cs +++ /dev/null @@ -1,751 +0,0 @@ -using System; -using System.Security; -using System.Runtime.InteropServices; - -namespace Nvidia.TextureTools -{ - #region Enums - - #region public enum Format - /// - /// Compression format. - /// - public enum Format - { - // No compression. - RGB, - RGBA = RGB, - - // DX9 formats. - DXT1, - DXT1a, - DXT3, - DXT5, - DXT5n, - - // DX10 formats. - BC1 = DXT1, - BC1a = DXT1a, - BC2 = DXT3, - BC3 = DXT5, - BC3n = DXT5n, - BC4, - BC5, - - DXT1n, // Not supported. - CTX1, // Not supported. - - BC6, - BC7, - } - #endregion - - #region public enum PixelType - /// - /// Pixel types. These basically indicate how the output should be interpreted, but do not have any influence over the input. They are only relevant in RGBA mode. - /// - enum PixelType - { - UnsignedNorm = 0, - SignedNorm = 1, // Not supported yet. - UnsignedInt = 2, // Not supported yet. - SignedInt = 3, // Not supported yet. - Float = 4, - UnsignedFloat = 5, - } - #endregion - - #region public enum Quality - /// - /// Quality modes. - /// - public enum Quality - { - Fastest, - Normal, - Production, - Highest, - } - #endregion - - #region public enum Decoder - /// - /// DXT decoder. - /// - enum Decoder - { - Decoder_D3D10, - Decoder_D3D9, - Decoder_NV5x, - }; - #endregion - - #region public enum WrapMode - /// - /// Wrap modes. - /// - public enum WrapMode - { - Clamp, - Repeat, - Mirror, - } - #endregion - - #region public enum TextureType - /// - /// Texture types. - /// - public enum TextureType - { - Texture2D, - TextureCube, - Texture3D, - } - #endregion - - #region public enum InputFormat - /// - /// Input formats. - /// - public enum InputFormat - { - BGRA_8UB, // Normalized [0, 1] 8 bit fixed point. - RGBA_16F, // 16 bit floating point. - RGBA_32F, // 32 bit floating point. - } - #endregion - - #region public enum MipmapFilter - /// - /// Mipmap downsampling filters. - /// - public enum MipmapFilter - { - Box, - Triangle, - Kaiser - } - #endregion - - #region public enum ResizeFilter - /// - /// Texture resize filters. - /// - public enum ResizeFilter - { - Box, - Triangle, - Kaiser, - Mitchell - } - #endregion - - #region public enum RoundMode - /// - /// Extents rounding mode. - /// - public enum RoundMode - { - None, - ToNextPowerOfTwo, - ToNearestPowerOfTwo, - ToPreviousPowerOfTwo - } - #endregion - - #region public enum AlphaMode - /// - /// Alpha mode. - /// - public enum AlphaMode - { - None, - Transparency, - Premultiplied - } - #endregion - - #region public enum CubeLayout - /// Cube layout formats. - /// (New in NVTT 2.1) - public enum CubeLayout - { - VerticalCross, - HorizontalCross, - Column, - Row, - LatitudeLongitude - }; - #endregion - - #region public enum EdgeFixup - /// Cube map edge fixup methods. - /// (New in NVTT 2.1) - public enum EdgeFixup - { - None, - Stretch, - Warp, - Average, - }; - #endregion - - #region public enum Error - /// - /// Error codes. - /// - public enum Error - { - InvalidInput, - UserInterruption, - UnsupportedFeature, - CudaError, - Unknown, - FileOpen, - FileWrite, - } - #endregion - - #endregion - - #region public class InputOptions - /// - /// Input options. - /// - public class InputOptions - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateInputOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyInputOptions(IntPtr inputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsTextureLayout(IntPtr inputOptions, TextureType type, int w, int h, int d); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttResetInputOptionsTextureLayout(IntPtr inputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttSetInputOptionsMipmapData(IntPtr inputOptions, IntPtr data, int w, int h, int d, int face, int mipmap); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsFormat(IntPtr inputOptions, InputFormat format); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsAlphaMode(IntPtr inputOptions, AlphaMode alphaMode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsGamma(IntPtr inputOptions, float inputGamma, float outputGamma); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsWrapMode(IntPtr inputOptions, WrapMode mode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMipmapFilter(IntPtr inputOptions, MipmapFilter filter); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMipmapGeneration(IntPtr inputOptions, bool generateMipmaps, int maxLevel); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsKaiserParameters(IntPtr inputOptions, float width, float alpha, float stretch); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalMap(IntPtr inputOptions, bool b); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsConvertToNormalMap(IntPtr inputOptions, bool convert); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsHeightEvaluation(IntPtr inputOptions, float redScale, float greenScale, float blueScale, float alphaScale); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalFilter(IntPtr inputOptions, float small, float medium, float big, float large); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsNormalizeMipmaps(IntPtr inputOptions, bool b); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsMaxExtents(IntPtr inputOptions, int d); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetInputOptionsRoundMode(IntPtr inputOptions, RoundMode mode); - #endregion - - internal IntPtr options; - - public InputOptions() - { - options = nvttCreateInputOptions(); - } - ~InputOptions() - { - nvttDestroyInputOptions(options); - } - - public void SetTextureLayout(TextureType type, int w, int h, int d) - { - nvttSetInputOptionsTextureLayout(options, type, w, h, d); - } - public void ResetTextureLayout() - { - nvttResetInputOptionsTextureLayout(options); - } - - public void SetMipmapData(IntPtr data, int width, int height, int depth, int face, int mipmap) - { - nvttSetInputOptionsMipmapData(options, data, width, height, depth, face, mipmap); - } - - public void SetFormat(InputFormat format) - { - nvttSetInputOptionsFormat(options, format); - } - - public void SetAlphaMode(AlphaMode alphaMode) - { - nvttSetInputOptionsAlphaMode(options, alphaMode); - } - - public void SetGamma(float inputGamma, float outputGamma) - { - nvttSetInputOptionsGamma(options, inputGamma, outputGamma); - } - - public void SetWrapMode(WrapMode wrapMode) - { - nvttSetInputOptionsWrapMode(options, wrapMode); - } - - public void SetMipmapFilter(MipmapFilter filter) - { - nvttSetInputOptionsMipmapFilter(options, filter); - } - - public void SetMipmapGeneration(bool enabled) - { - nvttSetInputOptionsMipmapGeneration(options, enabled, -1); - } - - public void SetMipmapGeneration(bool enabled, int maxLevel) - { - nvttSetInputOptionsMipmapGeneration(options, enabled, maxLevel); - } - - public void SetKaiserParameters(float width, float alpha, float stretch) - { - nvttSetInputOptionsKaiserParameters(options, width, alpha, stretch); - } - - public void SetNormalMap(bool b) - { - nvttSetInputOptionsNormalMap(options, b); - } - - public void SetConvertToNormalMap(bool convert) - { - nvttSetInputOptionsConvertToNormalMap(options, convert); - } - - public void SetHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale) - { - nvttSetInputOptionsHeightEvaluation(options, redScale, greenScale, blueScale, alphaScale); - } - - public void SetNormalFilter(float small, float medium, float big, float large) - { - nvttSetInputOptionsNormalFilter(options, small, medium, big, large); - } - - public void SetNormalizeMipmaps(bool b) - { - nvttSetInputOptionsNormalizeMipmaps(options, b); - } - - public void SetMaxExtents(int dim) - { - nvttSetInputOptionsMaxExtents(options, dim); - } - - public void SetRoundMode(RoundMode mode) - { - nvttSetInputOptionsRoundMode(options, mode); - } - } - #endregion - - #region public class CompressionOptions - /// - /// Compression options. - /// - public class CompressionOptions - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCompressionOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCompressionOptions(IntPtr compressionOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsFormat(IntPtr compressionOptions, Format format); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsQuality(IntPtr compressionOptions, Quality quality); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsColorWeights(IntPtr compressionOptions, float red, float green, float blue, float alpha); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsPixelFormat(IntPtr compressionOptions, uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetCompressionOptionsQuantization(IntPtr compressionOptions, bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold); - #endregion - - internal IntPtr options; - - public CompressionOptions() - { - options = nvttCreateCompressionOptions(); - } - ~CompressionOptions() - { - nvttDestroyCompressionOptions(options); - } - - public void SetFormat(Format format) - { - nvttSetCompressionOptionsFormat(options, format); - } - - public void SetQuality(Quality quality) - { - nvttSetCompressionOptionsQuality(options, quality); - } - - public void SetColorWeights(float red, float green, float blue) - { - nvttSetCompressionOptionsColorWeights(options, red, green, blue, 1.0f); - } - - public void SetColorWeights(float red, float green, float blue, float alpha) - { - nvttSetCompressionOptionsColorWeights(options, red, green, blue, alpha); - } - - public void SetPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) - { - nvttSetCompressionOptionsPixelFormat(options, bitcount, rmask, gmask, bmask, amask); - } - - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha) - { - nvttSetCompressionOptionsQuantization(options, colorDithering, alphaDithering, binaryAlpha, 127); - } - - public void SetQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold) - { - nvttSetCompressionOptionsQuantization(options, colorDithering, alphaDithering, binaryAlpha, alphaThreshold); - } - } - #endregion - - #region public class OutputOptions - /// - /// Output options. - /// - public class OutputOptions - { - #region Delegates - public delegate void ErrorHandler(Error error); - - //[UnmanagedFunctionPointer(CallingConvention.Cdecl)] - //public delegate void InternalErrorHandlerDelegate(Error error); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void BeginImageDelegate(int size, int width, int height, int depth, int face, int miplevel); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate bool WriteDataDelegate(IntPtr data, int size); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void EndImageDelegate(); - #endregion - - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateOutputOptions(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyOutputOptions(IntPtr outputOptions); - - [DllImport("nvtt", CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsFileName(IntPtr outputOptions, string fileName); - - //[DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - //private extern static void nvttSetOutputOptionsErrorHandler(IntPtr outputOptions, ErrorHandler errorHandler); - - private void ErrorCallback(Error error) - { - if (Error != null) Error(error); - } - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsOutputHeader(IntPtr outputOptions, bool b); - - [DllImport("nvtt", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, IntPtr beginImage, IntPtr writeData, IntPtr endImage); - - #endregion - - internal IntPtr options; - - public OutputOptions() - { - options = nvttCreateOutputOptions(); - //nvttSetOutputOptionsErrorHandler(options, new ErrorHandler(ErrorCallback)); - } - ~OutputOptions() - { - nvttDestroyOutputOptions(options); - } - - public void SetFileName(string fileName) - { - nvttSetOutputOptionsFileName(options, fileName); - } - - public event ErrorHandler Error; - - public void SetOutputHeader(bool b) - { - nvttSetOutputOptionsOutputHeader(options, b); - } - - public void SetOutputHandler(BeginImageDelegate beginImage, WriteDataDelegate writeImage, EndImageDelegate endImage) - { - IntPtr ptrBeginImage = IntPtr.Zero; - IntPtr ptrWriteData = IntPtr.Zero; - IntPtr ptrEndImage = IntPtr.Zero; - - if (beginImage != null || writeImage != null || endImage != null) - { - ptrBeginImage = Marshal.GetFunctionPointerForDelegate(beginImage); - ptrWriteData = Marshal.GetFunctionPointerForDelegate(writeImage); - ptrEndImage = Marshal.GetFunctionPointerForDelegate(endImage); - } - - nvttSetOutputOptionsOutputHandler(options, ptrBeginImage, ptrWriteData, ptrEndImage); - } - } - #endregion - - #region public static class Compressor - public class Compressor - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCompressor(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCompressor(IntPtr compressor); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttCompress(IntPtr compressor, IntPtr inputOptions, IntPtr compressionOptions, IntPtr outputOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static int nvttEstimateSize(IntPtr compressor, IntPtr inputOptions, IntPtr compressionOptions); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private static extern IntPtr nvttErrorString(Error error); - - #endregion - - internal IntPtr compressor; - - public Compressor() - { - compressor = nvttCreateCompressor(); - } - - ~Compressor() - { - nvttDestroyCompressor(compressor); - } - - public bool Compress(InputOptions input, CompressionOptions compression, OutputOptions output) - { - return nvttCompress(compressor, input.options, compression.options, output.options); - } - - public int EstimateSize(InputOptions input, CompressionOptions compression) - { - return nvttEstimateSize(compressor, input.options, compression.options); - } - - public static string ErrorString(Error error) - { - return Marshal.PtrToStringAnsi(nvttErrorString(error)); - } - - } - #endregion - - #region public static class Surface - public class Surface - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateSurface(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateSurface(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroySurface(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSurfaceSetWrapMode(IntPtr surface, WrapMode wrapMode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static WrapMode nvttSurfaceGetWrapMode(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSurfaceSetAlphaMode(IntPtr surface, AlphaMode alphaMode); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static AlphaMode nvttSurfaceGetAlphaMode(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttSurfaceSetNormalMap(IntPtr surface, bool isNormalMap); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static bool nvttSurfaceGetNormalMap(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static int nvttSurfaceGetWidth(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static int nvttSurfaceGetHeight(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static int nvttSurfaceGetDepth(IntPtr surface); - #endregion - - internal IntPtr surface; - - public Surface() - { - surface = nvttCreateSurface(); - } - - public Surface(Surface s) - { - surface = nvttCreateSurface(surface); - } - - ~Surface() - { - nvttDestroySurface(surface); - } - - #region Properties - public WrapMode WrapMode { - set { nvttSurfaceSetWrapMode(surface, value); } - get { return nvttSurfaceGetWrapMode(surface); } - } - - public AlphaMode AlphaMode { - set { nvttSurfaceSetAlphaMode(surface, value); } - get { return nvttSurfaceGetAlphaMode(surface); } - } - - public bool IsNormalMap - { - set { nvttSurfaceSetNormalMap(surface, value); } - get { return nvttSurfaceGetNormalMap(surface); } - } - - //public bool isNull(); - - public int Width - { - get { return nvttSurfaceGetWidth(surface); } - } - - public int Height - { - get { return nvttSurfaceGetHeight(surface); } - } - - public int Depth - { - get { return nvttSurfaceGetDepth(surface); } - } - #endregion - - //public TextureType type(); - //public int countMipmaps(); - //public int countMipmaps(int min_size); - //public float alphaTestCoverage(float alphaRef = 0.5); - //public float average(int channel, int alpha_channel = -1, float gamma = 2.2f); - //public IntPtr data(); - //public IntPtr channel(int i); - //public void histogram(int channel, float rangeMin, float rangeMax, int binCount, int binPtr[]); - //public void range(int channel, out float rangeMin, out float rangeMax, int alpha_channel = -1, float alpha_ref = 0.f); - - // @@ TODO - } - #endregion - - #region public static class CubeSurface - public class CubeSurface - { - #region Bindings - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCubeSurface(); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static IntPtr nvttCreateCubeSurface(IntPtr surface); - - [DllImport("nvtt"), SuppressUnmanagedCodeSecurity] - private extern static void nvttDestroyCubeSurface(IntPtr surface); - #endregion - - internal IntPtr cubeSurface; - - public CubeSurface() - { - cubeSurface = nvttCreateCubeSurface(); - } - - public CubeSurface(CubeSurface cs) - { - cubeSurface = nvttCreateCubeSurface(cs.cubeSurface); - } - - ~CubeSurface() - { - nvttDestroyCubeSurface(cubeSurface); - } - - - //public bool IsNull(); // @@ Use properties? - //public int EdgeLength(); // @@ Use properties? - //public int CountMipmaps(); // @@ Use properties? - - //public bool Load(String fileName, int mipmap); - //public bool Save(String fileName) const; - - //public Surface & Face(int face); - //public const Surface & Face(int face) const; - - - // @@ TODO - } - #endregion - -} // Nvidia.TextureTools namespace diff --git a/project/vc9/bc6h/bc6h.vcproj b/project/vc9/bc6h/bc6h.vcproj deleted file mode 100755 index ba159ed9..00000000 --- a/project/vc9/bc6h/bc6h.vcproj +++ /dev/null @@ -1,308 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/bc7/bc7.vcproj b/project/vc9/bc7/bc7.vcproj deleted file mode 100644 index 4dfdfa73..00000000 --- a/project/vc9/bc7/bc7.vcproj +++ /dev/null @@ -1,340 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/cubemaptest/cubemaptest.vcproj b/project/vc9/cubemaptest/cubemaptest.vcproj deleted file mode 100755 index e0702cc0..00000000 --- a/project/vc9/cubemaptest/cubemaptest.vcproj +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/hdrtest/hdrtest.vcproj b/project/vc9/hdrtest/hdrtest.vcproj deleted file mode 100755 index 3299430f..00000000 --- a/project/vc9/hdrtest/hdrtest.vcproj +++ /dev/null @@ -1,330 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/imperativeapi/imperativeapi.vcproj b/project/vc9/imperativeapi/imperativeapi.vcproj deleted file mode 100755 index 6799d75c..00000000 --- a/project/vc9/imperativeapi/imperativeapi.vcproj +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvassemble/nvassemble.rc b/project/vc9/nvassemble/nvassemble.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc9/nvassemble/nvassemble.rc and /dev/null differ diff --git a/project/vc9/nvassemble/nvassemble.vcproj b/project/vc9/nvassemble/nvassemble.vcproj deleted file mode 100644 index 0821d98a..00000000 --- a/project/vc9/nvassemble/nvassemble.vcproj +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvassemble/nvidia.ico b/project/vc9/nvassemble/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc9/nvassemble/nvidia.ico and /dev/null differ diff --git a/project/vc9/nvassemble/resource.h b/project/vc9/nvassemble/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc9/nvassemble/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/nvcompress/nvcompress.rc b/project/vc9/nvcompress/nvcompress.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc9/nvcompress/nvcompress.rc and /dev/null differ diff --git a/project/vc9/nvcompress/nvcompress.vcproj b/project/vc9/nvcompress/nvcompress.vcproj deleted file mode 100644 index 812d0e34..00000000 --- a/project/vc9/nvcompress/nvcompress.vcproj +++ /dev/null @@ -1,696 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvcompress/nvidia.ico b/project/vc9/nvcompress/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc9/nvcompress/nvidia.ico and /dev/null differ diff --git a/project/vc9/nvcompress/resource.h b/project/vc9/nvcompress/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc9/nvcompress/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/nvcore/nvcore.vcproj b/project/vc9/nvcore/nvcore.vcproj deleted file mode 100644 index 719e96fe..00000000 --- a/project/vc9/nvcore/nvcore.vcproj +++ /dev/null @@ -1,408 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvddsinfo/nvddsinfo.rc b/project/vc9/nvddsinfo/nvddsinfo.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc9/nvddsinfo/nvddsinfo.rc and /dev/null differ diff --git a/project/vc9/nvddsinfo/nvddsinfo.vcproj b/project/vc9/nvddsinfo/nvddsinfo.vcproj deleted file mode 100644 index a82870ec..00000000 --- a/project/vc9/nvddsinfo/nvddsinfo.vcproj +++ /dev/null @@ -1,370 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvddsinfo/nvidia.ico b/project/vc9/nvddsinfo/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc9/nvddsinfo/nvidia.ico and /dev/null differ diff --git a/project/vc9/nvddsinfo/resource.h b/project/vc9/nvddsinfo/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc9/nvddsinfo/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/nvdecompress/nvdecompress.rc b/project/vc9/nvdecompress/nvdecompress.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc9/nvdecompress/nvdecompress.rc and /dev/null differ diff --git a/project/vc9/nvdecompress/nvdecompress.vcproj b/project/vc9/nvdecompress/nvdecompress.vcproj deleted file mode 100644 index b647eb47..00000000 --- a/project/vc9/nvdecompress/nvdecompress.vcproj +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvdecompress/nvidia.ico b/project/vc9/nvdecompress/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc9/nvdecompress/nvidia.ico and /dev/null differ diff --git a/project/vc9/nvdecompress/resource.h b/project/vc9/nvdecompress/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc9/nvdecompress/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/nvimage/nvimage.vcproj b/project/vc9/nvimage/nvimage.vcproj deleted file mode 100644 index c1197a67..00000000 --- a/project/vc9/nvimage/nvimage.vcproj +++ /dev/null @@ -1,395 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvimgdiff/nvidia.ico b/project/vc9/nvimgdiff/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc9/nvimgdiff/nvidia.ico and /dev/null differ diff --git a/project/vc9/nvimgdiff/nvimgdiff.rc b/project/vc9/nvimgdiff/nvimgdiff.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc9/nvimgdiff/nvimgdiff.rc and /dev/null differ diff --git a/project/vc9/nvimgdiff/nvimgdiff.vcproj b/project/vc9/nvimgdiff/nvimgdiff.vcproj deleted file mode 100644 index c437aa00..00000000 --- a/project/vc9/nvimgdiff/nvimgdiff.vcproj +++ /dev/null @@ -1,391 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvimgdiff/resource.h b/project/vc9/nvimgdiff/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc9/nvimgdiff/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/nvmath/nvmath.vcproj b/project/vc9/nvmath/nvmath.vcproj deleted file mode 100644 index b998cf05..00000000 --- a/project/vc9/nvmath/nvmath.vcproj +++ /dev/null @@ -1,400 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvthread/nvthread.vcproj b/project/vc9/nvthread/nvthread.vcproj deleted file mode 100644 index d1561055..00000000 --- a/project/vc9/nvthread/nvthread.vcproj +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvtt.sln b/project/vc9/nvtt.sln deleted file mode 100644 index 582783a4..00000000 --- a/project/vc9/nvtt.sln +++ /dev/null @@ -1,445 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt", "nvtt\nvtt.vcproj", "{1AEB7681-57D8-48EE-813D-5C41CC38B647}" - ProjectSection(ProjectDependencies) = postProject - {CE017322-01FC-4851-9C8B-64E9A8E26C38} = {CE017322-01FC-4851-9C8B-64E9A8E26C38} - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB} = {3DD3A43D-C6EA-460F-821B-6C339A03C5BB} - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcompress", "nvcompress\nvcompress.vcproj", "{88079E38-83AA-4E8A-B18A-66A78D1B058B}" - ProjectSection(ProjectDependencies) = postProject - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB} = {3DD3A43D-C6EA-460F-821B-6C339A03C5BB} - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimage", "nvimage\nvimage.vcproj", "{4046F392-A18B-4C66-9639-3EABFFF5D531}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvcore", "nvcore\nvcore.vcproj", "{F143D180-D4C4-4037-B3DE-BE89A21C8D1D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvmath", "nvmath\nvmath.vcproj", "{50C465FE-B308-42BC-894D-89484482AF06}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "squish\squish.vcproj", "{CE017322-01FC-4851-9C8B-64E9A8E26C38}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvddsinfo", "nvddsinfo\nvddsinfo.vcproj", "{841B73C5-C679-4EEF-A50A-7D6106642B49}" - ProjectSection(ProjectDependencies) = postProject - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvdecompress", "nvdecompress\nvdecompress.vcproj", "{75A0527D-BFC9-49C3-B46B-CD1A901D5927}" - ProjectSection(ProjectDependencies) = postProject - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvimgdiff", "nvimgdiff\nvimgdiff.vcproj", "{05A59E8B-EA70-4F22-89E8-E0927BA13064}" - ProjectSection(ProjectDependencies) = postProject - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvassemble", "nvassemble\nvassemble.vcproj", "{3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}" - ProjectSection(ProjectDependencies) = postProject - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvzoom", "nvzoom\nvzoom.vcproj", "{51999D3E-EF22-4BDD-965F-4201034D3DCE}" - ProjectSection(ProjectDependencies) = postProject - {F974F34B-AF02-4C88-8E1E-85475094EA78} = {F974F34B-AF02-4C88-8E1E-85475094EA78} - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - {C33787E3-5564-4834-9FE3-A9020455A669} = {C33787E3-5564-4834-9FE3-A9020455A669} - {50C465FE-B308-42BC-894D-89484482AF06} = {50C465FE-B308-42BC-894D-89484482AF06} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nvidia.TextureTools", "Nvidia.TextureTools\Nvidia.TextureTools.csproj", "{CAB55C39-8FA9-4912-98D9-E52669C8911D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvtt-testsuite", "testsuite\testsuite.vcproj", "{317B694E-B5C1-42A6-956F-FC12B69175A6}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A08D9CB4-C9D8-46EF-A74D-0EAB11FE34C5}" - ProjectSection(SolutionItems) = preProject - nvconfig.h = nvconfig.h - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imperativeapi", "imperativeapi\imperativeapi.vcproj", "{7DCF280E-702B-49F3-84A7-AE7E146384D6}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc6h", "bc6h\bc6h.vcproj", "{C33787E3-5564-4834-9FE3-A9020455A669}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvthread", "nvthread\nvthread.vcproj", "{3DD3A43D-C6EA-460F-821B-6C339A03C5BB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubemaptest", "cubemaptest\cubemaptest.vcproj", "{CFB3FEAC-5720-4B16-9D7E-039DB180B641}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hdrtest", "hdrtest\hdrtest.vcproj", "{E493E368-A4CF-4A8D-99DD-E128CC3A27EF}" - ProjectSection(ProjectDependencies) = postProject - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} = {F143D180-D4C4-4037-B3DE-BE89A21C8D1D} - {1AEB7681-57D8-48EE-813D-5C41CC38B647} = {1AEB7681-57D8-48EE-813D-5C41CC38B647} - {4046F392-A18B-4C66-9639-3EABFFF5D531} = {4046F392-A18B-4C66-9639-3EABFFF5D531} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc7", "bc7\bc7.vcproj", "{F974F34B-AF02-4C88-8E1E-85475094EA78}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug-CUDA|Win32 = Debug-CUDA|Win32 - Debug-CUDA|x64 = Debug-CUDA|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - Release-CUDA|Win32 = Release-CUDA|Win32 - Release-CUDA|x64 = Release-CUDA|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.ActiveCfg = Debug|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|Win32.Build.0 = Debug|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.ActiveCfg = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug|x64.Build.0 = Debug|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.ActiveCfg = Release|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|Win32.Build.0 = Release|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.ActiveCfg = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release|x64.Build.0 = Release|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 - {1AEB7681-57D8-48EE-813D-5C41CC38B647}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Win32.ActiveCfg = Debug|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|Win32.Build.0 = Debug|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|x64.ActiveCfg = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug|x64.Build.0 = Debug|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Win32.ActiveCfg = Release|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|Win32.Build.0 = Release|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|x64.ActiveCfg = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release|x64.Build.0 = Release|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 - {88079E38-83AA-4E8A-B18A-66A78D1B058B}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.ActiveCfg = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|Win32.Build.0 = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug|x64.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Debug-CUDA|x64.Build.0 = Debug|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.ActiveCfg = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|Win32.Build.0 = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release|x64.Build.0 = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|Win32.Build.0 = Release|Win32 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|x64.ActiveCfg = Release|x64 - {4046F392-A18B-4C66-9639-3EABFFF5D531}.Release-CUDA|x64.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.ActiveCfg = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|Win32.Build.0 = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug|x64.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Debug-CUDA|x64.Build.0 = Debug|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.ActiveCfg = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|Win32.Build.0 = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release|x64.Build.0 = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|Win32.Build.0 = Release|Win32 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|x64.ActiveCfg = Release|x64 - {F143D180-D4C4-4037-B3DE-BE89A21C8D1D}.Release-CUDA|x64.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.ActiveCfg = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|Win32.Build.0 = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug|x64.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Debug-CUDA|x64.Build.0 = Debug|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.ActiveCfg = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|Win32.Build.0 = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release|x64.Build.0 = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|Win32.Build.0 = Release|Win32 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|x64.ActiveCfg = Release|x64 - {50C465FE-B308-42BC-894D-89484482AF06}.Release-CUDA|x64.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.ActiveCfg = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|Win32.Build.0 = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug|x64.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Debug-CUDA|x64.Build.0 = Debug|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.ActiveCfg = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|Win32.Build.0 = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release|x64.Build.0 = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|Win32.Build.0 = Release|Win32 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|x64.ActiveCfg = Release|x64 - {CE017322-01FC-4851-9C8B-64E9A8E26C38}.Release-CUDA|x64.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Win32.ActiveCfg = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|Win32.Build.0 = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|x64.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug|x64.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Debug-CUDA|x64.Build.0 = Debug|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Win32.ActiveCfg = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|Win32.Build.0 = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|x64.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release|x64.Build.0 = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|Win32.Build.0 = Release|Win32 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|x64.ActiveCfg = Release|x64 - {841B73C5-C679-4EEF-A50A-7D6106642B49}.Release-CUDA|x64.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Win32.ActiveCfg = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|Win32.Build.0 = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|x64.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug|x64.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Debug-CUDA|x64.Build.0 = Debug|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Win32.ActiveCfg = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|Win32.Build.0 = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|x64.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release|x64.Build.0 = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|Win32.Build.0 = Release|Win32 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|x64.ActiveCfg = Release|x64 - {75A0527D-BFC9-49C3-B46B-CD1A901D5927}.Release-CUDA|x64.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Win32.ActiveCfg = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|Win32.Build.0 = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|x64.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug|x64.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Debug-CUDA|x64.Build.0 = Debug|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Win32.ActiveCfg = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|Win32.Build.0 = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|x64.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release|x64.Build.0 = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|Win32.Build.0 = Release|Win32 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|x64.ActiveCfg = Release|x64 - {05A59E8B-EA70-4F22-89E8-E0927BA13064}.Release-CUDA|x64.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Win32.ActiveCfg = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|Win32.Build.0 = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|x64.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug|x64.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Debug-CUDA|x64.Build.0 = Debug|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Win32.ActiveCfg = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|Win32.Build.0 = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|x64.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release|x64.Build.0 = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|Win32.Build.0 = Release|Win32 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|x64.ActiveCfg = Release|x64 - {3BC6D760-91E8-4FFB-BD0E-F86F367AD8EA}.Release-CUDA|x64.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Win32.ActiveCfg = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|Win32.Build.0 = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|x64.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug|x64.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Debug-CUDA|x64.Build.0 = Debug|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Win32.ActiveCfg = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|Win32.Build.0 = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|x64.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release|x64.Build.0 = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|Win32.Build.0 = Release|Win32 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|x64.ActiveCfg = Release|x64 - {51999D3E-EF22-4BDD-965F-4201034D3DCE}.Release-CUDA|x64.Build.0 = Release|x64 - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|Win32.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug|x64.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|Win32.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|Win32.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|x64.ActiveCfg = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Debug-CUDA|x64.Build.0 = Debug|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|Win32.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release|x64.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|Win32.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|Win32.Build.0 = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|x64.ActiveCfg = Release|Any CPU - {CAB55C39-8FA9-4912-98D9-E52669C8911D}.Release-CUDA|x64.Build.0 = Release|Any CPU - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|Win32.ActiveCfg = Debug|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|Win32.Build.0 = Debug|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|x64.ActiveCfg = Debug|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug|x64.Build.0 = Debug|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|Win32.ActiveCfg = Debug-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|Win32.Build.0 = Debug-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|x64.ActiveCfg = Debug-CUDA|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Debug-CUDA|x64.Build.0 = Debug-CUDA|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|Win32.ActiveCfg = Release|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|Win32.Build.0 = Release|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|x64.ActiveCfg = Release|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release|x64.Build.0 = Release|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|Win32.ActiveCfg = Release-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|Win32.Build.0 = Release-CUDA|Win32 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|x64.ActiveCfg = Release-CUDA|x64 - {317B694E-B5C1-42A6-956F-FC12B69175A6}.Release-CUDA|x64.Build.0 = Release-CUDA|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|Win32.ActiveCfg = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|Win32.Build.0 = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|x64.ActiveCfg = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug|x64.Build.0 = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Debug-CUDA|x64.Build.0 = Debug|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|Win32.ActiveCfg = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|Win32.Build.0 = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|x64.ActiveCfg = Release|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release|x64.Build.0 = Release|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|Win32.Build.0 = Release|Win32 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|x64.ActiveCfg = Release|x64 - {7DCF280E-702B-49F3-84A7-AE7E146384D6}.Release-CUDA|x64.Build.0 = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|Win32.ActiveCfg = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|Win32.Build.0 = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|x64.ActiveCfg = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug|x64.Build.0 = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Debug-CUDA|x64.Build.0 = Debug|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|Win32.ActiveCfg = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|Win32.Build.0 = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|x64.ActiveCfg = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release|x64.Build.0 = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|Win32.Build.0 = Release|Win32 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|x64.ActiveCfg = Release|x64 - {C33787E3-5564-4834-9FE3-A9020455A669}.Release-CUDA|x64.Build.0 = Release|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug|Win32.ActiveCfg = Debug|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug|Win32.Build.0 = Debug|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug|x64.ActiveCfg = Debug|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug|x64.Build.0 = Debug|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Debug-CUDA|x64.Build.0 = Debug|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release|Win32.ActiveCfg = Release|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release|Win32.Build.0 = Release|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release|x64.ActiveCfg = Release|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release|x64.Build.0 = Release|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release-CUDA|Win32.Build.0 = Release|Win32 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release-CUDA|x64.ActiveCfg = Release|x64 - {3DD3A43D-C6EA-460F-821B-6C339A03C5BB}.Release-CUDA|x64.Build.0 = Release|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug|Win32.ActiveCfg = Debug|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug|Win32.Build.0 = Debug|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug|x64.ActiveCfg = Debug|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug|x64.Build.0 = Debug|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Debug-CUDA|x64.Build.0 = Debug|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release|Win32.ActiveCfg = Release|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release|Win32.Build.0 = Release|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release|x64.ActiveCfg = Release|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release|x64.Build.0 = Release|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release-CUDA|Win32.Build.0 = Release|Win32 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release-CUDA|x64.ActiveCfg = Release|x64 - {CFB3FEAC-5720-4B16-9D7E-039DB180B641}.Release-CUDA|x64.Build.0 = Release|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug|Win32.ActiveCfg = Debug|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug|Win32.Build.0 = Debug|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug|x64.ActiveCfg = Debug|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug|x64.Build.0 = Debug|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Debug-CUDA|x64.Build.0 = Debug|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release|Win32.ActiveCfg = Release|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release|Win32.Build.0 = Release|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release|x64.ActiveCfg = Release|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release|x64.Build.0 = Release|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|Win32.Build.0 = Release|Win32 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|x64.ActiveCfg = Release|x64 - {E493E368-A4CF-4A8D-99DD-E128CC3A27EF}.Release-CUDA|x64.Build.0 = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.ActiveCfg = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|Win32.Build.0 = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.ActiveCfg = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug|x64.Build.0 = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|Win32.ActiveCfg = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|Win32.Build.0 = Debug|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|x64.ActiveCfg = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Debug-CUDA|x64.Build.0 = Debug|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|Win32.ActiveCfg = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|Win32.Build.0 = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|x64.ActiveCfg = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release|x64.Build.0 = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.ActiveCfg = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.Build.0 = Release|Win32 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.ActiveCfg = Release|x64 - {F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/project/vc9/nvtt.vsprops b/project/vc9/nvtt.vsprops deleted file mode 100644 index 16ab0a4b..00000000 --- a/project/vc9/nvtt.vsprops +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - diff --git a/project/vc9/nvtt/nvtt.rc b/project/vc9/nvtt/nvtt.rc deleted file mode 100644 index 089d1e97..00000000 --- a/project/vc9/nvtt/nvtt.rc +++ /dev/null @@ -1,102 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,0,0 - PRODUCTVERSION 2,1,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "NVIDIA Corporation" - VALUE "FileDescription", "NVIDIA Texture Tools Dynamic Link Library" - VALUE "FileVersion", "2, 1, 0, 0" - VALUE "InternalName", "nvtt" - VALUE "LegalCopyright", "Copyright (C) 2007" - VALUE "OriginalFilename", "nvtt.dll" - VALUE "ProductName", "NVIDIA Texture Tools Dynamic Link Library" - VALUE "ProductVersion", "2, 1, 0, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/project/vc9/nvtt/nvtt.vcproj b/project/vc9/nvtt/nvtt.vcproj deleted file mode 100644 index 9f271722..00000000 --- a/project/vc9/nvtt/nvtt.vcproj +++ /dev/null @@ -1,1048 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvtt/resource.h b/project/vc9/nvtt/resource.h deleted file mode 100644 index 4df7169c..00000000 --- a/project/vc9/nvtt/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvtt.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/nvzoom/nvidia.ico b/project/vc9/nvzoom/nvidia.ico deleted file mode 100644 index 6aa721e6..00000000 Binary files a/project/vc9/nvzoom/nvidia.ico and /dev/null differ diff --git a/project/vc9/nvzoom/nvzoom.rc b/project/vc9/nvzoom/nvzoom.rc deleted file mode 100644 index 842ded19..00000000 Binary files a/project/vc9/nvzoom/nvzoom.rc and /dev/null differ diff --git a/project/vc9/nvzoom/nvzoom.vcproj b/project/vc9/nvzoom/nvzoom.vcproj deleted file mode 100644 index 3bbf22da..00000000 --- a/project/vc9/nvzoom/nvzoom.vcproj +++ /dev/null @@ -1,382 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/nvzoom/resource.h b/project/vc9/nvzoom/resource.h deleted file mode 100644 index e765787d..00000000 --- a/project/vc9/nvzoom/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by nvcompress.rc -// -#define IDI_ICON1 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/project/vc9/squish/squish.vcproj b/project/vc9/squish/squish.vcproj deleted file mode 100644 index cabeadc8..00000000 --- a/project/vc9/squish/squish.vcproj +++ /dev/null @@ -1,349 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/stress/stress.vcproj b/project/vc9/stress/stress.vcproj deleted file mode 100644 index fe687a8e..00000000 --- a/project/vc9/stress/stress.vcproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/project/vc9/testsuite/testsuite.vcproj b/project/vc9/testsuite/testsuite.vcproj deleted file mode 100644 index 47110c82..00000000 --- a/project/vc9/testsuite/testsuite.vcproj +++ /dev/null @@ -1,665 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f64b2633..4457b425 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,48 +11,8 @@ SUBDIRS(nvtt) SUBDIRS(bc6h) SUBDIRS(bc7) -# OpenGL -#INCLUDE(FindOpenGL) -#IF(OPENGL_FOUND) -# MESSAGE(STATUS "Looking for OpenGL - found") -#ELSE(OPENGL_FOUND) -# MESSAGE(STATUS "Looking for OpenGL - not found") -#ENDIF(OPENGL_FOUND) - -# GLUT -#INCLUDE(FindGLUT) -#IF(GLUT_FOUND) -# MESSAGE(STATUS "Looking for GLUT - found") -#ELSE(GLUT_FOUND) -# MESSAGE(STATUS "Looking for GLUT - not found") -#ENDIF(GLUT_FOUND) - -# DirectX -#INCLUDE(${NV_CMAKE_DIR}/FindDirectX.cmake) -#IF(DX10_FOUND) -# MESSAGE(STATUS "Looking for DirectX - found") -#ELSE(DX10_FOUND) -# MESSAGE(STATUS "Looking for DirectX - not found") -#ENDIF(DX10_FOUND) - -# GLEW -#INCLUDE(${NV_CMAKE_DIR}/FindGLEW.cmake) -#IF(GLEW_FOUND) -# MESSAGE(STATUS "Looking for GLEW - found") -#ELSE(GLEW_FOUND) -# MESSAGE(STATUS "Looking for GLEW - not found") -#ENDIF(GLEW_FOUND) - -# Cg -#INCLUDE(${NV_CMAKE_DIR}/FindCg.cmake) -#IF(CG_FOUND) -# MESSAGE(STATUS "Looking for Cg - found") -#ELSE(CG_FOUND) -# MESSAGE(STATUS "Looking for Cg - not found") -#ENDIF(CG_FOUND) - # CUDA -#FIND_PACKAGE(CUDA) +FIND_PACKAGE(CUDA) IF(CUDA_FOUND) IF(MINGW) MESSAGE(STATUS "Looking for CUDA - not supported on MinGW") @@ -66,71 +26,16 @@ ELSE(CUDA_FOUND) MESSAGE(STATUS "Looking for CUDA - not found") ENDIF(CUDA_FOUND) -# Maya -#INCLUDE(${NV_CMAKE_DIR}/FindMaya.cmake) -#IF(MAYA_FOUND) -# SET(HAVE_MAYA ${MAYA_FOUND} CACHE BOOL "Set to TRUE if Maya is found, FALSE otherwise") -# MESSAGE(STATUS "Looking for Maya - found") -#ELSE(MAYA_FOUND) -# MESSAGE(STATUS "Looking for Maya - not found") -#ENDIF(MAYA_FOUND) - -# FreeImage -#INCLUDE(${NV_CMAKE_DIR}/FindFreeImage.cmake) -#IF(FREEIMAGE_FOUND) -# SET(HAVE_FREEIMAGE ${FREEIMAGE_FOUND} CACHE BOOL "Set to TRUE if FreeImage is found, FALSE otherwise") -# MESSAGE(STATUS "Looking for FreeImage - found") -#ELSE(FREEIMAGE_FOUND) -# MESSAGE(STATUS "Looking for FreeImage - not found") -#ENDIF(FREEIMAGE_FOUND) - -# JPEG -#INCLUDE(FindJPEG) -#IF(JPEG_FOUND) -# SET(HAVE_JPEG ${JPEG_FOUND} CACHE BOOL "Set to TRUE if JPEG is found, FALSE otherwise") -# MESSAGE(STATUS "Looking for JPEG - found") -#ELSE(JPEG_FOUND) -# MESSAGE(STATUS "Looking for JPEG - not found") -#ENDIF(JPEG_FOUND) - -# PNG -#INCLUDE(FindPNG) -#IF(PNG_FOUND) -# SET(HAVE_PNG ${PNG_FOUND} CACHE BOOL "Set to TRUE if PNG is found, FALSE otherwise") -# MESSAGE(STATUS "Looking for PNG - found") -#ELSE(PNG_FOUND) -# MESSAGE(STATUS "Looking for PNG - not found") -#ENDIF(PNG_FOUND) - -# TIFF -#SET(TIFF_NAMES libtiff) -#INCLUDE(FindTIFF) -#IF(TIFF_FOUND) -# SET(HAVE_TIFF ${TIFF_FOUND} CACHE BOOL "Set to TRUE if TIFF is found, FALSE otherwise") -# MESSAGE(STATUS "Looking for TIFF - found") -#ELSE(TIFF_FOUND) -# MESSAGE(STATUS "Looking for TIFF - not found") -#ENDIF(TIFF_FOUND) - -# OpenEXR -#INCLUDE(${NV_CMAKE_DIR}/FindOpenEXR.cmake) -#IF(OPENEXR_FOUND) -# SET(HAVE_OPENEXR ${OPENEXR_FOUND} CACHE BOOL "Set to TRUE if OpenEXR is found, FALSE otherwise") -# MESSAGE(STATUS "Looking for OpenEXR - found") -#ELSE(OPENEXR_FOUND) -# MESSAGE(STATUS "Looking for OpenEXR - not found") -#ENDIF(OPENEXR_FOUND) - # OpenMP -INCLUDE(FindOpenMP) -IF(OPENMP_FOUND) - SET(HAVE_OPENMP ${OPENMP_FOUND} CACHE BOOL "Set to TRUE if OpenMP is found, FALSE otherwise") - MESSAGE(STATUS "Looking for OpenMP - found") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") -ELSE(OPENMP_FOUND) - MESSAGE(STATUS "Looking for OpenMP - not found") -ENDIF(OPENMP_FOUND) +# INCLUDE(FindOpenMP) +# IF(OPENMP_FOUND) +# SET(HAVE_OPENMP ${OPENMP_FOUND} CACHE BOOL "Set to TRUE if OpenMP is found, FALSE otherwise") +# MESSAGE(STATUS "Looking for OpenMP - found") +# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") +# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +# ELSE(OPENMP_FOUND) +# MESSAGE(STATUS "Looking for OpenMP - not found") +# ENDIF(OPENMP_FOUND) # Threads FIND_PACKAGE(Threads REQUIRED) @@ -149,5 +54,3 @@ CHECK_INCLUDE_FILES("dispatch/dispatch.h" HAVE_DISPATCH_H) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/nvconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/nvconfig.h) -#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/nvconfig.h DESTINATION include) - diff --git a/src/bc6h/CMakeLists.txt b/src/bc6h/CMakeLists.txt index 5c01c6c9..fd75e74f 100644 --- a/src/bc6h/CMakeLists.txt +++ b/src/bc6h/CMakeLists.txt @@ -15,9 +15,3 @@ SET(BC6H_SRCS ADD_LIBRARY(bc6h STATIC ${BC6H_SRCS}) TARGET_LINK_LIBRARIES(bc6h nvcore nvmath) - -IF(NOT WIN32) - IF(CMAKE_COMPILER_IS_GNUCXX) - SET_TARGET_PROPERTIES(bc6h PROPERTIES COMPILE_FLAGS -fPIC) - ENDIF(CMAKE_COMPILER_IS_GNUCXX) -ENDIF(NOT WIN32) diff --git a/src/bc7/CMakeLists.txt b/src/bc7/CMakeLists.txt index 99df434d..566fe1f5 100644 --- a/src/bc7/CMakeLists.txt +++ b/src/bc7/CMakeLists.txt @@ -23,11 +23,3 @@ SET(BC7_SRCS ADD_LIBRARY(bc7 STATIC ${BC7_SRCS}) TARGET_LINK_LIBRARIES(bc7 nvcore nvmath) - -TARGET_LINK_LIBRARIES(bc7 nvmath) - -IF(NOT WIN32) - IF(CMAKE_COMPILER_IS_GNUCXX) - SET_TARGET_PROPERTIES(bc7 PROPERTIES COMPILE_FLAGS -fPIC) - ENDIF(CMAKE_COMPILER_IS_GNUCXX) -ENDIF(NOT WIN32) diff --git a/src/nvconfig.h.in b/src/nvconfig.h.in index 16da6464..ecc1cc7e 100644 --- a/src/nvconfig.h.in +++ b/src/nvconfig.h.in @@ -10,7 +10,7 @@ #cmakedefine HAVE_OPENMP #cmakedefine HAVE_DISPATCH_H -#define HAVE_STBIMAGE +#define NV_HAVE_STBIMAGE //#cmakedefine HAVE_PNG //#cmakedefine HAVE_JPEG //#cmakedefine HAVE_TIFF diff --git a/src/nvcore/CMakeLists.txt b/src/nvcore/CMakeLists.txt index 3dfcb5d9..98081e65 100644 --- a/src/nvcore/CMakeLists.txt +++ b/src/nvcore/CMakeLists.txt @@ -10,6 +10,7 @@ SET(CORE_SRCS DefsVcWin32.h FileSystem.h FileSystem.cpp ForEach.h + Library.h Library.cpp Memory.h Memory.cpp Ptr.h RefCounted.h diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp index 829410d9..5c90f6f2 100644 --- a/src/nvcore/Debug.cpp +++ b/src/nvcore/Debug.cpp @@ -604,7 +604,7 @@ namespace # elif NV_CPU_X86 ucontext_t * ucp = (ucontext_t *)secret; return (void *) ucp->uc_mcontext->__ss.__eip; -# elif NV_CPU_ARM +# elif NV_CPU_ARM || NV_CPU_AARCH64 ucontext_t * ucp = (ucontext_t *)secret; return (void *) ucp->uc_mcontext->__ss.__pc; # else @@ -668,6 +668,13 @@ namespace # elif NV_CPU_AARCH64 ucontext_t * ucp = (ucontext_t *)secret; return (void *) ucp->uc_mcontext.pc; +# elif NV_CPU_E2K /* MCST Elbrus 2000 */ + // e2k has 3 stacks - Procedure Stack (PS), Procedure Chain Stack (PCS) and User Stack (US) + // CR0 and CR1 (Chain Register) are the 128-bit registers of the Procedure Chain Stack (PCS) + // CR's divided into _HI and _LO 64-bit parts (as in x86, for example, AX is divided into AH and AL) + // CR0_HI stores an Instruction Pointer + ucontext_t * ucp = (ucontext_t *)secret; + return (void *) ucp->uc_mcontext.cr0_hi; # else # error "Unknown CPU" # endif @@ -1008,8 +1015,7 @@ void debug::dumpInfo() #endif } -/// Dump callstack using the specified handler. -void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToSkip /*= 0*/) +static void dumpCallstackImpl(MessageHandler *messageHandler, int callstackLevelsToSkip, ...) { #if (NV_OS_WIN32 && NV_CC_MSVC) || (defined(HAVE_SIGNAL_H) && defined(HAVE_EXECINFO_H)) if (hasStackTrace()) @@ -1020,14 +1026,24 @@ void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToS Array lines; writeStackTrace(trace, size, callstackLevelsToSkip + 1, lines); // + 1 to skip the call to dumpCallstack + va_list empty; + va_start(empty, callstackLevelsToSkip); + va_end(empty); + for (uint i = 0; i < lines.count(); i++) { - messageHandler->log(lines[i], NULL); + messageHandler->log(lines[i], empty); delete lines[i]; } } #endif } +/// Dump callstack using the specified handler. +void debug::dumpCallstack(MessageHandler *messageHandler, int callstackLevelsToSkip /*= 0*/) +{ + dumpCallstackImpl(messageHandler, callstackLevelsToSkip); +} + /// Set the debug message handler. void debug::setMessageHandler(MessageHandler * message_handler) diff --git a/src/nvcore/Debug.h b/src/nvcore/Debug.h index c3a4144c..4aca31b8 100644 --- a/src/nvcore/Debug.h +++ b/src/nvcore/Debug.h @@ -166,7 +166,7 @@ NVCORE_API void NV_CDECL nvDebugPrint( const char *msg, ... ) __attribute__((for namespace nv { inline bool isValidPtr(const void * ptr) { - #if NV_CPU_X86_64 || POSH_CPU_PPC64 + #if NV_CPU_X86_64 || POSH_CPU_PPC64 || NV_CPU_AARCH64 if (ptr == NULL) return true; if (reinterpret_cast(ptr) < 0x10000ULL) return false; if (reinterpret_cast(ptr) >= 0x000007FFFFFEFFFFULL) return false; diff --git a/src/nvcore/DefsVcWin32.h b/src/nvcore/DefsVcWin32.h index 632817f3..74d9e847 100644 --- a/src/nvcore/DefsVcWin32.h +++ b/src/nvcore/DefsVcWin32.h @@ -29,7 +29,9 @@ # define strtoll _strtoi64 # define strtoull _strtoui64 #endif -#define chdir _chdir +#if _MSC_VER < 1900 +# define chdir _chdir +#endif #define getcwd _getcwd #if _MSC_VER < 1800 // Not sure what version introduced this. diff --git a/src/nvcore/FileSystem.cpp b/src/nvcore/FileSystem.cpp index 4336f5dd..8c09c166 100644 --- a/src/nvcore/FileSystem.cpp +++ b/src/nvcore/FileSystem.cpp @@ -6,7 +6,7 @@ #define _CRT_NONSTDC_NO_WARNINGS // _chdir is defined deprecated, but that's a bug, chdir is deprecated, _chdir is *not*. //#include // PathFileExists #include // GetFileAttributes -#include // _mkdir +#include // _mkdir, _chdir #elif NV_OS_XBOX #include #elif NV_OS_ORBIS @@ -81,11 +81,11 @@ bool FileSystem::copyFile(const char * src, const char * dst) { FILE * fsrc = fileOpen(src, "rb"); if (fsrc == NULL) return false; - NV_ON_RETURN(fclose(fsrc)); + defer{ fclose(fsrc); }; FILE * fdst = fileOpen(dst, "wb"); if (fdst == NULL) return false; - NV_ON_RETURN(fclose(fdst)); + defer{ fclose(fdst); }; char buffer[1024]; size_t n; diff --git a/src/nvcore/Library.cpp b/src/nvcore/Library.cpp new file mode 100644 index 00000000..a5ade772 --- /dev/null +++ b/src/nvcore/Library.cpp @@ -0,0 +1,44 @@ +#include "Library.h" +#include "Debug.h" + +#if NV_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#define VC_EXTRALEAN +#include +#elif NV_OS_XBOX +#include +#else +#include +#endif + + + +void * nvLoadLibrary(const char * name) +{ +#if NV_OS_WIN32 + return (void *)LoadLibraryExA( name, NULL, 0 ); +#elif NV_OS_XBOX + return (void *)LoadLibraryA( name ); +#else + return dlopen(name, RTLD_LAZY); +#endif +} + +void nvUnloadLibrary(void * handle) +{ + nvDebugCheck(handle != NULL); +#if NV_OS_WIN32 || NV_OS_XBOX + FreeLibrary((HMODULE)handle); +#else + dlclose(handle); +#endif +} + +void * nvBindSymbol(void * handle, const char * symbol) +{ +#if NV_OS_WIN32 || NV_OS_XBOX + return (void *)GetProcAddress((HMODULE)handle, symbol); +#else + return (void *)dlsym(handle, symbol); +#endif +} \ No newline at end of file diff --git a/src/nvcore/Library.h b/src/nvcore/Library.h new file mode 100644 index 00000000..537e935a --- /dev/null +++ b/src/nvcore/Library.h @@ -0,0 +1,51 @@ +// This code is in the public domain -- castano@gmail.com + +#pragma once +#ifndef NV_CORE_LIBRARY_H +#define NV_CORE_LIBRARY_H + +#include "nvcore.h" + +#if NV_OS_WIN32 +#define LIBRARY_NAME(name) #name ".dll" +#elif NV_OS_DARWIN +#define NV_LIBRARY_NAME(name) "lib" #name ".dylib" +#else +#define NV_LIBRARY_NAME(name) "lib" #name ".so" +#endif + +NVCORE_API void * nvLoadLibrary(const char * name); +NVCORE_API void nvUnloadLibrary(void * lib); +NVCORE_API void * nvBindSymbol(void * lib, const char * symbol); + +class NVCORE_CLASS Library +{ +public: + Library(const char * name) + { + handle = nvLoadLibrary(name); + } + ~Library() + { + if (isValid()) + { + nvUnloadLibrary(handle); + } + } + + bool isValid() const + { + return handle != NULL; + } + + void * bindSymbol(const char * symbol) + { + return nvBindSymbol(handle, symbol); + } + +private: + void * handle; +}; + + +#endif // NV_CORE_LIBRARY_H \ No newline at end of file diff --git a/src/nvcore/Utils.h b/src/nvcore/Utils.h index 2eb692cc..50400e0c 100644 --- a/src/nvcore/Utils.h +++ b/src/nvcore/Utils.h @@ -232,7 +232,7 @@ namespace nv inline uint64 nextPowerOfTwo(uint64 x) { nvDebugCheck(x != 0); - uint p = 1; + uint64 p = 1; while (x > p) { p += p; } diff --git a/src/nvcore/nvcore.h b/src/nvcore/nvcore.h index ecbaa5b3..f3bbb663 100644 --- a/src/nvcore/nvcore.h +++ b/src/nvcore/nvcore.h @@ -1,383 +1,385 @@ -// This code is in the public domain -- Ignacio Castaño - -#pragma once -#ifndef NV_CORE_H -#define NV_CORE_H - -// Function linkage -#if NVCORE_SHARED -#ifdef NVCORE_EXPORTS -#define NVCORE_API DLL_EXPORT -#define NVCORE_CLASS DLL_EXPORT_CLASS -#else -#define NVCORE_API DLL_IMPORT -#define NVCORE_CLASS DLL_IMPORT -#endif -#else // NVCORE_SHARED -#define NVCORE_API -#define NVCORE_CLASS -#endif // NVCORE_SHARED - - -// Platform definitions -#include - -// OS: -// NV_OS_WIN32 -// NV_OS_WIN64 -// NV_OS_MINGW -// NV_OS_CYGWIN -// NV_OS_LINUX -// NV_OS_UNIX -// NV_OS_DARWIN -// NV_OS_XBOX -// NV_OS_ORBIS -// NV_OS_IOS - -#define NV_OS_STRING POSH_OS_STRING - -#if defined POSH_OS_LINUX -# define NV_OS_LINUX 1 -# define NV_OS_UNIX 1 -#elif defined POSH_OS_ORBIS -# define NV_OS_ORBIS 1 -#elif defined POSH_OS_FREEBSD -# define NV_OS_FREEBSD 1 -# define NV_OS_UNIX 1 -#elif defined POSH_OS_NETBSD -# define NV_OS_NETBSD 1 -# define NV_OS_UNIX 1 -#elif defined POSH_OS_OPENBSD -# define NV_OS_OPENBSD 1 -# define NV_OS_UNIX 1 -#elif defined POSH_OS_CYGWIN32 -# define NV_OS_CYGWIN 1 -#elif defined POSH_OS_MINGW -# define NV_OS_MINGW 1 -# define NV_OS_WIN32 1 -#elif defined POSH_OS_OSX -# define NV_OS_OSX 1 // IC: Adding this, because iOS defines NV_OS_DARWIN too. -# define NV_OS_DARWIN 1 -# define NV_OS_UNIX 1 -#elif defined POSH_OS_IOS -# define NV_OS_DARWIN 1 //ACS should we keep this on IOS? -# define NV_OS_UNIX 1 -# define NV_OS_IOS 1 -#elif defined POSH_OS_UNIX -# define NV_OS_UNIX 1 -#elif defined POSH_OS_WIN64 -# define NV_OS_WIN32 1 -# define NV_OS_WIN64 1 -#elif defined POSH_OS_WIN32 -# define NV_OS_WIN32 1 -#elif defined POSH_OS_XBOX -# define NV_OS_XBOX 1 -#else -# error "Unsupported OS" -#endif - - -// Threading: -// some platforms don't implement __thread or similar for thread-local-storage -#if NV_OS_UNIX || NV_OS_ORBIS || NV_OS_IOS -# define NV_OS_USE_PTHREAD 1 -# if 0 //Apple finally added TLS support to iOS!// NV_OS_IOS -# define NV_OS_HAS_TLS_QUALIFIER 0 -# else -# define NV_OS_HAS_TLS_QUALIFIER 1 -# endif -#else -# define NV_OS_USE_PTHREAD 0 -# define NV_OS_HAS_TLS_QUALIFIER 1 -#endif - - -// CPUs: -// NV_CPU_X86 -// NV_CPU_X86_64 -// NV_CPU_PPC -// NV_CPU_ARM -// NV_CPU_ARM_64 - -#define NV_CPU_STRING POSH_CPU_STRING - -#if defined POSH_CPU_X86_64 -//# define NV_CPU_X86 1 -# define NV_CPU_X86_64 1 -#elif defined POSH_CPU_X86 -# define NV_CPU_X86 1 -#elif defined POSH_CPU_PPC -# define NV_CPU_PPC 1 -#elif defined POSH_CPU_STRONGARM -# define NV_CPU_ARM 1 -#elif defined POSH_CPU_AARCH64 -# define NV_CPU_ARM_64 1 -#else -# error "Unsupported CPU" -#endif - - -// Compiler: -// NV_CC_GNUC -// NV_CC_MSVC -// NV_CC_CLANG - -#if defined POSH_COMPILER_CLANG -# define NV_CC_CLANG 1 -# define NV_CC_GNUC 1 // Clang is compatible with GCC. -# define NV_CC_STRING "clang" -#elif defined POSH_COMPILER_GCC -# define NV_CC_GNUC 1 -# define NV_CC_STRING "gcc" -#elif defined POSH_COMPILER_MSVC -# define NV_CC_MSVC 1 -# define NV_CC_STRING "msvc" -#else -# error "Unsupported compiler" -#endif - -#if NV_CC_MSVC -#define NV_CC_CPP11 (__cplusplus > 199711L || _MSC_VER >= 1800) // Visual Studio 2013 has all the features we use, but doesn't advertise full C++11 support yet. -#else -// @@ IC: This works in CLANG, about GCC? -// @@ ES: Doesn't work in gcc. These 3 features are available in GCC >= 4.4. -#ifdef __clang__ -#define NV_CC_CPP11 (__has_feature(cxx_deleted_functions) && __has_feature(cxx_rvalue_references) && __has_feature(cxx_static_assert)) -#elif defined __GNUC__ -#define NV_CC_CPP11 ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -#endif -#endif - -// Endiannes: -// @@ POSH endian detection is broken for arm64 on iOS. They are bi-endian and iOS sets all their processors to little endian by default. -#if NV_OS_IOS -# define NV_LITTLE_ENDIAN 1 -# define NV_BIG_ENDIAN 0 -# define NV_ENDIAN_STRING "little" -#else -# define NV_LITTLE_ENDIAN POSH_LITTLE_ENDIAN -# define NV_BIG_ENDIAN POSH_BIG_ENDIAN -# define NV_ENDIAN_STRING POSH_ENDIAN_STRING -#endif - -// Define the right printf prefix for size_t arguments: -#if POSH_64BIT_POINTER -# define NV_SIZET_PRINTF_PREFIX POSH_I64_PRINTF_PREFIX -#else -# define NV_SIZET_PRINTF_PREFIX -#endif - - -// cmake config -#include "nvconfig.h" - -#if NV_OS_DARWIN -#include -//#include - -// Type definitions: -typedef uint8_t uint8; -typedef int8_t int8; - -typedef uint16_t uint16; -typedef int16_t int16; - -typedef uint32_t uint32; -typedef int32_t int32; - -typedef uint64_t uint64; -typedef int64_t int64; - -// POSH gets this wrong due to __LP64__ -#undef POSH_I64_PRINTF_PREFIX -#define POSH_I64_PRINTF_PREFIX "ll" - -#else - -// Type definitions: -typedef posh_u8_t uint8; -typedef posh_i8_t int8; - -typedef posh_u16_t uint16; -typedef posh_i16_t int16; - -typedef posh_u32_t uint32; -typedef posh_i32_t int32; - -//#if NV_OS_DARWIN -// OSX-64 is supposed to be LP64 (longs and pointers are 64 bits), thus uint64 is defined as -// unsigned long. However, some OSX headers define it as unsigned long long, producing errors, -// even though both types are 64 bit. Ideally posh should handle that, but it has not been -// updated in ages, so here I'm just falling back to the standard C99 types defined in inttypes.h -//#include -//typedef posh_u64_t uint64_t; -//typedef posh_i64_t int64_t; -//#else -typedef posh_u64_t uint64; -typedef posh_i64_t int64; -//#endif -#if NV_OS_DARWIN -// To avoid duplicate definitions. -#define _UINT64 -#endif -#endif - -// Aliases -typedef uint32 uint; - - -// Version string: -#define NV_VERSION_STRING \ - NV_OS_STRING "/" NV_CC_STRING "/" NV_CPU_STRING"/" \ - NV_ENDIAN_STRING"-endian - " __DATE__ "-" __TIME__ - - -// Disable copy constructor and assignment operator. -#if NV_CC_CPP11 -#define NV_FORBID_COPY(C) \ - C( const C & ) = delete; \ - C &operator=( const C & ) = delete -#else -#define NV_FORBID_COPY(C) \ - private: \ - C( const C & ); \ - C &operator=( const C & ) -#endif - -// Disable dynamic allocation on the heap. -// See Prohibiting Heap-Based Objects in More Effective C++. -#define NV_FORBID_HEAPALLOC() \ - private: \ - void *operator new(size_t size); \ - void *operator new[](size_t size) - //static void *operator new(size_t size); \ - //static void *operator new[](size_t size); - -// String concatenation macros. -#define NV_STRING_JOIN2(arg1, arg2) NV_DO_STRING_JOIN2(arg1, arg2) -#define NV_DO_STRING_JOIN2(arg1, arg2) arg1 ## arg2 -#define NV_STRING_JOIN3(arg1, arg2, arg3) NV_DO_STRING_JOIN3(arg1, arg2, arg3) -#define NV_DO_STRING_JOIN3(arg1, arg2, arg3) arg1 ## arg2 ## arg3 -#define NV_STRING2(x) #x -#define NV_STRING(x) NV_STRING2(x) - -#if NV_CC_MSVC -#define NV_MULTI_LINE_MACRO_BEGIN do { -#define NV_MULTI_LINE_MACRO_END \ - __pragma(warning(push)) \ - __pragma(warning(disable:4127)) \ - } while(false) \ - __pragma(warning(pop)) -#else -#define NV_MULTI_LINE_MACRO_BEGIN do { -#define NV_MULTI_LINE_MACRO_END } while(false) -#endif - -#if NV_CC_CPP11 -#define nvStaticCheck(x) static_assert((x), "Static assert "#x" failed") -#else -#define nvStaticCheck(x) typedef char NV_STRING_JOIN2(__static_assert_,__LINE__)[(x)] -#endif -#define NV_COMPILER_CHECK(x) nvStaticCheck(x) // I like this name best. - -// Make sure type definitions are fine. -NV_COMPILER_CHECK(sizeof(int8) == 1); -NV_COMPILER_CHECK(sizeof(uint8) == 1); -NV_COMPILER_CHECK(sizeof(int16) == 2); -NV_COMPILER_CHECK(sizeof(uint16) == 2); -NV_COMPILER_CHECK(sizeof(int32) == 4); -NV_COMPILER_CHECK(sizeof(uint32) == 4); -NV_COMPILER_CHECK(sizeof(int32) == 4); -NV_COMPILER_CHECK(sizeof(uint32) == 4); - -#include // for size_t -template char (&ArraySizeHelper(T (&array)[N]))[N]; -#define NV_ARRAY_SIZE(x) sizeof(ArraySizeHelper(x)) -//#define NV_ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) - -#if 0 // Disabled in The Witness. -#if NV_CC_MSVC -#define NV_MESSAGE(x) message(__FILE__ "(" NV_STRING(__LINE__) ") : " x) -#else -#define NV_MESSAGE(x) message(x) -#endif -#else -#define NV_MESSAGE(x) -#endif - - -// Startup initialization macro. -#define NV_AT_STARTUP(some_code) \ - namespace { \ - static struct NV_STRING_JOIN2(AtStartup_, __LINE__) { \ - NV_STRING_JOIN2(AtStartup_, __LINE__)() { some_code; } \ - } \ - NV_STRING_JOIN3(AtStartup_, __LINE__, Instance); \ - } - -namespace nv { - template - struct ScopeExit { - ScopeExit(F f) : f(f) {} - ~ScopeExit() { f(); } - F f; - }; - - template - ScopeExit MakeScopeExit(F f) { - return ScopeExit(f); - }; -} - -#define NV_ON_RETURN(code) \ - auto NV_STRING_JOIN2(scope_exit_, __LINE__) = nv::MakeScopeExit([=](){code;}) - - -// Indicate the compiler that the parameter is not used to suppress compier warnings. -#if NV_CC_MSVC -#define NV_UNUSED(a) ((a)=(a)) -#else -#define NV_UNUSED(a) _Pragma(NV_STRING(unused(a))) -#endif - -#if NV_CC_GNUC || NV_CC_CLANG -#define NV_LIKELY(x) __builtin_expect(!!(x), 1) -#define NV_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define NV_LIKELY(x) x -#define NV_UNLIKELY(x) x -#endif - -// Null index. @@ Move this somewhere else... it's only used by nvmesh. -//const unsigned int NIL = unsigned int(~0); -//#define NIL uint(~0) - -// Null pointer. -#ifndef NULL -#define NULL 0 -#endif - -// Platform includes -#if NV_CC_MSVC -# if NV_OS_WIN32 -# include "DefsVcWin32.h" -# elif NV_OS_XBOX -# include "DefsVcXBox.h" -# else -# error "MSVC: Platform not supported" -# endif -#elif NV_CC_GNUC -# if NV_OS_LINUX -# include "DefsGnucLinux.h" -# elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD -# include "DefsGnucDarwin.h" -# elif NV_OS_MINGW -# include "DefsGnucWin32.h" -# elif NV_OS_CYGWIN -# error "GCC: Cygwin not supported" -# else -# error "GCC: Platform not supported" -# endif -#endif - -#endif // NV_CORE_H +// This code is in the public domain -- Ignacio Castano + +#pragma once +#ifndef NV_CORE_H +#define NV_CORE_H + +// Function linkage +#if NVCORE_SHARED +#ifdef NVCORE_EXPORTS +#define NVCORE_API DLL_EXPORT +#define NVCORE_CLASS DLL_EXPORT_CLASS +#else +#define NVCORE_API DLL_IMPORT +#define NVCORE_CLASS DLL_IMPORT +#endif +#else // NVCORE_SHARED +#define NVCORE_API +#define NVCORE_CLASS +#endif // NVCORE_SHARED + + +// Platform definitions +#include + +// OS: +// NV_OS_WIN32 +// NV_OS_WIN64 +// NV_OS_MINGW +// NV_OS_CYGWIN +// NV_OS_LINUX +// NV_OS_UNIX +// NV_OS_DARWIN +// NV_OS_XBOX +// NV_OS_ORBIS +// NV_OS_IOS + +#define NV_OS_STRING POSH_OS_STRING + +#if defined POSH_OS_LINUX +# define NV_OS_LINUX 1 +# define NV_OS_UNIX 1 +#elif defined POSH_OS_ORBIS +# define NV_OS_ORBIS 1 +#elif defined POSH_OS_FREEBSD +# define NV_OS_FREEBSD 1 +# define NV_OS_UNIX 1 +#elif defined POSH_OS_NETBSD +# define NV_OS_NETBSD 1 +# define NV_OS_UNIX 1 +#elif defined POSH_OS_OPENBSD +# define NV_OS_OPENBSD 1 +# define NV_OS_UNIX 1 +#elif defined POSH_OS_CYGWIN32 +# define NV_OS_CYGWIN 1 +#elif defined POSH_OS_MINGW +# define NV_OS_MINGW 1 +# define NV_OS_WIN32 1 +#elif defined POSH_OS_OSX +# define NV_OS_OSX 1 // IC: Adding this, because iOS defines NV_OS_DARWIN too. +# define NV_OS_DARWIN 1 +# define NV_OS_UNIX 1 +#elif defined POSH_OS_IOS +# define NV_OS_DARWIN 1 //ACS should we keep this on IOS? +# define NV_OS_UNIX 1 +# define NV_OS_IOS 1 +#elif defined POSH_OS_UNIX +# define NV_OS_UNIX 1 +#elif defined POSH_OS_WIN64 +# define NV_OS_WIN32 1 +# define NV_OS_WIN64 1 +#elif defined POSH_OS_WIN32 +# define NV_OS_WIN32 1 +#elif defined POSH_OS_XBOX +# define NV_OS_XBOX 1 +#else +# error "Unsupported OS" +#endif + + +// Threading: +// some platforms don't implement __thread or similar for thread-local-storage +#if NV_OS_UNIX || NV_OS_ORBIS || NV_OS_IOS +# define NV_OS_USE_PTHREAD 1 +# if 0 //Apple finally added TLS support to iOS!// NV_OS_IOS +# define NV_OS_HAS_TLS_QUALIFIER 0 +# else +# define NV_OS_HAS_TLS_QUALIFIER 1 +# endif +#else +# define NV_OS_USE_PTHREAD 0 +# define NV_OS_HAS_TLS_QUALIFIER 1 +#endif + + +// CPUs: +// NV_CPU_X86 +// NV_CPU_X86_64 +// NV_CPU_PPC +// NV_CPU_ARM +// NV_CPU_AARCH64 +// NV_CPU_E2K + +#define NV_CPU_STRING POSH_CPU_STRING + +#if defined POSH_CPU_X86_64 +//# define NV_CPU_X86 1 +# define NV_CPU_X86_64 1 +#elif defined POSH_CPU_X86 +# define NV_CPU_X86 1 +#elif defined POSH_CPU_PPC +# define NV_CPU_PPC 1 +#elif defined POSH_CPU_STRONGARM +# define NV_CPU_ARM 1 +#elif defined POSH_CPU_AARCH64 +# define NV_CPU_AARCH64 1 +#elif defined POSH_CPU_E2K +# define NV_CPU_E2K 1 +#else +# error "Unsupported CPU" +#endif + + +// Compiler: +// NV_CC_GNUC +// NV_CC_MSVC +// NV_CC_CLANG + +#if defined POSH_COMPILER_CLANG +# define NV_CC_CLANG 1 +# define NV_CC_GNUC 1 // Clang is compatible with GCC. +# define NV_CC_STRING "clang" +#elif defined POSH_COMPILER_GCC +# define NV_CC_GNUC 1 +# define NV_CC_STRING "gcc" +#elif defined POSH_COMPILER_MSVC +# define NV_CC_MSVC 1 +# define NV_CC_STRING "msvc" +#else +# error "Unsupported compiler" +#endif + +#if NV_CC_MSVC +#define NV_CC_CPP11 (__cplusplus > 199711L || _MSC_VER >= 1800) // Visual Studio 2013 has all the features we use, but doesn't advertise full C++11 support yet. +#else +// @@ IC: This works in CLANG, about GCC? +// @@ ES: Doesn't work in gcc. These 3 features are available in GCC >= 4.4. +#ifdef __clang__ +#define NV_CC_CPP11 (__has_feature(cxx_deleted_functions) && __has_feature(cxx_rvalue_references) && __has_feature(cxx_static_assert)) +#elif defined __GNUC__ +#define NV_CC_CPP11 ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) +#endif +#endif + +// Endiannes: +// @@ POSH endian detection is broken for arm64 on iOS. They are bi-endian and iOS sets all their processors to little endian by default. +#if NV_OS_IOS +# define NV_LITTLE_ENDIAN 1 +# define NV_BIG_ENDIAN 0 +# define NV_ENDIAN_STRING "little" +#else +# define NV_LITTLE_ENDIAN POSH_LITTLE_ENDIAN +# define NV_BIG_ENDIAN POSH_BIG_ENDIAN +# define NV_ENDIAN_STRING POSH_ENDIAN_STRING +#endif + +// Define the right printf prefix for size_t arguments: +#if POSH_64BIT_POINTER +# define NV_SIZET_PRINTF_PREFIX POSH_I64_PRINTF_PREFIX +#else +# define NV_SIZET_PRINTF_PREFIX +#endif + + +// cmake config +#include "nvconfig.h" + +#if NV_OS_DARWIN +#include +//#include + +// Type definitions: +typedef uint8_t uint8; +typedef int8_t int8; + +typedef uint16_t uint16; +typedef int16_t int16; + +typedef uint32_t uint32; +typedef int32_t int32; + +typedef uint64_t uint64; +typedef int64_t int64; + +// POSH gets this wrong due to __LP64__ +#undef POSH_I64_PRINTF_PREFIX +#define POSH_I64_PRINTF_PREFIX "ll" + +#else + +// Type definitions: +typedef posh_u8_t uint8; +typedef posh_i8_t int8; + +typedef posh_u16_t uint16; +typedef posh_i16_t int16; + +typedef posh_u32_t uint32; +typedef posh_i32_t int32; + +//#if NV_OS_DARWIN +// OSX-64 is supposed to be LP64 (longs and pointers are 64 bits), thus uint64 is defined as +// unsigned long. However, some OSX headers define it as unsigned long long, producing errors, +// even though both types are 64 bit. Ideally posh should handle that, but it has not been +// updated in ages, so here I'm just falling back to the standard C99 types defined in inttypes.h +//#include +//typedef posh_u64_t uint64_t; +//typedef posh_i64_t int64_t; +//#else +typedef posh_u64_t uint64; +typedef posh_i64_t int64; +//#endif +#if NV_OS_DARWIN +// To avoid duplicate definitions. +#define _UINT64 +#endif +#endif + +// Aliases +typedef uint32 uint; + + +// Version string: +#define NV_VERSION_STRING \ + NV_OS_STRING "/" NV_CC_STRING "/" NV_CPU_STRING"/" \ + NV_ENDIAN_STRING"-endian - " __DATE__ "-" __TIME__ + + +// Disable copy constructor and assignment operator. +#if NV_CC_CPP11 +#define NV_FORBID_COPY(C) \ + C( const C & ) = delete; \ + C &operator=( const C & ) = delete +#else +#define NV_FORBID_COPY(C) \ + private: \ + C( const C & ); \ + C &operator=( const C & ) +#endif + +// Disable dynamic allocation on the heap. +// See Prohibiting Heap-Based Objects in More Effective C++. +#define NV_FORBID_HEAPALLOC() \ + private: \ + void *operator new(size_t size); \ + void *operator new[](size_t size) + //static void *operator new(size_t size); \ + //static void *operator new[](size_t size); + +// String concatenation macros. +#define NV_STRING_JOIN2(arg1, arg2) NV_DO_STRING_JOIN2(arg1, arg2) +#define NV_DO_STRING_JOIN2(arg1, arg2) arg1 ## arg2 +#define NV_STRING_JOIN3(arg1, arg2, arg3) NV_DO_STRING_JOIN3(arg1, arg2, arg3) +#define NV_DO_STRING_JOIN3(arg1, arg2, arg3) arg1 ## arg2 ## arg3 +#define NV_STRING2(x) #x +#define NV_STRING(x) NV_STRING2(x) + +#if NV_CC_MSVC +#define NV_MULTI_LINE_MACRO_BEGIN do { +#define NV_MULTI_LINE_MACRO_END \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + } while(false) \ + __pragma(warning(pop)) +#else +#define NV_MULTI_LINE_MACRO_BEGIN do { +#define NV_MULTI_LINE_MACRO_END } while(false) +#endif + +#if NV_CC_CPP11 +#define nvStaticCheck(x) static_assert((x), "Static assert "#x" failed") +#else +#define nvStaticCheck(x) typedef char NV_STRING_JOIN2(__static_assert_,__LINE__)[(x)] +#endif +#define NV_COMPILER_CHECK(x) nvStaticCheck(x) // I like this name best. + +// Make sure type definitions are fine. +NV_COMPILER_CHECK(sizeof(int8) == 1); +NV_COMPILER_CHECK(sizeof(uint8) == 1); +NV_COMPILER_CHECK(sizeof(int16) == 2); +NV_COMPILER_CHECK(sizeof(uint16) == 2); +NV_COMPILER_CHECK(sizeof(int32) == 4); +NV_COMPILER_CHECK(sizeof(uint32) == 4); +NV_COMPILER_CHECK(sizeof(int32) == 4); +NV_COMPILER_CHECK(sizeof(uint32) == 4); + +#include // for size_t +template char (&ArraySizeHelper(T (&array)[N]))[N]; +#define NV_ARRAY_SIZE(x) sizeof(ArraySizeHelper(x)) +//#define NV_ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) + +#if 0 // Disabled in The Witness. +#if NV_CC_MSVC +#define NV_MESSAGE(x) message(__FILE__ "(" NV_STRING(__LINE__) ") : " x) +#else +#define NV_MESSAGE(x) message(x) +#endif +#else +#define NV_MESSAGE(x) +#endif + + +// Startup initialization macro. +#define NV_AT_STARTUP(some_code) \ + namespace { \ + static struct NV_STRING_JOIN2(AtStartup_, __LINE__) { \ + NV_STRING_JOIN2(AtStartup_, __LINE__)() { some_code; } \ + } \ + NV_STRING_JOIN3(AtStartup_, __LINE__, Instance); \ + } + +namespace nv { + template + struct ScopeExit { + ScopeExit(F f) : f(f) {} + ~ScopeExit() { f(); } + F f; + }; + + struct ExitScopeHelp { + template + ScopeExit operator+(T t) { return t; } + }; +} + +#define defer const auto& __attribute__((unused)) NV_STRING_JOIN2(defer__, __LINE__) = nv::ExitScopeHelp() + [&]() + + +// Indicate the compiler that the parameter is not used to suppress compier warnings. +#if NV_CC_MSVC +#define NV_UNUSED(a) ((a)=(a)) +#else +#define NV_UNUSED(a) _Pragma(NV_STRING(unused(a))) +#endif + +#if NV_CC_GNUC || NV_CC_CLANG +#define NV_LIKELY(x) __builtin_expect(!!(x), 1) +#define NV_UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +#define NV_LIKELY(x) x +#define NV_UNLIKELY(x) x +#endif + +// Null index. @@ Move this somewhere else... it's only used by nvmesh. +//const unsigned int NIL = unsigned int(~0); +//#define NIL uint(~0) + +// Null pointer. +#ifndef NULL +#define NULL 0 +#endif + +// Platform includes +#if NV_CC_MSVC +# if NV_OS_WIN32 +# include "DefsVcWin32.h" +# elif NV_OS_XBOX +# include "DefsVcXBox.h" +# else +# error "MSVC: Platform not supported" +# endif +#elif NV_CC_GNUC +# if NV_OS_LINUX +# include "DefsGnucLinux.h" +# elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD +# include "DefsGnucDarwin.h" +# elif NV_OS_MINGW +# include "DefsGnucWin32.h" +# elif NV_OS_CYGWIN +# error "GCC: Cygwin not supported" +# else +# error "GCC: Platform not supported" +# endif +#endif + +#endif // NV_CORE_H diff --git a/src/nvimage/BlockDXT.cpp b/src/nvimage/BlockDXT.cpp index e98d8fa3..b72873de 100644 --- a/src/nvimage/BlockDXT.cpp +++ b/src/nvimage/BlockDXT.cpp @@ -67,18 +67,15 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4], bool d3d9/*= false*/) co // color_array[1].u = c.u; if( col0.u > col1.u ) { - int bias = 0; - if (d3d9) bias = 1; - // Four-color block: derive the other two colors. - color_array[2].r = (2 * color_array[0].r + color_array[1].r + bias) / 3; - color_array[2].g = (2 * color_array[0].g + color_array[1].g + bias) / 3; - color_array[2].b = (2 * color_array[0].b + color_array[1].b + bias) / 3; + color_array[2].r = (2 * color_array[0].r + color_array[1].r + d3d9) / 3; + color_array[2].g = (2 * color_array[0].g + color_array[1].g + d3d9) / 3; + color_array[2].b = (2 * color_array[0].b + color_array[1].b + d3d9) / 3; color_array[2].a = 0xFF; - color_array[3].r = (2 * color_array[1].r + color_array[0].r + bias) / 3; - color_array[3].g = (2 * color_array[1].g + color_array[0].g + bias) / 3; - color_array[3].b = (2 * color_array[1].b + color_array[0].b + bias) / 3; + color_array[3].r = (2 * color_array[1].r + color_array[0].r + d3d9) / 3; + color_array[3].g = (2 * color_array[1].g + color_array[0].g + d3d9) / 3; + color_array[3].b = (2 * color_array[1].b + color_array[0].b + d3d9) / 3; color_array[3].a = 0xFF; return 4; @@ -104,9 +101,9 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4], bool d3d9/*= false*/) co uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const { // Does bit expansion before interpolation. - color_array[0].b = (3 * col0.b * 22) / 8; - color_array[0].g = (col0.g << 2) | (col0.g >> 4); color_array[0].r = (3 * col0.r * 22) / 8; + color_array[0].g = (col0.g << 2) | (col0.g >> 4); + color_array[0].b = (3 * col0.b * 22) / 8; color_array[0].a = 0xFF; color_array[1].r = (3 * col1.r * 22) / 8; diff --git a/src/nvimage/BlockDXT.h b/src/nvimage/BlockDXT.h index c4627617..d0d70600 100644 --- a/src/nvimage/BlockDXT.h +++ b/src/nvimage/BlockDXT.h @@ -234,16 +234,16 @@ namespace nv // Serialization functions. - NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT1 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, AlphaBlockDXT3 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT3 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, AlphaBlockDXT5 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockDXT5 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockATI1 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockATI2 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockCTX1 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockBC6 & block); - NVIMAGE_API Stream & operator<<(Stream & stream, BlockBC7 & block); + Stream & operator<<(Stream & stream, BlockDXT1 & block); + Stream & operator<<(Stream & stream, AlphaBlockDXT3 & block); + Stream & operator<<(Stream & stream, BlockDXT3 & block); + Stream & operator<<(Stream & stream, AlphaBlockDXT5 & block); + Stream & operator<<(Stream & stream, BlockDXT5 & block); + Stream & operator<<(Stream & stream, BlockATI1 & block); + Stream & operator<<(Stream & stream, BlockATI2 & block); + Stream & operator<<(Stream & stream, BlockCTX1 & block); + Stream & operator<<(Stream & stream, BlockBC6 & block); + Stream & operator<<(Stream & stream, BlockBC7 & block); } // nv namespace diff --git a/src/nvimage/ColorBlock.cpp b/src/nvimage/ColorBlock.cpp index ad8f2b71..3f04307e 100644 --- a/src/nvimage/ColorBlock.cpp +++ b/src/nvimage/ColorBlock.cpp @@ -1,8 +1,6 @@ // This code is in the public domain -- castanyo@yahoo.es #include "ColorBlock.h" -#include "Image.h" -#include "FloatImage.h" #include "nvmath/Box.h" #include "nvmath/Vector.inl" @@ -53,17 +51,6 @@ ColorBlock::ColorBlock(const ColorBlock & block) } -/// Initialize this color block. -ColorBlock::ColorBlock(const Image * img, uint x, uint y) -{ - init(img, x, y); -} - -void ColorBlock::init(const Image * img, uint x, uint y) -{ - init(img->width(), img->height(), (const uint *)img->pixels(), x, y); -} - void ColorBlock::init(uint w, uint h, const uint * data, uint x, uint y) { nvDebugCheck(data != NULL); diff --git a/src/nvimage/ColorBlock.h b/src/nvimage/ColorBlock.h index f87cb6df..597d69d6 100644 --- a/src/nvimage/ColorBlock.h +++ b/src/nvimage/ColorBlock.h @@ -9,9 +9,6 @@ namespace nv { - class Image; - class FloatImage; - /// Uncompressed 4x4 color block. struct ColorBlock @@ -19,9 +16,7 @@ namespace nv ColorBlock(); ColorBlock(const uint * linearImage); ColorBlock(const ColorBlock & block); - ColorBlock(const Image * img, uint x, uint y); - void init(const Image * img, uint x, uint y); void init(uint w, uint h, const uint * data, uint x, uint y); void init(uint w, uint h, const float * data, uint x, uint y); diff --git a/src/nvimage/DirectDrawSurface.cpp b/src/nvimage/DirectDrawSurface.cpp index be8146e2..69707a70 100644 --- a/src/nvimage/DirectDrawSurface.cpp +++ b/src/nvimage/DirectDrawSurface.cpp @@ -1,25 +1,4 @@ -// Copyright NVIDIA Corporation 2007 -- Ignacio Castano -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. +// MIT license see full LICENSE text at end of file #include "DirectDrawSurface.h" #include "ColorBlock.h" @@ -352,6 +331,76 @@ namespace nvUnreachable(); } + static bool hasAlpha(DXGI_FORMAT format) { + switch(format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: + case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: + case DXGI_FORMAT_R32G32B32A32_SINT: + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: + case DXGI_FORMAT_R16G16B16A16_SINT: + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10A2_UINT: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SNORM: + case DXGI_FORMAT_R8G8B8A8_SINT: + case DXGI_FORMAT_A8_UNORM: + case DXGI_FORMAT_B5G5R5A1_UNORM: + case DXGI_FORMAT_B8G8R8A8_UNORM: + //case DXGI_FORMAT_B8G8R8X8_UNORM: + case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + //case DXGI_FORMAT_B8G8R8X8_TYPELESS: + //case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + case DXGI_FORMAT_BC1_UNORM: // BC1a + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + return true; + } + return false; + } + + static bool hasAlpha(D3DFORMAT format) { + switch(format) { + case D3DFMT_A8R8G8B8: + case D3DFMT_A1R5G5B5: + case D3DFMT_A4R4G4B4: + case D3DFMT_A8: + case D3DFMT_A8R3G3B2: + case D3DFMT_A2B10G10R10: + case D3DFMT_A8B8G8R8: + case D3DFMT_A2R10G10B10: + case D3DFMT_A16B16G16R16: + case D3DFMT_A8P8: + case D3DFMT_A8L8: + case D3DFMT_A4L4: + case D3DFMT_A16B16G16R16F: + case D3DFMT_A32B32G32R32F: + case FOURCC_DXT1: // DXT1a + case FOURCC_DXT2: + case FOURCC_DXT3: + case FOURCC_DXT4: + case FOURCC_DXT5: + case FOURCC_BC7L: + return true; + } + return false; + } + } // namespace namespace nv @@ -508,6 +557,20 @@ const RGBAPixelFormat *nv::findDXGIPixelFormat(uint dxgiFormat) return NULL; } +const RGBAPixelFormat *nv::findD3D9PixelFormat(uint d3d9Format) +{ + for (int i = 0; i < s_formatCount; i++) + { + if (s_formats[i].d3d9Format == d3d9Format) { + return &s_formats[i].pixelFormat; + } + } + + return NULL; +} + + + DDSHeader::DDSHeader() { this->fourcc = FOURCC_DDS; @@ -522,7 +585,7 @@ DDSHeader::DDSHeader() // Store version information on the reserved header attributes. this->reserved[9] = FOURCC_NVTT; - this->reserved[10] = (2 << 16) | (1 << 8) | (0); // major.minor.revision + this->reserved[10] = (2 << 16) | (1 << 8) | (2); // major.minor.revision this->pf.size = 32; this->pf.flags = 0; @@ -912,16 +975,6 @@ DirectDrawSurface::DirectDrawSurface() : stream(NULL) { } -DirectDrawSurface::DirectDrawSurface(const char * name) : stream(NULL) -{ - load(name); -} - -DirectDrawSurface::DirectDrawSurface(Stream * s) : stream(NULL) -{ - load(s); -} - DirectDrawSurface::~DirectDrawSurface() { delete stream; @@ -1020,7 +1073,8 @@ bool DirectDrawSurface::isSupported() const return false; } - if (isTextureCube()) { + if (isTextureCube()) + { if (header.width != header.height) return false; if ((header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) != DDSCAPS2_CUBEMAP_ALL_FACES) @@ -1036,40 +1090,56 @@ bool DirectDrawSurface::isSupported() const bool DirectDrawSurface::hasAlpha() const { + // If the file was generated by us, just use the DDPF_ALPHAPIXELS flag. + if (header.reserved[9] == FOURCC_NVTT) { + return (header.pf.flags & DDPF_ALPHAPIXELS); + } + + // Otherwise make assumptions based on the pixel format. if (header.hasDX10Header()) { -#pragma NV_MESSAGE("TODO: Update hasAlpha to handle all DX10 formats.") - return - header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM || - header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM || - header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM; + return ::hasAlpha((DXGI_FORMAT)header.header10.dxgiFormat); } else { + //if (header.pf.flags & DDPF_ALPHAPIXELS) return true; + if (header.pf.flags & DDPF_RGB) { return header.pf.amask != 0; } else if (header.pf.flags & DDPF_FOURCC) { - if (header.pf.fourcc == FOURCC_RXGB || - header.pf.fourcc == FOURCC_ATI1 || - header.pf.fourcc == FOURCC_ATI2 || - header.pf.flags & DDPF_NORMAL) - { - return false; - } - else - { - // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?) - return true; - } + return ::hasAlpha((D3DFORMAT)header.pf.fourcc); } return false; } } +bool DirectDrawSurface::isColorsRGB() const +{ + if (header.hasDX10Header()) { + switch (header.header10.dxgiFormat) { + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + case DXGI_FORMAT_BC7_UNORM_SRGB: + return true; + } + } + else { + //if (header.reserved[9] == FOURCC_NVTT) + if (header.pf.flags & DDPF_SRGB) return true; + } + + return false; +} + + uint DirectDrawSurface::mipmapCount() const { nvDebugCheck(isValid()); @@ -1172,114 +1242,84 @@ void DirectDrawSurface::setUserVersion(int version) header.setUserVersion(version); } -void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) +static uint mipmapExtent(uint mipmap, uint x) { - nvDebugCheck(isValid()); + for (uint m = 0; m < mipmap; m++) { + x = max(1U, x / 2); + } + return x; +} - stream->seek(offset(face, mipmap)); +uint DirectDrawSurface::surfaceWidth(uint mipmap) const +{ + return mipmapExtent(mipmap, width()); +} - uint w = width(); - uint h = height(); - uint d = depth(); +uint DirectDrawSurface::surfaceHeight(uint mipmap) const +{ + return mipmapExtent(mipmap, height()); +} - // Compute width and height. - for (uint m = 0; m < mipmap; m++) - { - w = max(1U, w / 2); - h = max(1U, h / 2); - d = max(1U, d / 2); - } +uint DirectDrawSurface::surfaceDepth(uint mipmap) const +{ + return mipmapExtent(mipmap, depth()); +} - img->allocate(w, h, d); +uint DirectDrawSurface::surfaceSize(uint mipmap) const +{ + uint w = surfaceWidth(mipmap); + uint h = surfaceHeight(mipmap); + uint d = surfaceDepth(mipmap); - if (hasAlpha()) - { - img->setFormat(Image::Format_ARGB); - } - else - { - img->setFormat(Image::Format_RGB); - } + uint blockSize = header.blockSize(); - if (header.hasDX10Header()) - { - if (const RGBAPixelFormat *format = findDXGIPixelFormat(header.header10.dxgiFormat)) { - readLinearImage(img, format->bitcount, format->rmask, format->gmask, format->bmask, format->amask); - } - else { - readBlockImage(img); - } + if (blockSize == 0) { + uint bitCount = header.pixelSize(); + uint pitch = computeBytePitch(w, bitCount, 1); // Asuming 1 byte alignment, which is the same D3DX expects. + return pitch * h * d; } - else - { - if (header.pf.flags & DDPF_RGB) - { - readLinearImage(img, header.pf.bitcount, header.pf.rmask, header.pf.gmask, header.pf.bmask, header.pf.amask); - } - else if (header.pf.flags & DDPF_FOURCC) - { - readBlockImage(img); - } + else { + w = (w + 3) / 4; + h = (h + 3) / 4; + //d = d; // @@ How are 3D textures aligned? + return blockSize * w * h * d; } } -/*void * DirectDrawSurface::readData(uint * sizePtr) +uint DirectDrawSurface::faceSize() const { - uint header_size = 128; // sizeof(DDSHeader); + const uint count = mipmapCount(); + uint size = 0; - if (header.hasDX10Header()) + for (uint m = 0; m < count; m++) { - header_size += 20; // sizeof(DDSHeader10); + size += surfaceSize(m); } - stream->seek(header_size); - - int size = stream->size() - header_size; - *sizePtr = size; - - void * data = new unsigned char [size]; - - size = stream->serialize(data, size); - nvDebugCheck(size == *sizePtr); - - return data; -}*/ + return size; +} -/*uint DirectDrawSurface::surfaceSize(uint mipmap) const +uint DirectDrawSurface::offset(uint face, uint mipmap) { - uint w = header.width(); - uint h = header.height(); - uint d = header.depth(); - for (int m = 0; m < mipmap; m++) { - w = (w + 1) / 2; - h = (h + 1) / 2; - d = (d + 1) / 2; - } - - bool isBlockFormat; - uint blockOrPixelSize; + uint size = 128; // sizeof(DDSHeader); - if (header.hasDX10Header()) { - blockOrPixelSize = blockSize(header10.dxgiFormat); - isBlockFormat = (blockOrPixelSize != 0); - if (isBlockFormat) { - blockOrPixelSize = pixelSize(header10.dxgiFormat); - } - } - else { - header.pf.flags + if (header.hasDX10Header()) + { + size += 20; // sizeof(DDSHeader10); } - if (isBlockFormat) { - w = (w + 3) / 4; - h = (h + 3) / 4; - d = (d + 3) / 4; // @@ Is it necessary to align the depths? + if (face != 0) + { + size += face * faceSize(); } - uint blockOrPixelCount = w * h * d; + for (uint m = 0; m < mipmap; m++) + { + size += surfaceSize(m); + } - return blockCount = blockOrPixelSize; -}*/ + return size; +} bool DirectDrawSurface::readSurface(uint face, uint mipmap, void * data, uint size) { @@ -1292,134 +1332,190 @@ bool DirectDrawSurface::readSurface(uint face, uint mipmap, void * data, uint si } -void DirectDrawSurface::readLinearImage(Image * img, uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) -{ - nvDebugCheck(stream != NULL); - nvDebugCheck(img != NULL); - - const uint w = img->width(); - const uint h = img->height(); - const uint d = img->depth(); - - uint rshift, rsize; - PixelFormat::maskShiftAndSize(rmask, &rshift, &rsize); - - uint gshift, gsize; - PixelFormat::maskShiftAndSize(gmask, &gshift, &gsize); - uint bshift, bsize; - PixelFormat::maskShiftAndSize(bmask, &bshift, &bsize); +void DirectDrawSurface::printInfo() const +{ + printf("Flags: 0x%.8X\n", header.flags); + if (header.flags & DDSD_CAPS) printf("\tDDSD_CAPS\n"); + if (header.flags & DDSD_PIXELFORMAT) printf("\tDDSD_PIXELFORMAT\n"); + if (header.flags & DDSD_WIDTH) printf("\tDDSD_WIDTH\n"); + if (header.flags & DDSD_HEIGHT) printf("\tDDSD_HEIGHT\n"); + if (header.flags & DDSD_DEPTH) printf("\tDDSD_DEPTH\n"); + if (header.flags & DDSD_PITCH) printf("\tDDSD_PITCH\n"); + if (header.flags & DDSD_LINEARSIZE) printf("\tDDSD_LINEARSIZE\n"); + if (header.flags & DDSD_MIPMAPCOUNT) printf("\tDDSD_MIPMAPCOUNT\n"); - uint ashift, asize; - PixelFormat::maskShiftAndSize(amask, &ashift, &asize); + printf("Height: %d\n", header.height); + printf("Width: %d\n", header.width); + printf("Depth: %d\n", header.depth); + if (header.flags & DDSD_PITCH) printf("Pitch: %d\n", header.pitch); + else if (header.flags & DDSD_LINEARSIZE) printf("Linear size: %d\n", header.pitch); + printf("Mipmap count: %d\n", header.mipmapcount); - uint byteCount = (bitcount + 7) / 8; + printf("Pixel Format:\n"); + printf("\tFlags: 0x%.8X\n", header.pf.flags); + if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n"); + if (header.pf.flags & DDPF_LUMINANCE) printf("\t\tDDPF_LUMINANCE\n"); + if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n"); + if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n"); + if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n"); + if (header.pf.flags & DDPF_PALETTEINDEXED1) printf("\t\tDDPF_PALETTEINDEXED1\n"); + if (header.pf.flags & DDPF_PALETTEINDEXED2) printf("\t\tDDPF_PALETTEINDEXED2\n"); + if (header.pf.flags & DDPF_PALETTEINDEXED4) printf("\t\tDDPF_PALETTEINDEXED4\n"); + if (header.pf.flags & DDPF_PALETTEINDEXED8) printf("\t\tDDPF_PALETTEINDEXED8\n"); + if (header.pf.flags & DDPF_ALPHAPREMULT) printf("\t\tDDPF_ALPHAPREMULT\n"); + if (header.pf.flags & DDPF_NORMAL) printf("\t\tDDPF_NORMAL\n"); -#pragma NV_MESSAGE("TODO: Support floating point linear images and other FOURCC codes.") + if (header.pf.fourcc != 0) { + // Display fourcc code even when DDPF_FOURCC flag not set. + printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n", + ((header.pf.fourcc >> 0) & 0xFF), + ((header.pf.fourcc >> 8) & 0xFF), + ((header.pf.fourcc >> 16) & 0xFF), + ((header.pf.fourcc >> 24) & 0xFF), + header.pf.fourcc); + } - // Read linear RGB images. - for (uint z = 0; z < d; z++) + if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0)) { - for (uint y = 0; y < h; y++) - { - for (uint x = 0; x < w; x++) - { - uint c = 0; - stream->serialize(&c, byteCount); - - Color32 pixel(0, 0, 0, 0xFF); - pixel.r = PixelFormat::convert((c & rmask) >> rshift, rsize, 8); - pixel.g = PixelFormat::convert((c & gmask) >> gshift, gsize, 8); - pixel.b = PixelFormat::convert((c & bmask) >> bshift, bsize, 8); - pixel.a = PixelFormat::convert((c & amask) >> ashift, asize, 8); + printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n", + (header.pf.bitcount >> 0) & 0xFF, + (header.pf.bitcount >> 8) & 0xFF, + (header.pf.bitcount >> 16) & 0xFF, + (header.pf.bitcount >> 24) & 0xFF, + header.pf.bitcount); + } + else + { + printf("\tBit count: %d\n", header.pf.bitcount); + } - img->pixel(x, y, z) = pixel; - } + printf("\tRed mask: 0x%.8X\n", header.pf.rmask); + printf("\tGreen mask: 0x%.8X\n", header.pf.gmask); + printf("\tBlue mask: 0x%.8X\n", header.pf.bmask); + printf("\tAlpha mask: 0x%.8X\n", header.pf.amask); + + printf("Caps:\n"); + printf("\tCaps 1: 0x%.8X\n", header.caps.caps1); + if (header.caps.caps1 & DDSCAPS_COMPLEX) printf("\t\tDDSCAPS_COMPLEX\n"); + if (header.caps.caps1 & DDSCAPS_TEXTURE) printf("\t\tDDSCAPS_TEXTURE\n"); + if (header.caps.caps1 & DDSCAPS_MIPMAP) printf("\t\tDDSCAPS_MIPMAP\n"); + + printf("\tCaps 2: 0x%.8X\n", header.caps.caps2); + if (header.caps.caps2 & DDSCAPS2_VOLUME) printf("\t\tDDSCAPS2_VOLUME\n"); + else if (header.caps.caps2 & DDSCAPS2_CUBEMAP) + { + printf("\t\tDDSCAPS2_CUBEMAP\n"); + if ((header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) == DDSCAPS2_CUBEMAP_ALL_FACES) printf("\t\tDDSCAPS2_CUBEMAP_ALL_FACES\n"); + else { + if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEX) printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEX\n"); + if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEX\n"); + if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEY\n"); + if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEY\n"); + if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEZ\n"); + if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEZ\n"); } } + + printf("\tCaps 3: 0x%.8X\n", header.caps.caps3); + printf("\tCaps 4: 0x%.8X\n", header.caps.caps4); + + if (header.hasDX10Header()) + { + printf("DX10 Header:\n"); + printf("\tDXGI Format: %u (%s)\n", header.header10.dxgiFormat, getDxgiFormatString((DXGI_FORMAT)header.header10.dxgiFormat)); + printf("\tResource dimension: %u (%s)\n", header.header10.resourceDimension, getD3d10ResourceDimensionString((DDS_DIMENSION)header.header10.resourceDimension)); + printf("\tMisc flag: %u\n", header.header10.miscFlag); + printf("\tArray size: %u\n", header.header10.arraySize); + } + + if (header.reserved[9] == FOURCC_NVTT) + { + int major = (header.reserved[10] >> 16) & 0xFF; + int minor = (header.reserved[10] >> 8) & 0xFF; + int revision= header.reserved[10] & 0xFF; + + printf("Version:\n"); + printf("\tNVIDIA Texture Tools %d.%d.%d\n", major, minor, revision); + } + + if (header.reserved[7] == FOURCC_UVER) + { + printf("User Version: %d\n", header.reserved[8]); + } } -void DirectDrawSurface::readBlockImage(Image * img) + +static bool readLinearImage(Image * img, uint8 * data, uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) { - nvDebugCheck(stream != NULL); nvDebugCheck(img != NULL); + nvDebugCheck(data != NULL); - const uint w = img->width(); - const uint h = img->height(); + const uint w = img->width; + const uint h = img->height; + const uint d = img->depth; - const uint bw = (w + 3) / 4; - const uint bh = (h + 3) / 4; + uint rshift, rsize; + PixelFormat::maskShiftAndSize(rmask, &rshift, &rsize); + + uint gshift, gsize; + PixelFormat::maskShiftAndSize(gmask, &gshift, &gsize); + + uint bshift, bsize; + PixelFormat::maskShiftAndSize(bmask, &bshift, &bsize); - for (uint by = 0; by < bh; by++) + uint ashift, asize; + PixelFormat::maskShiftAndSize(amask, &ashift, &asize); + + uint byteCount = (bitcount + 7) / 8; + + // Read linear RGB images. + for (uint z = 0; z < d; z++) { - for (uint bx = 0; bx < bw; bx++) + for (uint y = 0; y < h; y++) { - ColorBlock block; + for (uint x = 0; x < w; x++) + { + uint c; + memcpy(&c, data, byteCount); + data += byteCount; - // Read color block. - readBlock(&block); + Color32 pixel(0, 0, 0, 0xFF); + pixel.r = PixelFormat::convert((c & rmask) >> rshift, rsize, 8); + pixel.g = PixelFormat::convert((c & gmask) >> gshift, gsize, 8); + pixel.b = PixelFormat::convert((c & bmask) >> bshift, bsize, 8); + pixel.a = PixelFormat::convert((c & amask) >> ashift, asize, 8); - // Write color block. - for (uint y = 0; y < min(4U, h-4*by); y++) - { - for (uint x = 0; x < min(4U, w-4*bx); x++) - { - img->pixel(4*bx+x, 4*by+y) = block.color(x, y); - } + img->pixel(x, y, z) = pixel; } } } -} - -static Color32 buildNormal(uint8 x, uint8 y) -{ - float nx = 2 * (x / 255.0f) - 1; - float ny = 2 * (y / 255.0f) - 1; - float nz = 0.0f; - if (1 - nx*nx - ny*ny > 0) nz = sqrtf(1 - nx*nx - ny*ny); - uint8 z = clamp(int(255.0f * (nz + 1) / 2.0f), 0, 255); - return Color32(x, y, z); + return true; } -void DirectDrawSurface::readBlock(ColorBlock * rgba) +static void readBlock(ColorBlock * rgba, uint8 * data, uint dxgiFormat, bool isNormalMap, bool swapRA) { - nvDebugCheck(stream != NULL); nvDebugCheck(rgba != NULL); + nvDebugCheck(data != NULL); - uint fourcc = header.pf.fourcc; - - // Map DX10 block formats to fourcc codes. - if (header.hasDX10Header()) - { - if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM) fourcc = FOURCC_DXT1; - else if (header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM) fourcc = FOURCC_DXT3; - else if (header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM) fourcc = FOURCC_DXT5; - else if (header.header10.dxgiFormat == DXGI_FORMAT_BC4_UNORM) fourcc = FOURCC_ATI1; - else if (header.header10.dxgiFormat == DXGI_FORMAT_BC5_UNORM) fourcc = FOURCC_ATI2; - } - - if (fourcc == FOURCC_DXT1) + if (dxgiFormat == DXGI_FORMAT_BC1_UNORM) { - BlockDXT1 block; - *stream << block; - block.decodeBlock(rgba); + BlockDXT1 * block = (BlockDXT1 *)data; + block->decodeBlock(rgba); } - else if (fourcc == FOURCC_DXT2 || fourcc == FOURCC_DXT3) + else if (dxgiFormat == DXGI_FORMAT_BC2_UNORM) { - BlockDXT3 block; - *stream << block; - block.decodeBlock(rgba); + BlockDXT3 * block = (BlockDXT3 *)data; + block->decodeBlock(rgba); } - else if (fourcc == FOURCC_DXT4 || fourcc == FOURCC_DXT5 || fourcc == FOURCC_RXGB) + else if (dxgiFormat == DXGI_FORMAT_BC3_UNORM) { - BlockDXT5 block; - *stream << block; - block.decodeBlock(rgba); + BlockDXT5 * block = (BlockDXT5 *)data; + block->decodeBlock(rgba); - if (fourcc == FOURCC_RXGB) - { + if (swapRA) { // Swap R & A. for (int i = 0; i < 16; i++) { @@ -1430,262 +1526,264 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba) } } } - else if (fourcc == FOURCC_ATI1) + else if (DXGI_FORMAT_BC4_UNORM) { - BlockATI1 block; - *stream << block; - block.decodeBlock(rgba); + BlockATI1 * block = (BlockATI1 *)data; + block->decodeBlock(rgba); } - else if (fourcc == FOURCC_ATI2) + else if (DXGI_FORMAT_BC5_UNORM) { - BlockATI2 block; - *stream << block; - block.decodeBlock(rgba); + BlockATI2 * block = (BlockATI2 *)data; + block->decodeBlock(rgba); } - else if (header.hasDX10Header() && header.header10.dxgiFormat == DXGI_FORMAT_BC6H_UF16) + else if (dxgiFormat == DXGI_FORMAT_BC6H_UF16) { - BlockBC6 block; - *stream << block; + BlockBC6 * block = (BlockBC6 *)data; Vector4 colors[16]; - block.decodeBlock(colors); + block->decodeBlock(colors); // Clamp to [0, 1] and round to 8-bit for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { - Vector4 px = colors[y*4 + x]; + Vector4 px = colors[y * 4 + x]; rgba->color(x, y).setRGBA( - ftoi_round(clamp(px.x, 0.0f, 1.0f) * 255.0f), - ftoi_round(clamp(px.y, 0.0f, 1.0f) * 255.0f), - ftoi_round(clamp(px.z, 0.0f, 1.0f) * 255.0f), - 0xFF); + ftoi_round(clamp(px.x, 0.0f, 1.0f) * 255.0f), + ftoi_round(clamp(px.y, 0.0f, 1.0f) * 255.0f), + ftoi_round(clamp(px.z, 0.0f, 1.0f) * 255.0f), + 0xFF); } } } - else if (header.hasDX10Header() && header.header10.dxgiFormat == DXGI_FORMAT_BC7_UNORM) + else if (dxgiFormat == DXGI_FORMAT_BC7_UNORM) { - BlockBC7 block; - *stream << block; - block.decodeBlock(rgba); + BlockBC7 * block = (BlockBC7 *)data; + block->decodeBlock(rgba); } else { nvDebugCheck(false); } - // If normal flag set, convert to normal. - if (header.pf.flags & DDPF_NORMAL) + // If normal flag set, reconstruct Z from XY. + if (isNormalMap) { - if (fourcc == FOURCC_ATI2) - { - for (int i = 0; i < 16; i++) - { - Color32 & c = rgba->color(i); - c = buildNormal(c.r, c.g); - } - } - else if (fourcc == FOURCC_DXT5) + for (int i = 0; i < 16; i++) { - for (int i = 0; i < 16; i++) - { - Color32 & c = rgba->color(i); - c = buildNormal(c.a, c.g); - } - } - } -} + Color32 & c = rgba->color(i); - -static uint mipmapExtent(uint mipmap, uint x) -{ - for (uint m = 0; m < mipmap; m++) { - x = max(1U, x / 2); + float nx = 2 * (c.r / 255.0f) - 1; + float ny = 2 * (c.g / 255.0f) - 1; + float nz = 0.0f; + if (1 - nx * nx - ny * ny > 0) nz = sqrtf(1 - nx * nx - ny * ny); + c.b = clamp(int(255.0f * (nz + 1) / 2.0f), 0, 255); + } } - return x; -} - -uint DirectDrawSurface::surfaceWidth(uint mipmap) const -{ - return mipmapExtent(mipmap, width()); -} - -uint DirectDrawSurface::surfaceHeight(uint mipmap) const -{ - return mipmapExtent(mipmap, height()); } -uint DirectDrawSurface::surfaceDepth(uint mipmap) const -{ - return mipmapExtent(mipmap, depth()); -} - -uint DirectDrawSurface::surfaceSize(uint mipmap) const -{ - uint w = surfaceWidth(mipmap); - uint h = surfaceHeight(mipmap); - uint d = surfaceDepth(mipmap); - - uint blockSize = header.blockSize(); - - if (blockSize == 0) { - uint bitCount = header.pixelSize(); - uint pitch = computeBytePitch(w, bitCount, 1); // Asuming 1 byte alignment, which is the same D3DX expects. - return pitch * h * d; - } - else { - w = (w + 3) / 4; - h = (h + 3) / 4; - //d = d; // @@ How are 3D textures aligned? - return blockSize * w * h * d; - } -} -uint DirectDrawSurface::faceSize() const +static bool readBlockImage(Image * img, uint8 * data, uint dxgiFormat, bool isNormalMap, bool swapRA) { - const uint count = mipmapCount(); - uint size = 0; + nvDebugCheck(img != NULL); + nvDebugCheck(data != NULL); - for (uint m = 0; m < count; m++) - { - size += surfaceSize(m); + switch (dxgiFormat) { + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + dxgiFormat = DXGI_FORMAT_BC1_UNORM; + break; + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + dxgiFormat = DXGI_FORMAT_BC2_UNORM; + break; + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + dxgiFormat = DXGI_FORMAT_BC3_UNORM; + break; + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + //case DXGI_FORMAT_BC4_SNORM; // Not supported. + dxgiFormat = DXGI_FORMAT_BC4_UNORM; + break; + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + //case DXGI_FORMAT_BC5_SNORM: // Not supported. + dxgiFormat = DXGI_FORMAT_BC5_UNORM; + break; + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + dxgiFormat = DXGI_FORMAT_BC6H_UF16; + break; + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + dxgiFormat = DXGI_FORMAT_BC7_UNORM; + break; + default: + return false; } - return size; -} + const uint w = img->width; + const uint h = img->height; + const uint d = img->depth; -uint DirectDrawSurface::offset(const uint face, const uint mipmap) -{ - uint size = 128; // sizeof(DDSHeader); + const uint bw = (w + 3) / 4; + const uint bh = (h + 3) / 4; - if (header.hasDX10Header()) + for (uint z = 0; z < d; z++) { - size += 20; // sizeof(DDSHeader10); - } + for (uint by = 0; by < bh; by++) + { + for (uint bx = 0; bx < bw; bx++) + { + ColorBlock block; - if (face != 0) - { - size += face * faceSize(); - } + // Read color block. + readBlock(&block, data, dxgiFormat, isNormalMap, swapRA); - for (uint m = 0; m < mipmap; m++) - { - size += surfaceSize(m); + // Write color block. + for (uint y = 0; y < min(4U, h - 4 * by); y++) + { + for (uint x = 0; x < min(4U, w - 4 * bx); x++) + { + img->pixel(4 * bx + x, 4 * by + y) = block.color(x, y); + } + } + } + } } - return size; + return true; } -void DirectDrawSurface::printInfo() const +bool nv::imageFromDDS(Image * img, DirectDrawSurface & dds, uint face, uint mipmap) { - printf("Flags: 0x%.8X\n", header.flags); - if (header.flags & DDSD_CAPS) printf("\tDDSD_CAPS\n"); - if (header.flags & DDSD_PIXELFORMAT) printf("\tDDSD_PIXELFORMAT\n"); - if (header.flags & DDSD_WIDTH) printf("\tDDSD_WIDTH\n"); - if (header.flags & DDSD_HEIGHT) printf("\tDDSD_HEIGHT\n"); - if (header.flags & DDSD_DEPTH) printf("\tDDSD_DEPTH\n"); - if (header.flags & DDSD_PITCH) printf("\tDDSD_PITCH\n"); - if (header.flags & DDSD_LINEARSIZE) printf("\tDDSD_LINEARSIZE\n"); - if (header.flags & DDSD_MIPMAPCOUNT) printf("\tDDSD_MIPMAPCOUNT\n"); + if (!dds.isValid()) return false; - printf("Height: %d\n", header.height); - printf("Width: %d\n", header.width); - printf("Depth: %d\n", header.depth); - if (header.flags & DDSD_PITCH) printf("Pitch: %d\n", header.pitch); - else if (header.flags & DDSD_LINEARSIZE) printf("Linear size: %d\n", header.pitch); - printf("Mipmap count: %d\n", header.mipmapcount); - - printf("Pixel Format:\n"); - printf("\tFlags: 0x%.8X\n", header.pf.flags); - if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n"); - if (header.pf.flags & DDPF_LUMINANCE) printf("\t\tDDPF_LUMINANCE\n"); - if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n"); - if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n"); - if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n"); - if (header.pf.flags & DDPF_PALETTEINDEXED1) printf("\t\tDDPF_PALETTEINDEXED1\n"); - if (header.pf.flags & DDPF_PALETTEINDEXED2) printf("\t\tDDPF_PALETTEINDEXED2\n"); - if (header.pf.flags & DDPF_PALETTEINDEXED4) printf("\t\tDDPF_PALETTEINDEXED4\n"); - if (header.pf.flags & DDPF_PALETTEINDEXED8) printf("\t\tDDPF_PALETTEINDEXED8\n"); - if (header.pf.flags & DDPF_ALPHAPREMULT) printf("\t\tDDPF_ALPHAPREMULT\n"); - if (header.pf.flags & DDPF_NORMAL) printf("\t\tDDPF_NORMAL\n"); + uint size = dds.surfaceSize(mipmap); + uint8 * data = malloc(size); + defer { free(data); }; - if (header.pf.fourcc != 0) { - // Display fourcc code even when DDPF_FOURCC flag not set. - printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n", - ((header.pf.fourcc >> 0) & 0xFF), - ((header.pf.fourcc >> 8) & 0xFF), - ((header.pf.fourcc >> 16) & 0xFF), - ((header.pf.fourcc >> 24) & 0xFF), - header.pf.fourcc); + if (!dds.readSurface(face, mipmap, data, size)) { + return false; } - if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0)) + uint w = dds.surfaceWidth(mipmap); + uint h = dds.surfaceHeight(mipmap); + uint d = dds.surfaceDepth(mipmap); + + img->allocate(w, h, d); + + if (dds.hasAlpha()) { - printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n", - (header.pf.bitcount >> 0) & 0xFF, - (header.pf.bitcount >> 8) & 0xFF, - (header.pf.bitcount >> 16) & 0xFF, - (header.pf.bitcount >> 24) & 0xFF, - header.pf.bitcount); + img->format = Image::Format_ARGB; } else { - printf("\tBit count: %d\n", header.pf.bitcount); + img->format = Image::Format_XRGB; } - printf("\tRed mask: 0x%.8X\n", header.pf.rmask); - printf("\tGreen mask: 0x%.8X\n", header.pf.gmask); - printf("\tBlue mask: 0x%.8X\n", header.pf.bmask); - printf("\tAlpha mask: 0x%.8X\n", header.pf.amask); - - printf("Caps:\n"); - printf("\tCaps 1: 0x%.8X\n", header.caps.caps1); - if (header.caps.caps1 & DDSCAPS_COMPLEX) printf("\t\tDDSCAPS_COMPLEX\n"); - if (header.caps.caps1 & DDSCAPS_TEXTURE) printf("\t\tDDSCAPS_TEXTURE\n"); - if (header.caps.caps1 & DDSCAPS_MIPMAP) printf("\t\tDDSCAPS_MIPMAP\n"); + img->sRGB = dds.isColorsRGB(); - printf("\tCaps 2: 0x%.8X\n", header.caps.caps2); - if (header.caps.caps2 & DDSCAPS2_VOLUME) printf("\t\tDDSCAPS2_VOLUME\n"); - else if (header.caps.caps2 & DDSCAPS2_CUBEMAP) + if (dds.header.isBlockFormat()) { - printf("\t\tDDSCAPS2_CUBEMAP\n"); - if ((header.caps.caps2 & DDSCAPS2_CUBEMAP_ALL_FACES) == DDSCAPS2_CUBEMAP_ALL_FACES) printf("\t\tDDSCAPS2_CUBEMAP_ALL_FACES\n"); + bool isNormalMap = false; + bool swapRA = false; + uint dxgiFormat = DXGI_FORMAT_UNKNOWN; + if (dds.header.hasDX10Header()) { + dxgiFormat = dds.header.header10.dxgiFormat; + } else { - if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEX) printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEX\n"); - if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEX\n"); - if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEY\n"); - if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEY\n"); - if (header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) printf("\t\tDDSCAPS2_CUBEMAP_POSITIVEZ\n"); - if (header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) printf("\t\tDDSCAPS2_CUBEMAP_NEGATIVEZ\n"); + switch (dds.header.pf.fourcc) { + case FOURCC_DXT1: dxgiFormat = DXGI_FORMAT_BC1_UNORM; break; + case FOURCC_DXT3: dxgiFormat = DXGI_FORMAT_BC2_UNORM; break; + case FOURCC_DXT5: dxgiFormat = DXGI_FORMAT_BC3_UNORM; break; + case FOURCC_ATI1: dxgiFormat = DXGI_FORMAT_BC4_UNORM; break; + case FOURCC_ATI2: dxgiFormat = DXGI_FORMAT_BC5_UNORM; break; + case FOURCC_RXGB: dxgiFormat = DXGI_FORMAT_BC3_UNORM; swapRA = true; break; + } } - } - - printf("\tCaps 3: 0x%.8X\n", header.caps.caps3); - printf("\tCaps 4: 0x%.8X\n", header.caps.caps4); + if (dds.header.pf.flags & DDPF_NORMAL) isNormalMap = true; - if (header.hasDX10Header()) + return readBlockImage(img, data, dxgiFormat, isNormalMap, swapRA); + } + else { - printf("DX10 Header:\n"); - printf("\tDXGI Format: %u (%s)\n", header.header10.dxgiFormat, getDxgiFormatString((DXGI_FORMAT)header.header10.dxgiFormat)); - printf("\tResource dimension: %u (%s)\n", header.header10.resourceDimension, getD3d10ResourceDimensionString((DDS_DIMENSION)header.header10.resourceDimension)); - printf("\tMisc flag: %u\n", header.header10.miscFlag); - printf("\tArray size: %u\n", header.header10.arraySize); + if (dds.header.hasDX10Header()) + { + if (const RGBAPixelFormat *format = findDXGIPixelFormat(dds.header.header10.dxgiFormat)) { + return readLinearImage(img, data, format->bitcount, format->rmask, format->gmask, format->bmask, format->amask); + } + } + else + { + if (dds.header.pf.flags & DDPF_RGB) + { + return readLinearImage(img, data, dds.header.pf.bitcount, dds.header.pf.rmask, dds.header.pf.gmask, dds.header.pf.bmask, dds.header.pf.amask); + } + else if (dds.header.pf.flags & DDPF_FOURCC) + { + if (const RGBAPixelFormat *format = findD3D9PixelFormat(dds.header.pf.fourcc)) { + return readLinearImage(img, data, format->bitcount, format->rmask, format->gmask, format->bmask, format->amask); + } + } + } } - if (header.reserved[9] == FOURCC_NVTT) - { - int major = (header.reserved[10] >> 16) & 0xFF; - int minor = (header.reserved[10] >> 8) & 0xFF; - int revision= header.reserved[10] & 0xFF; + return false; // Not supported. +} - printf("Version:\n"); - printf("\tNVIDIA Texture Tools %d.%d.%d\n", major, minor, revision); - } +bool nv::imageFromDDS(FloatImage * img, DirectDrawSurface & dds, uint face, uint mipmap) +{ + if (!dds.isValid()) return false; - if (header.reserved[7] == FOURCC_UVER) - { - printf("User Version: %d\n", header.reserved[8]); + uint size = dds.surfaceSize(mipmap); + uint8 * data = malloc(size); + defer{ free(data); }; + + if (!dds.readSurface(face, mipmap, data, size)) { + return false; } + + uint w = dds.surfaceWidth(mipmap); + uint h = dds.surfaceHeight(mipmap); + uint d = dds.surfaceDepth(mipmap); + + // @@ + + return false; } + + + + +// Copyright NVIDIA Corporation 2007 -- Ignacio Castano +// Copyright (c) 2008-2020 -- Ignacio Castano +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/nvimage/DirectDrawSurface.h b/src/nvimage/DirectDrawSurface.h index 1049f067..b741ac47 100644 --- a/src/nvimage/DirectDrawSurface.h +++ b/src/nvimage/DirectDrawSurface.h @@ -1,29 +1,5 @@ -// Copyright NVIDIA Corporation 2007 -- Ignacio Castano -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - +// MIT license see full LICENSE text at end of file #pragma once -#ifndef NV_IMAGE_DIRECTDRAWSURFACE_H -#define NV_IMAGE_DIRECTDRAWSURFACE_H #include "nvimage.h" @@ -34,8 +10,8 @@ namespace nv { class Image; + class FloatImage; class Stream; - struct ColorBlock; enum DDPF { @@ -269,7 +245,6 @@ namespace nv }; extern uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); - extern uint findDXGIFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); struct RGBAPixelFormat @@ -281,9 +256,10 @@ namespace nv uint amask; }; + extern const RGBAPixelFormat *findD3D9PixelFormat(uint dxgiFormat); extern const RGBAPixelFormat *findDXGIPixelFormat(uint dxgiFormat); - struct NVIMAGE_CLASS DDSPixelFormat + struct DDSPixelFormat { uint size; uint flags; @@ -295,7 +271,7 @@ namespace nv uint amask; }; - struct NVIMAGE_CLASS DDSCaps + struct DDSCaps { uint caps1; uint caps2; @@ -304,7 +280,7 @@ namespace nv }; /// DDS file header for DX10. - struct NVIMAGE_CLASS DDSHeader10 + struct DDSHeader10 { uint dxgiFormat; uint resourceDimension; @@ -314,7 +290,7 @@ namespace nv }; /// DDS file header. - struct NVIMAGE_CLASS DDSHeader + struct DDSHeader { uint fourcc; uint size; @@ -369,16 +345,14 @@ namespace nv bool isBlockFormat() const; }; - NVIMAGE_API Stream & operator<< (Stream & s, DDSHeader & header); + Stream & operator<< (Stream & s, DDSHeader & header); /// DirectDraw Surface. (DDS) - class NVIMAGE_CLASS DirectDrawSurface + class DirectDrawSurface { public: DirectDrawSurface(); - DirectDrawSurface(const char * file); - DirectDrawSurface(Stream * stream); ~DirectDrawSurface(); bool load(const char * filename); @@ -388,6 +362,7 @@ namespace nv bool isSupported() const; bool hasAlpha() const; + bool isColorsRGB() const; uint mipmapCount() const; uint width() const; @@ -399,13 +374,12 @@ namespace nv bool isTexture3D() const; bool isTextureCube() const; bool isTextureArray() const; + bool isBlockFormat() const; void setNormalFlag(bool b); void setHasAlphaFlag(bool b); void setUserVersion(int version); - void mipmap(Image * img, uint f, uint m); - uint surfaceWidth(uint mipmap) const; uint surfaceHeight(uint mipmap) const; uint surfaceDepth(uint mipmap) const; @@ -422,15 +396,35 @@ namespace nv uint faceSize() const; uint offset(uint face, uint mipmap); - void readLinearImage(Image * img, uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); - void readBlockImage(Image * img); - void readBlock(ColorBlock * rgba); - - - private: Stream * stream; + //void * data; }; + bool imageFromDDS(Image * img, DirectDrawSurface & dds, uint face, uint mipmap); + bool imageFromDDS(FloatImage * img, DirectDrawSurface & dds, uint face, uint mipmap); + } // nv namespace -#endif // NV_IMAGE_DIRECTDRAWSURFACE_H +// Copyright NVIDIA Corporation 2007 -- Ignacio Castano +// Copyright (c) 2008-2020 -- Ignacio Castano +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/nvimage/ErrorMetric.cpp b/src/nvimage/ErrorMetric.cpp index 3f632efd..b4f0b42f 100644 --- a/src/nvimage/ErrorMetric.cpp +++ b/src/nvimage/ErrorMetric.cpp @@ -93,9 +93,9 @@ float nv::averageColorError(const FloatImage * ref, const FloatImage * img, bool float b1 = ref->pixel(i + count * 2); float a1 = ref->pixel(i + count * 3); - float r = fabs(r0 - r1); - float g = fabs(g0 - g1); - float b = fabs(b0 - b1); + float r = fabsf(r0 - r1); + float g = fabsf(g0 - g1); + float b = fabsf(b0 - b1); float a = 1; if (alphaWeight) a = a1; @@ -125,7 +125,7 @@ float nv::averageAlphaError(const FloatImage * ref, const FloatImage * img) float a = a0 - a1; - mae += fabs(a); + mae += fabsf(a); } return float(mae / count); diff --git a/src/nvimage/Filter.cpp b/src/nvimage/Filter.cpp index 183f1fb7..da92ba46 100644 --- a/src/nvimage/Filter.cpp +++ b/src/nvimage/Filter.cpp @@ -35,7 +35,9 @@ #include "Filter.h" +#include "nvmath/nvmath.h" #include "nvmath/Vector.h" // Vector4 + #include "nvcore/Utils.h" // swap #include // memset @@ -52,7 +54,7 @@ namespace return 1.0f + x*x*(-1.0f/6.0f + x*x*1.0f/120.0f); } else { - return sin(x) / x; + return sinf(x) / x; } } @@ -157,7 +159,7 @@ BoxFilter::BoxFilter(float width) : Filter(width) {} float BoxFilter::evaluate(float x) const { - if (fabs(x) <= m_width) return 1.0f; + if (fabsf(x) <= m_width) return 1.0f; else return 0.0f; } @@ -167,7 +169,7 @@ TriangleFilter::TriangleFilter(float width) : Filter(width) {} float TriangleFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < m_width ) return m_width - x; return 0.0f; } @@ -177,7 +179,7 @@ QuadraticFilter::QuadraticFilter() : Filter(1.5f) {} float QuadraticFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 0.5f ) return 0.75f - x * x; if( x < 1.5f ) { float t = x - 1.5f; @@ -192,7 +194,7 @@ CubicFilter::CubicFilter() : Filter(1.0f) {} float CubicFilter::evaluate(float x) const { // f(t) = 2|t|^3 - 3|t|^2 + 1, -1 <= t <= 1 - x = fabs(x); + x = fabsf(x); if( x < 1.0f ) return((2.0f * x - 3.0f) * x * x + 1.0f); return 0.0f; } @@ -202,7 +204,7 @@ BSplineFilter::BSplineFilter() : Filter(2.0f) {} float BSplineFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 1.0f ) return (4.0f + x * x * (-6.0f + x * 3.0f)) / 6.0f; if( x < 2.0f ) { float t = 2.0f - x; @@ -216,7 +218,7 @@ MitchellFilter::MitchellFilter() : Filter(2.0f) { setParameters(1.0f/3.0f, 1.0f/ float MitchellFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 1.0f ) return p0 + x * x * (p2 + x * p3); if( x < 2.0f ) return q0 + x * (q1 + x * (q2 + x * q3)); return 0.0f; @@ -238,7 +240,7 @@ LanczosFilter::LanczosFilter() : Filter(3.0f) {} float LanczosFilter::evaluate(float x) const { - x = fabs(x); + x = fabsf(x); if( x < 3.0f ) return sincf(PI * x) * sincf(PI * x / 3.0f); return 0.0f; } @@ -357,7 +359,7 @@ void Kernel2::normalize() { float total = 0.0f; for(uint i = 0; i < m_windowSize*m_windowSize; i++) { - total += fabs(m_data[i]); + total += fabsf(m_data[i]); } float inv = 1.0f / total; diff --git a/src/nvimage/Filter.h b/src/nvimage/Filter.h index ab814f15..dd478388 100644 --- a/src/nvimage/Filter.h +++ b/src/nvimage/Filter.h @@ -1,8 +1,5 @@ // This code is in the public domain -- castanyo@yahoo.es - #pragma once -#ifndef NV_IMAGE_FILTER_H -#define NV_IMAGE_FILTER_H #include "nvimage.h" #include "nvcore/Debug.h" @@ -12,7 +9,7 @@ namespace nv class Vector4; /// Base filter class. - class NVIMAGE_CLASS Filter + class Filter { public: Filter(float width); @@ -30,7 +27,7 @@ namespace nv }; // Box filter. - class NVIMAGE_CLASS BoxFilter : public Filter + class BoxFilter : public Filter { public: BoxFilter(); @@ -39,7 +36,7 @@ namespace nv }; // Triangle (bilinear/tent) filter. - class NVIMAGE_CLASS TriangleFilter : public Filter + class TriangleFilter : public Filter { public: TriangleFilter(); @@ -48,7 +45,7 @@ namespace nv }; // Quadratic (bell) filter. - class NVIMAGE_CLASS QuadraticFilter : public Filter + class QuadraticFilter : public Filter { public: QuadraticFilter(); @@ -56,7 +53,7 @@ namespace nv }; // Cubic filter from Thatcher Ulrich. - class NVIMAGE_CLASS CubicFilter : public Filter + class CubicFilter : public Filter { public: CubicFilter(); @@ -64,7 +61,7 @@ namespace nv }; // Cubic b-spline filter from Paul Heckbert. - class NVIMAGE_CLASS BSplineFilter : public Filter + class BSplineFilter : public Filter { public: BSplineFilter(); @@ -73,7 +70,7 @@ namespace nv /// Mitchell & Netravali's two-param cubic /// @see "Reconstruction Filters in Computer Graphics", SIGGRAPH 88 - class NVIMAGE_CLASS MitchellFilter : public Filter + class MitchellFilter : public Filter { public: MitchellFilter(); @@ -87,7 +84,7 @@ namespace nv }; // Lanczos3 filter. - class NVIMAGE_CLASS LanczosFilter : public Filter + class LanczosFilter : public Filter { public: LanczosFilter(); @@ -95,7 +92,7 @@ namespace nv }; // Sinc filter. - class NVIMAGE_CLASS SincFilter : public Filter + class SincFilter : public Filter { public: SincFilter(float w); @@ -103,7 +100,7 @@ namespace nv }; // Kaiser filter. - class NVIMAGE_CLASS KaiserFilter : public Filter + class KaiserFilter : public Filter { public: KaiserFilter(float w); @@ -132,7 +129,7 @@ namespace nv /// A 1D kernel. Used to precompute filter weights. - class NVIMAGE_CLASS Kernel1 + class Kernel1 { NV_FORBID_COPY(Kernel1); public: @@ -162,7 +159,7 @@ namespace nv /// A 2D kernel. - class NVIMAGE_CLASS Kernel2 + class Kernel2 { public: Kernel2(uint width); @@ -195,7 +192,7 @@ namespace nv /// A 1D polyphase kernel - class NVIMAGE_CLASS PolyphaseKernel + class PolyphaseKernel { NV_FORBID_COPY(PolyphaseKernel); public: @@ -230,5 +227,3 @@ namespace nv }; } // nv namespace - -#endif // NV_IMAGE_FILTER_H diff --git a/src/nvimage/FloatImage.cpp b/src/nvimage/FloatImage.cpp index f6113286..20a5452e 100644 --- a/src/nvimage/FloatImage.cpp +++ b/src/nvimage/FloatImage.cpp @@ -56,9 +56,9 @@ void FloatImage::initFrom(const Image * img) nvCheck(img != NULL); uint channel_count = 3; - if (img->format() == Image::Format_ARGB) channel_count = 4; + if (img->format == Image::Format_ARGB) channel_count = 4; - allocate(channel_count, img->width(), img->height(), img->depth()); + allocate(channel_count, img->width, img->height, img->depth); float * red_channel = channel(0); float * green_channel = channel(1); @@ -1393,7 +1393,7 @@ float FloatImage::alphaTestCoverage(float alphaRef, int alphaChannel, float alph return coverage / float(w * h); #else - const uint n = 8; + const uint n = 4; // If we want subsampling: for (uint y = 0; y < h-1; y++) { @@ -1404,18 +1404,20 @@ float FloatImage::alphaTestCoverage(float alphaRef, int alphaChannel, float alph float alpha01 = nv::saturate(pixel(alphaChannel, x+0, y+1, 0) * alphaScale); float alpha11 = nv::saturate(pixel(alphaChannel, x+1, y+1, 0) * alphaScale); + float texel_coverage = 0.0f; for (uint sy = 0; sy < n; sy++) { float fy = (sy + 0.5f) / n; for (uint sx = 0; sx < n; sx++) { float fx = (sx + 0.5f) / n; float alpha = alpha00 * (1 - fx) * (1 - fy) + alpha10 * fx * (1 - fy) + alpha01 * (1 - fx) * fy + alpha11 * fx * fy; - if (alpha > alphaRef) coverage += 1.0f; + if (alpha > alphaRef) texel_coverage += 1.0f; } } + coverage += texel_coverage / (n * n); } } - return coverage / float(w * h * n * n); + return coverage / float((w - 1) * (h - 1)); #endif } diff --git a/src/nvimage/FloatImage.h b/src/nvimage/FloatImage.h index 42cd86a3..2c1213ff 100644 --- a/src/nvimage/FloatImage.h +++ b/src/nvimage/FloatImage.h @@ -34,78 +34,78 @@ namespace nv WrapMode_Mirror }; - NVIMAGE_API FloatImage(); - NVIMAGE_API FloatImage(const FloatImage & img); - NVIMAGE_API FloatImage(const Image * img); - NVIMAGE_API virtual ~FloatImage(); + FloatImage(); + FloatImage(const FloatImage & img); + FloatImage(const Image * img); + ~FloatImage(); /** @name Conversion. */ //@{ - NVIMAGE_API void initFrom(const Image * img); - NVIMAGE_API Image * createImage(uint base_component = 0, uint num = 4) const; - NVIMAGE_API Image * createImageGammaCorrect(float gamma = 2.2f) const; + void initFrom(const Image * img); + Image * createImage(uint base_component = 0, uint num = 4) const; + Image * createImageGammaCorrect(float gamma = 2.2f) const; //@} /** @name Allocation. */ //@{ - NVIMAGE_API void allocate(uint c, uint w, uint h, uint d = 1); - NVIMAGE_API void free(); // Does not clear members. - NVIMAGE_API void resizeChannelCount(uint c); + void allocate(uint c, uint w, uint h, uint d = 1); + void free(); // Does not clear members. + void resizeChannelCount(uint c); //@} /** @name Manipulation. */ //@{ - NVIMAGE_API void clear(float f = 0.0f); - NVIMAGE_API void clear(uint component, float f = 0.0f); - NVIMAGE_API void copyChannel(uint src, uint dst); + void clear(float f = 0.0f); + void clear(uint component, float f = 0.0f); + void copyChannel(uint src, uint dst); - NVIMAGE_API void normalize(uint base_component); + void normalize(uint base_component); - NVIMAGE_API void packNormals(uint base_component); - NVIMAGE_API void expandNormals(uint base_component); - NVIMAGE_API void scaleBias(uint base_component, uint num, float scale, float add); + void packNormals(uint base_component); + void expandNormals(uint base_component); + void scaleBias(uint base_component, uint num, float scale, float add); - NVIMAGE_API void clamp(uint base_component, uint num, float low, float high); + void clamp(uint base_component, uint num, float low, float high); - NVIMAGE_API void toLinear(uint base_component, uint num, float gamma = 2.2f); - NVIMAGE_API void toGamma(uint base_component, uint num, float gamma = 2.2f); - NVIMAGE_API void exponentiate(uint base_component, uint num, float power); + void toLinear(uint base_component, uint num, float gamma = 2.2f); + void toGamma(uint base_component, uint num, float gamma = 2.2f); + void exponentiate(uint base_component, uint num, float power); - NVIMAGE_API void transform(uint base_component, const Matrix & m, const Vector4 & offset); - NVIMAGE_API void swizzle(uint base_component, uint r, uint g, uint b, uint a); + void transform(uint base_component, const Matrix & m, const Vector4 & offset); + void swizzle(uint base_component, uint r, uint g, uint b, uint a); - NVIMAGE_API FloatImage * fastDownSample() const; - NVIMAGE_API FloatImage * downSample(const Filter & filter, WrapMode wm) const; - NVIMAGE_API FloatImage * downSample(const Filter & filter, WrapMode wm, uint alpha) const; - NVIMAGE_API FloatImage * resize(const Filter & filter, uint w, uint h, WrapMode wm) const; - NVIMAGE_API FloatImage * resize(const Filter & filter, uint w, uint h, uint d, WrapMode wm) const; - NVIMAGE_API FloatImage * resize(const Filter & filter, uint w, uint h, WrapMode wm, uint alpha) const; - NVIMAGE_API FloatImage * resize(const Filter & filter, uint w, uint h, uint d, WrapMode wm, uint alpha) const; + FloatImage * fastDownSample() const; + FloatImage * downSample(const Filter & filter, WrapMode wm) const; + FloatImage * downSample(const Filter & filter, WrapMode wm, uint alpha) const; + FloatImage * resize(const Filter & filter, uint w, uint h, WrapMode wm) const; + FloatImage * resize(const Filter & filter, uint w, uint h, uint d, WrapMode wm) const; + FloatImage * resize(const Filter & filter, uint w, uint h, WrapMode wm, uint alpha) const; + FloatImage * resize(const Filter & filter, uint w, uint h, uint d, WrapMode wm, uint alpha) const; - NVIMAGE_API void convolve(const Kernel2 & k, uint c, WrapMode wm); + void convolve(const Kernel2 & k, uint c, WrapMode wm); - //NVIMAGE_API FloatImage * downSample(const Kernel1 & filter, WrapMode wm) const; - //NVIMAGE_API FloatImage * downSample(const Kernel1 & filter, uint w, uint h, WrapMode wm) const; + //FloatImage * downSample(const Kernel1 & filter, WrapMode wm) const; + //FloatImage * downSample(const Kernel1 & filter, uint w, uint h, WrapMode wm) const; //@} - NVIMAGE_API float applyKernelXY(const Kernel2 * k, int x, int y, int z, uint c, WrapMode wm) const; - NVIMAGE_API float applyKernelX(const Kernel1 * k, int x, int y, int z, uint c, WrapMode wm) const; - NVIMAGE_API float applyKernelY(const Kernel1 * k, int x, int y, int z, uint c, WrapMode wm) const; - NVIMAGE_API float applyKernelZ(const Kernel1 * k, int x, int y, int z, uint c, WrapMode wm) const; - NVIMAGE_API void applyKernelX(const PolyphaseKernel & k, int y, int z, uint c, WrapMode wm, float * output) const; - NVIMAGE_API void applyKernelY(const PolyphaseKernel & k, int x, int z, uint c, WrapMode wm, float * output, int output_stride) const; - NVIMAGE_API void applyKernelZ(const PolyphaseKernel & k, int x, int y, uint c, WrapMode wm, float * output) const; - NVIMAGE_API void applyKernelX(const PolyphaseKernel & k, int y, int z, uint c, uint a, WrapMode wm, float * output) const; - NVIMAGE_API void applyKernelY(const PolyphaseKernel & k, int x, int z, uint c, uint a, WrapMode wm, float * output, int output_stride) const; - NVIMAGE_API void applyKernelZ(const PolyphaseKernel & k, int x, int y, uint c, uint a, WrapMode wm, float * output) const; + float applyKernelXY(const Kernel2 * k, int x, int y, int z, uint c, WrapMode wm) const; + float applyKernelX(const Kernel1 * k, int x, int y, int z, uint c, WrapMode wm) const; + float applyKernelY(const Kernel1 * k, int x, int y, int z, uint c, WrapMode wm) const; + float applyKernelZ(const Kernel1 * k, int x, int y, int z, uint c, WrapMode wm) const; + void applyKernelX(const PolyphaseKernel & k, int y, int z, uint c, WrapMode wm, float * output) const; + void applyKernelY(const PolyphaseKernel & k, int x, int z, uint c, WrapMode wm, float * output, int output_stride) const; + void applyKernelZ(const PolyphaseKernel & k, int x, int y, uint c, WrapMode wm, float * output) const; + void applyKernelX(const PolyphaseKernel & k, int y, int z, uint c, uint a, WrapMode wm, float * output) const; + void applyKernelY(const PolyphaseKernel & k, int x, int z, uint c, uint a, WrapMode wm, float * output, int output_stride) const; + void applyKernelZ(const PolyphaseKernel & k, int x, int y, uint c, uint a, WrapMode wm, float * output) const; - NVIMAGE_API void flipX(); - NVIMAGE_API void flipY(); - NVIMAGE_API void flipZ(); + void flipX(); + void flipY(); + void flipZ(); - NVIMAGE_API float alphaTestCoverage(float alphaRef, int alphaChannel, float alphaScale = 1.0f) const; - NVIMAGE_API void scaleAlphaToCoverage(float coverage, float alphaRef, int alphaChannel); + float alphaTestCoverage(float alphaRef, int alphaChannel, float alphaScale = 1.0f) const; + void scaleAlphaToCoverage(float coverage, float alphaRef, int alphaChannel); uint width() const { return m_width; } diff --git a/src/nvimage/Image.cpp b/src/nvimage/Image.cpp index 0ac84a60..629d184a 100644 --- a/src/nvimage/Image.cpp +++ b/src/nvimage/Image.cpp @@ -15,15 +15,11 @@ using namespace nv; -Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(NULL) +Image::Image(const Image & img) { -} - -Image::Image(const Image & img) : m_data(NULL) -{ - allocate(img.m_width, img.m_height, img.m_depth); - m_format = img.m_format; - memcpy(m_data, img.m_data, sizeof(Color32) * m_width * m_height * m_depth); + allocate(img.width, img.height, img.depth); + format = img.format; + memcpy(data, img.data, sizeof(Color32) * width * height * depth); } Image::~Image() @@ -33,28 +29,35 @@ Image::~Image() const Image & Image::operator=(const Image & img) { - allocate(img.m_width, img.m_height, m_depth); - m_format = img.m_format; - memcpy(m_data, img.m_data, sizeof(Color32) * m_width * m_height * m_depth); + allocate(img.width, img.height, depth); + format = img.format; + memcpy(data, img.data, sizeof(Color32) * width * height * depth); return *this; } void Image::allocate(uint w, uint h, uint d/*= 1*/) { - m_width = w; - m_height = h; - m_depth = d; - m_data = realloc(m_data, w * h * d); + width = w; + height = h; + depth = d; + data = realloc(data, w * h * d); } void Image::acquire(Color32 * data, uint w, uint h, uint d/*= 1*/) { free(); - m_width = w; - m_height = h; - m_depth = d; - m_data = data; + width = w; + height = h; + depth = d; + this->data = data; +} + +void Image::free() +{ + ::free(data); + width = height = depth = 0; + data = NULL; } void Image::resize(uint w, uint h, uint d/*= 1*/) { @@ -66,9 +69,9 @@ void Image::resize(uint w, uint h, uint d/*= 1*/) { // Copy image. uint x, y, z; - for(z = 0; z < min(d, m_depth); z++) { - for(y = 0; y < min(h, m_height); y++) { - for(x = 0; x < min(w, m_width); x++) { + for(z = 0; z < min(d, depth); z++) { + for(y = 0; y < min(h, height); y++) { + for(x = 0; x < min(w, width); x++) { img.pixel(x, y, z) = pixel(x, y, z); } for(; x < w; x++) { @@ -89,11 +92,12 @@ void Image::resize(uint w, uint h, uint d/*= 1*/) { } } - swap(m_width, img.m_width); - swap(m_height, img.m_height); - swap(m_depth, img.m_depth); - swap(m_format, img.m_format); - swap(m_data, img.m_data); + swap(width, img.width); + swap(height, img.height); + swap(depth, img.depth); + swap(format, img.format); + swap(sRGB, img.sRGB); + swap(data, img.data); } bool Image::load(const char * name) @@ -105,106 +109,74 @@ bool Image::load(const char * name) return false; } - swap(m_width, img->m_width); - swap(m_height, img->m_height); - swap(m_depth, img->m_depth); - swap(m_format, img->m_format); - swap(m_data, img->m_data); + swap(width, img->width); + swap(height, img->height); + swap(depth, img->depth); + swap(format, img->format); + swap(sRGB, img->sRGB); + swap(data, img->data); return true; } -void Image::wrap(void * data, uint w, uint h, uint d) +void Image::wrap(void * _data, uint w, uint h, uint d) { free(); - m_data = (Color32 *)data; - m_width = w; - m_height = h; - m_depth = d; + data = (Color32 *)_data; + width = w; + height = h; + depth = d; } void Image::unwrap() { - m_data = NULL; - m_width = 0; - m_height = 0; - m_depth = 0; -} - - -void Image::free() -{ - ::free(m_data); - m_data = NULL; -} - - -uint Image::width() const -{ - return m_width; + data = NULL; + width = 0; + height = 0; + depth = 0; } -uint Image::height() const -{ - return m_height; -} - -uint Image::depth() const -{ - return m_depth; -} const Color32 * Image::scanline(uint h) const { - nvDebugCheck(h < m_height); - return m_data + h * m_width; + nvDebugCheck(h < height); + return data + h * width; } Color32 * Image::scanline(uint h) { - nvDebugCheck(h < m_height); - return m_data + h * m_width; + nvDebugCheck(h < height); + return data + h * width; } const Color32 * Image::pixels() const { - return m_data; + return data; } Color32 * Image::pixels() { - return m_data; + return data; } const Color32 & Image::pixel(uint idx) const { - nvDebugCheck(idx < m_width * m_height * m_depth); - return m_data[idx]; + nvDebugCheck(idx < width * height * depth); + return data[idx]; } Color32 & Image::pixel(uint idx) { - nvDebugCheck(idx < m_width * m_height * m_depth); - return m_data[idx]; -} - - -Image::Format Image::format() const -{ - return m_format; -} - -void Image::setFormat(Image::Format f) -{ - m_format = f; + nvDebugCheck(idx < width * height * depth); + return data[idx]; } void Image::fill(Color32 c) { - const uint size = m_width * m_height * m_depth; + const uint size = width * height * depth; for (uint i = 0; i < size; ++i) { - m_data[i] = c; + data[i] = c; } } diff --git a/src/nvimage/Image.h b/src/nvimage/Image.h index e8f6fa6c..901526cc 100644 --- a/src/nvimage/Image.h +++ b/src/nvimage/Image.h @@ -1,8 +1,5 @@ // This code is in the public domain -- castanyo@yahoo.es - #pragma once -#ifndef NV_IMAGE_IMAGE_H -#define NV_IMAGE_IMAGE_H #include "nvimage.h" #include "nvcore/Debug.h" @@ -15,18 +12,17 @@ namespace nv { class Color32; - /// 32 bit RGBA image. - class NVIMAGE_CLASS Image + // 32 bit ARGB image. + class Image { public: - enum Format - { - Format_RGB, + enum Format : uint8 { + Format_XRGB, Format_ARGB, }; - Image(); + Image() {} Image(const Image & img); ~Image(); @@ -36,16 +32,13 @@ namespace nv void allocate(uint w, uint h, uint d = 1); void acquire(Color32 * data, uint w, uint h, uint d = 1); bool load(const char * name); + void free(); void resize(uint w, uint h, uint d = 1); void wrap(void * data, uint w, uint h, uint d = 1); void unwrap(); - uint width() const; - uint height() const; - uint depth() const; - const Color32 * scanline(uint h) const; Color32 * scanline(uint h); @@ -58,36 +51,28 @@ namespace nv const Color32 & pixel(uint x, uint y, uint z = 0) const; Color32 & pixel(uint x, uint y, uint z = 0); - Format format() const; - void setFormat(Format f); - void fill(Color32 c); - private: - void free(); - private: - uint m_width; - uint m_height; - uint m_depth; - Format m_format; - Color32 * m_data; + uint width = 0; + uint height = 0; + uint depth = 0; + Format format = Format_XRGB; + bool sRGB = false; + Color32 * data = NULL; }; inline const Color32 & Image::pixel(uint x, uint y, uint z) const { - nvDebugCheck(x < m_width && y < m_height && z < m_depth); - return pixel((z * m_height + y) * m_width + x); + nvDebugCheck(x < width && y < height && z < depth); + return pixel((z * height + y) * width + x); } inline Color32 & Image::pixel(uint x, uint y, uint z) { - nvDebugCheck(x < m_width && y < m_height && z < m_depth); - return pixel((z * m_height + y) * m_width + x); + nvDebugCheck(x < width && y < height && z < depth); + return pixel((z * height + y) * width + x); } } // nv namespace - - -#endif // NV_IMAGE_IMAGE_H diff --git a/src/nvimage/ImageIO.cpp b/src/nvimage/ImageIO.cpp index 047cf395..f4c0b13c 100644 --- a/src/nvimage/ImageIO.cpp +++ b/src/nvimage/ImageIO.cpp @@ -55,8 +55,15 @@ extern "C" { #endif #if defined(NV_HAVE_STBIMAGE) +# define STB_IMAGE_STATIC // To avoid conflicts with users importing stb_image on their own. +# define STB_IMAGE_IMPLEMENTATION # define STBI_NO_STDIO -# include +# include "stb_image.h" + +//# define STB_IMAGE_WRITE_STATIC +//# define STB_IMAGE_WRITE_IMPLEMENTATION +//# define STBI_WRITE_NO_STDIO +//# include "stb_image_write.h" #endif @@ -64,7 +71,7 @@ using namespace nv; -struct Color555 { +/*struct Color555 { uint16 b : 5; uint16 g : 5; uint16 r : 5; @@ -194,7 +201,7 @@ static Image * loadTGA(Stream & s) } } else if( grey ) { - img->setFormat(Image::Format_ARGB); + img->format = Image::Format_ARGB; for( int y = 0; y < tga.height; y++ ) { for( int x = 0; x < tga.width; x++ ) { @@ -229,7 +236,7 @@ static Image * loadTGA(Stream & s) } } else if( tga.pixel_size == 32 ) { - img->setFormat(Image::Format_ARGB); + img->format = Image::Format_ARGB; for( int y = 0; y < tga.height; y++ ) { for( int x = 0; x < tga.width; x++ ) { @@ -246,6 +253,7 @@ static Image * loadTGA(Stream & s) return img.release(); } +*/ // Save TGA image. static bool saveTGA(Stream & s, const Image * img) @@ -265,9 +273,9 @@ static bool saveTGA(Stream & s, const Image * img) tga.head.x_origin = 0; tga.head.y_origin = 0; - tga.head.width = img->width(); - tga.head.height = img->height(); - if(img->format() == Image::Format_ARGB) { + tga.head.width = img->width; + tga.head.height = img->height; + if(img->format == Image::Format_ARGB) { tga.head.pixel_size = 32; tga.head.flags = TGA_ORIGIN_UPPER | TGA_HAS_ALPHA; } @@ -279,8 +287,8 @@ static bool saveTGA(Stream & s, const Image * img) // @@ Serialize directly. tga.allocate(); - const uint n = img->width() * img->height(); - if(img->format() == Image::Format_ARGB) { + const uint n = img->width * img->height; + if(img->format == Image::Format_ARGB) { for(uint i = 0; i < n; i++) { Color32 color = img->pixel(i); tga.mem[4 * i + 0] = color.b; @@ -305,13 +313,13 @@ static bool saveTGA(Stream & s, const Image * img) return true; } -#pragma optimize("", off) +/*#pragma optimize("", off) // Save BMP image. static bool saveBMP(Stream & s, const Image * img) { - int w = img->width(); - int h = img->height(); + int w = img->width; + int h = img->height; int image_size = w * h * 3; BmpFileHeader header; @@ -348,7 +356,7 @@ static bool saveBMP(Stream & s, const Image * img) } return true; -} +}*/ /*static Image * loadPPM(Stream & s) { @@ -362,8 +370,8 @@ static bool savePPM(Stream & s, const Image * img) //if (img->depth() != 1) return false; //if (img->format() == Image::Format_ARGB) return false; - uint w = img->width(); - uint h = img->height(); + uint w = img->width; + uint h = img->height; TextWriter writer(&s); writer.format("P6\n"); @@ -392,7 +400,7 @@ static bool savePPM(Stream & s, const Image * img) }*/ // Load PSD image. -static Image * loadPSD(Stream & s) +/*static Image * loadPSD(Stream & s) { nvCheck(!s.isError()); nvCheck(s.isLoading()); @@ -453,7 +461,7 @@ static Image * loadPSD(Stream & s) else { // Enable alpha. - img->setFormat(Image::Format_ARGB); + img->format = Image::Format_ARGB; // Ignore remaining channels. channel_num = 4; @@ -541,7 +549,7 @@ static Image * loadPSD(Stream & s) } return img.release(); -} +}*/ static FloatImage * loadFloatDDS(Stream & s) { @@ -1755,14 +1763,14 @@ static Image * loadSTB(Stream & s) uint8 * data = stbi_load_from_memory(buffer, size, &w, &h, &n, 4); // @@ Hack: STB is returning n=4, because we request 4 components, even when input only has 3. - n = 3; + //n = 3; delete [] buffer; if (data != NULL) { Image * img = new Image; img->acquire((Color32 *)data, w, h); - img->setFormat(n == 4 ? Image::Format_ARGB : Image::Format_RGB); + img->format = (n == 4) ? Image::Format_ARGB : Image::Format_XRGB; int count = w * h; for (int i = 0; i < count; ++i) { @@ -1836,13 +1844,13 @@ Image * nv::ImageIO::load(const char * fileName, Stream & s) const char * extension = Path::extension(fileName); - if (strCaseDiff(extension, ".tga") == 0) { + /*if (strCaseDiff(extension, ".tga") == 0) { return loadTGA(s); - } + }*/ - if (strCaseDiff(extension, ".psd") == 0) { + /*if (strCaseDiff(extension, ".psd") == 0) { return loadPSD(s); - } + }*/ /*if (strCaseDiff(extension, ".ppm") == 0) { return loadPPM(s); @@ -1883,9 +1891,9 @@ bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, con const char * extension = Path::extension(fileName); - if (strCaseDiff(extension, ".bmp") == 0) { + /*if (strCaseDiff(extension, ".bmp") == 0) { return saveBMP(s, img); - } + }*/ if (strCaseDiff(extension, ".tga") == 0) { return saveTGA(s, img); @@ -2026,7 +2034,7 @@ bool nv::ImageIO::saveFloat(const char * fileName, Stream & s, const FloatImage if (componentCount == 1) { Color32 * c = image->pixels(); - const uint count = image->width() * image->height(); + const uint count = image->width * image->height; for (uint i = 0; i < count; i++) { c[i].b = c[i].g = c[i].r; @@ -2035,7 +2043,7 @@ bool nv::ImageIO::saveFloat(const char * fileName, Stream & s, const FloatImage if (componentCount == 4) { - image->setFormat(Image::Format_ARGB); + image->format = Image::Format_ARGB; } return ImageIO::save(fileName, s, image.ptr()); diff --git a/src/nvimage/ImageIO.h b/src/nvimage/ImageIO.h index 25490ab3..3911f7d2 100644 --- a/src/nvimage/ImageIO.h +++ b/src/nvimage/ImageIO.h @@ -1,14 +1,8 @@ // This code is in the public domain -- castanyo@yahoo.es - #pragma once -#ifndef NV_IMAGE_IMAGEIO_H -#define NV_IMAGE_IMAGEIO_H #include "nvimage.h" -#include "nvcore/StrLib.h" - - namespace nv { class Image; @@ -17,21 +11,18 @@ namespace nv namespace ImageIO { - NVIMAGE_API Image * load(const char * fileName); - NVIMAGE_API Image * load(const char * fileName, Stream & s); + Image * load(const char * fileName); + Image * load(const char * fileName, Stream & s); - NVIMAGE_API FloatImage * loadFloat(const char * fileName); - NVIMAGE_API FloatImage * loadFloat(const char * fileName, Stream & s); + FloatImage * loadFloat(const char * fileName); + FloatImage * loadFloat(const char * fileName, Stream & s); - NVIMAGE_API bool save(const char * fileName, const Image * img, const char ** tags=NULL); // NULL terminated list. - NVIMAGE_API bool save(const char * fileName, Stream & s, const Image * img, const char ** tags=NULL); + bool save(const char * fileName, const Image * img, const char ** tags=NULL); // NULL terminated list. + bool save(const char * fileName, Stream & s, const Image * img, const char ** tags=NULL); - NVIMAGE_API bool saveFloat(const char * fileName, const FloatImage * fimage, uint baseComponent, uint componentCount); - NVIMAGE_API bool saveFloat(const char * fileName, Stream & s, const FloatImage * fimage, uint baseComponent, uint componentCount); + bool saveFloat(const char * fileName, const FloatImage * fimage, uint baseComponent, uint componentCount); + bool saveFloat(const char * fileName, Stream & s, const FloatImage * fimage, uint baseComponent, uint componentCount); } // ImageIO namespace } // nv namespace - - -#endif // NV_IMAGE_IMAGEIO_H diff --git a/src/nvimage/KtxFile.h b/src/nvimage/KtxFile.h index b1b36743..555bd349 100644 --- a/src/nvimage/KtxFile.h +++ b/src/nvimage/KtxFile.h @@ -130,7 +130,7 @@ namespace nv }; - NVIMAGE_API Stream & operator<< (Stream & s, KtxHeader & header); + Stream & operator<< (Stream & s, KtxHeader & header); /* struct KtxFile { diff --git a/src/nvimage/NormalMap.cpp b/src/nvimage/NormalMap.cpp index 754166a8..b8215cf3 100644 --- a/src/nvimage/NormalMap.cpp +++ b/src/nvimage/NormalMap.cpp @@ -43,8 +43,8 @@ static FloatImage * createNormalMap(const Image * img, FloatImage::WrapMode wm, nvDebugCheck(kdv != NULL); nvDebugCheck(img != NULL); - const uint w = img->width(); - const uint h = img->height(); + const uint w = img->width; + const uint h = img->height; AutoPtr fimage(new FloatImage()); fimage->allocate(4, w, h); diff --git a/src/nvimage/Quantize.cpp b/src/nvimage/Quantize.cpp index 4aaf3bb8..64842ef4 100644 --- a/src/nvimage/Quantize.cpp +++ b/src/nvimage/Quantize.cpp @@ -32,8 +32,8 @@ void nv::Quantize::BinaryAlpha( Image * image, int alpha_threshold /*= 127*/ ) { nvCheck(image != NULL); - const uint w = image->width(); - const uint h = image->height(); + const uint w = image->width; + const uint h = image->height; for(uint y = 0; y < h; y++) { for(uint x = 0; x < w; x++) { @@ -76,8 +76,8 @@ void nv::Quantize::FloydSteinberg_BinaryAlpha( Image * image, int alpha_threshol { nvCheck(image != NULL); - const uint w = image->width(); - const uint h = image->height(); + const uint w = image->width; + const uint h = image->height; // @@ Use fixed point? float * row0 = new float[(w+2)]; @@ -130,8 +130,8 @@ void nv::Quantize::Truncate(Image * image, uint rsize, uint gsize, uint bsize, u { nvCheck(image != NULL); - const uint w = image->width(); - const uint h = image->height(); + const uint w = image->width; + const uint h = image->height; for(uint y = 0; y < h; y++) { for(uint x = 0; x < w; x++) { @@ -163,8 +163,8 @@ void nv::Quantize::FloydSteinberg(Image * image, uint rsize, uint gsize, uint bs { nvCheck(image != NULL); - const uint w = image->width(); - const uint h = image->height(); + const uint w = image->width; + const uint h = image->height; Vector4 * row0 = new Vector4[w+2]; Vector4 * row1 = new Vector4[w+2]; diff --git a/src/nvimage/ValveTextureFormat.h b/src/nvimage/ValveTextureFormat.h deleted file mode 100644 index 7b62ef7d..00000000 --- a/src/nvimage/ValveTextureFormat.h +++ /dev/null @@ -1,122 +0,0 @@ - -/* -For more info: -http://developer.valvesoftware.com/wiki/VTF - -File Layout: - VTF Header - VTF Low Resolution Image Data - For Each Mipmap (Smallest to Largest) - For Each Frame (First to Last) - For Each Face (First to Last) - For Each Z Slice (Min to Max; Varies with Mipmap) - VTF High Resolution Image Data - - -*/ - - -enum -{ - IMAGE_FORMAT_NONE = -1, - IMAGE_FORMAT_RGBA8888 = 0, - IMAGE_FORMAT_ABGR8888, - IMAGE_FORMAT_RGB888, - IMAGE_FORMAT_BGR888, - IMAGE_FORMAT_RGB565, - IMAGE_FORMAT_I8, - IMAGE_FORMAT_IA88, - IMAGE_FORMAT_P8, - IMAGE_FORMAT_A8, - IMAGE_FORMAT_RGB888_BLUESCREEN, - IMAGE_FORMAT_BGR888_BLUESCREEN, - IMAGE_FORMAT_ARGB8888, - IMAGE_FORMAT_BGRA8888, - IMAGE_FORMAT_DXT1, - IMAGE_FORMAT_DXT3, - IMAGE_FORMAT_DXT5, - IMAGE_FORMAT_BGRX8888, - IMAGE_FORMAT_BGR565, - IMAGE_FORMAT_BGRX5551, - IMAGE_FORMAT_BGRA4444, - IMAGE_FORMAT_DXT1_ONEBITALPHA, - IMAGE_FORMAT_BGRA5551, - IMAGE_FORMAT_UV88, - IMAGE_FORMAT_UVWQ8888, - IMAGE_FORMAT_RGBA16161616F, - IMAGE_FORMAT_RGBA16161616, - IMAGE_FORMAT_UVLX8888, - IMAGE_FORMAT_R32F, //!< = Luminance - 32 bpp - IMAGE_FORMAT_RGB323232F, //!< = Red, Green, Blue - 96 bpp - IMAGE_FORMAT_RGBA32323232F, //!< = Red, Green, Blue, Alpha - 128 bpp - IMAGE_FORMAT_NV_DST16, - IMAGE_FORMAT_NV_DST24, - IMAGE_FORMAT_NV_INTZ, - IMAGE_FORMAT_NV_RAWZ, - IMAGE_FORMAT_ATI_DST16, - IMAGE_FORMAT_ATI_DST24, - IMAGE_FORMAT_NV_NULL, - IMAGE_FORMAT_ATI2N, - IMAGE_FORMAT_ATI1N, -}; - - -enum -{ - TEXTUREFLAGS_POINTSAMPLE = 0x00000001, - TEXTUREFLAGS_TRILINEAR = 0x00000002, - TEXTUREFLAGS_CLAMPS = 0x00000004, - TEXTUREFLAGS_CLAMPT = 0x00000008, - TEXTUREFLAGS_ANISOTROPIC = 0x00000010, - TEXTUREFLAGS_HINT_DXT5 = 0x00000020, - TEXTUREFLAGS_NOCOMPRESS = 0x00000040, - TEXTUREFLAGS_NORMAL = 0x00000080, - TEXTUREFLAGS_NOMIP = 0x00000100, - TEXTUREFLAGS_NOLOD = 0x00000200, - TEXTUREFLAGS_MINMIP = 0x00000400, - TEXTUREFLAGS_PROCEDURAL = 0x00000800, - TEXTUREFLAGS_ONEBITALPHA = 0x00001000, - TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000, - TEXTUREFLAGS_ENVMAP = 0x00004000, - TEXTUREFLAGS_RENDERTARGET = 0x00008000, - TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000, - TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000, - TEXTUREFLAGS_SINGLECOPY = 0x00040000, - TEXTUREFLAGS_ONEOVERMIPLEVELINALPHA = 0x00080000, - TEXTUREFLAGS_PREMULTCOLORBYONEOVERMIPLEVEL = 0x00100000, - TEXTUREFLAGS_NORMALTODUDV = 0x00200000, - TEXTUREFLAGS_ALPHATESTMIPGENERATION = 0x00400000, - TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000, - TEXTUREFLAGS_NICEFILTERED = 0x01000000, - TEXTUREFLAGS_CLAMPU = 0x02000000 -}; - - -struct VtfHeader -{ - char signature[4]; // File signature ("VTF\0"). - uint32 version[2]; // version[0].version[1] (currently 7.2). - uint32 headerSize; // Size of the header struct (16 byte aligned; currently 80 bytes). - - // 7.0 - uint16 width; // Width of the largest mipmap in pixels. Must be a power of 2. - uint16 height; // Height of the largest mipmap in pixels. Must be a power of 2. - uint32 flags; // VTF flags. - uint16 frames; // Number of frames, if animated (1 for no animation). - uint16 firstFrame; // First frame in animation (0 based). - uint8 padding0[4]; // reflectivity padding (16 byte alignment). - float reflectivity[3]; // reflectivity vector. - uint8 padding1[4]; // reflectivity padding (8 byte packing). - float bumpmapScale; // Bumpmap scale. - uint32 highResImageFormat; // High resolution image format. - uint8 mipmapCount; // Number of mipmaps. - uint32 lowResImageFormat; // Low resolution image format (always DXT1). - uint8 lowResImageWidth; // Low resolution image width. - uint8 lowResImageHeight; // Low resolution image height. - - // 7.2 - uint16 depth; // Depth of the largest mipmap in pixels. - // Must be a power of 2. Can be 0 or 1 for a 2D texture (v7.2 only). -}; - - diff --git a/src/nvimage/nvimage.h b/src/nvimage/nvimage.h index e6edc55c..e46b48c8 100644 --- a/src/nvimage/nvimage.h +++ b/src/nvimage/nvimage.h @@ -1,32 +1,13 @@ // This code is in the public domain -- castanyo@yahoo.es - #pragma once -#ifndef NV_IMAGE_H -#define NV_IMAGE_H #include "nvcore/nvcore.h" #include "nvcore/Debug.h" // nvDebugCheck #include "nvcore/Utils.h" // isPowerOfTwo -// Function linkage -#if NVIMAGE_SHARED -#ifdef NVIMAGE_EXPORTS -#define NVIMAGE_API DLL_EXPORT -#define NVIMAGE_CLASS DLL_EXPORT_CLASS -#else -#define NVIMAGE_API DLL_IMPORT -#define NVIMAGE_CLASS DLL_IMPORT -#endif -#else -#define NVIMAGE_API -#define NVIMAGE_CLASS -#endif - - namespace nv { // Some utility functions: - inline uint computeBitPitch(uint w, uint bitsize, uint alignmentInBits) { nvDebugCheck(isPowerOfTwo(alignmentInBits)); @@ -42,7 +23,4 @@ namespace nv { return (pitch + 7) / 8; } - } // nv namespace - -#endif // NV_IMAGE_H diff --git a/src/nvmath/CMakeLists.txt b/src/nvmath/CMakeLists.txt index c59cfebd..c7a01edc 100644 --- a/src/nvmath/CMakeLists.txt +++ b/src/nvmath/CMakeLists.txt @@ -10,20 +10,11 @@ SET(MATH_SRCS Matrix.h Matrix.inl Matrix.cpp Plane.h Plane.inl Plane.cpp SphericalHarmonic.h SphericalHarmonic.cpp - SimdVector.h SimdVector_SSE.h SimdVector_VE.h Vector.h Vector.inl) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -# targets -ADD_DEFINITIONS(-DNVMATH_EXPORTS) - -IF(NVMATH_SHARED) - ADD_DEFINITIONS(-DNVMATH_SHARED=1) - ADD_LIBRARY(nvmath SHARED ${MATH_SRCS}) -ELSE(NVMATH_SHARED) - ADD_LIBRARY(nvmath ${MATH_SRCS}) -ENDIF(NVMATH_SHARED) +ADD_LIBRARY(nvmath ${MATH_SRCS}) TARGET_LINK_LIBRARIES(nvmath ${LIBS} nvcore) diff --git a/src/nvmath/Color.h b/src/nvmath/Color.h index 5cdc374b..bdb9a8d1 100644 --- a/src/nvmath/Color.h +++ b/src/nvmath/Color.h @@ -10,7 +10,7 @@ namespace nv { /// 64 bit color stored as BGRA. - class NVMATH_CLASS Color64 + class Color64 { public: Color64() { } @@ -46,7 +46,7 @@ namespace nv }; /// 32 bit color stored as BGRA. - class NVMATH_CLASS Color32 + class Color32 { public: Color32() { } @@ -96,12 +96,12 @@ namespace nv /// 16 bit 565 BGR color. - class NVMATH_CLASS Color16 + struct Color16 { - public: Color16() { } Color16(const Color16 & c) : u(c.u) { } explicit Color16(uint16 U) : u(U) { } + Color16(uint8 r, uint8 g, uint8 b) : r(r), g(g), b(b) { } union { struct { @@ -120,7 +120,7 @@ namespace nv }; /// 16 bit 4444 BGRA color. - class NVMATH_CLASS Color16_4444 + class Color16_4444 { public: Color16_4444() { } diff --git a/src/nvmath/Fitting.cpp b/src/nvmath/Fitting.cpp index 6ac2ab96..69545480 100644 --- a/src/nvmath/Fitting.cpp +++ b/src/nvmath/Fitting.cpp @@ -3,12 +3,12 @@ #include "Fitting.h" #include "Vector.inl" #include "Plane.inl" +#include "Matrix.inl" #include "nvcore/Array.inl" #include "nvcore/Utils.h" // max, swap #include // FLT_MAX -//#include #include using namespace nv; @@ -668,7 +668,7 @@ bool nv::Fit::eigenSolveSymmetric4(const float matrix[10], float eigenValues[4], return true; } -#include "nvmath/Matrix.inl" + inline float signNonzero(float x) { diff --git a/src/nvmath/Fitting.h b/src/nvmath/Fitting.h index 7a88cd28..4c5ee59c 100644 --- a/src/nvmath/Fitting.h +++ b/src/nvmath/Fitting.h @@ -1,9 +1,7 @@ // This code is in the public domain -- Ignacio Castaño - #pragma once -#ifndef NV_MATH_FITTING_H -#define NV_MATH_FITTING_H +#include "nvmath.h" // NV_EPSILON #include "Vector.h" #include "Plane.h" @@ -46,5 +44,3 @@ namespace nv } } // nv namespace - -#endif // NV_MATH_FITTING_H diff --git a/src/nvmath/Half.cpp b/src/nvmath/Half.cpp index c4ea48fa..d5a54262 100644 --- a/src/nvmath/Half.cpp +++ b/src/nvmath/Half.cpp @@ -294,7 +294,7 @@ uint32 _uint32_nlz( uint32 x ) { // Count Leading Zeros static inline uint32 _uint32_cntlz( uint32 x ) { -#if NV_CC_GCC +#if NV_CC_GNUC /* On PowerPC, this will map to insn: cntlzw */ /* On Pentium, this will map to insn: clz */ uint32 is_x_nez_msb = _uint32_neg( x ); @@ -692,7 +692,7 @@ __asm /* This method is faster than the OpenEXR implementation (very often * used, eg. in Ogre), with the additional benefit of rounding, inspired - * by James Tursa’s half-precision code. */ + * by James TursaÂ’s half-precision code. */ static inline uint16_t float_to_half_branch(uint32_t x) { uint16_t bits = (x >> 16) & 0x8000; /* Get the sign */ @@ -742,7 +742,7 @@ static inline uint16_t float_to_half_branch(uint32_t x) #define S256(x) S64((x)), S64((x)+64), S64((x)+128), S64((x)+192) #define S1024(x) S256((x)), S256((x)+256), S256((x)+512), S256((x)+768) -/* Lookup table-based algorithm from “Fast Half Float Conversions” +/* Lookup table-based algorithm from “Fast Half Float Conversions” * by Jeroen van der Zijp, November 2008. No rounding is performed, * and some NaN values may be incorrectly converted to Inf. */ static inline uint16_t float_to_half_nobranch(uint32_t x) diff --git a/src/nvmath/Matrix.cpp b/src/nvmath/Matrix.cpp index d171d136..75429e51 100644 --- a/src/nvmath/Matrix.cpp +++ b/src/nvmath/Matrix.cpp @@ -57,7 +57,7 @@ static bool ludcmp(float **a, int n, int *indx, float *d) } a[i][j]=sum; - float dum = vv[i]*fabs(sum); + float dum = vv[i]*fabsf(sum); if (dum >= big) { // Is the figure of merit for the pivot better than the best so far? big = dum; @@ -284,8 +284,8 @@ Matrix nv::inverse(const Matrix & m) { for (i=0; i<4; i++) { /* eliminate in column i, below diag */ max = -1.; for (k=i; k<4; k++) /* find pivot for column i */ - if (fabs(A(k, i)) > max) { - max = fabs(A(k, i)); + if (fabsf(A(k, i)) > max) { + max = fabsf(A(k, i)); j = k; } if (max<=0.) return B; /* if no nonzero pivot, PUNT */ @@ -340,7 +340,7 @@ Matrix3 nv::inverse(const Matrix3 & m) { max = -1.; for (k=i; k<3; k++) /* find pivot for column i */ if (fabs(A(k, i)) > max) { - max = fabs(A(k, i)); + max = fabsf(A(k, i)); j = k; } if (max<=0.) return B; /* if no nonzero pivot, PUNT */ diff --git a/src/nvmath/Matrix.h b/src/nvmath/Matrix.h index d1171a15..6bf0bf3d 100644 --- a/src/nvmath/Matrix.h +++ b/src/nvmath/Matrix.h @@ -1,8 +1,6 @@ // This code is in the public domain -- castanyo@yahoo.es #pragma once -#ifndef NV_MATH_MATRIX_H -#define NV_MATH_MATRIX_H #include "Vector.h" @@ -15,7 +13,7 @@ namespace nv enum identity_t { identity }; // 2x2 matrix. - class NVMATH_CLASS Matrix2 + class Matrix2 { public: Matrix2(); @@ -55,7 +53,7 @@ namespace nv // 3x3 matrix. - class NVMATH_CLASS Matrix3 + class Matrix3 { public: Matrix3(); @@ -96,7 +94,7 @@ namespace nv // 4x4 matrix. - class NVMATH_CLASS Matrix + class Matrix { public: typedef Matrix const & Arg; @@ -150,5 +148,3 @@ namespace nv extern Matrix inverse(const Matrix & m); } // nv namespace - -#endif // NV_MATH_MATRIX_H diff --git a/src/nvmath/Matrix.inl b/src/nvmath/Matrix.inl index f742656b..6f025c3e 100644 --- a/src/nvmath/Matrix.inl +++ b/src/nvmath/Matrix.inl @@ -1,10 +1,9 @@ // This code is in the public domain -- castanyo@yahoo.es #pragma once -#ifndef NV_MATH_MATRIX_INL -#define NV_MATH_MATRIX_INL #include "Matrix.h" +#include "nvmath.h" namespace nv { @@ -729,7 +728,7 @@ namespace nv // Get perspective matrix. inline Matrix perspective(float fovy, float aspect, float zNear, float zFar) { - float xmax = zNear * tan(fovy / 2); + float xmax = zNear * tanf(fovy / 2); float xmin = -xmax; float ymax = xmax / aspect; @@ -741,7 +740,7 @@ namespace nv // Get inverse perspective matrix. inline Matrix perspectiveInverse(float fovy, float aspect, float zNear, float zFar) { - float xmax = zNear * tan(fovy / 2); + float xmax = zNear * tanf(fovy / 2); float xmin = -xmax; float ymax = xmax / aspect; @@ -753,7 +752,7 @@ namespace nv // Get infinite perspective matrix. inline Matrix perspective(float fovy, float aspect, float zNear) { - float x = zNear * tan(fovy / 2); + float x = zNear * tanf(fovy / 2); float y = x / aspect; return frustum( -x, x, -y, y, zNear ); } @@ -1462,6 +1461,3 @@ public: }; #endif - - -#endif // NV_MATH_MATRIX_INL diff --git a/src/nvmath/PackedFloat.cpp b/src/nvmath/PackedFloat.cpp index 3327d20d..6f3d107d 100755 --- a/src/nvmath/PackedFloat.cpp +++ b/src/nvmath/PackedFloat.cpp @@ -25,24 +25,25 @@ Vector3 nv::r11g11b10_to_vector3(FloatR11G11B10 v) { FloatR11G11B10 nv::vector3_to_r11g11b10(const Vector3 & v) { } -// These are based on: -// http://www.graphics.cornell.edu/~bjw/rgbe/rgbe.c -// While this may not be the best way to encode/decode RGBE8, I'm not making any changes to maintain compatibility. +// Implementation based on on: +// https://cbloomrants.blogspot.com/2020/06/widespread-error-in-radiance-hdr-rgbe.html FloatRGBE8 nv::vector3_to_rgbe8(const Vector3 & v) { float m = max3(v.x, v.y, v.z); FloatRGBE8 rgbe; - if (m < 1e-32) { + if (m < 1e-32f) { + // Exponent byte = 0 is a special encoding that makes RGB output = 0 rgbe.v = 0; } else { int e; - float scale = frexpf(m, &e) * 256.0f / m; - rgbe.r = U8(ftoi_round(v.x * scale)); - rgbe.g = U8(ftoi_round(v.y * scale)); - rgbe.b = U8(ftoi_round(v.z * scale)); + frexpf(m, &e); + float scale = ldexpf(1.0f, -exponent + 8); + rgbe.r = U8(v.x * scale); + rgbe.g = U8(v.y * scale); + rgbe.b = U8(v.z * scale); rgbe.e = U8(e + 128); } @@ -52,8 +53,8 @@ FloatRGBE8 nv::vector3_to_rgbe8(const Vector3 & v) { Vector3 nv::rgbe8_to_vector3(FloatRGBE8 v) { if (v.e != 0) { - float scale = ldexpf(1.0f, v.e-(int)(128+8)); // +8 to divide by 256. @@ Shouldn't we divide by 255 instead? - return scale * Vector3(float(v.r), float(v.g), float(v.b)); + float scale = ldexpf(1.0f, (int)v.e-128+8); // +8 to divide by 256. + return scale * Vector3(float(v.r + 0.5f), float(v.g + 0.5f), float(v.b + 0.5f)); } return Vector3(0); diff --git a/src/nvmath/PackedFloat.h b/src/nvmath/PackedFloat.h index bf84b854..dc3ed991 100755 --- a/src/nvmath/PackedFloat.h +++ b/src/nvmath/PackedFloat.h @@ -62,17 +62,17 @@ namespace nv }; }; - NVMATH_API Vector3 rgb9e5_to_vector3(FloatRGB9E5 v); - NVMATH_API FloatRGB9E5 vector3_to_rgb9e5(const Vector3 & v); + Vector3 rgb9e5_to_vector3(FloatRGB9E5 v); + FloatRGB9E5 vector3_to_rgb9e5(const Vector3 & v); - NVMATH_API float float11_to_float32(uint v); - NVMATH_API float float10_to_float32(uint v); + float float11_to_float32(uint v); + float float10_to_float32(uint v); - NVMATH_API Vector3 r11g11b10_to_vector3(FloatR11G11B10 v); - NVMATH_API FloatR11G11B10 vector3_to_r11g11b10(const Vector3 & v); + Vector3 r11g11b10_to_vector3(FloatR11G11B10 v); + FloatR11G11B10 vector3_to_r11g11b10(const Vector3 & v); - NVMATH_API Vector3 rgbe8_to_vector3(FloatRGBE8 v); - NVMATH_API FloatRGBE8 vector3_to_rgbe8(const Vector3 & v); + Vector3 rgbe8_to_vector3(FloatRGBE8 v); + FloatRGBE8 vector3_to_rgbe8(const Vector3 & v); } // nv diff --git a/src/nvmath/Plane.h b/src/nvmath/Plane.h index dc468b28..a4dff248 100644 --- a/src/nvmath/Plane.h +++ b/src/nvmath/Plane.h @@ -1,17 +1,14 @@ // This code is in the public domain -- Ignacio Castaño #pragma once -#ifndef NV_MATH_PLANE_H -#define NV_MATH_PLANE_H -#include "nvmath.h" #include "Vector.h" namespace nv { class Matrix; - class NVMATH_CLASS Plane + class Plane { public: Plane(); @@ -38,5 +35,3 @@ namespace nv } // nv namespace - -#endif // NV_MATH_PLANE_H diff --git a/src/nvmath/SimdVector.h b/src/nvmath/SimdVector.h deleted file mode 100644 index 94e5186e..00000000 --- a/src/nvmath/SimdVector.h +++ /dev/null @@ -1,12 +0,0 @@ -// This code is in the public domain -- Ignacio Castaño - -#include "Vector.h" // Vector3, Vector4 - - -#if NV_USE_ALTIVEC -# include "SimdVector_VE.h" -#endif - -#if NV_USE_SSE -# include "SimdVector_SSE.h" -#endif diff --git a/src/nvmath/SimdVector_SSE.h b/src/nvmath/SimdVector_SSE.h deleted file mode 100644 index c816de25..00000000 --- a/src/nvmath/SimdVector_SSE.h +++ /dev/null @@ -1,216 +0,0 @@ -/* ----------------------------------------------------------------------------- - - Copyright (c) 2006 Simon Brown si@sjbrown.co.uk - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -------------------------------------------------------------------------- */ - -#ifndef NV_SIMD_VECTOR_SSE_H -#define NV_SIMD_VECTOR_SSE_H - -#include "nvcore/Memory.h" - -#include -#if (NV_USE_SSE > 1) -#include -#endif - -// See this for ideas: -// http://molecularmusings.wordpress.com/2011/10/18/simdifying-multi-platform-math/ - - -namespace nv { - -#define NV_SIMD_NATIVE NV_FORCEINLINE -#define NV_SIMD_INLINE inline - - class SimdVector - { - public: - __m128 vec; - - typedef SimdVector const& Arg; - - NV_SIMD_NATIVE SimdVector() {} - - NV_SIMD_NATIVE explicit SimdVector(__m128 v) : vec(v) {} - - NV_SIMD_NATIVE explicit SimdVector(float f) { - vec = _mm_set1_ps(f); - } - - NV_SIMD_NATIVE explicit SimdVector(const float * v) - { - vec = _mm_load_ps( v ); - } - - NV_SIMD_NATIVE SimdVector(float x, float y, float z, float w) - { - vec = _mm_setr_ps( x, y, z, w ); - } - - NV_SIMD_NATIVE SimdVector(const SimdVector & arg) : vec(arg.vec) {} - - NV_SIMD_NATIVE SimdVector & operator=(const SimdVector & arg) - { - vec = arg.vec; - return *this; - } - - NV_SIMD_INLINE float toFloat() const - { - NV_ALIGN_16 float f; - _mm_store_ss(&f, vec); - return f; - } - - NV_SIMD_INLINE Vector3 toVector3() const - { - NV_ALIGN_16 float c[4]; - _mm_store_ps( c, vec ); - return Vector3( c[0], c[1], c[2] ); - } - - NV_SIMD_INLINE Vector4 toVector4() const - { - NV_ALIGN_16 float c[4]; - _mm_store_ps( c, vec ); - return Vector4( c[0], c[1], c[2], c[3] ); - } - -#define SSE_SPLAT( a ) ((a) | ((a) << 2) | ((a) << 4) | ((a) << 6)) - NV_SIMD_NATIVE SimdVector splatX() const { return SimdVector( _mm_shuffle_ps( vec, vec, SSE_SPLAT( 0 ) ) ); } - NV_SIMD_NATIVE SimdVector splatY() const { return SimdVector( _mm_shuffle_ps( vec, vec, SSE_SPLAT( 1 ) ) ); } - NV_SIMD_NATIVE SimdVector splatZ() const { return SimdVector( _mm_shuffle_ps( vec, vec, SSE_SPLAT( 2 ) ) ); } - NV_SIMD_NATIVE SimdVector splatW() const { return SimdVector( _mm_shuffle_ps( vec, vec, SSE_SPLAT( 3 ) ) ); } -#undef SSE_SPLAT - - NV_SIMD_NATIVE SimdVector& operator+=( Arg v ) - { - vec = _mm_add_ps( vec, v.vec ); - return *this; - } - - NV_SIMD_NATIVE SimdVector& operator-=( Arg v ) - { - vec = _mm_sub_ps( vec, v.vec ); - return *this; - } - - NV_SIMD_NATIVE SimdVector& operator*=( Arg v ) - { - vec = _mm_mul_ps( vec, v.vec ); - return *this; - } - }; - - - NV_SIMD_NATIVE SimdVector operator+( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( _mm_add_ps( left.vec, right.vec ) ); - } - - NV_SIMD_NATIVE SimdVector operator-( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( _mm_sub_ps( left.vec, right.vec ) ); - } - - NV_SIMD_NATIVE SimdVector operator*( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( _mm_mul_ps( left.vec, right.vec ) ); - } - - // Returns a*b + c - NV_SIMD_INLINE SimdVector multiplyAdd( SimdVector::Arg a, SimdVector::Arg b, SimdVector::Arg c ) - { - return SimdVector( _mm_add_ps( _mm_mul_ps( a.vec, b.vec ), c.vec ) ); - } - - // Returns -( a*b - c ) - NV_SIMD_INLINE SimdVector negativeMultiplySubtract( SimdVector::Arg a, SimdVector::Arg b, SimdVector::Arg c ) - { - return SimdVector( _mm_sub_ps( c.vec, _mm_mul_ps( a.vec, b.vec ) ) ); - } - - NV_SIMD_INLINE SimdVector reciprocal( SimdVector::Arg v ) - { - // get the reciprocal estimate - __m128 estimate = _mm_rcp_ps( v.vec ); - - // one round of Newton-Rhaphson refinement - __m128 diff = _mm_sub_ps( _mm_set1_ps( 1.0f ), _mm_mul_ps( estimate, v.vec ) ); - return SimdVector( _mm_add_ps( _mm_mul_ps( diff, estimate ), estimate ) ); - } - - NV_SIMD_NATIVE SimdVector min( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( _mm_min_ps( left.vec, right.vec ) ); - } - - NV_SIMD_NATIVE SimdVector max( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( _mm_max_ps( left.vec, right.vec ) ); - } - - NV_SIMD_INLINE SimdVector truncate( SimdVector::Arg v ) - { -#if (NV_USE_SSE == 1) - // convert to ints - __m128 input = v.vec; - __m64 lo = _mm_cvttps_pi32( input ); - __m64 hi = _mm_cvttps_pi32( _mm_movehl_ps( input, input ) ); - - // convert to floats - __m128 part = _mm_movelh_ps( input, _mm_cvtpi32_ps( input, hi ) ); - __m128 truncated = _mm_cvtpi32_ps( part, lo ); - - // clear out the MMX multimedia state to allow FP calls later - _mm_empty(); - return SimdVector( truncated ); -#else - // use SSE2 instructions - return SimdVector( _mm_cvtepi32_ps( _mm_cvttps_epi32( v.vec ) ) ); -#endif - } - - NV_SIMD_NATIVE SimdVector compareEqual( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( _mm_cmpeq_ps( left.vec, right.vec ) ); - } - - NV_SIMD_INLINE SimdVector select( SimdVector::Arg off, SimdVector::Arg on, SimdVector::Arg bits ) - { - __m128 a = _mm_andnot_ps( bits.vec, off.vec ); - __m128 b = _mm_and_ps( bits.vec, on.vec ); - - return SimdVector( _mm_or_ps( a, b ) ); - } - - NV_SIMD_INLINE bool compareAnyLessThan( SimdVector::Arg left, SimdVector::Arg right ) - { - __m128 bits = _mm_cmplt_ps( left.vec, right.vec ); - int value = _mm_movemask_ps( bits ); - return value != 0; - } - -} // namespace nv - -#endif // NV_SIMD_VECTOR_SSE_H diff --git a/src/nvmath/SimdVector_VE.h b/src/nvmath/SimdVector_VE.h deleted file mode 100644 index 57806ee6..00000000 --- a/src/nvmath/SimdVector_VE.h +++ /dev/null @@ -1,189 +0,0 @@ -/* ----------------------------------------------------------------------------- - - Copyright (c) 2006 Simon Brown si@sjbrown.co.uk - Copyright (c) 2016 Raptor Engineering, LLC - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -------------------------------------------------------------------------- */ - -#ifndef NV_SIMD_VECTOR_VE_H -#define NV_SIMD_VECTOR_VE_H - -#ifndef __APPLE_ALTIVEC__ -#include -#undef bool -#endif - -namespace nv { - - class SimdVector - { - public: - vector float vec; - - typedef SimdVector Arg; - - SimdVector() {} - explicit SimdVector(float v) : vec(vec_splats(v)) {} - explicit SimdVector(vector float v) : vec(v) {} - SimdVector(const SimdVector & arg) : vec(arg.vec) {} - - SimdVector& operator=(const SimdVector & arg) - { - vec = arg.vec; - return *this; - } - - SimdVector(const float * v) - { - union { vector float v; float c[4]; } u; - u.c[0] = v[0]; - u.c[1] = v[1]; - u.c[2] = v[2]; - u.c[3] = v[3]; - vec = u.v; - } - - SimdVector(float x, float y, float z, float w) - { - union { vector float v; float c[4]; } u; - u.c[0] = x; - u.c[1] = y; - u.c[2] = z; - u.c[3] = w; - vec = u.v; - } - - float toFloat() const - { - union { vector float v; float c[4]; } u; - u.v = vec; - return u.c[0]; - } - - Vector3 toVector3() const - { - union { vector float v; float c[4]; } u; - u.v = vec; - return Vector3( u.c[0], u.c[1], u.c[2] ); - } - - Vector4 toVector4() const - { - union { vector float v; float c[4]; } u; - u.v = vec; - return Vector4( u.c[0], u.c[1], u.c[2], u.c[3] ); - } - - SimdVector splatX() const { return SimdVector( vec_splat( vec, 0 ) ); } - SimdVector splatY() const { return SimdVector( vec_splat( vec, 1 ) ); } - SimdVector splatZ() const { return SimdVector( vec_splat( vec, 2 ) ); } - SimdVector splatW() const { return SimdVector( vec_splat( vec, 3 ) ); } - - SimdVector& operator+=( Arg v ) - { - vec = vec_add( vec, v.vec ); - return *this; - } - - SimdVector& operator-=( Arg v ) - { - vec = vec_sub( vec, v.vec ); - return *this; - } - - SimdVector& operator*=( Arg v ) - { - vec = vec_madd( vec, v.vec, vec_splats( -0.0f ) ); - return *this; - } - }; - - inline SimdVector operator+( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( vec_add( left.vec, right.vec ) ); - } - - inline SimdVector operator-( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( vec_sub( left.vec, right.vec ) ); - } - - inline SimdVector operator*( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( vec_madd( left.vec, right.vec, vec_splats( -0.0f ) ) ); - } - - // Returns a*b + c - inline SimdVector multiplyAdd( SimdVector::Arg a, SimdVector::Arg b, SimdVector::Arg c ) - { - return SimdVector( vec_madd( a.vec, b.vec, c.vec ) ); - } - - // Returns -( a*b - c ) - inline SimdVector negativeMultiplySubtract( SimdVector::Arg a, SimdVector::Arg b, SimdVector::Arg c ) - { - return SimdVector( vec_nmsub( a.vec, b.vec, c.vec ) ); - } - - inline SimdVector reciprocal( SimdVector::Arg v ) - { - // get the reciprocal estimate - vector float estimate = vec_re( v.vec ); - - // one round of Newton-Rhaphson refinement - vector float diff = vec_nmsub( estimate, v.vec, vec_splats( 1.0f ) ); - return SimdVector( vec_madd( diff, estimate, estimate ) ); - } - - inline SimdVector min( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( vec_min( left.vec, right.vec ) ); - } - - inline SimdVector max( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( vec_max( left.vec, right.vec ) ); - } - - inline SimdVector truncate( SimdVector::Arg v ) - { - return SimdVector( vec_trunc( v.vec ) ); - } - - inline SimdVector compareEqual( SimdVector::Arg left, SimdVector::Arg right ) - { - return SimdVector( ( vector float )vec_cmpeq( left.vec, right.vec ) ); - } - - inline SimdVector select( SimdVector::Arg off, SimdVector::Arg on, SimdVector::Arg bits ) - { - return SimdVector( vec_sel( off.vec, on.vec, ( vector unsigned int )bits.vec ) ); - } - - inline bool compareAnyLessThan( SimdVector::Arg left, SimdVector::Arg right ) - { - return vec_any_lt( left.vec, right.vec ) != 0; - } - -} // namespace nv - -#endif // NV_SIMD_VECTOR_VE_H diff --git a/src/nvmath/SphericalHarmonic.h b/src/nvmath/SphericalHarmonic.h index b7f57742..962588f3 100644 --- a/src/nvmath/SphericalHarmonic.h +++ b/src/nvmath/SphericalHarmonic.h @@ -4,6 +4,7 @@ #define NV_MATH_SPHERICALHARMONIC_H #include "nvmath.h" +#include "Vector.h" #include // memcpy @@ -13,11 +14,11 @@ namespace nv class Vector3; class Matrix; - NVMATH_API float legendrePolynomial( int l, int m, float x ) NV_CONST; - NVMATH_API float shBasis( int l, int m, float theta, float phi ) NV_CONST; - NVMATH_API float shBasis( int l, int m, const Vector3 & v ) NV_CONST; - NVMATH_API float hshBasis( int l, int m, float theta, float phi ) NV_CONST; - NVMATH_API float hshBasis( int l, int m, const Vector3 & v ) NV_CONST; + float legendrePolynomial( int l, int m, float x ) NV_CONST; + float shBasis( int l, int m, float theta, float phi ) NV_CONST; + float shBasis( int l, int m, const Vector3 & v ) NV_CONST; + float hshBasis( int l, int m, float theta, float phi ) NV_CONST; + float hshBasis( int l, int m, const Vector3 & v ) NV_CONST; class Sh; float dot(const Sh & a, const Sh & b) NV_CONST; @@ -31,33 +32,33 @@ namespace nv public: /// Construct a spherical harmonic of the given order. - Sh(int o) : m_order(o) + Sh(int o) : order(o) { - m_elemArray = new float[basisNum()]; + coef = new float[basisNum()]; } /// Copy constructor. - Sh(const Sh & sh) : m_order(sh.order()) + Sh(const Sh & sh) : order(sh.order) { - m_elemArray = new float[basisNum()]; - memcpy(m_elemArray, sh.m_elemArray, sizeof(float) * basisNum()); + coef = new float[basisNum()]; + memcpy(coef, sh.coef, sizeof(float) * basisNum()); } /// Destructor. ~Sh() { - delete [] m_elemArray; - m_elemArray = NULL; + delete [] coef; + coef = NULL; } /// Get number of bands. - static int bandNum(int m_order) { - return m_order + 1; + static int bandNum(int order) { + return order + 1; } /// Get number of sh basis. - static int basisNum(int m_order) { - return (m_order + 1) * (m_order + 1); + static int basisNum(int order) { + return (order + 1) * (order + 1); } /// Get the index for the given coefficients. @@ -65,46 +66,40 @@ namespace nv return l * l + l + m; } - /// Get sh order. - int order() const - { - return m_order; - } - /// Get sh order. int bandNum() const { - return bandNum(m_order); + return bandNum(order); } /// Get sh order. int basisNum() const { - return basisNum(m_order); + return basisNum(order); } /// Get sh coefficient indexed by l,m. float elem( int l, int m ) const { - return m_elemArray[index(l, m)]; + return coef[index(l, m)]; } /// Get sh coefficient indexed by l,m. float & elem( int l, int m ) { - return m_elemArray[index(l, m)]; + return coef[index(l, m)]; } /// Get sh coefficient indexed by i. float elemAt( int i ) const { - return m_elemArray[i]; + return coef[i]; } /// Get sh coefficient indexed by i. float & elemAt( int i ) { - return m_elemArray[i]; + return coef[i]; } @@ -112,47 +107,47 @@ namespace nv void reset() { for( int i = 0; i < basisNum(); i++ ) { - m_elemArray[i] = 0.0f; + coef[i] = 0.0f; } } /// Copy spherical harmonic. void operator= ( const Sh & sh ) { - nvDebugCheck(order() <= sh.order()); + nvDebugCheck(order <= sh.order); for(int i = 0; i < basisNum(); i++) { - m_elemArray[i] = sh.m_elemArray[i]; + coef[i] = sh.coef[i]; } } /// Add spherical harmonics. void operator+= ( const Sh & sh ) { - nvDebugCheck(order() == sh.order()); + nvDebugCheck(order == sh.order); for(int i = 0; i < basisNum(); i++) { - m_elemArray[i] += sh.m_elemArray[i]; + coef[i] += sh.coef[i]; } } /// Substract spherical harmonics. void operator-= ( const Sh & sh ) { - nvDebugCheck(order() == sh.order()); + nvDebugCheck(order == sh.order); for(int i = 0; i < basisNum(); i++) { - m_elemArray[i] -= sh.m_elemArray[i]; + coef[i] -= sh.coef[i]; } } // Not exactly convolution, nor product. void operator*= ( const Sh & sh ) { - nvDebugCheck(order() == sh.order()); + nvDebugCheck(order == sh.order); for(int i = 0; i < basisNum(); i++) { - m_elemArray[i] *= sh.m_elemArray[i]; + coef[i] *= sh.coef[i]; } } @@ -160,17 +155,17 @@ namespace nv void operator*= ( float f ) { for(int i = 0; i < basisNum(); i++) { - m_elemArray[i] *= f; + coef[i] *= f; } } /// Add scaled spherical harmonics. void addScaled( const Sh & sh, float f ) { - nvDebugCheck(order() == sh.order()); + nvDebugCheck(order == sh.order); for(int i = 0; i < basisNum(); i++) { - m_elemArray[i] += sh.m_elemArray[i] * f; + coef[i] += sh.coef[i] * f; } } @@ -188,7 +183,7 @@ namespace nv /// Evaluate void eval(const Vector3 & dir) { - for(int l = 0; l <= m_order; l++) { + for(int l = 0; l <= order; l++) { for(int m = -l; m <= l; m++) { elem(l, m) = shBasis(l, m, dir); } @@ -199,17 +194,15 @@ namespace nv /// Evaluate the spherical harmonic function. float sample(const Vector3 & dir) const { - Sh sh(order()); + Sh sh(order); sh.eval(dir); return dot(sh, *this); } - protected: - - const int m_order; - float * m_elemArray; + const int order; + float * coef; }; @@ -217,10 +210,10 @@ namespace nv /// Compute dot product of the spherical harmonics. inline float dot(const Sh & a, const Sh & b) { - nvDebugCheck(a.order() == b.order()); + nvDebugCheck(a.order == b.order); float sum = 0; - for( int i = 0; i < Sh::basisNum(a.order()); i++ ) { + for( int i = 0; i < Sh::basisNum(a.order); i++ ) { sum += a.elemAt(i) * b.elemAt(i); } @@ -239,9 +232,34 @@ namespace nv /// Copy constructor. Sh2(const Sh2 & sh) : Sh(sh) {} + // Fast evaluation from: PPS' Efficient Spherical Harmonic Evaluation http://jcgt.org/published/0002/02/06/ + void eval(const Vector3 & dir) { + float fZ2 = dir.z * dir.z; + coef[0] = 0.2820947917738781f; + coef[2] = 0.4886025119029199f * dir.z; + coef[6] = 0.9461746957575601f * fZ2 + -0.3153915652525201f; + + float fC0 = dir.x; + float fS0 = dir.y; + + float fTmpA = -0.48860251190292f; + coef[3] = fTmpA * fC0; + coef[1] = fTmpA * fS0; + + float fTmpB = -1.092548430592079f * dir.z; + coef[7] = fTmpB * fC0; + coef[5] = fTmpB * fS0; + + float fC1 = dir.x * fC0 - dir.y * fS0; + float fS1 = dir.x * fS0 + dir.y * fC0; + + float fTmpC = 0.5462742152960395f; + coef[8] = fTmpC * fC1; + coef[4] = fTmpC * fS1; + } + /// Spherical harmonic resulting from projecting the clamped cosine transfer function to the SH basis. - void cosineTransfer() - { + void cosineTransfer() { const float c1 = 0.282095f; // K(0, 0) const float c2 = 0.488603f; // K(1, 0) const float c3 = 1.092548f; // sqrt(15.0f / PI) / 2.0f = K(2, -2) @@ -256,17 +274,17 @@ namespace nv const float const4 = c4 * normalization * (1.0f / 4.0f); const float const5 = c5 * normalization * (1.0f / 4.0f); - m_elemArray[0] = const1; + coef[0] = const1; - m_elemArray[1] = -const2; - m_elemArray[2] = const2; - m_elemArray[3] = -const2; + coef[1] = -const2; + coef[2] = const2; + coef[3] = -const2; - m_elemArray[4] = const3; - m_elemArray[5] = -const3; - m_elemArray[6] = const4; - m_elemArray[7] = -const3; - m_elemArray[8] = const5; + coef[4] = const3; + coef[5] = -const3; + coef[6] = const4; + coef[7] = -const3; + coef[8] = const5; } }; @@ -352,8 +370,8 @@ namespace nv /// Rotate the given coefficients. /*void transform( const Sh & restrict source, Sh * restrict dest ) const { nvCheck( &source != dest ); // Make sure there's no aliasing. - nvCheck( dest->m_order <= m_order ); - nvCheck( m_order <= source.m_order ); + nvCheck( dest->order <= order ); + nvCheck( order <= source.order ); if (m_identity) { *dest = source; @@ -361,7 +379,7 @@ namespace nv } // Loop through each band. - for (int l = 0; l <= dest->m_order; l++) { + for (int l = 0; l <= dest->order; l++) { for (int mo = -l; mo <= l; mo++) { @@ -377,10 +395,10 @@ namespace nv }*/ - NVMATH_API void multiply( const ShMatrix &A, const ShMatrix &B ); - NVMATH_API void rotation( const Matrix & m ); - NVMATH_API void rotation( int axis, float angles ); - NVMATH_API void print(); + void multiply( const ShMatrix &A, const ShMatrix &B ); + void rotation( const Matrix & m ); + void rotation( int axis, float angles ); + void print(); private: diff --git a/src/nvmath/Vector.h b/src/nvmath/Vector.h index ad18672a..f525ef5e 100644 --- a/src/nvmath/Vector.h +++ b/src/nvmath/Vector.h @@ -1,14 +1,12 @@ // This code is in the public domain -- castanyo@yahoo.es #pragma once -#ifndef NV_MATH_VECTOR_H -#define NV_MATH_VECTOR_H -#include "nvmath.h" +#include "nvcore/nvcore.h" namespace nv { - class NVMATH_CLASS Vector2 + class Vector2 { public: typedef Vector2 const & Arg; @@ -33,9 +31,6 @@ namespace nv void operator*=(float s); void operator*=(Vector2::Arg v); - friend bool operator==(Vector2::Arg a, Vector2::Arg b); - friend bool operator!=(Vector2::Arg a, Vector2::Arg b); - union { struct { float x, y; @@ -44,7 +39,7 @@ namespace nv }; }; - class NVMATH_CLASS Vector3 + class Vector3 { public: typedef Vector3 const & Arg; @@ -75,9 +70,6 @@ namespace nv void operator*=(Vector3::Arg v); void operator/=(Vector3::Arg v); - friend bool operator==(Vector3::Arg a, Vector3::Arg b); - friend bool operator!=(Vector3::Arg a, Vector3::Arg b); - union { struct { float x, y, z; @@ -86,7 +78,7 @@ namespace nv }; }; - class NVMATH_CLASS Vector4 + class Vector4 { public: typedef Vector4 const & Arg; @@ -121,9 +113,6 @@ namespace nv void operator*=(Vector4::Arg v); void operator/=(Vector4::Arg v); - friend bool operator==(Vector4::Arg a, Vector4::Arg b); - friend bool operator!=(Vector4::Arg a, Vector4::Arg b); - union { struct { float x, y, z, w; @@ -146,4 +135,3 @@ template T to(const nv::Vector2 & v) { NV_COMPILER_CHECK(sizeof(T) template T to(const nv::Vector3 & v) { NV_COMPILER_CHECK(sizeof(T) == sizeof(nv::Vector3)); return T(v.x, v.y, v.z); } template T to(const nv::Vector4 & v) { NV_COMPILER_CHECK(sizeof(T) == sizeof(nv::Vector4)); return T(v.x, v.y, v.z, v.w); } -#endif // NV_MATH_VECTOR_H diff --git a/src/nvmath/Vector.inl b/src/nvmath/Vector.inl index 5807912d..1d87eb39 100644 --- a/src/nvmath/Vector.inl +++ b/src/nvmath/Vector.inl @@ -1,26 +1,15 @@ // This code is in the public domain -- castanyo@yahoo.es #pragma once -#ifndef NV_MATH_VECTOR_INL -#define NV_MATH_VECTOR_INL #include "Vector.h" +#include "nvmath.h" + #include "nvcore/Utils.h" // min, max #include "nvcore/Hash.h" // hash namespace nv { - - // Helpers to convert vector types. Assume T has x,y members and 2 argument constructor. - //template T to(Vector2::Arg v) { return T(v.x, v.y); } - - // Helpers to convert vector types. Assume T has x,y,z members and 3 argument constructor. - //template T to(Vector3::Arg v) { return T(v.x, v.y, v.z); } - - // Helpers to convert vector types. Assume T has x,y,z members and 3 argument constructor. - //template T to(Vector4::Arg v) { return T(v.x, v.y, v.z, v.w); } - - // Vector2 inline Vector2::Vector2() {} inline Vector2::Vector2(float f) : x(f), y(f) {} @@ -537,7 +526,8 @@ namespace nv inline Vector3 operator/(Vector3::Arg v, float s) { - return scale(v, 1.0f/s); + //return scale(v, 1.0f/s); + return Vector3(v.x / s, v.y / s, v.z / s); } /*inline Vector3 add_scaled(Vector3::Arg a, Vector3::Arg b, float s) @@ -915,5 +905,3 @@ namespace nv #endif //NV_OS_IOS } // nv namespace - -#endif // NV_MATH_VECTOR_INL diff --git a/src/nvmath/ftoi.h b/src/nvmath/ftoi.h index ffc68896..a99af8e3 100755 --- a/src/nvmath/ftoi.h +++ b/src/nvmath/ftoi.h @@ -1,11 +1,13 @@ // This code is in the public domain -- castano@gmail.com #pragma once -#ifndef NV_MATH_FTOI_H -#define NV_MATH_FTOI_H #include "nvmath/nvmath.h" +#if NV_USE_SSE + #include +#endif + #include namespace nv @@ -246,5 +248,3 @@ namespace nv } // nv - -#endif // NV_MATH_FTOI_H diff --git a/src/nvmath/nvmath.h b/src/nvmath/nvmath.h index d15a5068..2a4f8873 100644 --- a/src/nvmath/nvmath.h +++ b/src/nvmath/nvmath.h @@ -1,34 +1,19 @@ // This code is in the public domain -- castanyo@yahoo.es #pragma once -#ifndef NV_MATH_H -#define NV_MATH_H #include "nvcore/nvcore.h" #include "nvcore/Debug.h" // nvDebugCheck #include "nvcore/Utils.h" // max, clamp +// Both cmath and math for C++11 and C function definitions. +#include #include #if NV_OS_WIN32 || NV_OS_XBOX #include // finite, isnan #endif - -// Function linkage -#if NVMATH_SHARED -#ifdef NVMATH_EXPORTS -#define NVMATH_API DLL_EXPORT -#define NVMATH_CLASS DLL_EXPORT_CLASS -#else -#define NVMATH_API DLL_IMPORT -#define NVMATH_CLASS DLL_IMPORT -#endif -#else // NVMATH_SHARED -#define NVMATH_API -#define NVMATH_CLASS -#endif // NVMATH_SHARED - // Set some reasonable defaults. #ifndef NV_USE_ALTIVEC # define NV_USE_ALTIVEC NV_CPU_PPC @@ -53,10 +38,6 @@ # endif #endif -#if NV_USE_SSE - #include -#endif - // Internally set NV_USE_SIMD when either altivec or sse is available. #if NV_USE_ALTIVEC && NV_USE_SSE # error "Cannot enable both altivec and sse!" @@ -102,7 +83,7 @@ inline float sqrtf_assert(const float f) return sqrtf(f); } -extern "C" inline double acos_assert(const double f) +extern "C" inline double acos_assert(const double f) { nvDebugCheck(f >= -1.0f && f <= 1.0f); return acos(f); @@ -183,12 +164,12 @@ namespace nv inline bool isNan(const float f) { -#if NV_OS_WIN32 || NV_OS_XBOX +#if __cplusplus >= 199711L + return std::isnan(f); +#elif NV_OS_WIN32 || NV_OS_XBOX return _isnan(f) != 0; -#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD || NV_OS_ORBIS +#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD || NV_OS_ORBIS || NV_OS_LINUX return isnan(f); -#elif NV_OS_LINUX - return isnanf(f); #else # error "isNan not supported" #endif @@ -222,7 +203,7 @@ namespace nv inline float frac(float f) { - return f - floor(f); + return f - floorf(f); } inline float floatRound(float f) @@ -250,7 +231,7 @@ namespace nv } inline float smoothstep(float edge0, float edge1, float x) { - x = linearstep(edge0, edge1, x); + x = linearstep(edge0, edge1, x); // Evaluate polynomial return x*x*(3 - 2*x); @@ -331,5 +312,3 @@ namespace nv } // nv - -#endif // NV_MATH_H diff --git a/src/nvthread/Atomic.h b/src/nvthread/Atomic.h index 970fec70..bf5fad20 100644 --- a/src/nvthread/Atomic.h +++ b/src/nvthread/Atomic.h @@ -61,7 +61,7 @@ namespace nv { #elif POSH_CPU_STRONGARM || POSH_CPU_AARCH64 // need more specific cpu type for armv7? // also utilizes a full barrier - // currently treating laod like x86 - this could be wrong + // currently treating load like x86 - this could be wrong // this is the easiest but slowest way to do this nvCompilerReadWriteBarrier(); @@ -78,6 +78,16 @@ namespace nv { uint32 ret = *ptr; // replace with ldrex? nvCompilerReadWriteBarrier(); return ret; +#elif POSH_CPU_E2K + // need more specific cpu type for e2k? + // also utilizes a full barrier + // currently treating load like x86 - this could be wrong + + // this is the easiest but slowest way to do this + nvCompilerReadWriteBarrier(); + uint32 ret = *ptr; // replace with ldrex? + nvCompilerReadWriteBarrier(); + return ret; #else #error "Not implemented" #endif @@ -102,6 +112,11 @@ namespace nv { nvCompilerReadWriteBarrier(); *ptr = value; //strex? nvCompilerReadWriteBarrier(); +#elif POSH_CPU_E2K + // this is the easiest but slowest way to do this + nvCompilerReadWriteBarrier(); + *ptr = value; //strex? + nvCompilerReadWriteBarrier(); #else #error "Atomics not implemented." #endif diff --git a/src/nvthread/nvthread.cpp b/src/nvthread/nvthread.cpp index b727f2e6..866593d2 100644 --- a/src/nvthread/nvthread.cpp +++ b/src/nvthread/nvthread.cpp @@ -8,7 +8,9 @@ #include "Win32.h" #elif NV_OS_UNIX #include +#if !NV_OS_LINUX #include +#endif #include #elif NV_OS_DARWIN #import diff --git a/src/nvtt/BlockCompressor.cpp b/src/nvtt/BlockCompressor.cpp index 5b703ac3..097675bf 100644 --- a/src/nvtt/BlockCompressor.cpp +++ b/src/nvtt/BlockCompressor.cpp @@ -206,15 +206,19 @@ void FloatColorCompressor::compress(AlphaMode alphaMode, uint w, uint h, uint d, // BC1 -#include "CompressorDXT1.h" - -void FastCompressorDXT1::compressBlock(Vector4 colors[16], float weights[16], const CompressionOptions::Private & compressionOptions, void * output) -{ - compress_dxt1_fast(colors, weights, compressionOptions.colorWeight.xyz(), (BlockDXT1 *)output); +#include "icbc.h" + +inline icbc::Quality qualityLevel(const CompressionOptions::Private & compressionOptions) { + if (compressionOptions.quality == Quality_Fastest) + return icbc::Quality_Fast; + else if (compressionOptions.quality == Quality_Production) + return icbc::Quality_Max; + return icbc::Quality_Default; } + void CompressorDXT1::compressBlock(Vector4 colors[16], float weights[16], const CompressionOptions::Private & compressionOptions, void * output) { - compress_dxt1(colors, weights, compressionOptions.colorWeight.xyz(), /*three_color_mode*/true, (BlockDXT1 *)output); + icbc::compress_dxt1(qualityLevel(compressionOptions), (float*)colors, weights, compressionOptions.colorWeight.component, /*three_color_mode*/true, /*three_color_black*/true, output); } @@ -275,145 +279,6 @@ void CompressorETC2_RGBM::compressBlock(Vector4 colors[16], float weights[16], c // External compressors. -#if defined(HAVE_ATITC) - -typedef int BOOL; -typedef _W64 unsigned long ULONG_PTR; -typedef ULONG_PTR DWORD_PTR; -#include "atitc/ATI_Compress.h" - -void AtiCompressorDXT1::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions) -{ - nvDebugCheck(d == 1); - - // Init source texture - ATI_TC_Texture srcTexture; - srcTexture.dwSize = sizeof(srcTexture); - srcTexture.dwWidth = w; - srcTexture.dwHeight = h; - if (inputFormat == InputFormat_BGRA_8UB) - { - srcTexture.dwPitch = w * 4; - srcTexture.format = ATI_TC_FORMAT_ARGB_8888; - } - else - { - // @@ Floating point input is not swizzled. - srcTexture.dwPitch = w * 16; - srcTexture.format = ATI_TC_FORMAT_ARGB_32F; - } - srcTexture.dwDataSize = ATI_TC_CalculateBufferSize(&srcTexture); - srcTexture.pData = (ATI_TC_BYTE*) data; - - // Init dest texture - ATI_TC_Texture destTexture; - destTexture.dwSize = sizeof(destTexture); - destTexture.dwWidth = w; - destTexture.dwHeight = h; - destTexture.dwPitch = 0; - destTexture.format = ATI_TC_FORMAT_DXT1; - destTexture.dwDataSize = ATI_TC_CalculateBufferSize(&destTexture); - destTexture.pData = (ATI_TC_BYTE*) mem::malloc(destTexture.dwDataSize); - - ATI_TC_CompressOptions options; - options.dwSize = sizeof(options); - options.bUseChannelWeighting = false; - options.bUseAdaptiveWeighting = false; - options.bDXT1UseAlpha = false; - options.nCompressionSpeed = ATI_TC_Speed_Normal; - options.bDisableMultiThreading = false; - //options.bDisableMultiThreading = true; - - // Compress - ATI_TC_ConvertTexture(&srcTexture, &destTexture, &options, NULL, NULL, NULL); - - if (outputOptions.outputHandler != NULL) { - outputOptions.outputHandler->writeData(destTexture.pData, destTexture.dwDataSize); - } - - mem::free(destTexture.pData); -} - -void AtiCompressorDXT5::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions) -{ - nvDebugCheck(d == 1); - - // Init source texture - ATI_TC_Texture srcTexture; - srcTexture.dwSize = sizeof(srcTexture); - srcTexture.dwWidth = w; - srcTexture.dwHeight = h; - if (inputFormat == InputFormat_BGRA_8UB) - { - srcTexture.dwPitch = w * 4; - srcTexture.format = ATI_TC_FORMAT_ARGB_8888; - } - else - { - srcTexture.dwPitch = w * 16; - srcTexture.format = ATI_TC_FORMAT_ARGB_32F; - } - srcTexture.dwDataSize = ATI_TC_CalculateBufferSize(&srcTexture); - srcTexture.pData = (ATI_TC_BYTE*) data; - - // Init dest texture - ATI_TC_Texture destTexture; - destTexture.dwSize = sizeof(destTexture); - destTexture.dwWidth = w; - destTexture.dwHeight = h; - destTexture.dwPitch = 0; - destTexture.format = ATI_TC_FORMAT_DXT5; - destTexture.dwDataSize = ATI_TC_CalculateBufferSize(&destTexture); - destTexture.pData = (ATI_TC_BYTE*) mem::malloc(destTexture.dwDataSize); - - // Compress - ATI_TC_ConvertTexture(&srcTexture, &destTexture, NULL, NULL, NULL, NULL); - - if (outputOptions.outputHandler != NULL) { - outputOptions.outputHandler->writeData(destTexture.pData, destTexture.dwDataSize); - } - - mem::free(destTexture.pData); -} - -#endif // defined(HAVE_ATITC) - -#if defined(HAVE_SQUISH) - -//#include "squish/squish.h" -#include "squish-1.10/squish.h" - -void SquishCompressorDXT1::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions) -{ - nvDebugCheck(d == 1); - nvDebugCheck(false); - -#pragma message(NV_FILE_LINE "TODO: Convert input to fixed point ABGR format instead of ARGB") - /* - Image img(*image); - int count = img.width() * img.height(); - for (int i = 0; i < count; i++) - { - Color32 c = img.pixel(i); - img.pixel(i) = Color32(c.b, c.g, c.r, c.a); - } - - int size = squish::GetStorageRequirements(img.width(), img.height(), squish::kDxt1); - void * blocks = mem::malloc(size); - - squish::CompressImage((const squish::u8 *)img.pixels(), img.width(), img.height(), blocks, squish::kDxt1 | squish::kColourClusterFit); - - if (outputOptions.outputHandler != NULL) { - outputOptions.outputHandler->writeData(blocks, size); - } - - mem::free(blocks); - */ -} - -#endif // defined(HAVE_SQUISH) - - #if defined(HAVE_D3DX) void D3DXCompressorDXT1::compress(InputFormat inputFormat, AlphaMode alphaMode, uint w, uint h, uint d, void * data, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions) @@ -568,7 +433,7 @@ void EtcLibCompressor::compress(AlphaMode alphaMode, uint w, uint h, uint d, con #if defined(HAVE_RGETC) #include "rg_etc1.h" -NV_AT_STARTUP(rg_etc1::pack_etc1_block_init()); +NV_AT_STARTUP(rg_etc1::pack_etc1_block_init()); // @@ Do this in context init. void RgEtcCompressor::compressBlock(ColorBlock & rgba, AlphaMode alphaMode, const CompressionOptions::Private & compressionOptions, void * output) { @@ -590,6 +455,60 @@ void RgEtcCompressor::compressBlock(ColorBlock & rgba, AlphaMode alphaMode, cons #endif +#if defined(HAVE_ETCPACK) + +void EtcPackCompressor::compress(nvtt::AlphaMode alphaMode, uint w, uint h, uint d, const float * data, nvtt::TaskDispatcher * dispatcher, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions) +{ + uint8 *imgdec = (uint8 *)malloc(expandedwidth*expandedheight * 3); + + uint32 block1, block2; + + if (compressionOptions.quality == Quality_Fastest) { + compressBlockDiffFlipFast(img, imgdec, expandedwidth, expandedheight, 4 * x, 4 * y, block1, block2); + } + else { + compressBlockETC1Exhaustive(img, imgdec, expandedwidth, expandedheight, 4 * x, 4 * y, block1, block2); + } +} + +#endif + +#if defined(HAVE_ETCINTEL) +#include "kernel_ispc.h" + +void EtcIntelCompressor::compress(nvtt::AlphaMode alphaMode, uint w, uint h, uint d, const float * data, nvtt::TaskDispatcher * dispatcher, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions) +{ + nvCheck(d == 1); + + // Allocate and convert input. + nv::Array src; + const uint count = w * h; + src.resize(4 * count); + + for (uint i = 0; i < count; i++) { + src[4 * i + 0] = data[count * 0 + i]; // @@ Scale by 256? + src[4 * i + 1] = data[count * 1 + i]; + src[4 * i + 2] = data[count * 2 + i]; + src[4 * i + 3] = data[count * 3 + i]; + } + + int bw = (w + 3) / 4; + int bw = (w + 3) / 4; + + // Allocate output. + nv::Array dst; + dst.resize(bw * bh * 4); + + ispc::rgba_surface surface; + surface.ptr = src.buffer(); + surface.width = w; + surface.height = h; + surface.stride = w * 4; + + ispc::CompressBlocksBC1_ispc(&surface, dst) +} + +#endif #if defined(HAVE_PVRTEXTOOL) @@ -603,7 +522,7 @@ void CompressorPVR::compress(AlphaMode alphaMode, uint w, uint h, uint d, const //pvrtexture::PixelType src_pixel_type = pvrtexture::PixelType('b','g','r','a',8,8,8,8); pvrtexture::PixelType src_pixel_type = pvrtexture::PixelType('r','g','b',0,8,8,8,0); - pvrtexture::CPVRTextureHeader header(src_pixel_type.PixelTypeID, w, h, d, 1/*num mips*/, 1/*num array*/, 1/*num faces*/, color_space, ePVRTVarTypeUnsignedByteNorm); + pvrtexture::CPVRTextureHeader header(src_pixel_type.PixelTypeID, h, w, d, 1/*num mips*/, 1/*num array*/, 1/*num faces*/, color_space, ePVRTVarTypeUnsignedByteNorm); /* uint count = w * h * d; diff --git a/src/nvtt/BlockCompressor.h b/src/nvtt/BlockCompressor.h index 63a9b7cb..294531a0 100644 --- a/src/nvtt/BlockCompressor.h +++ b/src/nvtt/BlockCompressor.h @@ -1,29 +1,5 @@ -// Copyright (c) 2009-2011 Ignacio Castano -// Copyright (c) 2007-2009 NVIDIA Corporation -- Ignacio Castano -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -#ifndef NVTT_BLOCKCOMPRESSOR_H -#define NVTT_BLOCKCOMPRESSOR_H + +#pragma once #include "Compressor.h" @@ -50,11 +26,6 @@ namespace nv // BC1 - struct FastCompressorDXT1 : public FloatColorCompressor - { - virtual void compressBlock(Vector4 colors[16], float weights[16], const nvtt::CompressionOptions::Private & compressionOptions, void * output); - virtual uint blockSize(const nvtt::CompressionOptions::Private &) const { return 8; } - }; struct CompressorDXT1 : public FloatColorCompressor { virtual void compressBlock(Vector4 colors[16], float weights[16], const nvtt::CompressionOptions::Private & compressionOptions, void * output); @@ -103,25 +74,6 @@ namespace nv // External compressors. -#if defined(HAVE_ATITC) - struct AtiCompressorDXT1 : public CompressorInterface - { - virtual void compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alphaMode, uint w, uint h, uint d, void * data, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions); - }; - - struct AtiCompressorDXT5 : public CompressorInterface - { - virtual void compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alphaMode, uint w, uint h, uint d, void * data, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions); - }; -#endif - -#if defined(HAVE_SQUISH) - struct SquishCompressorDXT1 : public CompressorInterface - { - virtual void compress(nvtt::InputFormat inputFormat, nvtt::AlphaMode alphaMode, uint w, uint h, uint d, void * data, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions); - }; -#endif - #if defined(HAVE_D3DX) struct D3DXCompressorDXT1 : public CompressorInterface { @@ -181,6 +133,20 @@ namespace nv }; #endif +#if defined(HAVE_ETCPACK) + struct EtcPackCompressor : public CompressorInterface + { + virtual void compress(nvtt::AlphaMode alphaMode, uint w, uint h, uint d, const float * data, nvtt::TaskDispatcher * dispatcher, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions); + }; +#endif + +#if defined(HAVE_ETCINTEL) + struct EtcIntelCompressor : public CompressorInterface + { + virtual void compress(nvtt::AlphaMode alphaMode, uint w, uint h, uint d, const float * data, nvtt::TaskDispatcher * dispatcher, const nvtt::CompressionOptions::Private & compressionOptions, const nvtt::OutputOptions::Private & outputOptions); + }; +#endif + #if defined(HAVE_PVRTEXTOOL) struct CompressorPVR : public CompressorInterface { @@ -189,6 +155,3 @@ namespace nv #endif } // nv namespace - - -#endif // NVTT_BLOCKCOMPRESSOR_H diff --git a/src/nvtt/CMakeLists.txt b/src/nvtt/CMakeLists.txt index 445aa1ed..987c1859 100644 --- a/src/nvtt/CMakeLists.txt +++ b/src/nvtt/CMakeLists.txt @@ -1,63 +1,67 @@ -PROJECT(nvtt) - -ADD_SUBDIRECTORY(squish) - -SET(NVTT_SRCS - nvtt.h nvtt.cpp - nvtt_wrapper.h nvtt_wrapper.cpp - ClusterFit.h ClusterFit.cpp - Compressor.h - BlockCompressor.h BlockCompressor.cpp - CompressorDX9.h CompressorDX9.cpp - CompressorDX10.h CompressorDX10.cpp - CompressorDX11.h CompressorDX11.cpp - CompressorDXT1.h CompressorDXT1.cpp - CompressorDXT5_RGBM.h CompressorDXT5_RGBM.cpp - CompressorETC.h CompressorETC.cpp - CompressorRGB.h CompressorRGB.cpp - Context.h Context.cpp - QuickCompressDXT.h QuickCompressDXT.cpp - OptimalCompressDXT.h OptimalCompressDXT.cpp - SingleColorLookup.h SingleColorLookup.cpp - CompressionOptions.h CompressionOptions.cpp - InputOptions.h InputOptions.cpp - OutputOptions.h OutputOptions.cpp - TaskDispatcher.h #TaskDispatcher.cpp - Surface.h Surface.cpp - CubeSurface.h CubeSurface.cpp - cuda/CudaUtils.h cuda/CudaUtils.cpp - cuda/CudaMath.h - cuda/BitmapTable.h - cuda/CudaCompressorDXT.h cuda/CudaCompressorDXT.cpp) - -IF (CUDA_FOUND) - ADD_DEFINITIONS(-DHAVE_CUDA) - CUDA_COMPILE(CUDA_SRCS cuda/CompressKernel.cu) - SET(NVTT_SRCS ${NVTT_SRCS} ${CUDA_SRCS}) - SET(LIBS ${LIBS} ${CUDA_LIBRARIES}) - INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS}) -ENDIF (CUDA_FOUND) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${NV_SOURCE_DIR}/extern/rg_etc1_v104) - -ADD_DEFINITIONS(-DNVTT_EXPORTS) - -IF(NVTT_SHARED) - ADD_LIBRARY(nvtt SHARED ${NVTT_SRCS}) -ELSE(NVTT_SHARED) - ADD_LIBRARY(nvtt ${NVTT_SRCS}) -ENDIF(NVTT_SHARED) - -TARGET_LINK_LIBRARIES(nvtt ${LIBS} nvcore nvimage nvthread squish bc6h bc7 nvmath rg_etc1) - -INSTALL(TARGETS nvtt - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - -INSTALL(FILES nvtt.h DESTINATION include/nvtt) - - -ADD_SUBDIRECTORY(tools) -ADD_SUBDIRECTORY(tests) +PROJECT(nvtt) + +ADD_SUBDIRECTORY(squish) + +SET(NVTT_SRCS + nvtt.h nvtt.cpp + nvtt_wrapper.h nvtt_wrapper.cpp + Compressor.h + BlockCompressor.h BlockCompressor.cpp + CompressorDX9.h CompressorDX9.cpp + CompressorDX10.h CompressorDX10.cpp + CompressorDX11.h CompressorDX11.cpp + icbc.h icbc.cpp + CompressorDXT5_RGBM.h CompressorDXT5_RGBM.cpp + CompressorETC.h CompressorETC.cpp + CompressorRGB.h CompressorRGB.cpp + Context.h Context.cpp + QuickCompressDXT.h QuickCompressDXT.cpp + OptimalCompressDXT.h OptimalCompressDXT.cpp + SingleColorLookup.h SingleColorLookup.cpp + CompressionOptions.h CompressionOptions.cpp + InputOptions.h InputOptions.cpp + OutputOptions.h OutputOptions.cpp + TaskDispatcher.h #TaskDispatcher.cpp + Surface.h Surface.cpp + CubeSurface.h CubeSurface.cpp + cuda/CudaUtils.h cuda/CudaUtils.cpp + cuda/CudaMath.h + cuda/BitmapTable.h + cuda/CudaCompressorDXT.h cuda/CudaCompressorDXT.cpp + #${NV_SOURCE_DIR}/extern/rg_etc1_v104/rg_etc1.h ${NV_SOURCE_DIR}/extern/rg_etc1_v104/rg_etc1.cpp + #${NV_SOURCE_DIR}/extern/etcpack/etcpack.cxx ${NV_SOURCE_DIR}/extern/etcpack/etcdec.cxx + ) + +IF (CUDA_FOUND) + ADD_DEFINITIONS(-DHAVE_CUDA) + CUDA_COMPILE(CUDA_SRCS cuda/CompressKernel.cu) + SET(NVTT_SRCS ${NVTT_SRCS} ${CUDA_SRCS}) + SET(LIBS ${LIBS} ${CUDA_LIBRARIES}) + INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS}) +ENDIF (CUDA_FOUND) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${NV_SOURCE_DIR}/extern/rg_etc1_v104) + +ADD_DEFINITIONS(-DNVTT_EXPORTS) +#ADD_DEFINITIONS(-DHAVE_RGETC) +#ADD_DEFINITIONS(-DHAVE_ETCPACK) + +IF(NVTT_SHARED) + ADD_LIBRARY(nvtt SHARED ${NVTT_SRCS}) +ELSE(NVTT_SHARED) + ADD_LIBRARY(nvtt ${NVTT_SRCS}) +ENDIF(NVTT_SHARED) + +TARGET_LINK_LIBRARIES(nvtt ${LIBS} nvcore nvimage nvthread nvsquish bc6h bc7 nvmath rg_etc1) + +INSTALL(TARGETS nvtt + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + +INSTALL(FILES nvtt.h nvtt_wrapper.h DESTINATION include/nvtt) + + +ADD_SUBDIRECTORY(tools) +ADD_SUBDIRECTORY(tests) diff --git a/src/nvtt/ClusterFit.cpp b/src/nvtt/ClusterFit.cpp deleted file mode 100644 index 39bbbc42..00000000 --- a/src/nvtt/ClusterFit.cpp +++ /dev/null @@ -1,587 +0,0 @@ -/* ----------------------------------------------------------------------------- - - Copyright (c) 2006 Simon Brown si@sjbrown.co.uk - Copyright (c) 2006 Ignacio Castano icastano@nvidia.com - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -------------------------------------------------------------------------- */ - -#include "ClusterFit.h" -#include "nvmath/Fitting.h" -#include "nvmath/Vector.inl" -#include "nvmath/ftoi.h" -#include "nvimage/ColorBlock.h" - -#include // FLT_MAX - -using namespace nv; - -ClusterFit::ClusterFit() -{ -} - -void ClusterFit::setColorSet(const Vector3 * colors, const float * weights, int count) -{ - // initialise the best error -#if NVTT_USE_SIMD - m_besterror = SimdVector( FLT_MAX ); - Vector3 metric = m_metric.toVector3(); -#else - m_besterror = FLT_MAX; - Vector3 metric = m_metric; -#endif - - m_count = count; - - Vector3 principal = Fit::computePrincipalComponent_PowerMethod(count, colors, weights, metric); - //Vector3 principal = Fit::computePrincipalComponent_EigenSolver(count, colors, weights, metric); - - // build the list of values - int order[16]; - float dps[16]; - for (uint i = 0; i < m_count; ++i) - { - dps[i] = dot(colors[i], principal); - order[i] = i; - } - - // stable sort - for (uint i = 0; i < m_count; ++i) - { - for (uint j = i; j > 0 && dps[j] < dps[j - 1]; --j) - { - swap(dps[j], dps[j - 1]); - swap(order[j], order[j - 1]); - } - } - - // weight all the points -#if NVTT_USE_SIMD - m_xxsum = SimdVector( 0.0f ); - m_xsum = SimdVector( 0.0f ); -#else - m_xxsum = Vector3(0.0f); - m_xsum = Vector3(0.0f); - m_wsum = 0.0f; -#endif - - for (uint i = 0; i < m_count; ++i) - { - int p = order[i]; -#if NVTT_USE_SIMD - NV_ALIGN_16 Vector4 tmp(colors[p], 1); - m_weighted[i] = SimdVector(tmp.component) * SimdVector(weights[p]); - m_xxsum += m_weighted[i] * m_weighted[i]; - m_xsum += m_weighted[i]; -#else - m_weighted[i] = colors[p] * weights[p]; - m_xxsum += m_weighted[i] * m_weighted[i]; - m_xsum += m_weighted[i]; - m_weights[i] = weights[p]; - m_wsum += m_weights[i]; -#endif - } -} - - - -void ClusterFit::setColorWeights(Vector4::Arg w) -{ -#if NVTT_USE_SIMD - NV_ALIGN_16 Vector4 tmp(w.xyz(), 1); - m_metric = SimdVector(tmp.component); -#else - m_metric = w.xyz(); -#endif - m_metricSqr = m_metric * m_metric; -} - -float ClusterFit::bestError() const -{ -#if NVTT_USE_SIMD - SimdVector x = m_xxsum * m_metricSqr; - SimdVector error = m_besterror + x.splatX() + x.splatY() + x.splatZ(); - return error.toFloat(); -#else - return m_besterror + dot(m_xxsum, m_metricSqr); -#endif - -} - -#if NVTT_USE_SIMD - -bool ClusterFit::compress3( Vector3 * start, Vector3 * end ) -{ - const int count = m_count; - const SimdVector one = SimdVector(1.0f); - const SimdVector zero = SimdVector(0.0f); - const SimdVector half(0.5f, 0.5f, 0.5f, 0.25f); - const SimdVector two = SimdVector(2.0); - const SimdVector grid( 31.0f, 63.0f, 31.0f, 0.0f ); - const SimdVector gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f, 0.0f ); - - // declare variables - SimdVector beststart = SimdVector( 0.0f ); - SimdVector bestend = SimdVector( 0.0f ); - SimdVector besterror = SimdVector( FLT_MAX ); - - SimdVector x0 = zero; - - int b0 = 0, b1 = 0; - - // check all possible clusters for this total order - for( int c0 = 0; c0 <= count; c0++) - { - SimdVector x1 = zero; - - for( int c1 = 0; c1 <= count-c0; c1++) - { - const SimdVector x2 = m_xsum - x1 - x0; - - //Vector3 alphax_sum = x0 + x1 * 0.5f; - //float alpha2_sum = w0 + w1 * 0.25f; - const SimdVector alphax_sum = multiplyAdd(x1, half, x0); // alphax_sum, alpha2_sum - const SimdVector alpha2_sum = alphax_sum.splatW(); - - //const Vector3 betax_sum = x2 + x1 * 0.5f; - //const float beta2_sum = w2 + w1 * 0.25f; - const SimdVector betax_sum = multiplyAdd(x1, half, x2); // betax_sum, beta2_sum - const SimdVector beta2_sum = betax_sum.splatW(); - - //const float alphabeta_sum = w1 * 0.25f; - const SimdVector alphabeta_sum = (x1 * half).splatW(); // alphabeta_sum - - // const float factor = 1.0f / (alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum); - const SimdVector factor = reciprocal( negativeMultiplySubtract(alphabeta_sum, alphabeta_sum, alpha2_sum*beta2_sum) ); - - SimdVector a = negativeMultiplySubtract(betax_sum, alphabeta_sum, alphax_sum*beta2_sum) * factor; - SimdVector b = negativeMultiplySubtract(alphax_sum, alphabeta_sum, betax_sum*alpha2_sum) * factor; - - // clamp to the grid - a = min( one, max( zero, a ) ); - b = min( one, max( zero, b ) ); - a = truncate( multiplyAdd( grid, a, half ) ) * gridrcp; - b = truncate( multiplyAdd( grid, b, half ) ) * gridrcp; - - // compute the error (we skip the constant xxsum) - SimdVector e1 = multiplyAdd( a*a, alpha2_sum, b*b*beta2_sum ); - SimdVector e2 = negativeMultiplySubtract( a, alphax_sum, a*b*alphabeta_sum ); - SimdVector e3 = negativeMultiplySubtract( b, betax_sum, e2 ); - SimdVector e4 = multiplyAdd( two, e3, e1 ); - - // apply the metric to the error term - SimdVector e5 = e4 * m_metricSqr; - SimdVector error = e5.splatX() + e5.splatY() + e5.splatZ(); - - // keep the solution if it wins - if( compareAnyLessThan( error, besterror ) ) - { - besterror = error; - beststart = a; - bestend = b; - b0 = c0; - b1 = c1; - } - - x1 += m_weighted[c0+c1]; - } - - x0 += m_weighted[c0]; - } - - // save the block if necessary - if( compareAnyLessThan( besterror, m_besterror ) ) - { - - *start = beststart.toVector3(); - *end = bestend.toVector3(); - - // save the error - m_besterror = besterror; - - return true; - } - - return false; -} - -bool ClusterFit::compress4( Vector3 * start, Vector3 * end ) -{ - const int count = m_count; - const SimdVector one = SimdVector(1.0f); - const SimdVector zero = SimdVector(0.0f); - const SimdVector half = SimdVector(0.5f); - const SimdVector two = SimdVector(2.0); - const SimdVector onethird( 1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f, 1.0f/9.0f ); - const SimdVector twothirds( 2.0f/3.0f, 2.0f/3.0f, 2.0f/3.0f, 4.0f/9.0f ); - const SimdVector twonineths = SimdVector( 2.0f/9.0f ); - const SimdVector grid( 31.0f, 63.0f, 31.0f, 0.0f ); - const SimdVector gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f, 0.0f ); - - // declare variables - SimdVector beststart = SimdVector( 0.0f ); - SimdVector bestend = SimdVector( 0.0f ); - SimdVector besterror = SimdVector( FLT_MAX ); - - SimdVector x0 = zero; - int b0 = 0, b1 = 0, b2 = 0; - - // check all possible clusters for this total order - for( int c0 = 0; c0 <= count; c0++) - { - SimdVector x1 = zero; - - for( int c1 = 0; c1 <= count-c0; c1++) - { - SimdVector x2 = zero; - - for( int c2 = 0; c2 <= count-c0-c1; c2++) - { - const SimdVector x3 = m_xsum - x2 - x1 - x0; - - //const Vector3 alphax_sum = x0 + x1 * (2.0f / 3.0f) + x2 * (1.0f / 3.0f); - //const float alpha2_sum = w0 + w1 * (4.0f/9.0f) + w2 * (1.0f/9.0f); - const SimdVector alphax_sum = multiplyAdd(x2, onethird, multiplyAdd(x1, twothirds, x0)); // alphax_sum, alpha2_sum - const SimdVector alpha2_sum = alphax_sum.splatW(); - - //const Vector3 betax_sum = x3 + x2 * (2.0f / 3.0f) + x1 * (1.0f / 3.0f); - //const float beta2_sum = w3 + w2 * (4.0f/9.0f) + w1 * (1.0f/9.0f); - const SimdVector betax_sum = multiplyAdd(x2, twothirds, multiplyAdd(x1, onethird, x3)); // betax_sum, beta2_sum - const SimdVector beta2_sum = betax_sum.splatW(); - - //const float alphabeta_sum = (w1 + w2) * (2.0f/9.0f); - const SimdVector alphabeta_sum = twonineths*( x1 + x2 ).splatW(); // alphabeta_sum - - //const float factor = 1.0f / (alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum); - const SimdVector factor = reciprocal( negativeMultiplySubtract(alphabeta_sum, alphabeta_sum, alpha2_sum*beta2_sum) ); - - SimdVector a = negativeMultiplySubtract(betax_sum, alphabeta_sum, alphax_sum*beta2_sum) * factor; - SimdVector b = negativeMultiplySubtract(alphax_sum, alphabeta_sum, betax_sum*alpha2_sum) * factor; - - // clamp to the grid - a = min( one, max( zero, a ) ); - b = min( one, max( zero, b ) ); - a = truncate( multiplyAdd( grid, a, half ) ) * gridrcp; - b = truncate( multiplyAdd( grid, b, half ) ) * gridrcp; - - // compute the error (we skip the constant xxsum) - SimdVector e1 = multiplyAdd( a*a, alpha2_sum, b*b*beta2_sum ); - SimdVector e2 = negativeMultiplySubtract( a, alphax_sum, a*b*alphabeta_sum ); - SimdVector e3 = negativeMultiplySubtract( b, betax_sum, e2 ); - SimdVector e4 = multiplyAdd( two, e3, e1 ); - -#if 1 - // apply the metric to the error term - SimdVector e5 = e4 * m_metricSqr; - SimdVector error = e5.splatX() + e5.splatY() + e5.splatZ(); -#else - // @@ Is there a horizontal max SIMD instruction? - SimdVector error = e4.splatX() + e4.splatY() + e4.splatZ(); - error *= two; - error += max(max(e4.splatX(), e4.splatY()), e4.splatZ()); - error -= min(min(e4.splatX(), e4.splatY()), e4.splatZ()); - -#endif - - // keep the solution if it wins - if (compareAnyLessThan(error, besterror)) - { - besterror = error; - beststart = a; - bestend = b; - b0 = c0; - b1 = c1; - b2 = c2; - } - - x2 += m_weighted[c0+c1+c2]; - } - - x1 += m_weighted[c0+c1]; - } - - x0 += m_weighted[c0]; - } - - // save the block if necessary - if (compareAnyLessThan(besterror, m_besterror)) - { - *start = beststart.toVector3(); - *end = bestend.toVector3(); - - // save the error - m_besterror = besterror; - - return true; - } - - return false; -} - -#else - -inline Vector3 round565(const Vector3 & v) { - uint r = ftoi_trunc(v.x * 31.0f); - float r0 = float(((r+0) << 3) | ((r+0) >> 2)); - float r1 = float(((r+1) << 3) | ((r+1) >> 2)); - if (fabs(v.x - r1) < fabs(v.x - r0)) r = min(r+1, 31U); - r = (r << 3) | (r >> 2); - - uint g = ftoi_trunc(v.y * 63.0f); - float g0 = float(((g+0) << 2) | ((g+0) >> 4)); - float g1 = float(((g+1) << 2) | ((g+1) >> 4)); - if (fabs(v.y - g1) < fabs(v.y - g0)) g = min(g+1, 63U); - g = (g << 2) | (g >> 4); - - uint b = ftoi_trunc(v.z * 31.0f); - float b0 = float(((b+0) << 3) | ((b+0) >> 2)); - float b1 = float(((b+1) << 3) | ((b+1) >> 2)); - if (fabs(v.z - b1) < fabs(v.z - b0)) b = min(b+1, 31U); - - b = (b << 3) | (b >> 2); - - return Vector3(float(r)/255, float(g)/255, float(b)/255); -} - -bool ClusterFit::compress3(Vector3 * start, Vector3 * end) -{ - const uint count = m_count; - const Vector3 grid( 31.0f, 63.0f, 31.0f ); - const Vector3 gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f ); - - // declare variables - Vector3 beststart( 0.0f ); - Vector3 bestend( 0.0f ); - float besterror = FLT_MAX; - - Vector3 x0(0.0f); - float w0 = 0.0f; - - int b0 = 0, b1 = 0; - - // check all possible clusters for this total order - for (uint c0 = 0; c0 <= count; c0++) - { - Vector3 x1(0.0f); - float w1 = 0.0f; - - for (uint c1 = 0; c1 <= count-c0; c1++) - { - float w2 = m_wsum - w0 - w1; - - // These factors could be entirely precomputed. - float const alpha2_sum = w0 + w1 * 0.25f; - float const beta2_sum = w2 + w1 * 0.25f; - float const alphabeta_sum = w1 * 0.25f; - float const factor = 1.0f / (alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum); - - Vector3 const alphax_sum = x0 + x1 * 0.5f; - Vector3 const betax_sum = m_xsum - alphax_sum; - - Vector3 a = (alphax_sum*beta2_sum - betax_sum*alphabeta_sum) * factor; - Vector3 b = (betax_sum*alpha2_sum - alphax_sum*alphabeta_sum) * factor; - - // clamp to the grid - a = clamp(a, 0, 1); - b = clamp(b, 0, 1); -#if 1 - a = floor(grid * a + 0.5f) * gridrcp; - b = floor(grid * b + 0.5f) * gridrcp; -#else - - //int ar = ftoi_round(31 * a.x); ar = (ar << 3) | (ar >> 2); a.x = float(ar) / 255.0f; - //int ag = ftoi_round(63 * a.y); ar = (ag << 2) | (ag >> 4); a.y = float(ag) / 255.0f; - //int ab = ftoi_round(31 * a.z); ar = (ab << 3) | (ab >> 2); a.z = float(ab) / 255.0f; - //int br = ftoi_round(31 * b.x); br = (br << 3) | (br >> 2); b.x = float(br) / 255.0f; - //int bg = ftoi_round(63 * b.y); br = (bg << 2) | (bg >> 4); b.y = float(bg) / 255.0f; - //int bb = ftoi_round(31 * b.z); br = (bb << 3) | (bb >> 2); b.z = float(bb) / 255.0f; - - /*a = floor(a * grid + 0.5f); - a.x = (a.x * 8 + floorf(a.x / 4)) / 255.0f; - a.y = (a.y * 4 + floorf(a.y / 16)) / 255.0f; - a.z = (a.z * 8 + floorf(a.z / 4)) / 255.0f; - - b = floor(b * grid + 0.5f); - b.x = (b.x * 8 + floorf(b.x / 4)) / 255.0f; - b.y = (b.y * 4 + floorf(b.y / 16)) / 255.0f; - b.z = (b.z * 8 + floorf(b.z / 4)) / 255.0f;*/ - - a = round565(a); - b = round565(b); -#endif - - // compute the error - Vector3 e1 = a*a*alpha2_sum + b*b*beta2_sum + 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum ); - - // apply the metric to the error term - float error = dot(e1, m_metricSqr); - - // keep the solution if it wins - if (error < besterror) - { - besterror = error; - beststart = a; - bestend = b; - b0 = c0; - b1 = c1; - } - - x1 += m_weighted[c0+c1]; - w1 += m_weights[c0+c1]; - } - - x0 += m_weighted[c0]; - w0 += m_weights[c0]; - } - - // save the block if necessary - if( besterror < m_besterror ) - { - - *start = beststart; - *end = bestend; - - // save the error - m_besterror = besterror; - - return true; - } - - return false; -} - -bool ClusterFit::compress4(Vector3 * start, Vector3 * end) -{ - const uint count = m_count; - const Vector3 grid( 31.0f, 63.0f, 31.0f ); - const Vector3 gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f ); - - // declare variables - Vector3 beststart( 0.0f ); - Vector3 bestend( 0.0f ); - float besterror = FLT_MAX; - - Vector3 x0(0.0f); - float w0 = 0.0f; - int b0 = 0, b1 = 0, b2 = 0; - - // check all possible clusters for this total order - for (uint c0 = 0; c0 <= count; c0++) - { - Vector3 x1(0.0f); - float w1 = 0.0f; - - for (uint c1 = 0; c1 <= count-c0; c1++) - { - Vector3 x2(0.0f); - float w2 = 0.0f; - - for (uint c2 = 0; c2 <= count-c0-c1; c2++) - { - float w3 = m_wsum - w0 - w1 - w2; - - float const alpha2_sum = w0 + w1 * (4.0f/9.0f) + w2 * (1.0f/9.0f); - float const beta2_sum = w3 + w2 * (4.0f/9.0f) + w1 * (1.0f/9.0f); - float const alphabeta_sum = (w1 + w2) * (2.0f/9.0f); - float const factor = 1.0f / (alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum); - - Vector3 const alphax_sum = x0 + x1 * (2.0f / 3.0f) + x2 * (1.0f / 3.0f); - Vector3 const betax_sum = m_xsum - alphax_sum; - - Vector3 a = ( alphax_sum*beta2_sum - betax_sum*alphabeta_sum )*factor; - Vector3 b = ( betax_sum*alpha2_sum - alphax_sum*alphabeta_sum )*factor; - - // clamp to the grid - a = clamp(a, 0, 1); - b = clamp(b, 0, 1); -#if 0 - a = floor(a * grid + 0.5f) * gridrcp; - b = floor(b * grid + 0.5f) * gridrcp; -#else - //int ar = ftoi_round(31 * a.x); ar = (ar << 3) | (ar >> 2); a.x = float(ar) / 255.0f; - //int ag = ftoi_round(63 * a.y); ar = (ag << 2) | (ag >> 4); a.y = float(ag) / 255.0f; - //int ab = ftoi_round(31 * a.z); ar = (ab << 3) | (ab >> 2); a.z = float(ab) / 255.0f; - //int br = ftoi_round(31 * b.x); br = (br << 3) | (br >> 2); b.x = float(br) / 255.0f; - //int bg = ftoi_round(63 * b.y); br = (bg << 2) | (bg >> 4); b.y = float(bg) / 255.0f; - //int bb = ftoi_round(31 * b.z); br = (bb << 3) | (bb >> 2); b.z = float(bb) / 255.0f; - - /* - a = floor(a * grid + 0.5f); - a.x = (a.x * 8 + floorf(a.x / 4)) / 255.0f; - a.y = (a.y * 4 + floorf(a.y / 16)) / 255.0f; - a.z = (a.z * 8 + floorf(a.z / 4)) / 255.0f; - - b = floor(b * grid + 0.5f); - b.x = (b.x * 8 + floorf(b.x / 4)) / 255.0f; - b.y = (b.y * 4 + floorf(b.y / 16)) / 255.0f; - b.z = (b.z * 8 + floorf(b.z / 4)) / 255.0f; - */ - - a = round565(a); - b = round565(b); -#endif - // @@ It would be much more accurate to evaluate the error exactly. - - // compute the error - Vector3 e1 = a*a*alpha2_sum + b*b*beta2_sum + 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum ); - - // apply the metric to the error term - float error = dot( e1, m_metricSqr ); - - // keep the solution if it wins - if (error < besterror) - { - besterror = error; - beststart = a; - bestend = b; - b0 = c0; - b1 = c1; - b2 = c2; - } - - x2 += m_weighted[c0+c1+c2]; - w2 += m_weights[c0+c1+c2]; - } - - x1 += m_weighted[c0+c1]; - w1 += m_weights[c0+c1]; - } - - x0 += m_weighted[c0]; - w0 += m_weights[c0]; - } - - // save the block if necessary - if (besterror < m_besterror) - { - *start = beststart; - *end = bestend; - - // save the error - m_besterror = besterror; - - return true; - } - - return false; -} - -#endif // NVTT_USE_SIMD diff --git a/src/nvtt/ClusterFit.h b/src/nvtt/ClusterFit.h deleted file mode 100644 index 7f85b6c1..00000000 --- a/src/nvtt/ClusterFit.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ----------------------------------------------------------------------------- - - Copyright (c) 2006 Simon Brown si@sjbrown.co.uk - Copyright (c) 2006 Ignacio Castano icastano@nvidia.com - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -------------------------------------------------------------------------- */ - -#ifndef NVTT_CLUSTERFIT_H -#define NVTT_CLUSTERFIT_H - -#include "nvmath/SimdVector.h" -#include "nvmath/Vector.h" -#include "nvcore/Memory.h" - -// Use SIMD version if altivec or SSE are available. -#define NVTT_USE_SIMD (NV_USE_ALTIVEC || NV_USE_SSE) -//#define NVTT_USE_SIMD 0 - -namespace nv { - - struct ColorSet; - - class ClusterFit - { - public: - ClusterFit(); - - //void setColorSet(const ColorSet * set); - void setColorSet(const Vector3 * colors, const float * weights, int count); - - void setColorWeights(const Vector4 & w); - float bestError() const; - - bool compress3(Vector3 * start, Vector3 * end); - bool compress4(Vector3 * start, Vector3 * end); - - private: - - uint m_count; - - // IC: Color and weight arrays are larger than necessary to avoid compiler warning. - - #if NVTT_USE_SIMD - NV_ALIGN_16 SimdVector m_weighted[17]; // color | weight - SimdVector m_metric; // vec3 - SimdVector m_metricSqr; // vec3 - SimdVector m_xxsum; // color | weight - SimdVector m_xsum; // color | weight (wsum) - SimdVector m_besterror; // scalar - #else - Vector3 m_weighted[17]; - float m_weights[17]; - Vector3 m_metric; - Vector3 m_metricSqr; - Vector3 m_xxsum; - Vector3 m_xsum; - float m_wsum; - float m_besterror; - #endif - }; - -} // nv namespace - -#endif // NVTT_CLUSTERFIT_H diff --git a/src/nvtt/CompressorDX9.cpp b/src/nvtt/CompressorDX9.cpp index c05c7623..1402421e 100644 --- a/src/nvtt/CompressorDX9.cpp +++ b/src/nvtt/CompressorDX9.cpp @@ -27,8 +27,6 @@ #include "OptimalCompressDXT.h" #include "CompressionOptions.h" #include "OutputOptions.h" -#include "ClusterFit.h" -//#include "CompressorDXT1.h" #include "CompressorDXT5_RGBM.h" // squish diff --git a/src/nvtt/CompressorDXT1.cpp b/src/nvtt/CompressorDXT1.cpp deleted file mode 100644 index 8a096690..00000000 --- a/src/nvtt/CompressorDXT1.cpp +++ /dev/null @@ -1,884 +0,0 @@ - -#include "CompressorDXT1.h" -#include "SingleColorLookup.h" -#include "ClusterFit.h" - -#include "nvimage/ColorBlock.h" -#include "nvimage/BlockDXT.h" - -#include "nvmath/Color.inl" -#include "nvmath/Vector.inl" -#include "nvmath/Fitting.h" -#include "nvmath/ftoi.h" - -#include "nvcore/Utils.h" // swap - -#include // memset -#include // FLT_MAX - - -using namespace nv; - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Color conversion functions. - -static const float midpoints5[32] = { - 0.015686f, 0.047059f, 0.078431f, 0.111765f, 0.145098f, 0.176471f, 0.207843f, 0.241176f, 0.274510f, 0.305882f, 0.337255f, 0.370588f, 0.403922f, 0.435294f, 0.466667f, 0.5f, - 0.533333f, 0.564706f, 0.596078f, 0.629412f, 0.662745f, 0.694118f, 0.725490f, 0.758824f, 0.792157f, 0.823529f, 0.854902f, 0.888235f, 0.921569f, 0.952941f, 0.984314f, 1.0f -}; - -static const float midpoints6[64] = { - 0.007843f, 0.023529f, 0.039216f, 0.054902f, 0.070588f, 0.086275f, 0.101961f, 0.117647f, 0.133333f, 0.149020f, 0.164706f, 0.180392f, 0.196078f, 0.211765f, 0.227451f, 0.245098f, - 0.262745f, 0.278431f, 0.294118f, 0.309804f, 0.325490f, 0.341176f, 0.356863f, 0.372549f, 0.388235f, 0.403922f, 0.419608f, 0.435294f, 0.450980f, 0.466667f, 0.482353f, 0.500000f, - 0.517647f, 0.533333f, 0.549020f, 0.564706f, 0.580392f, 0.596078f, 0.611765f, 0.627451f, 0.643137f, 0.658824f, 0.674510f, 0.690196f, 0.705882f, 0.721569f, 0.737255f, 0.754902f, - 0.772549f, 0.788235f, 0.803922f, 0.819608f, 0.835294f, 0.850980f, 0.866667f, 0.882353f, 0.898039f, 0.913725f, 0.929412f, 0.945098f, 0.960784f, 0.976471f, 0.992157f, 1.0f -}; - -/*void init_tables() { - for (int i = 0; i < 31; i++) { - float f0 = float(((i+0) << 3) | ((i+0) >> 2)) / 255.0f; - float f1 = float(((i+1) << 3) | ((i+1) >> 2)) / 255.0f; - midpoints5[i] = (f0 + f1) * 0.5; - } - midpoints5[31] = 1.0f; - - for (int i = 0; i < 63; i++) { - float f0 = float(((i+0) << 2) | ((i+0) >> 4)) / 255.0f; - float f1 = float(((i+1) << 2) | ((i+1) >> 4)) / 255.0f; - midpoints6[i] = (f0 + f1) * 0.5; - } - midpoints6[63] = 1.0f; -}*/ - -static Color16 vector3_to_color16(const Vector3 & v) { - // Truncate. - uint r = ftoi_trunc(clamp(v.x * 31.0f, 0.0f, 31.0f)); - uint g = ftoi_trunc(clamp(v.y * 63.0f, 0.0f, 63.0f)); - uint b = ftoi_trunc(clamp(v.z * 31.0f, 0.0f, 31.0f)); - - // Round exactly according to 565 bit-expansion. - r += (v.x > midpoints5[r]); - g += (v.y > midpoints6[g]); - b += (v.z > midpoints5[b]); - - return Color16((r << 11) | (g << 5) | b); -} - - -static Color32 bitexpand_color16_to_color32(Color16 c16) { - Color32 c32; - //c32.b = (c16.b << 3) | (c16.b >> 2); - //c32.g = (c16.g << 2) | (c16.g >> 4); - //c32.r = (c16.r << 3) | (c16.r >> 2); - //c32.a = 0xFF; - - c32.u = ((c16.u << 3) & 0xf8) | ((c16.u << 5) & 0xfc00) | ((c16.u << 8) & 0xf80000); - c32.u |= (c32.u >> 5) & 0x070007; - c32.u |= (c32.u >> 6) & 0x000300; - - return c32; -} - -/*static Color32 bitexpand_color16_to_color32(int r, int g, int b) { - Color32 c32; - c32.b = (b << 3) | (b >> 2); - c32.g = (g << 2) | (g >> 4); - c32.r = (r << 3) | (r >> 2); - c32.a = 0xFF; - return c32; -}*/ - -static Color16 truncate_color32_to_color16(Color32 c32) { - Color16 c16; - c16.b = (c32.b >> 3); - c16.g = (c32.g >> 2); - c16.r = (c32.r >> 3); - return c16; -} - -/*inline Vector3 r5g6b5_to_vector3(int r, int g, int b) -{ - Vector3 c; - c.x = float((r << 3) | (r >> 2)); - c.y = float((g << 2) | (g >> 4)); - c.z = float((b << 3) | (b >> 2)); - return c; -}*/ - -inline Vector3 color_to_vector3(Color32 c) -{ - const float scale = 1.0f / 255.0f; - return Vector3(c.r * scale, c.g * scale, c.b * scale); -} - -inline Color32 vector3_to_color(Vector3 v) -{ - Color32 color; - color.r = U8(ftoi_round(saturate(v.x) * 255)); - color.g = U8(ftoi_round(saturate(v.y) * 255)); - color.b = U8(ftoi_round(saturate(v.z) * 255)); - color.a = 255; - return color; -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Input block processing. - -inline static void color_block_to_vector_block(const ColorBlock & rgba, Vector3 block[16]) -{ - for (int i = 0; i < 16; i++) - { - const Color32 c = rgba.color(i); - block[i] = Vector3(c.r, c.g, c.b); - } -} - -// Find first valid color. -static bool find_valid_color_rgb(const Vector3 * colors, const float * weights, int count, Vector3 * valid_color) -{ - for (int i = 0; i < count; i++) { - if (weights[i] > 0.0f) { - *valid_color = colors[i]; - return true; - } - } - - // No valid colors. - return false; -} - -static bool is_single_color_rgb(const Vector3 * colors, const float * weights, int count, Vector3 color) -{ - for (int i = 0; i < count; i++) { - if (weights[i] > 0.0f) { - if (colors[i] != color) return false; - } - } - - return true; -} - -// Find similar colors and combine them together. -static int reduce_colors(const Vector4 * input_colors, const float * input_weights, Vector3 * colors, float * weights) -{ - int n = 0; - for (int i = 0; i < 16; i++) - { - Vector3 ci = input_colors[i].xyz(); - float wi = input_weights[i]; - - if (wi > 0) { - // Find matching color. - int j; - for (j = 0; j < n; j++) { - if (equal(colors[j].x, ci.x) && equal(colors[j].y, ci.y) && equal(colors[j].z, ci.z)) { - weights[j] += wi; - break; - } - } - - // No match found. Add new color. - if (j == n) { - colors[n] = ci; - weights[n] = wi; - n++; - } - } - } - - nvDebugCheck(n <= 16); - - return n; -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Error evaluation. - -// Different ways of estimating the error. -/*static float evaluate_mse(const Vector3 & p, const Vector3 & c) { - //return (square(p.x-c.x) * w2.x + square(p.y-c.y) * w2.y + square(p.z-c.z) * w2.z); - Vector3 d = (p - c); - return dot(d, d); -}*/ - -static float evaluate_mse(const Vector3 & p, const Vector3 & c, const Vector3 & w) { - //return (square(p.x-c.x) * w2.x + square(p.y-c.y) * w2.y + square(p.z-c.z) * w2.z); - Vector3 d = (p - c) * w; - return dot(d, d); -} - -/*static float evaluate_mse(const Vector3 & p, const Vector3 & c, const Vector3 & w) { - return ww.x * square(p.x-c.x) + ww.y * square(p.y-c.y) + ww.z * square(p.z-c.z); -}*/ - -static int evaluate_mse(const Color32 & p, const Color32 & c) { - return (square(int(p.r)-c.r) + square(int(p.g)-c.g) + square(int(p.b)-c.b)); -} - -/*static float evaluate_mse(const Vector3 palette[4], const Vector3 & c, const Vector3 & w) { - float e0 = evaluate_mse(palette[0], c, w); - float e1 = evaluate_mse(palette[1], c, w); - float e2 = evaluate_mse(palette[2], c, w); - float e3 = evaluate_mse(palette[3], c, w); - return min(min(e0, e1), min(e2, e3)); -}*/ - -static int evaluate_mse(const Color32 palette[4], const Color32 & c) { - int e0 = evaluate_mse(palette[0], c); - int e1 = evaluate_mse(palette[1], c); - int e2 = evaluate_mse(palette[2], c); - int e3 = evaluate_mse(palette[3], c); - return min(min(e0, e1), min(e2, e3)); -} - -// Returns MSE error in [0-255] range. -static int evaluate_mse(const BlockDXT1 * output, Color32 color, int index) { - Color32 palette[4]; - output->evaluatePalette(palette, /*d3d9=*/false); - - return evaluate_mse(palette[index], color); -} - -// Returns weighted MSE error in [0-255] range. -static float evaluate_palette_error(Color32 palette[4], const Color32 * colors, const float * weights, int count) { - - float total = 0.0f; - for (int i = 0; i < count; i++) { - total += weights[i] * evaluate_mse(palette, colors[i]); - } - - return total; -} - -#if 0 -static float evaluate_mse(const BlockDXT1 * output, const Vector3 colors[16]) { - Color32 palette[4]; - output->evaluatePalette(palette, /*d3d9=*/false); - - // convert palette to float. - Vector3 vector_palette[4]; - for (int i = 0; i < 4; i++) { - vector_palette[i] = color_to_vector3(palette[i]); - } - - // evaluate error for each index. - float error = 0.0f; - for (int i = 0; i < 16; i++) { - int index = (output->indices >> (2*i)) & 3; // @@ Is this the right order? - error += evaluate_mse(vector_palette[index], colors[i]); - } - - return error; -} -#endif - -static float evaluate_mse(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, const BlockDXT1 * output) { - Color32 palette[4]; - output->evaluatePalette(palette, /*d3d9=*/false); - - // convert palette to float. - Vector3 vector_palette[4]; - for (int i = 0; i < 4; i++) { - vector_palette[i] = color_to_vector3(palette[i]); - } - - // evaluate error for each index. - float error = 0.0f; - for (int i = 0; i < 16; i++) { - int index = (output->indices >> (2 * i)) & 3; - error += input_weights[i] * evaluate_mse(vector_palette[index], input_colors[i].xyz(), color_weights); - } - return error; -} - - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Palette evaluation. - -static void evaluate_palette4(Color32 palette[4]) { - palette[2].r = (2 * palette[0].r + palette[1].r) / 3; - palette[2].g = (2 * palette[0].g + palette[1].g) / 3; - palette[2].b = (2 * palette[0].b + palette[1].b) / 3; - palette[3].r = (2 * palette[1].r + palette[0].r) / 3; - palette[3].g = (2 * palette[1].g + palette[0].g) / 3; - palette[3].b = (2 * palette[1].b + palette[0].b) / 3; -} - -static void evaluate_palette3(Color32 palette[4]) { - palette[2].r = (palette[0].r + palette[1].r) / 2; - palette[2].g = (palette[0].g + palette[1].g) / 2; - palette[2].b = (palette[0].b + palette[1].b) / 2; - palette[3].r = 0; - palette[3].g = 0; - palette[3].b = 0; -} - -static void evaluate_palette(Color16 c0, Color16 c1, Color32 palette[4]) { - palette[0] = bitexpand_color16_to_color32(c0); - palette[1] = bitexpand_color16_to_color32(c1); - if (c0.u > c1.u) { - evaluate_palette4(palette); - } - else { - evaluate_palette3(palette); - } -} - -static void evaluate_palette(Color16 c0, Color16 c1, Vector3 palette[4]) { - Color32 palette32[4]; - evaluate_palette(c0, c1, palette32); - - for (int i = 0; i < 4; i++) { - palette[i] = color_to_vector3(palette32[i]); - } -} - -/*static void evaluate_palette3(Color16 c0, Color16 c1, Vector3 palette[4]) { - nvDebugCheck(c0.u > c1.u); - - Color32 palette32[4]; - evaluate_palette(c0, c1, palette32); - - for (int i = 0; i < 4; i++) { - palette[i] = color_to_vector3(palette32[i]); - } -}*/ - - - - - -static uint compute_indices4(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 palette[4]) { - - uint indices = 0; - for (int i = 0; i < 16; i++) { - float d0 = evaluate_mse(palette[0], input_colors[i].xyz(), color_weights); - float d1 = evaluate_mse(palette[1], input_colors[i].xyz(), color_weights); - float d2 = evaluate_mse(palette[2], input_colors[i].xyz(), color_weights); - float d3 = evaluate_mse(palette[3], input_colors[i].xyz(), color_weights); - - uint b0 = d0 > d3; - uint b1 = d1 > d2; - uint b2 = d0 > d2; - uint b3 = d1 > d3; - uint b4 = d2 > d3; - - uint x0 = b1 & b2; - uint x1 = b0 & b3; - uint x2 = b0 & b4; - - indices |= (x2 | ((x0 | x1) << 1)) << (2 * i); - } - - return indices; -} - - -static uint compute_indices(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 palette[4]) { - - uint indices = 0; - for (int i = 0; i < 16; i++) { - float d0 = evaluate_mse(palette[0], input_colors[i].xyz(), color_weights); - float d1 = evaluate_mse(palette[1], input_colors[i].xyz(), color_weights); - float d2 = evaluate_mse(palette[2], input_colors[i].xyz(), color_weights); - float d3 = evaluate_mse(palette[3], input_colors[i].xyz(), color_weights); - - uint index; - if (d0 < d1 && d0 < d2 && d0 < d3) index = 0; - else if (d1 < d2 && d1 < d3) index = 1; - else if (d2 < d3) index = 2; - else index = 3; - - indices |= index << (2 * i); - } - - return indices; -} - - -static void output_block3(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 & v0, const Vector3 & v1, BlockDXT1 * block) -{ - Color16 color0 = vector3_to_color16(v0); - Color16 color1 = vector3_to_color16(v1); - - if (color0.u > color1.u) { - swap(color0, color1); - } - - Vector3 palette[4]; - evaluate_palette(color0, color1, palette); - - block->col0 = color0; - block->col1 = color1; - block->indices = compute_indices(input_colors, color_weights, palette); -} - -static void output_block4(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 & v0, const Vector3 & v1, BlockDXT1 * block) -{ - Color16 color0 = vector3_to_color16(v0); - Color16 color1 = vector3_to_color16(v1); - - if (color0.u < color1.u) { - swap(color0, color1); - } - - Vector3 palette[4]; - evaluate_palette(color0, color1, palette); - - block->col0 = color0; - block->col1 = color1; - block->indices = compute_indices4(input_colors, color_weights, palette); -} - - - - - -// Single color compressor, based on: -// https://mollyrocket.com/forums/viewtopic.php?t=392 -static void compress_dxt1_single_color_optimal(Color32 c, BlockDXT1 * output) -{ - output->col0.r = OMatch5[c.r][0]; - output->col0.g = OMatch6[c.g][0]; - output->col0.b = OMatch5[c.b][0]; - output->col1.r = OMatch5[c.r][1]; - output->col1.g = OMatch6[c.g][1]; - output->col1.b = OMatch5[c.b][1]; - output->indices = 0xaaaaaaaa; - - if (output->col0.u < output->col1.u) - { - swap(output->col0.u, output->col1.u); - output->indices ^= 0x55555555; - } -} - - -float nv::compress_dxt1_single_color_optimal(Color32 c, BlockDXT1 * output) -{ - ::compress_dxt1_single_color_optimal(c, output); - - // Multiply by 16^2, the weight associated to a single color. - // Divide by 255*255 to covert error to [0-1] range. - return (256.0f / (255*255)) * evaluate_mse(output, c, output->indices & 3); -} - - -float nv::compress_dxt1_single_color_optimal(const Vector3 & color, BlockDXT1 * output) -{ - return compress_dxt1_single_color_optimal(vector3_to_color(color), output); -} - - -// Compress block using the average color. -float nv::compress_dxt1_single_color(const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, BlockDXT1 * output) -{ - // Compute block average. - Vector3 color_sum(0); - float weight_sum = 0; - - for (int i = 0; i < count; i++) { - color_sum += colors[i] * weights[i]; - weight_sum += weights[i]; - } - - // Compress optimally. - ::compress_dxt1_single_color_optimal(vector3_to_color(color_sum / weight_sum), output); - - // Decompress block color. - Color32 palette[4]; - evaluate_palette(output->col0, output->col1, palette); - //output->evaluatePalette(palette, /*d3d9=*/false); - - Vector3 block_color = color_to_vector3(palette[output->indices & 0x3]); - - // Evaluate error. - float error = 0; - for (int i = 0; i < count; i++) { - error += weights[i] * evaluate_mse(block_color, colors[i], color_weights); - } - return error; -} - - -/* @@ Not implemented yet. -// Low quality baseline compressor. -float nv::compress_dxt1_least_squares_fit(const Vector3 * input_colors, const Vector3 * colors, const float * weights, int count, BlockDXT1 * output) -{ - // @@ Iterative best end point fit. - - return FLT_MAX; -}*/ - - -float nv::compress_dxt1_bounding_box_exhaustive(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, int max_volume, BlockDXT1 * output) -{ - // Compute bounding box. - Vector3 min_color(1.0f); - Vector3 max_color(0.0f); - - for (int i = 0; i < count; i++) { - min_color = min(min_color, colors[i]); - max_color = max(max_color, colors[i]); - } - - // Convert to 5:6:5 - int min_r = ftoi_floor(31 * min_color.x); - int min_g = ftoi_floor(63 * min_color.y); - int min_b = ftoi_floor(31 * min_color.z); - int max_r = ftoi_ceil(31 * max_color.x); - int max_g = ftoi_ceil(63 * max_color.y); - int max_b = ftoi_ceil(31 * max_color.z); - - // Expand the box. - int range_r = max_r - min_r; - int range_g = max_g - min_g; - int range_b = max_b - min_b; - - min_r = max(0, min_r - range_r / 2 - 2); - min_g = max(0, min_g - range_g / 2 - 2); - min_b = max(0, min_b - range_b / 2 - 2); - - max_r = min(31, max_r + range_r / 2 + 2); - max_g = min(63, max_g + range_g / 2 + 2); - max_b = min(31, max_b + range_b / 2 + 2); - - // Estimate size of search space. - int volume = (max_r-min_r+1) * (max_g-min_g+1) * (max_b-min_b+1); - - // if size under search_limit, then proceed. Note that search_volume is sqrt of number of evaluations. - if (volume > max_volume) { - return FLT_MAX; - } - - // @@ Convert to fixed point before building box? - Color32 colors32[16]; - for (int i = 0; i < count; i++) { - colors32[i] = toColor32(Vector4(colors[i], 1)); - } - - float best_error = FLT_MAX; - Color16 best0, best1; // @@ Record endpoints as Color16? - - Color16 c0, c1; - Color32 palette[4]; - - for(int r0 = min_r; r0 <= max_r; r0++) - for(int g0 = min_g; g0 <= max_g; g0++) - for(int b0 = min_b; b0 <= max_b; b0++) - { - c0.r = r0; c0.g = g0; c0.b = b0; - palette[0] = bitexpand_color16_to_color32(c0); - - for(int r1 = min_r; r1 <= max_r; r1++) - for(int g1 = min_g; g1 <= max_g; g1++) - for(int b1 = min_b; b1 <= max_b; b1++) - { - c1.r = r1; c1.g = g1; c1.b = b1; - palette[1] = bitexpand_color16_to_color32(c1); - - if (c0.u > c1.u) { - // Evaluate error in 4 color mode. - evaluate_palette4(palette); - } - else { - if (three_color_mode) { - // Evaluate error in 3 color mode. - evaluate_palette3(palette); - } - else { - // Skip 3 color mode. - continue; - } - } - - float error = evaluate_palette_error(palette, colors32, weights, count); - - if (error < best_error) { - best_error = error; - best0 = c0; - best1 = c1; - } - } - } - - output->col0 = best0; - output->col1 = best1; - - Vector3 vector_palette[4]; - evaluate_palette(output->col0, output->col1, vector_palette); - - output->indices = compute_indices(input_colors, color_weights, vector_palette); - - return best_error / (255 * 255); -} - - -void nv::compress_dxt1_cluster_fit(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, BlockDXT1 * output) -{ - ClusterFit fit; - fit.setColorWeights(Vector4(color_weights, 1)); - fit.setColorSet(colors, weights, count); - - // start & end are in [0, 1] range. - Vector3 start, end; - fit.compress4(&start, &end); - - if (three_color_mode && fit.compress3(&start, &end)) { - output_block3(input_colors, color_weights, start, end, output); - } - else { - output_block4(input_colors, color_weights, start, end, output); - } -} - - - - -float nv::compress_dxt1(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, bool three_color_mode, BlockDXT1 * output) -{ - Vector3 colors[16]; - float weights[16]; - int count = reduce_colors(input_colors, input_weights, colors, weights); - - if (count == 0) { - // Output trivial block. - output->col0.u = 0; - output->col1.u = 0; - output->indices = 0; - return 0; - } - - - float error = FLT_MAX; - - // Sometimes the single color compressor produces better results than the exhaustive. This introduces discontinuities between blocks that - // use different compressors. For this reason, this is not enabled by default. - if (1) { - error = compress_dxt1_single_color(colors, weights, count, color_weights, output); - - if (error == 0.0f || count == 1) { - // Early out. - return error; - } - } - - // This is too expensive, even with a low threshold. - // If high quality: - if (/* DISABLES CODE */ (0)) { - BlockDXT1 exhaustive_output; - float exhaustive_error = compress_dxt1_bounding_box_exhaustive(input_colors, colors, weights, count, color_weights, three_color_mode, 1400, &exhaustive_output); - - if (exhaustive_error != FLT_MAX) { - float exhaustive_error2 = evaluate_mse(input_colors, input_weights, color_weights, &exhaustive_output); - - // The exhaustive compressor does not use color_weights, so the results may be different. - //nvCheck(equal(exhaustive_error, exhaustive_error2)); - - if (exhaustive_error2 < error) { - *output = exhaustive_output; - error = exhaustive_error; - } - } - } - - // @@ TODO. - // This is pretty fast and in some cases can produces better quality than cluster fit. - //error = compress_dxt1_least_squares_fit(colors, weigths, error, output); - - // Cluster fit cannot handle single color blocks, so encode them optimally if we haven't encoded them already. - if (error == FLT_MAX && count == 1) { - error = compress_dxt1_single_color_optimal(colors[0], output); - } - - if (count > 1) { - BlockDXT1 cluster_fit_output; - compress_dxt1_cluster_fit(input_colors, colors, weights, count, color_weights, three_color_mode, &cluster_fit_output); - - float cluster_fit_error = evaluate_mse(input_colors, input_weights, color_weights, &cluster_fit_output); - - if (cluster_fit_error < error) { - *output = cluster_fit_output; - error = cluster_fit_error; - } - } - - return error; -} - - -// Once we have an index assignment we have colors grouped in 1-4 clusters. -// If 1 clusters -> Use optimal compressor. -// If 2 clusters -> Try: (0, 1), (1, 2), (0, 2), (0, 3) - [0, 1] -// If 3 clusters -> Try: (0, 1, 2), (0, 1, 3), (0, 2, 3) - [0, 1, 2] -// If 4 clusters -> Try: (0, 1, 2, 3) - -// @@ How do we do the initial index/cluster assignment? Use standard cluster fit. - - -// Least squares fitting of color end points for the given indices. @@ Take weights into account. -static bool optimize_end_points4(uint indices, const Vector4 * colors, /*const float * weights,*/ int count, Vector3 * a, Vector3 * b) -{ - float alpha2_sum = 0.0f; - float beta2_sum = 0.0f; - float alphabeta_sum = 0.0f; - Vector3 alphax_sum(0.0f); - Vector3 betax_sum(0.0f); - - for (int i = 0; i < count; i++) - { - const uint bits = indices >> (2 * i); - - float beta = float(bits & 1); - if (bits & 2) beta = (1 + beta) / 3.0f; - float alpha = 1.0f - beta; - - alpha2_sum += alpha * alpha; - beta2_sum += beta * beta; - alphabeta_sum += alpha * beta; - alphax_sum += alpha * colors[i].xyz(); - betax_sum += beta * colors[i].xyz(); - } - - float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; - if (equal(denom, 0.0f)) return false; - - float factor = 1.0f / denom; - - *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); - *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); - - return true; -} - - -// Least squares fitting of color end points for the given indices. @@ This does not support black/transparent index. @@ Take weights into account. -static bool optimize_end_points3(uint indices, const Vector3 * colors, /*const float * weights,*/ int count, Vector3 * a, Vector3 * b) -{ - float alpha2_sum = 0.0f; - float beta2_sum = 0.0f; - float alphabeta_sum = 0.0f; - Vector3 alphax_sum(0.0f); - Vector3 betax_sum(0.0f); - - for (int i = 0; i < count; i++) - { - const uint bits = indices >> (2 * i); - - float beta = float(bits & 1); - if (bits & 2) beta = 0.5f; - float alpha = 1.0f - beta; - - alpha2_sum += alpha * alpha; - beta2_sum += beta * beta; - alphabeta_sum += alpha * beta; - alphax_sum += alpha * colors[i]; - betax_sum += beta * colors[i]; - } - - float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; - if (equal(denom, 0.0f)) return false; - - float factor = 1.0f / denom; - - *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); - *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); - - return true; -} - -// @@ After optimization we need to round end points. Round in all possible directions, and pick best. - - - -// find minimum and maximum colors based on bounding box in color space -inline static void fit_colors_bbox(const Vector3 * colors, int count, Vector3 * restrict c0, Vector3 * restrict c1) -{ - *c0 = Vector3(0); - *c1 = Vector3(255); - - for (int i = 0; i < count; i++) { - *c0 = max(*c0, colors[i]); - *c1 = min(*c1, colors[i]); - } -} - -inline static void select_diagonal(const Vector3 * colors, int count, Vector3 * restrict c0, Vector3 * restrict c1) -{ - Vector3 center = (*c0 + *c1) * 0.5f; - - Vector2 covariance = Vector2(0); - for (int i = 0; i < count; i++) { - Vector3 t = colors[i] - center; - covariance += t.xy() * t.z; - } - - float x0 = c0->x; - float y0 = c0->y; - float x1 = c1->x; - float y1 = c1->y; - - if (covariance.x < 0) { - swap(x0, x1); - } - if (covariance.y < 0) { - swap(y0, y1); - } - - c0->set(x0, y0, c0->z); - c1->set(x1, y1, c1->z); -} - -inline static void inset_bbox(Vector3 * restrict c0, Vector3 * restrict c1) -{ - Vector3 inset = (*c0 - *c1) / 16.0f - (8.0f / 255.0f) / 16.0f; - *c0 = clamp(*c0 - inset, 0.0f, 255.0f); - *c1 = clamp(*c1 + inset, 0.0f, 255.0f); -} - - - -float nv::compress_dxt1_fast(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, BlockDXT1 * output) -{ - Vector3 colors[16]; - float weights[16]; - int count = reduce_colors(input_colors, input_weights, colors, weights); - - if (count == 0) { - // Output trivial block. - output->col0.u = 0; - output->col1.u = 0; - output->indices = 0; - return 0; - } - - - float error = FLT_MAX; - error = compress_dxt1_single_color(colors, weights, count, color_weights, output); - - if (error == 0.0f || count == 1) { - // Early out. - return error; - } - - // Quick end point selection. - Vector3 c0, c1; - fit_colors_bbox(colors, count, &c0, &c1); - select_diagonal(colors, count, &c0, &c1); - inset_bbox(&c0, &c1); - output_block4(input_colors, color_weights, c0, c1, output); - - // Refine color for the selected indices. - if (optimize_end_points4(output->indices, input_colors, 16, &c0, &c1)) { - output_block4(input_colors, color_weights, c0, c1, output); - } - - return evaluate_mse(input_colors, input_weights, color_weights, output); -} - - - diff --git a/src/nvtt/CompressorDXT1.h b/src/nvtt/CompressorDXT1.h deleted file mode 100644 index ac5bdb53..00000000 --- a/src/nvtt/CompressorDXT1.h +++ /dev/null @@ -1,26 +0,0 @@ - -namespace nv { - - class Color32; - struct ColorBlock; - struct BlockDXT1; - class Vector3; - class Vector4; - - // All these functions return MSE. - - float compress_dxt1_single_color_optimal(Color32 c, BlockDXT1 * output); - float compress_dxt1_single_color_optimal(const Vector3 & color, BlockDXT1 * output); - - float compress_dxt1_single_color(const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, BlockDXT1 * output); - //float compress_dxt1_least_squares_fit(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, BlockDXT1 * output); - float compress_dxt1_bounding_box_exhaustive(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, int search_limit, BlockDXT1 * output); - void compress_dxt1_cluster_fit(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, BlockDXT1 * output); - - // Cluster fit end point selection. - float compress_dxt1(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, bool three_color_mode, BlockDXT1 * output); - - // Quick end point selection followed by least squares refinement. - float compress_dxt1_fast(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, BlockDXT1 * output); - -} diff --git a/src/nvtt/CompressorDXT5_RGBM.cpp b/src/nvtt/CompressorDXT5_RGBM.cpp index 3274f2c7..65d547c2 100644 --- a/src/nvtt/CompressorDXT5_RGBM.cpp +++ b/src/nvtt/CompressorDXT5_RGBM.cpp @@ -1,5 +1,5 @@ #include "CompressorDXT5_RGBM.h" -#include "CompressorDXT1.h" +#include "icbc.h" #include "OptimalCompressDXT.h" #include "QuickCompressDXT.h" @@ -58,8 +58,10 @@ float nv::compress_dxt5_rgbm(const Vector4 input_colors[16], const float input_w float rgb_weights[16]; convert_to_rgbm(input_colors, input_weights, min_m, input_colors_rgbm, rgb_weights); + float color_weights[3] = { 1.0f,1.0f,1.0f }; + // Compress RGB. - compress_dxt1(input_colors_rgbm, rgb_weights, Vector3(1), /*three_color_mode=*/false, &output->color); + icbc::compress_dxt1(icbc::Quality_Default, (float *)input_colors_rgbm, rgb_weights, color_weights, /*three_color_mode=*/false, /*hq=*/false, &output->color); // Decompress RGB/M block. nv::ColorBlock RGB; diff --git a/src/nvtt/CompressorETC.cpp b/src/nvtt/CompressorETC.cpp index 4fb8e1c9..7248a509 100644 --- a/src/nvtt/CompressorETC.cpp +++ b/src/nvtt/CompressorETC.cpp @@ -6,8 +6,8 @@ #include "nvmath/Color.inl" #include "nvcore/Utils.h" // clamp -#define HAVE_RGETC NV_OS_OSX -#define HAVE_ETCPACK 0 // Only enable in OSX for debugging. +//#define HAVE_RGETC 0 +//#define HAVE_ETCPACK 0 // Only enable in OSX for debugging. #if HAVE_RGETC #include "rg_etc1.h" @@ -190,7 +190,7 @@ static const float midpoints5[32] = { // ETC2 Modes: // - ETC1: // - two partitions (flip modes): 2*(4x2, 2x4) -// - two base colors sotred as 444+444 or 555+333 +// - two base colors stored as 444+444 or 555+333 // - two 3 bit intensity modifiers // - T Mode. 2 colors 444, 3 bit intensity modifiers, 2 bit indices. // - H Mode. 2 colors 444, 3 bit intensity modifiers, 2 bit indices. diff --git a/src/nvtt/Context.cpp b/src/nvtt/Context.cpp index 37c201b9..5e3220cb 100644 --- a/src/nvtt/Context.cpp +++ b/src/nvtt/Context.cpp @@ -30,6 +30,7 @@ #include "CompressionOptions.h" #include "OutputOptions.h" #include "Surface.h" +#include "icbc.h" #include "CompressorDX9.h" #include "CompressorDX10.h" @@ -67,6 +68,8 @@ Compressor::Compressor() : m(*new Compressor::Private()) enableCudaAcceleration(m.cudaSupported); m.dispatcher = &m.defaultDispatcher; + + icbc::init_dxt1(); } Compressor::~Compressor() @@ -537,6 +540,67 @@ void Compressor::Private::quantize(Surface & img, const CompressionOptions::Priv } } +namespace +{ + enum + { + // internal format + GL_RGB8 = 0x8051, + GL_RGBA8 = 0x8058, + GL_R16 = 0x822A, + GL_RGBA16F = 0x881A, + GL_R11F_G11F_B10F = 0x8C3A, + + // type + GL_UNSIGNED_BYTE = 0x1401, + GL_HALF_FLOAT = 0x140B, + GL_UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B, + GL_UNSIGNED_SHORT = 0x1403, + + // format + GL_RED = 0x1903, + GL_RGB = 0x1907, + GL_RGBA = 0x1908, + GL_BGR = 0x80E0, + GL_BGRA = 0x80E1, + }; + + struct GLFormatDescriptor + { + uint glFormat; // for uncompressed texture glBaseInternalFormat == glFormat + uint glInternalFormat; + uint glType; + uint glTypeSize; + RGBAPixelFormat pixelFormat; + }; + + static const GLFormatDescriptor s_glFormats[] = + { + { GL_BGR, GL_RGB8, GL_UNSIGNED_BYTE, 1, { 24, 0xFF0000, 0xFF00, 0xFF, 0 } }, + { GL_BGRA, GL_RGBA8, GL_UNSIGNED_BYTE, 1, { 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000 } }, + { GL_RGBA, GL_RGBA8, GL_UNSIGNED_BYTE, 1, { 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000 } }, + }; + + static const uint s_glFormatCount = NV_ARRAY_SIZE(s_glFormats); + + static const GLFormatDescriptor* findGLFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) + { + for (int i = 0; i < s_glFormatCount; i++) + { + if (s_glFormats[i].pixelFormat.bitcount == bitcount && + s_glFormats[i].pixelFormat.rmask == rmask && + s_glFormats[i].pixelFormat.gmask == gmask && + s_glFormats[i].pixelFormat.bmask == bmask && + s_glFormats[i].pixelFormat.amask == amask) + { + return &s_glFormats[i]; + } + } + + return nullptr; + } +} + bool Compressor::Private::outputHeader(nvtt::TextureType textureType, int w, int h, int d, int arraySize, int mipmapCount, bool isNormalMap, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions) const { if (w <= 0 || h <= 0 || d <= 0 || arraySize <= 0 || mipmapCount <= 0) @@ -837,12 +901,52 @@ bool Compressor::Private::outputHeader(nvtt::TextureType textureType, int w, int bool supported = true; - // TODO non-compressed formats if (compressionOptions.format == Format_RGBA) { - //header.glType = ?; - //header.glTypeSize = ?; - //header.glFormat = ?; + const uint bitcount = compressionOptions.getBitCount(); + + if (compressionOptions.pixelType == PixelType_Float) { + if (compressionOptions.rsize == 16 && compressionOptions.gsize == 16 && compressionOptions.bsize == 16 && compressionOptions.asize == 16) { + header.glType = GL_HALF_FLOAT; + header.glTypeSize = 2; + header.glFormat = GL_RGBA; + header.glInternalFormat = GL_RGBA16F; + header.glBaseInternalFormat = GL_RGBA; + } + else if (compressionOptions.rsize == 11 && compressionOptions.gsize == 11 && compressionOptions.bsize == 10 && compressionOptions.asize == 0) { + header.glType = GL_UNSIGNED_INT_10F_11F_11F_REV; + header.glTypeSize = 4; + header.glFormat = GL_RGB; + header.glInternalFormat = GL_R11F_G11F_B10F; + header.glBaseInternalFormat = GL_RGB; + } + else { + supported = false; + } + } + else { + if (bitcount == 16 && compressionOptions.rsize == 16) { + header.glType = GL_UNSIGNED_SHORT; + header.glTypeSize = 2; + header.glFormat = GL_RED; + header.glInternalFormat = GL_R16; + header.glBaseInternalFormat = GL_RED; + } + else { + const GLFormatDescriptor* glFormatDesc = findGLFormat(compressionOptions.bitcount, compressionOptions.rmask, compressionOptions.gmask, compressionOptions.bmask, compressionOptions.amask); + + if (glFormatDesc) { + header.glType = glFormatDesc->glType; + header.glTypeSize = glFormatDesc->glTypeSize; + header.glFormat = glFormatDesc->glFormat; + header.glInternalFormat = glFormatDesc->glInternalFormat; + header.glBaseInternalFormat = header.glFormat; + } + else { + supported = false; + } + } + } } else { @@ -850,7 +954,7 @@ bool Compressor::Private::outputHeader(nvtt::TextureType textureType, int w, int header.glTypeSize = 1; header.glFormat = 0; - if (compressionOptions.format == Format_DXT1) { + if (compressionOptions.format == Format_DXT1 || compressionOptions.format == Format_DXT1n) { header.glInternalFormat = outputOptions.srgb ? KTX_INTERNAL_COMPRESSED_SRGB_S3TC_DXT1 : KTX_INTERNAL_COMPRESSED_RGB_S3TC_DXT1; header.glBaseInternalFormat = KTX_BASE_INTERNAL_RGB; } @@ -862,7 +966,7 @@ bool Compressor::Private::outputHeader(nvtt::TextureType textureType, int w, int header.glInternalFormat = outputOptions.srgb ? KTX_INTERNAL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3 : KTX_INTERNAL_COMPRESSED_RGBA_S3TC_DXT3; header.glBaseInternalFormat = KTX_BASE_INTERNAL_RGBA; } - else if (compressionOptions.format == Format_DXT5 || compressionOptions.format == Format_BC3_RGBM) { + else if (compressionOptions.format == Format_DXT5 || compressionOptions.format == Format_DXT5n || compressionOptions.format == Format_BC3_RGBM) { header.glInternalFormat = outputOptions.srgb ? KTX_INTERNAL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5 : KTX_INTERNAL_COMPRESSED_RGBA_S3TC_DXT5; header.glBaseInternalFormat = KTX_BASE_INTERNAL_RGBA; } @@ -906,8 +1010,6 @@ bool Compressor::Private::outputHeader(nvtt::TextureType textureType, int w, int else { supported = false; } - - //TODO compressionOptions.format == Format_DXT1n, Format_DXT5n ? There seems to be no way to indicate a normal map using ktx. Maybe via key value data? } if (!supported) @@ -941,31 +1043,16 @@ CompressorInterface * Compressor::Private::chooseCpuCompressor(const Compression } else if (compressionOptions.format == Format_DXT1) { -#if defined(HAVE_ATITC) - if (compressionOptions.externalCompressor == "ati") return new AtiCompressorDXT1; - else -#endif - -#if defined(HAVE_SQUISH) - if (compressionOptions.externalCompressor == "squish") return new SquishCompressorDXT1; - else -#endif - #if defined(HAVE_D3DX) if (compressionOptions.externalCompressor == "d3dx") return new D3DXCompressorDXT1; else #endif -#if defined(HAVE_D3DX) +#if defined(HAVE_STB) if (compressionOptions.externalCompressor == "stb") return new StbCompressorDXT1; else #endif - if (compressionOptions.quality == Quality_Fastest) - { - return new FastCompressorDXT1; - } - return new CompressorDXT1; } else if (compressionOptions.format == Format_DXT1a) @@ -992,11 +1079,6 @@ CompressorInterface * Compressor::Private::chooseCpuCompressor(const Compression } else if (compressionOptions.format == Format_DXT5) { -#if defined(HAVE_ATITC) - if (compressionOptions.externalCompressor == "ati") return new AtiCompressorDXT5; - else -#endif - if (compressionOptions.quality == Quality_Fastest) { return new FastCompressorDXT5; @@ -1054,6 +1136,12 @@ CompressorInterface * Compressor::Private::chooseCpuCompressor(const Compression #endif #if defined(HAVE_ETCLIB) if (compressionOptions.externalCompressor == "etclib") return new EtcLibCompressor; +#endif +#if defined(HAVE_ETCPACK) + if (compressionOptions.format == Format_ETC1 && compressionOptions.externalCompressor == "etcpack") return new EtcPackCompressor; +#endif +#if defined(HAVE_ETCINTEL) + if (compressionOptions.format == Format_ETC1 && compressionOptions.externalCompressor == "intel") return new EtcIntelCompressor; #endif if (compressionOptions.format == Format_ETC1) return new CompressorETC1; else if (compressionOptions.format == Format_ETC2_R) return new CompressorETC2_R; diff --git a/src/nvtt/CubeSurface.cpp b/src/nvtt/CubeSurface.cpp index 22b6a45e..ea3abec6 100644 --- a/src/nvtt/CubeSurface.cpp +++ b/src/nvtt/CubeSurface.cpp @@ -39,7 +39,7 @@ using namespace nvtt; // Solid angle of an axis aligned quad from (0,0,1) to (x,y,1) // See: http://www.fizzmoll11.com/thesis/ for a derivation of this formula. static float areaElement(float x, float y) { - return atan2(x*y, sqrtf(x*x + y*y + 1)); + return atan2f(x*y, sqrtf(x*x + y*y + 1)); } // Solid angle of a hemicube texel. @@ -206,19 +206,19 @@ static const Vector3 faceV[6] = { static Vector2 toPolar(Vector3::Arg v) { Vector2 p; - p.x = atan2(v.x, v.y); // theta + p.x = atan2f(v.x, v.y); // theta p.y = acosf(v.z); // phi return p; } static Vector2 toPlane(float theta, float phi) { - float x = sin(phi) * cos(theta); - float y = sin(phi) * sin(theta); - float z = cos(phi); + float x = sinf(phi) * cosf(theta); + float y = sinf(phi) * sinf(theta); + float z = cosf(phi); Vector2 p; - p.x = x / fabs(z); - p.y = y / fabs(z); + p.x = x / fabsf(z); + p.y = y / fabsf(z); //p.x = tan(phi) * cos(theta); //p.y = tan(phi) * sin(theta); @@ -227,8 +227,8 @@ static Vector2 toPlane(float theta, float phi) { static Vector2 toPlane(Vector3::Arg v) { Vector2 p; - p.x = v.x / fabs(v.z); - p.y = v.y / fabs(v.z); + p.x = v.x / fabsf(v.z); + p.y = v.y / fabsf(v.z); return p; } @@ -303,7 +303,10 @@ const Surface & CubeSurface::face(int f) const bool CubeSurface::load(const char * fileName, int mipmap) { if (strEqual(Path::extension(fileName), ".dds")) { - nv::DirectDrawSurface dds(fileName); + nv::DirectDrawSurface dds; + if (!dds.load(fileName)) { + return false; + } if (!dds.isValid()/* || !dds.isSupported()*/) { return false; @@ -529,6 +532,24 @@ void CubeSurface::clamp(int channel, float low/*= 0.0f*/, float high/*= 1.0f*/) CubeSurface CubeSurface::irradianceFilter(int size, EdgeFixup fixupMethod) const { + // Evaluate spherical harmonic for each output texel. + CubeSurface output; + output.m->allocate(size); + + Sh2 shr, shg, shb; + + computeIrradianceSH3(0, shr.coef); + computeIrradianceSH3(1, shg.coef); + computeIrradianceSH3(2, shb.coef); + + // @@ Sample spherical harmonic from every direction. + + return CubeSurface(); +} + + +void CubeSurface::computeLuminanceIrradianceSH3(float coef[9]) const{ + m->allocateTexelTable(); // Transform this cube to spherical harmonic basis @@ -537,6 +558,10 @@ CubeSurface CubeSurface::irradianceFilter(int size, EdgeFixup fixupMethod) const // For each texel of the input cube. const uint edgeLength = m->edgeLength; for (uint f = 0; f < 6; f++) { + + const Surface & inputFace = m->face[f]; + const FloatImage * inputImage = inputFace.m->image; + for (uint y = 0; y < edgeLength; y++) { for (uint x = 0; x < edgeLength; x++) { @@ -546,30 +571,62 @@ CubeSurface CubeSurface::irradianceFilter(int size, EdgeFixup fixupMethod) const Sh2 shDir; shDir.eval(dir); - sh.addScaled(sh, solidAngle); + float r = inputImage->pixel(0, x, y, 0); + float g = inputImage->pixel(1, x, y, 0); + float b = inputImage->pixel(2, x, y, 0); + float lum = 0.333f * (r + g + b); // @@ use the proper luminance formula. + + sh.addScaled(shDir, lum * solidAngle); } } } + for (int i = 0; i < 9; i++) { + coef[i] = sh.coef[i]; + } +} - // Evaluate spherical harmonic for each output texel. - CubeSurface output; - output.m->allocate(size); +void CubeSurface::computeIrradianceSH3(int channel, float coef[9]) const { + + m->allocateTexelTable(); + + // Transform this cube to spherical harmonic basis + Sh2 sh; + // For each texel of the input cube. + const uint edgeLength = m->edgeLength; + for (uint f = 0; f < 6; f++) { + const Surface & inputFace = m->face[f]; + const FloatImage * inputImage = inputFace.m->image; - // @@ TODO - return CubeSurface(); -} + for (uint y = 0; y < edgeLength; y++) { + for (uint x = 0; x < edgeLength; x++) { + + Vector3 dir = m->texelTable->direction(f, x, y); + float solidAngle = m->texelTable->solidAngle(f, x, y); + Sh2 shDir; + shDir.eval(dir); + float c = inputImage->pixel(channel, x, y, 0); + + sh.addScaled(shDir, c * solidAngle); + } + } + } + + for (int i = 0; i < 9; i++) { + coef[i] = sh.elemAt(i); + } +} // Convolve filter against this cube. Vector3 CubeSurface::Private::applyAngularFilter(const Vector3 & filterDir, float coneAngle, float * filterTable, int tableSize) { - const float cosineConeAngle = cos(coneAngle); + const float cosineConeAngle = cosf(coneAngle); nvDebugCheck(cosineConeAngle >= 0); Vector3 color(0); @@ -690,7 +747,7 @@ Vector3 CubeSurface::Private::applyAngularFilter(const Vector3 & filterDir, floa // Convolve filter against this cube. Vector3 CubeSurface::Private::applyCosinePowerFilter(const Vector3 & filterDir, float coneAngle, float cosinePower) { - const float cosineConeAngle = cos(coneAngle); + const float cosineConeAngle = cosf(coneAngle); nvDebugCheck(cosineConeAngle >= 0); Vector3 color(0); @@ -790,6 +847,8 @@ Vector3 CubeSurface::Private::applyCosinePowerFilter(const Vector3 & filterDir, return color; } + + #include "nvthread/ParallelFor.h" struct ApplyAngularFilterContext { @@ -832,7 +891,7 @@ CubeSurface CubeSurface::cosinePowerFilter(int size, float cosinePower, EdgeFixu CubeSurface filteredCube; filteredCube.m->allocate(size); - // Texel table is stored along with the surface so that it's compute only once. + // Texel table is stored along with the surface so that it's computed only once. m->allocateTexelTable(); const float threshold = 0.001f; @@ -968,7 +1027,6 @@ CubeSurface CubeSurface::fastResample(int size, EdgeFixup fixupMethod) const return resampledCube; } - void CubeSurface::toLinear(float gamma) { if (isNull()) return; diff --git a/src/nvtt/CubeSurface.h b/src/nvtt/CubeSurface.h index b5e37576..ed1b6c4c 100644 --- a/src/nvtt/CubeSurface.h +++ b/src/nvtt/CubeSurface.h @@ -88,6 +88,9 @@ namespace nvtt void allocateTexelTable() { + if (edgeLength == 0) { + edgeLength = face[0].width(); + } if (texelTable == NULL) { texelTable = new TexelTable(edgeLength); } diff --git a/src/nvtt/Surface.cpp b/src/nvtt/Surface.cpp index 41421cae..a3bc7944 100644 --- a/src/nvtt/Surface.cpp +++ b/src/nvtt/Surface.cpp @@ -44,6 +44,7 @@ #include "nvthread/ParallelFor.h" #include "nvcore/Array.inl" +#include "nvcore/StrLib.h" #include #include // memset, memcpy @@ -569,62 +570,80 @@ bool Surface::load(const char * fileName, bool * hasAlpha/*= NULL*/) AutoPtr img(ImageIO::loadFloat(fileName)); if (img == NULL) { // Try loading as DDS. - if (nv::strEqual(nv::Path::extension(fileName), ".dds")) { - nv::DirectDrawSurface dds; - if (dds.load(fileName)) { - if (dds.header.isBlockFormat()) { - int w = dds.surfaceWidth(0); - int h = dds.surfaceHeight(0); - uint size = dds.surfaceSize(0); - - void * data = malloc(size); - dds.readSurface(0, 0, data, size); - - // @@ Handle all formats! @@ Get nvtt format from dds.surfaceFormat() ? - - if (dds.header.hasDX10Header()) { - if (dds.header.header10.dxgiFormat == DXGI_FORMAT_BC6H_UF16) { - this->setImage2D(nvtt::Format_BC6, nvtt::Decoder_D3D10, w, h, data); - } - else { - // @@ - nvCheck(false); - } - } - else { - uint fourcc = dds.header.pf.fourcc; - if (fourcc == FOURCC_DXT1) { - this->setImage2D(nvtt::Format_BC1, nvtt::Decoder_D3D10, w, h, data); - } - else if (fourcc == FOURCC_DXT5) { - this->setImage2D(nvtt::Format_BC3, nvtt::Decoder_D3D10, w, h, data); - } - else { - // @@ - nvCheck(false); - } - } + if (!nv::strEqual(nv::Path::extension(fileName), ".dds")) { + return false; + } - free(data); + nv::DirectDrawSurface dds; + if (!dds.load(fileName)) { + return false; + } + + if (dds.header.isBlockFormat()) { + int w = dds.surfaceWidth(0); + int h = dds.surfaceHeight(0); + uint size = dds.surfaceSize(0); + + void * data = malloc(size); + dds.readSurface(0, 0, data, size); + + // @@ Handle all formats! @@ Get nvtt format from dds.surfaceFormat() ? + + if (dds.header.hasDX10Header()) { + if (dds.header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM || dds.header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM_SRGB) { + this->setImage2D(nvtt::Format_BC1, nvtt::Decoder_D3D10, w, h, data); + } + else if (dds.header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM || dds.header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM_SRGB) { + this->setImage2D(nvtt::Format_BC2, nvtt::Decoder_D3D10, w, h, data); + } + else if (dds.header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM || dds.header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM_SRGB) { + this->setImage2D(nvtt::Format_BC3, nvtt::Decoder_D3D10, w, h, data); + } + else if (dds.header.header10.dxgiFormat == DXGI_FORMAT_BC6H_UF16) { + this->setImage2D(nvtt::Format_BC6, nvtt::Decoder_D3D10, w, h, data); + } + else if (dds.header.header10.dxgiFormat == DXGI_FORMAT_BC7_UNORM || dds.header.header10.dxgiFormat == DXGI_FORMAT_BC7_UNORM_SRGB) { + this->setImage2D(nvtt::Format_BC7, nvtt::Decoder_D3D10, w, h, data); } else { - Image img; - dds.mipmap(&img, /*face=*/0, /*mipmap=*/0); + // @@ + nvCheck(false && "Format not handled with DDS10 header."); + } + } + else { + uint fourcc = dds.header.pf.fourcc; + if (fourcc == FOURCC_DXT1) { + this->setImage2D(nvtt::Format_BC1, nvtt::Decoder_D3D10, w, h, data); + } + else if (fourcc == FOURCC_DXT3) { + this->setImage2D(nvtt::Format_BC2, nvtt::Decoder_D3D10, w, h, data); + } + else if (fourcc == FOURCC_DXT5) { + this->setImage2D(nvtt::Format_BC3, nvtt::Decoder_D3D10, w, h, data); + } + else { + // @@ + nvCheck(false && "Format not handled with DDS9 header."); + } + } - int w = img.width(); - int h = img.height(); - int d = img.depth(); + free(data); + } + else { + // @@ Separate image decoder from dds reader. + Image img; + imageFromDDS(&img, dds, /*face=*/0, /*mipmap=*/0); - // @@ Add support for all pixel formats. + int w = img.width; + int h = img.height; + int d = img.depth; - this->setImage(nvtt::InputFormat_BGRA_8UB, w, h, d, img.pixels()); - } + // @@ Add support for all pixel formats. - return true; - } + this->setImage(nvtt::InputFormat_BGRA_8UB, w, h, d, img.pixels()); } - return false; + return true; } detach(); @@ -634,7 +653,7 @@ bool Surface::load(const char * fileName, bool * hasAlpha/*= NULL*/) } // @@ Have loadFloat allocate the image with the desired number of channels. - //img->resizeChannelCount(4); + img->resizeChannelCount(4); // Block compressors expect a 4 channel texture. delete m->image; m->image = img.release(); @@ -657,7 +676,7 @@ bool Surface::save(const char * fileName, bool hasAlpha/*=0*/, bool hdr/*=0*/) c nvCheck(image != NULL); if (hasAlpha) { - image->setFormat(Image::Format_ARGB); + image->format = Image::Format_ARGB; } return ImageIO::save(fileName, image.ptr()); @@ -1499,24 +1518,47 @@ static float toSrgb(float f) { return f; } -void Surface::toSrgb() -{ +// sRGB approximation from: http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html +static float toSrgbFast(float f) { + f = saturate(f); + float s1 = sqrtf(f); + float s2 = sqrtf(s1); + float s3 = sqrtf(s2); + return 0.662002687f * s1 + 0.684122060f * s2 - 0.323583601f * s3 - 0.0225411470f * f; +} + +void Surface::toSrgb() { if (isNull()) return; detach(); FloatImage * img = m->image; - const uint count = img->pixelCount(); - for (uint c = 0; c < 3; c++) { - float * channel = img->channel(c); - for (uint i = 0; i < count; i++) { - //parallel_for(count, 128, [=](int i) { - channel[i] = ::toSrgb(channel[i]); - }//); + const uint count = 3 * img->pixelCount(); + float * channel = img->channel(0); + for (uint i = 0; i < count; i++) { + channel[i] = ::toSrgb(channel[i]); } } +void Surface::toSrgbFast() { + if (isNull()) return; + + detach(); + + FloatImage * img = m->image; + + const uint count = 3 * img->pixelCount(); + float * channel = img->channel(0); + for (uint i = 0; i < count; i++) { + channel[i] = ::toSrgbFast(channel[i]); + } + //parallel_for(count, 128, [=](int i) { + // channel[i] = toSrgbFast(channel[i]); + //}); +} + + static float fromSrgb(float f) { if (f < 0.0f) f = 0.0f; else if (f < 0.04045f) f = f / 12.92f; @@ -1525,24 +1567,48 @@ static float fromSrgb(float f) { return f; } -void Surface::toLinearFromSrgb() -{ +// sRGB approximation from: http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html +static float fromSrgbFast(float f) { + f = saturate(f); + return f * (f * (f * 0.305306011f + 0.682171111f) + 0.012522878f); +} + + +void Surface::toLinearFromSrgb() { if (isNull()) return; detach(); FloatImage * img = m->image; - const uint count = img->pixelCount(); - for (uint c = 0; c < 3; c++) { - float * channel = img->channel(c); - for (uint i = 0; i < count; i++) { - //parallel_for(count, 128, [=](int i) { - channel[i] = ::fromSrgb(channel[i]); - }//); + const uint count = 3 *img->pixelCount(); + float * channel = img->channel(0); + for (uint i = 0; i < count; i++) { + channel[i] = ::fromSrgb(channel[i]); + } + //parallel_for(count, 128, [=](int i) { + // channel[i] = ::fromSrgb(channel[i]); + //}); +} + +void Surface::toLinearFromSrgbFast() { + if (isNull()) return; + + detach(); + + FloatImage * img = m->image; + + const uint count = 3 * img->pixelCount(); + float * channel = img->channel(0); + for (uint i = 0; i < count; i++) { + channel[i] = ::fromSrgbFast(channel[i]); } + //parallel_for(count, 128, [=](int i) { + // channel[i] = ::fromSrgbFast(channel[i]); + //}); } + static float toXenonSrgb(float f) { if (f < 0) f = 0; else if (f < (1.0f/16.0f)) f = 4.0f * f; @@ -1946,7 +2012,7 @@ static Color32 toRgbe8(float r, float g, float b) } else { int e; - v = frexp(v, &e) * 256.0f / v; + v = frexpf(v, &e) * 256.0f / v; c.r = uint8(clamp(r * v, 0.0f, 255.0f)); c.g = uint8(clamp(g * v, 0.0f, 255.0f)); c.b = uint8(clamp(b * v, 0.0f, 255.0f)); @@ -2798,13 +2864,13 @@ void Surface::transformNormals(NormalTransform xform) float discriminant = b * b - 4.0f * a * c; float t = (-b + sqrtf(discriminant)) / (2.0f * a); - float d = fabs(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); + float d = fabsf(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); while (d > 0.0001) { float ft = 1 - n.z * t - (n.x*n.x + n.y*n.y)*t*t + n.x*n.x*n.y*n.y*t*t*t*t; float fit = - n.z - 2*(n.x*n.x + n.y*n.y)*t + 4*n.x*n.x*n.y*n.y*t*t*t; t -= ft / fit; - d = fabs(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); + d = fabsf(n.z * t - (1 - n.x*n.x*t*t) * (1 - n.y*n.y*t*t)); }; n.x = n.x * t; diff --git a/src/nvtt/TaskDispatcher.h b/src/nvtt/TaskDispatcher.h index 168ba561..d3a698d2 100644 --- a/src/nvtt/TaskDispatcher.h +++ b/src/nvtt/TaskDispatcher.h @@ -17,7 +17,7 @@ // Parallel Patterns Library (PPL) is part of Microsoft's concurrency runtime: // http://msdn.microsoft.com/en-us/library/dd504870.aspx #if NV_OS_WIN32 && _MSC_VER >= 1600 -#define HAVE_PPL 1 +//#define HAVE_PPL 1 #include #endif diff --git a/src/nvtt/cuda/CudaUtils.cpp b/src/nvtt/cuda/CudaUtils.cpp index 1611bf41..e880f8bf 100644 --- a/src/nvtt/cuda/CudaUtils.cpp +++ b/src/nvtt/cuda/CudaUtils.cpp @@ -23,6 +23,7 @@ // OTHER DEALINGS IN THE SOFTWARE. #include "nvcore/Debug.h" +#include "nvcore/Library.h" #include "CudaUtils.h" #if defined HAVE_CUDA diff --git a/src/nvtt/icbc.cpp b/src/nvtt/icbc.cpp new file mode 100644 index 00000000..19986372 --- /dev/null +++ b/src/nvtt/icbc.cpp @@ -0,0 +1,3 @@ +#define ICBC_IMPLEMENTATION +//#define ICBC_SIMD 2 // SSE4.1 +#include "icbc.h" diff --git a/src/nvtt/icbc.h b/src/nvtt/icbc.h new file mode 100644 index 00000000..681a77ad --- /dev/null +++ b/src/nvtt/icbc.h @@ -0,0 +1,3633 @@ +// icbc.h v1.05 +// A High Quality SIMD BC1 Encoder by Ignacio Castano . +// +// LICENSE: +// MIT license at the end of this file. + +#ifndef ICBC_H +#define ICBC_H + +namespace icbc { + + enum Decoder { + Decoder_D3D10 = 0, + Decoder_NVIDIA = 1, + Decoder_AMD = 2 + }; + + void init_dxt1(Decoder decoder = Decoder_D3D10); + + enum Quality { + Quality_Level1, // Box fit + least squares fit. + Quality_Level2, // Cluster fit 4, threshold = 24. + Quality_Level3, // Cluster fit 4, threshold = 32. + Quality_Level4, // Cluster fit 4, threshold = 48. + Quality_Level5, // Cluster fit 4, threshold = 64. + Quality_Level6, // Cluster fit 4, threshold = 96. + Quality_Level7, // Cluster fit 4, threshold = 128. + Quality_Level8, // Cluster fit 4+3, threshold = 256. + Quality_Level9, // Cluster fit 4+3, threshold = 256 + Refinement. + + Quality_Fast = Quality_Level1, + Quality_Default = Quality_Level8, + Quality_Max = Quality_Level9, + }; + + void decode_dxt1(const void * block, unsigned char rgba_block[16 * 4], Decoder decoder = Decoder_D3D10); + float evaluate_dxt1_error(const unsigned char rgba_block[16 * 4], const void * block, Decoder decoder = Decoder_D3D10); + + float compress_dxt1(Quality level, const float * input_colors, const float * input_weights, const float color_weights[3], bool three_color_mode, bool three_color_black, void * output); +} + +#endif // ICBC_H + +#ifdef ICBC_IMPLEMENTATION + +// Instruction level support must be chosen at compile time setting ICBC_SIMD to one of these values: +#define ICBC_SCALAR 0 +#define ICBC_SSE2 1 +#define ICBC_SSE41 2 +#define ICBC_AVX1 3 +#define ICBC_AVX2 4 +#define ICBC_AVX512 5 +#define ICBC_NEON -1 +#define ICBC_VMX -2 + +#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) + #define ICBC_X86 1 +#endif + +#if (defined(__arm__) || defined(_M_ARM)) + #define ICBC_ARM 1 +#endif + +#if (defined(__PPC__) || defined(_M_PPC)) + #define ICBC_PPC 1 +#endif + +// SIMD version. +#ifndef ICBC_SIMD + #if ICBC_X86 + #if __AVX512F__ + #define ICBC_SIMD ICBC_AVX512 + #elif __AVX2__ + #define ICBC_SIMD ICBC_AVX2 + #elif __AVX__ + #define ICBC_SIMD ICBC_AVX1 + #elif __SSE4_1__ + #define ICBC_SIMD ICBC_SSE41 + #elif __SSE2__ + #define ICBC_SIMD ICBC_SSE2 + #else + #define ICBC_SIMD ICBC_SCALAR + #endif + #endif + + #if ICBC_ARM + #if __ARM_NEON__ + #define ICBC_SIMD ICBC_NEON + #else + #define ICBC_SIMD ICBC_SCALAR + #endif + #endif + + #if ICBC_PPC + #define ICBC_SIMD ICBC_VMX + #endif +#endif + +// AVX1 does not require FMA, and depending on whether it's Intel or AMD you may have FMA3 or FMA4. What a mess. +#ifndef ICBC_USE_FMA +//#define ICBC_USE_FMA 3 +//#define ICBC_USE_FMA 4 +#endif + +#if ICBC_SIMD >= ICBC_AVX2 +#define ICBC_BMI2 1 +#endif + +// Apparently rcp is not deterministic (different precision on Intel and AMD), enable if you don't care about that for a small performance boost. +//#define ICBC_USE_RCP 1 + +#if ICBC_SIMD == ICBC_AVX2 +#define ICBC_USE_AVX2_PERMUTE2 1 // Using permutevar8x32 and bitops. +#endif + +#if ICBC_SIMD == ICBC_AVX512 +#define ICBC_USE_AVX512_PERMUTE 1 +#endif + +#if ICBC_SIMD == ICBC_NEON +#define ICBC_USE_NEON_VTL 0 // Not tested. +#endif + + +// Some experimental knobs: +#define ICBC_PERFECT_ROUND 0 // Enable perfect rounding to compute cluster fit residual. + + +#if ICBC_SIMD >= ICBC_SSE2 +#include +#endif + +#if ICBC_SIMD >= ICBC_SSE41 +#include +#endif + +#if ICBC_SIMD >= ICBC_AVX1 +#include +#endif + +#if ICBC_SIMD >= ICBC_AVX512 && _MSC_VER +#include +#endif + +#if ICBC_SIMD == ICBC_NEON +#include +#endif + +#if ICBC_SIMD == ICBC_VMX +#include +#endif + +#if _MSC_VER +#include // _BitScanReverse +#endif + +#include +#include // abs +#include // memset +#include // fabsf +#include // FLT_MAX + +#ifndef ICBC_ASSERT +#if _DEBUG +#define ICBC_ASSERT assert +#include +#else +#define ICBC_ASSERT(x) +#endif +#endif + +namespace icbc { + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Basic Templates + +template inline void swap(T & a, T & b) { + T temp(a); + a = b; + b = temp; +} + +template inline T max(const T & a, const T & b) { + return (b < a) ? a : b; +} + +template inline T min(const T & a, const T & b) { + return (a < b) ? a : b; +} + +template inline T clamp(const T & x, const T & a, const T & b) { + return min(max(x, a), b); +} + +template inline T square(const T & a) { + return a * a; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Basic Types + +typedef uint8_t uint8; +typedef int8_t int8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint32_t uint; + + +struct Color16 { + union { + struct { + uint16 b : 5; + uint16 g : 6; + uint16 r : 5; + }; + uint16 u; + }; +}; + +struct Color32 { + union { + struct { + uint8 b, g, r, a; + }; + uint32 u; + }; +}; + +struct BlockDXT1 { + Color16 col0; + Color16 col1; + uint32 indices; +}; + + +struct Vector3 { + float x; + float y; + float z; + + inline void operator+=(Vector3 v) { + x += v.x; y += v.y; z += v.z; + } + inline void operator*=(Vector3 v) { + x *= v.x; y *= v.y; z *= v.z; + } + inline void operator*=(float s) { + x *= s; y *= s; z *= s; + } +}; + +struct Vector4 { + union { + struct { + float x, y, z, w; + }; + Vector3 xyz; + }; +}; + + +inline Vector3 operator*(Vector3 v, float s) { + return { v.x * s, v.y * s, v.z * s }; +} + +inline Vector3 operator*(float s, Vector3 v) { + return { v.x * s, v.y * s, v.z * s }; +} + +inline Vector3 operator*(Vector3 a, Vector3 b) { + return { a.x * b.x, a.y * b.y, a.z * b.z }; +} + +inline float dot(Vector3 a, Vector3 b) { + return a.x * b.x + a.y * b.y + a.z * b.z; +} + +inline Vector3 operator+(Vector3 a, Vector3 b) { + return { a.x + b.x, a.y + b.y, a.z + b.z }; +} + +inline Vector3 operator-(Vector3 a, Vector3 b) { + return { a.x - b.x, a.y - b.y, a.z - b.z }; +} + +inline Vector3 operator/(Vector3 v, float s) { + return { v.x / s, v.y / s, v.z / s }; +} + +inline float saturate(float x) { + return clamp(x, 0.0f, 1.0f); +} + +inline Vector3 saturate(Vector3 v) { + return { saturate(v.x), saturate(v.y), saturate(v.z) }; +} + +inline Vector3 min(Vector3 a, Vector3 b) { + return { min(a.x, b.x), min(a.y, b.y), min(a.z, b.z) }; +} + +inline Vector3 max(Vector3 a, Vector3 b) { + return { max(a.x, b.x), max(a.y, b.y), max(a.z, b.z) }; +} + +inline bool operator==(const Vector3 & a, const Vector3 & b) { + return a.x == b.x && a.y == b.y && a.z == b.z; +} + +inline Vector3 scalar_to_vector3(float f) { + return {f, f, f}; +} + +inline float lengthSquared(Vector3 v) { + return dot(v, v); +} + +inline bool equal(float a, float b, float epsilon = 0.0001) { + // http://realtimecollisiondetection.net/blog/?p=89 + //return fabsf(a - b) < epsilon * max(1.0f, max(fabsf(a), fabsf(b))); + return fabsf(a - b) < epsilon; +} + +inline bool equal(Vector3 a, Vector3 b, float epsilon) { + return equal(a.x, b.x, epsilon) && equal(a.y, b.y, epsilon) && equal(a.z, b.z, epsilon); +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// SIMD + +#ifndef ICBC_ALIGN_16 +#if __GNUC__ +# define ICBC_ALIGN_16 __attribute__ ((__aligned__ (16))) +#else // _MSC_VER +# define ICBC_ALIGN_16 __declspec(align(16)) +#endif +#endif + +#if __GNUC__ +#define ICBC_FORCEINLINE inline __attribute__((always_inline)) +#else +#define ICBC_FORCEINLINE __forceinline +#endif + + +// Count trailing zeros (BSR). +ICBC_FORCEINLINE int ctz(uint mask) { +#if __GNUC__ + return __builtin_ctz(mask); +#else + unsigned long index; + _BitScanReverse(&index, mask); + return (int)index; +#endif +} + + +#if ICBC_SIMD == ICBC_SCALAR // Purely scalar version. + +constexpr int VEC_SIZE = 1; + +using VFloat = float; +using VMask = bool; + +ICBC_FORCEINLINE float & lane(VFloat & v, int i) { return v; } +ICBC_FORCEINLINE VFloat vzero() { return 0.0f; } +ICBC_FORCEINLINE VFloat vbroadcast(float x) { return x; } +ICBC_FORCEINLINE VFloat vload(const float * ptr) { return *ptr; } +ICBC_FORCEINLINE VFloat vrcp(VFloat a) { return 1.0f / a; } +ICBC_FORCEINLINE VFloat vmadd(VFloat a, VFloat b, VFloat c) { return a * b + c; } +ICBC_FORCEINLINE VFloat vmsub(VFloat a, VFloat b, VFloat c) { return a * b - c; } +ICBC_FORCEINLINE VFloat vm2sub(VFloat a, VFloat b, VFloat c, VFloat d) { return a * b - c * d; } +ICBC_FORCEINLINE VFloat vsaturate(VFloat a) { return min(max(a, 0.0f), 1.0f); } +ICBC_FORCEINLINE VFloat vround01(VFloat a) { return float(int(a + 0.5f)); } +ICBC_FORCEINLINE VFloat lane_id() { return 0; } +ICBC_FORCEINLINE VFloat vselect(VMask mask, VFloat a, VFloat b) { return mask ? b : a; } +ICBC_FORCEINLINE VMask vbroadcast(bool b) { return b; } +ICBC_FORCEINLINE bool all(VMask m) { return m; } +ICBC_FORCEINLINE bool any(VMask m) { return m; } +ICBC_FORCEINLINE uint mask(VMask m) { return (uint)m; } +ICBC_FORCEINLINE int reduce_min_index(VFloat v) { return 0; } +ICBC_FORCEINLINE void vtranspose4(VFloat & a, VFloat & b, VFloat & c, VFloat & d) {} + +#elif ICBC_SIMD == ICBC_SSE2 || ICBC_SIMD == ICBC_SSE41 + +constexpr int VEC_SIZE = 4; + +#if __GNUC__ +// GCC needs a struct so that we can overload operators. +union VFloat { + __m128 v; + float m128_f32[VEC_SIZE]; + + VFloat() {} + VFloat(__m128 v) : v(v) {} + operator __m128 & () { return v; } +}; +union VMask { + __m128 m; + + VMask() {} + VMask(__m128 m) : m(m) {} + operator __m128 & () { return m; } +}; +#else +using VFloat = __m128; +using VMask = __m128; +#endif + +ICBC_FORCEINLINE float & lane(VFloat & v, int i) { + return v.m128_f32[i]; +} + +ICBC_FORCEINLINE VFloat vzero() { + return _mm_setzero_ps(); +} + +ICBC_FORCEINLINE VFloat vbroadcast(float x) { + return _mm_set1_ps(x); +} + +ICBC_FORCEINLINE VFloat vload(const float * ptr) { + return _mm_load_ps(ptr); +} + +ICBC_FORCEINLINE VFloat vgather(const float * base, VFloat index) { + VFloat v; + for (int i = 0; i < VEC_SIZE; i++) { + lane(v, i) = base[int(lane(index, i))]; + } + return v; +} + +ICBC_FORCEINLINE VFloat operator+(VFloat a, VFloat b) { + return _mm_add_ps(a, b); +} + +ICBC_FORCEINLINE VFloat operator-(VFloat a, VFloat b) { + return _mm_sub_ps(a, b); +} + +ICBC_FORCEINLINE VFloat operator*(VFloat a, VFloat b) { + return _mm_mul_ps(a, b); +} + +ICBC_FORCEINLINE VFloat vrcp(VFloat a) { +#if ICBC_USE_RCP + VFloat r = _mm_rcp_ps(a); + return _mm_mul_ps(r, _mm_sub_ps(vbroadcast(2.0f), _mm_mul_ps(r, a))); // r * (2 - r * a) +#else + return _mm_div_ps(vbroadcast(1.0f), a); +#endif +} + +// a*b+c +ICBC_FORCEINLINE VFloat vmadd(VFloat a, VFloat b, VFloat c) { + return a * b + c; +} + +ICBC_FORCEINLINE VFloat vmsub(VFloat a, VFloat b, VFloat c) { + return a * b - c; +} + +ICBC_FORCEINLINE VFloat vm2sub(VFloat a, VFloat b, VFloat c, VFloat d) { + return a * b - c * d; +} + +ICBC_FORCEINLINE VFloat vsaturate(VFloat a) { + auto zero = _mm_setzero_ps(); + auto one = _mm_set1_ps(1.0f); + return _mm_min_ps(_mm_max_ps(a, zero), one); +} + +// Assumes a is in [0, 1] range. +ICBC_FORCEINLINE VFloat vround01(VFloat a) { +#if ICBC_SIMD == ICBC_SSE41 + return _mm_round_ps(a, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); +#else + return _mm_cvtepi32_ps(_mm_cvttps_epi32(a + vbroadcast(0.5f))); +#endif +} + +ICBC_FORCEINLINE VFloat vtruncate(VFloat a) { +#if ICBC_SIMD == ICBC_SSE41 + return _mm_round_ps(a, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return _mm_cvtepi32_ps(_mm_cvttps_epi32(a)); +#endif +} + +ICBC_FORCEINLINE VFloat lane_id() { + return _mm_set_ps(3, 2, 1, 0); +} + +ICBC_FORCEINLINE VMask operator> (VFloat A, VFloat B) { return _mm_cmpgt_ps(A, B); } +ICBC_FORCEINLINE VMask operator>=(VFloat A, VFloat B) { return _mm_cmpge_ps(A, B); } +ICBC_FORCEINLINE VMask operator< (VFloat A, VFloat B) { return _mm_cmplt_ps(A, B); } +ICBC_FORCEINLINE VMask operator<=(VFloat A, VFloat B) { return _mm_cmple_ps(A, B); } + +ICBC_FORCEINLINE VMask operator| (VMask A, VMask B) { return _mm_or_ps(A, B); } +ICBC_FORCEINLINE VMask operator& (VMask A, VMask B) { return _mm_and_ps(A, B); } +ICBC_FORCEINLINE VMask operator^ (VMask A, VMask B) { return _mm_xor_ps(A, B); } + +// mask ? b : a +ICBC_FORCEINLINE VFloat vselect(VMask mask, VFloat a, VFloat b) { +#if ICBC_SIMD == ICBC_SSE41 + return _mm_blendv_ps(a, b, mask); +#else + return _mm_or_ps(_mm_andnot_ps(mask, a), _mm_and_ps(mask, b)); +#endif +} + +ICBC_FORCEINLINE VMask vbroadcast(bool b) { + return _mm_castsi128_ps(_mm_set1_epi32(-int32_t(b))); +} + +ICBC_FORCEINLINE bool all(VMask m) { + int value = _mm_movemask_ps(m); + return value == 0x7; +} + +ICBC_FORCEINLINE bool any(VMask m) { + int value = _mm_movemask_ps(m); + return value != 0; +} + +ICBC_FORCEINLINE uint mask(VMask m) { + return (uint)_mm_movemask_ps(m); +} + +ICBC_FORCEINLINE int reduce_min_index(VFloat v) { + + // First do an horizontal reduction. // v = [ D C | B A ] + VFloat shuf = _mm_shuffle_ps(v, v, _MM_SHUFFLE(2, 3, 0, 1)); // [ C D | A B ] + VFloat mins = _mm_min_ps(v, shuf); // mins = [ D+C C+D | B+A A+B ] + shuf = _mm_movehl_ps(shuf, mins); // [ C D | D+C C+D ] // let the compiler avoid a mov by reusing shuf + mins = _mm_min_ss(mins, shuf); + mins = _mm_shuffle_ps(mins, mins, _MM_SHUFFLE(0, 0, 0, 0)); + + // Then find the index. + uint mask = _mm_movemask_ps(v <= mins); + return ctz(mask); +} + +// https://gcc.gnu.org/legacy-ml/gcc-patches/2005-10/msg00324.html +ICBC_FORCEINLINE void vtranspose4(VFloat & r0, VFloat & r1, VFloat & r2, VFloat & r3) { + VFloat t0 = _mm_unpacklo_ps(r0, r1); + VFloat t1 = _mm_unpacklo_ps(r2, r3); + VFloat t2 = _mm_unpackhi_ps(r0, r1); + VFloat t3 = _mm_unpackhi_ps(r2, r3); + r0 = _mm_movelh_ps(t0, t1); + r1 = _mm_movehl_ps(t1, t0); + r2 = _mm_movelh_ps(t2, t3); + r3 = _mm_movehl_ps(t3, t2); +} + + +#elif ICBC_SIMD == ICBC_AVX1 || ICBC_SIMD == ICBC_AVX2 + +constexpr int VEC_SIZE = 8; + +#if __GNUC__ +union VFloat { + __m256 v; + float m256_f32[VEC_SIZE]; + + VFloat() {} + VFloat(__m256 v) : v(v) {} + operator __m256 & () { return v; } +}; +union VInt { + __m256i v; + int m256_i32[VEC_SIZE]; + + VInt() {} + VInt(__m256i v) : v(v) {} + operator __m256i & () { return v; } +}; +union VMask { + __m256 m; + + VMask() {} + VMask(__m256 m) : m(m) {} + operator __m256 & () { return m; } +}; +#else +using VFloat = __m256; +using VInt = __m256i; +using VMask = __m256; // Emulate mask vector using packed float. +#endif + +ICBC_FORCEINLINE float & lane(VFloat & v, int i) { + return v.m256_f32[i]; +} + +ICBC_FORCEINLINE VFloat vzero() { + return _mm256_setzero_ps(); +} + +ICBC_FORCEINLINE VFloat vbroadcast(float a) { + return _mm256_set1_ps(a); +} + +ICBC_FORCEINLINE VFloat vload(const float * ptr) { + return _mm256_load_ps(ptr); +} + +ICBC_FORCEINLINE VFloat vgather(const float * base, VFloat index) { +#if ICBC_SIMD == ICBC_AVX2 + return _mm256_i32gather_ps(base, _mm256_cvtps_epi32(index), 4); +#else + VFloat v; + for (int i = 0; i < VEC_SIZE; i++) { + lane(v, i) = base[int(lane(index, i))]; + } + return v; +#endif +} + +ICBC_FORCEINLINE VFloat operator+(VFloat a, VFloat b) { + return _mm256_add_ps(a, b); +} + +ICBC_FORCEINLINE VFloat operator-(VFloat a, VFloat b) { + return _mm256_sub_ps(a, b); +} + +ICBC_FORCEINLINE VFloat operator*(VFloat a, VFloat b) { + return _mm256_mul_ps(a, b); +} + +ICBC_FORCEINLINE VFloat vrcp(VFloat a) { +#if ICBC_USE_RCP + #if ICBC_SIMD == ICBC_AVX512 + VFloat r = _mm256_rcp14_ps(a); + #else + VFloat r = _mm256_rcp_ps(a); + #endif + + // r = r * (2 - r * a) + #if ICBC_USE_FMA == 3 || ICBC_AVX2 + return _mm256_mul_ps(r, _mm256_fnmadd_ps(r, a, vbroadcast(2.0f))); + #else + return _mm256_mul_ps(r, _mm256_sub_ps(vbroadcast(2.0f), _mm256_mul_ps(r, a))); + #endif +#else + return _mm256_div_ps(vbroadcast(1.0f), a); +#endif +} + +// a*b+c +ICBC_FORCEINLINE VFloat vmadd(VFloat a, VFloat b, VFloat c) { +#if ICBC_USE_FMA == 3 || ICBC_SIMD == ICBC_AVX2 + return _mm256_fmadd_ps(a, b, c); +#elif ICBC_USE_FMA == 4 + return _mm256_macc_ps(a, b, c); +#else + return ((a * b) + c); +#endif +} + +ICBC_FORCEINLINE VFloat vmsub(VFloat a, VFloat b, VFloat c) { +#if ICBC_USE_FMA == 3 || ICBC_SIMD == ICBC_AVX2 + return _mm256_fmsub_ps(a, b, c); +#elif ICBC_USE_FMA == 4 + return _mm256_msub_ps(a, b, c); +#else + return ((a * b) - c); +#endif +} + +ICBC_FORCEINLINE VFloat vm2sub(VFloat a, VFloat b, VFloat c, VFloat d) { + return vmsub(a, b, c * d); +} + +ICBC_FORCEINLINE VFloat vsaturate(VFloat a) { + __m256 zero = _mm256_setzero_ps(); + __m256 one = _mm256_set1_ps(1.0f); + return _mm256_min_ps(_mm256_max_ps(a, zero), one); +} + +ICBC_FORCEINLINE VFloat vround01(VFloat a) { + return _mm256_round_ps(a, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC); +} + +ICBC_FORCEINLINE VFloat vtruncate(VFloat a) { + return _mm256_round_ps(a, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +} + +ICBC_FORCEINLINE VFloat lane_id() { + return _mm256_set_ps(7, 6, 5, 4, 3, 2, 1, 0); +} + +ICBC_FORCEINLINE VMask operator> (VFloat A, VFloat B) { return _mm256_cmp_ps(A, B, _CMP_GT_OQ); } +ICBC_FORCEINLINE VMask operator>=(VFloat A, VFloat B) { return _mm256_cmp_ps(A, B, _CMP_GE_OQ); } +ICBC_FORCEINLINE VMask operator< (VFloat A, VFloat B) { return _mm256_cmp_ps(A, B, _CMP_LT_OQ); } +ICBC_FORCEINLINE VMask operator<=(VFloat A, VFloat B) { return _mm256_cmp_ps(A, B, _CMP_LE_OQ); } + +ICBC_FORCEINLINE VMask operator| (VMask A, VMask B) { return _mm256_or_ps(A, B); } +ICBC_FORCEINLINE VMask operator& (VMask A, VMask B) { return _mm256_and_ps(A, B); } +ICBC_FORCEINLINE VMask operator^ (VMask A, VMask B) { return _mm256_xor_ps(A, B); } + +// mask ? b : a +ICBC_FORCEINLINE VFloat vselect(VMask mask, VFloat a, VFloat b) { + return _mm256_blendv_ps(a, b, mask); +} + +ICBC_FORCEINLINE VMask vbroadcast(bool b) { + return _mm256_castsi256_ps(_mm256_set1_epi32(-int32_t(b))); +} + +ICBC_FORCEINLINE bool all(VMask m) { + __m256 zero = _mm256_setzero_ps(); + return _mm256_testc_ps(_mm256_cmp_ps(zero, zero, _CMP_EQ_UQ), m) == 0; +} + +ICBC_FORCEINLINE bool any(VMask m) { + return _mm256_testz_ps(m, m) == 0; +} + +ICBC_FORCEINLINE uint mask(VMask m) { + return (uint)_mm256_movemask_ps(m); +} + +// This is missing on some GCC versions. +#if !defined _mm256_set_m128 +#define _mm256_set_m128(hi, lo) _mm256_insertf128_ps(_mm256_castps128_ps256(lo), (hi), 0x1) +#endif + +ICBC_FORCEINLINE int reduce_min_index(VFloat v) { + + __m128 vlow = _mm256_castps256_ps128(v); + __m128 vhigh = _mm256_extractf128_ps(v, 1); + vlow = _mm_min_ps(vlow, vhigh); + + // First do an horizontal reduction. // v = [ D C | B A ] + __m128 shuf = _mm_shuffle_ps(vlow, vlow, _MM_SHUFFLE(2, 3, 0, 1)); // [ C D | A B ] + __m128 mins = _mm_min_ps(vlow, shuf); // mins = [ D+C C+D | B+A A+B ] + shuf = _mm_movehl_ps(shuf, mins); // [ C D | D+C C+D ] + mins = _mm_min_ss(mins, shuf); + + VFloat vmin = _mm256_permute_ps(_mm256_set_m128(mins, mins), 0); // _MM256_PERMUTE(0, 0, 0, 0, 0, 0, 0, 0) + + // Then find the index. + uint mask = _mm256_movemask_ps(v <= vmin); + return ctz(mask); +} + +// AoS to SoA +ICBC_FORCEINLINE void vtranspose4(VFloat & a, VFloat & b, VFloat & c, VFloat & d) { + VFloat r0 = _mm256_unpacklo_ps(a, b); + VFloat r1 = _mm256_unpacklo_ps(c, d); + VFloat r2 = _mm256_permute2f128_ps(r0, r1, 0x20); + VFloat r3 = _mm256_permute2f128_ps(r0, r1, 0x31); + r0 = _mm256_unpackhi_ps(a, b); + r1 = _mm256_unpackhi_ps(c, d); + a = _mm256_unpacklo_ps(r2, r3); + b = _mm256_unpackhi_ps(r2, r3); + r2 = _mm256_permute2f128_ps(r0, r1, 0x20); + r3 = _mm256_permute2f128_ps(r0, r1, 0x31); + c = _mm256_unpacklo_ps(r2, r3); + d = _mm256_unpackhi_ps(r2, r3); +} + +ICBC_FORCEINLINE VInt vzeroi() { + return _mm256_setzero_si256(); +} + +ICBC_FORCEINLINE VInt vbroadcast(int a) { + return _mm256_set1_epi32(a); +} + +ICBC_FORCEINLINE VInt vload(const int * ptr) { + return _mm256_load_si256((const __m256i*)ptr); +} + +ICBC_FORCEINLINE VInt operator- (VInt A, int b) { return _mm256_sub_epi32(A, _mm256_set1_epi32(b)); } +ICBC_FORCEINLINE VInt operator& (VInt A, int b) { return _mm256_and_si256(A, _mm256_set1_epi32(b)); } +ICBC_FORCEINLINE VInt operator>> (VInt A, int b) { return _mm256_srli_epi32(A, b); } + +ICBC_FORCEINLINE VMask operator> (VInt A, int b) { return _mm256_castsi256_ps(_mm256_cmpgt_epi32(A, _mm256_set1_epi32(b))); } +ICBC_FORCEINLINE VMask operator== (VInt A, int b) { return _mm256_castsi256_ps(_mm256_cmpeq_epi32(A, _mm256_set1_epi32(b))); } + +// mask ? v[idx] : 0 +ICBC_FORCEINLINE VFloat vpermuteif(VMask mask, VFloat v, VInt idx) { + return _mm256_and_ps(_mm256_permutevar8x32_ps(v, idx), mask); +} + +// mask ? (idx > 8 ? vhi[idx] : vlo[idx]) : 0 +ICBC_FORCEINLINE VFloat vpermute2if(VMask mask, VFloat vlo, VFloat vhi, VInt idx) { +#if 0 + VMask mhi = idx > 7; + vlo = _mm256_permutevar8x32_ps(vlo, idx); + vhi = _mm256_permutevar8x32_ps(vhi, idx); + VFloat v = _mm256_blendv_ps(vlo, vhi, mhi); + return _mm256_and_ps(v, mask); +#else + // Fabian Giesen says not to mix _mm256_blendv_ps and _mm256_permutevar8x32_ps since they contend for the same gates and instead suggests the following: + vhi = _mm256_xor_ps(vhi, vlo); + VFloat v = _mm256_permutevar8x32_ps(vlo, idx); + VMask mhi = idx > 7; + v = _mm256_xor_ps(v, _mm256_and_ps(_mm256_permutevar8x32_ps(vhi, idx), mhi)); + return _mm256_and_ps(v, mask); +#endif +} + + +#elif ICBC_SIMD == ICBC_AVX512 + +constexpr int VEC_SIZE = 16; + +#if __GNUC__ +union VFloat { + __m512 v; + float m512_f32[VEC_SIZE]; + + VFloat() {} + VFloat(__m512 v) : v(v) {} + operator __m512 & () { return v; } +}; +union VInt { + __m512i v; + int m512i_i32[VEC_SIZE]; + + VInt() {} + VInt(__m512i v) : v(v) {} + operator __m512i & () { return v; } +}; +#else +using VFloat = __m512; +using VInt = __m512i; +#endif +struct VMask { __mmask16 m; }; + +ICBC_FORCEINLINE float & lane(VFloat & v, int i) { + return v.m512_f32[i]; +} + +ICBC_FORCEINLINE VFloat vzero() { + return _mm512_setzero_ps(); +} + +ICBC_FORCEINLINE VFloat vbroadcast(float a) { + return _mm512_set1_ps(a); +} + +ICBC_FORCEINLINE VFloat vload(const float * ptr) { + return _mm512_load_ps(ptr); +} + +ICBC_FORCEINLINE VFloat vload(VMask mask, const float * ptr) { + return _mm512_mask_load_ps(_mm512_undefined(), mask.m, ptr); +} + +ICBC_FORCEINLINE VFloat vload(VMask mask, const float * ptr, float fallback) { + return _mm512_mask_load_ps(_mm512_set1_ps(fallback), mask.m, ptr); +} + +ICBC_FORCEINLINE VFloat vgather(const float * base, VFloat index) { + return _mm512_i32gather_ps(_mm512_cvtps_epi32(index), base, 4); +} + +ICBC_FORCEINLINE VFloat operator+(VFloat a, VFloat b) { + return _mm512_add_ps(a, b); +} + +ICBC_FORCEINLINE VFloat operator-(VFloat a, VFloat b) { + return _mm512_sub_ps(a, b); +} + +ICBC_FORCEINLINE VFloat operator*(VFloat a, VFloat b) { + return _mm512_mul_ps(a, b); +} + +ICBC_FORCEINLINE VFloat vrcp(VFloat a) { +#if ICBC_USE_RCP + VFloat r = _mm512_rcp14_ps(a); + + // r = r * (2 - r * a) + return _mm512_mul_ps(r, _mm512_fnmadd_ps(r, a, vbroadcast(2.0f))); +#else + return _mm512_div_ps(vbroadcast(1.0f), a); +#endif +} + +// a*b+c +ICBC_FORCEINLINE VFloat vmadd(VFloat a, VFloat b, VFloat c) { + return _mm512_fmadd_ps(a, b, c); +} + +ICBC_FORCEINLINE VFloat vmsub(VFloat a, VFloat b, VFloat c) { + return _mm512_fmsub_ps(a, b, c); +} + +ICBC_FORCEINLINE VFloat vm2sub(VFloat a, VFloat b, VFloat c, VFloat d) { + return vmsub(a, b, c * d); +} + +ICBC_FORCEINLINE VFloat vsaturate(VFloat a) { + auto zero = _mm512_setzero_ps(); + auto one = _mm512_set1_ps(1.0f); + return _mm512_min_ps(_mm512_max_ps(a, zero), one); +} + +ICBC_FORCEINLINE VFloat vround01(VFloat a) { + return _mm512_roundscale_ps(a, _MM_FROUND_TO_NEAREST_INT); +} + +ICBC_FORCEINLINE VFloat vtruncate(VFloat a) { + return _mm512_roundscale_ps(a, _MM_FROUND_TO_ZERO); +} + +ICBC_FORCEINLINE VFloat lane_id() { + return _mm512_set_ps(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); +} + +ICBC_FORCEINLINE VMask operator> (VFloat A, VFloat B) { return { _mm512_cmp_ps_mask(A, B, _CMP_GT_OQ) }; } +ICBC_FORCEINLINE VMask operator>=(VFloat A, VFloat B) { return { _mm512_cmp_ps_mask(A, B, _CMP_GE_OQ) }; } +ICBC_FORCEINLINE VMask operator< (VFloat A, VFloat B) { return { _mm512_cmp_ps_mask(A, B, _CMP_LT_OQ) }; } +ICBC_FORCEINLINE VMask operator<=(VFloat A, VFloat B) { return { _mm512_cmp_ps_mask(A, B, _CMP_LE_OQ) }; } + +ICBC_FORCEINLINE VMask operator! (VMask A) { return { _mm512_knot(A.m) }; } +ICBC_FORCEINLINE VMask operator| (VMask A, VMask B) { return { _mm512_kor(A.m, B.m) }; } +ICBC_FORCEINLINE VMask operator& (VMask A, VMask B) { return { _mm512_kand(A.m, B.m) }; } +ICBC_FORCEINLINE VMask operator^ (VMask A, VMask B) { return { _mm512_kxor(A.m, B.m) }; } + +// mask ? b : a +ICBC_FORCEINLINE VFloat vselect(VMask mask, VFloat a, VFloat b) { + return _mm512_mask_blend_ps(mask.m, a, b); +} + +ICBC_FORCEINLINE VMask vbroadcast(bool b) { + return { __mmask16(-int16_t(b)) }; +} + +ICBC_FORCEINLINE bool all(VMask mask) { + return mask.m == 0xFFFFFFFF; +} + +ICBC_FORCEINLINE bool any(VMask mask) { + return mask.m != 0; +} + +ICBC_FORCEINLINE uint mask(VMask mask) { + return mask.m; +} + +ICBC_FORCEINLINE int reduce_min_index(VFloat v) { + + // First do an horizontal reduction. + VFloat vmin = vbroadcast(_mm512_reduce_min_ps(v)); + + // Then find the index. + VMask mask = (v <= vmin); + return ctz(mask.m); +} + +//ICBC_FORCEINLINE void vtranspose4(VFloat & a, VFloat & b, VFloat & c, VFloat & d); // @@ + +ICBC_FORCEINLINE int lane(VInt v, int i) { + //return _mm256_extract_epi32(v, i); + return v.m512i_i32[i]; +} + +ICBC_FORCEINLINE VInt vzeroi() { + return _mm512_setzero_epi32(); +} + +ICBC_FORCEINLINE VInt vbroadcast(int a) { + return _mm512_set1_epi32(a); +} + +ICBC_FORCEINLINE VInt vload(const int * ptr) { + return _mm512_load_epi32(ptr); +} + +ICBC_FORCEINLINE VInt operator- (VInt A, int b) { return _mm512_sub_epi32(A, vbroadcast(b)); } +ICBC_FORCEINLINE VInt operator& (VInt A, int b) { return _mm512_and_epi32(A, vbroadcast(b)); } +ICBC_FORCEINLINE VInt operator>> (VInt A, int b) { return _mm512_srli_epi32(A, b); } + +ICBC_FORCEINLINE VMask operator> (VInt A, int b) { return { _mm512_cmpgt_epi32_mask(A, vbroadcast(b)) }; } +ICBC_FORCEINLINE VMask operator>=(VInt A, int b) { return { _mm512_cmpge_epi32_mask(A, vbroadcast(b)) }; } +ICBC_FORCEINLINE VMask operator== (VInt A, int b) { return { _mm512_cmpeq_epi32_mask(A, vbroadcast(b)) }; } + +// mask ? v[idx] : 0 +ICBC_FORCEINLINE VFloat vpermuteif(VMask mask, VFloat v, VInt idx) { + return _mm512_maskz_permutexvar_ps(mask.m, idx, v); +} + + +#elif ICBC_SIMD == ICBC_NEON + +constexpr int VEC_SIZE = 4; + +#if __GNUC__ +union VFloat { + float32x4_t v; + float e[4]; + VFloat() {} + VFloat(float32x4_t v) : v(v) {} + operator float32x4_t & () { return v; } +}; +struct VMask { + uint32x4_t v; + VMask() {} + VMask(uint32x4_t v) : v(v) {} + operator uint32x4_t & () { return v; } +}; +#else +using VFloat = float32x4_t; +using VMask = uint32x4_t; +#endif + +ICBC_FORCEINLINE float & lane(VFloat & v, int i) { +#if defined(__clang__) + return v.e[i]; +#elif defined(_MSC_VER) + return v.n128_f32[i]; +#else + return v.v[i]; +#endif +} + +ICBC_FORCEINLINE VFloat vzero() { + return vdupq_n_f32(0.0f); +} + +ICBC_FORCEINLINE VFloat vbroadcast(float a) { + return vdupq_n_f32(a); +} + +ICBC_FORCEINLINE VFloat vload(const float * ptr) { + return vld1q_f32(ptr); +} + +ICBC_FORCEINLINE VFloat operator+(VFloat a, VFloat b) { + return vaddq_f32(a, b); +} + +ICBC_FORCEINLINE VFloat operator-(VFloat a, VFloat b) { + return vsubq_f32(a, b); +} + +ICBC_FORCEINLINE VFloat operator*(VFloat a, VFloat b) { + return vmulq_f32(a, b); +} + +ICBC_FORCEINLINE VFloat vrcp(VFloat a) { +//#if ICBC_USE_RCP + VFloat rcp = vrecpeq_f32(a); + //return rcp; + return vmulq_f32(vrecpsq_f32(a, rcp), rcp); +//#else +// return vdiv_f32(vbroadcast(1.0f), a); // @@ ARMv8 only? +//#endif +} + +// a*b+c +ICBC_FORCEINLINE VFloat vmadd(VFloat a, VFloat b, VFloat c) { + return vmlaq_f32(c, a, b); +} + +ICBC_FORCEINLINE VFloat vmsub(VFloat a, VFloat b, VFloat c) { + return a * b - c; +} + +ICBC_FORCEINLINE VFloat vm2sub(VFloat a, VFloat b, VFloat c, VFloat d) { + // vmlsq_f32(a, b, c) == a - (b * c) + return vmlsq_f32(a * b, c, d); +} + +ICBC_FORCEINLINE VFloat vsaturate(VFloat a) { + return vminq_f32(vmaxq_f32(a, vzero()), vbroadcast(1)); +} + +ICBC_FORCEINLINE VFloat vround01(VFloat a) { +#if __ARM_RACH >= 8 + return vrndqn_f32(a); // Round to integral (to nearest, ties to even) +#else + return vcvtq_f32_s32(vcvtq_s32_f32(a + vbroadcast(0.5))); +#endif +} + +ICBC_FORCEINLINE VFloat vtruncate(VFloat a) { +#if __ARM_RACH >= 8 + return vrndq_f32(a); +#else + return vcvtq_f32_s32(vcvtq_s32_f32(a)); +#endif +} + +ICBC_FORCEINLINE VFloat lane_id() { + ICBC_ALIGN_16 float data[4] = { 0, 1, 2, 3 }; + return vld1q_f32(data); +} + +ICBC_FORCEINLINE VMask operator> (VFloat A, VFloat B) { return { vcgtq_f32(A, B) }; } +ICBC_FORCEINLINE VMask operator>=(VFloat A, VFloat B) { return { vcgeq_f32(A, B) }; } +ICBC_FORCEINLINE VMask operator< (VFloat A, VFloat B) { return { vcltq_f32(A, B) }; } +ICBC_FORCEINLINE VMask operator<=(VFloat A, VFloat B) { return { vcleq_f32(A, B) }; } + +ICBC_FORCEINLINE VMask operator| (VMask A, VMask B) { return { vorrq_u32(A, B) }; } +ICBC_FORCEINLINE VMask operator& (VMask A, VMask B) { return { vandq_u32(A, B) }; } +ICBC_FORCEINLINE VMask operator^ (VMask A, VMask B) { return { veorq_u32(A, B) }; } + +// mask ? b : a +ICBC_FORCEINLINE VFloat vselect(VMask mask, VFloat a, VFloat b) { + return vbslq_f32(mask, b, a); +} + +ICBC_FORCEINLINE bool all(VMask mask) { + uint32x2_t m2 = vpmin_u32(vget_low_u32(mask), vget_high_u32(mask)); + uint32x2_t m1 = vpmin_u32(m2, m2); +#if defined(_MSC_VER) + return m1.n64_u32[0] != 0; +#else + return m1[0] != 0; +#endif +} + +ICBC_FORCEINLINE bool any(VMask mask) { + uint32x2_t m2 = vpmax_u32(vget_low_u32(mask), vget_high_u32(mask)); + uint32x2_t m1 = vpmax_u32(m2, m2); +#if defined(_MSC_VER) + return m1.n64_u32[0] != 0; +#else + return m1[0] != 0; +#endif +} + +// @@ Is this the best we can do? +// From: https://github.com/jratcliff63367/sse2neon/blob/master/SSE2NEON.h +ICBC_FORCEINLINE uint mask(VMask mask) { + static const uint32x4_t movemask = { 1, 2, 4, 8 }; + static const uint32x4_t highbit = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + uint32x4_t t1 = vtstq_u32(mask, highbit); + uint32x4_t t2 = vandq_u32(t1, movemask); + uint32x2_t t3 = vorr_u32(vget_low_u32(t2), vget_high_u32(t2)); + return vget_lane_u32(t3, 0) | vget_lane_u32(t3, 1); +} + +inline int reduce_min_index(VFloat v) { +#if 0 + float32x2_t m2 = vpmin_f32(vget_low_u32(V), vget_high_u32(v)); + float32x2_t m1 = vpmin_f32(m2, m2); + float min_value = vget_lane_f32(m1, 0); + VFloat vmin = vbroadcast(min_value); + + // (v <= vmin) + + // @@ Find the lane that contains minValue? +#endif + + // @@ Is there a better way to do this reduction? + int min_idx = 0; + float min_value = lane(v, 0); + + for (int i = 1; i < VEC_SIZE; i++) { + float value = lane(v, i); + if (value < min_value) { + min_value = value; + min_idx = i; + } + } + + return min_idx; +} + +// https://github.com/Maratyszcza/NNPACK/blob/master/src/neon/transpose.h +ICBC_FORCEINLINE void vtranspose4(VFloat & a, VFloat & b, VFloat & c, VFloat & d) { + // row0 = ( x00 x01 x02 x03 ) + // row1 = ( x10 x11 x12 x13 ) + // row2 = ( x20 x21 x22 x23 ) + // row3 = ( x30 x31 x32 x33 ) + + // row01 = ( x00 x10 x02 x12 ), ( x01 x11 x03, x13 ) + // row23 = ( x20 x30 x22 x32 ), ( x21 x31 x23, x33 ) + float32x4x2_t row01 = vtrnq_f32(a, b); + float32x4x2_t row23 = vtrnq_f32(c, d); + + // row0 = ( x00 x10 x20 x30 ) + // row1 = ( x01 x11 x21 x31 ) + // row2 = ( x02 x12 x22 x32 ) + // row3 = ( x03 x13 x23 x33 ) + a = vcombine_f32(vget_low_f32(row01.val[0]), vget_low_f32(row23.val[0])); + b = vcombine_f32(vget_low_f32(row01.val[1]), vget_low_f32(row23.val[1])); + c = vcombine_f32(vget_high_f32(row01.val[0]), vget_high_f32(row23.val[0])); + d = vcombine_f32(vget_high_f32(row01.val[1]), vget_high_f32(row23.val[1])); +} + +#elif ICBC_SIMD == ICBC_VMX + +constexpr int VEC_SIZE = 4; + +union VFloat { + vectro float v; + float e[4]; + VFloat() {} + VFloat(vector float v) : v(v) {} + operator vector float & () { return v; } +}; +struct VMask { + vector unsigned int v; + VMask() {} + VMask(vector unsigned int v) : v(v) {} + operator vector unsigned int & () { return v; } +}; + +ICBC_FORCEINLINE float & lane(VFloat & v, int i) { + return v.e[i]; +} + +ICBC_FORCEINLINE VFloat vzero() { + return vec_splats(0.0f); +} + +ICBC_FORCEINLINE VFloat vbroadcast(float a) { + return vec_splats(a); +} + +ICBC_FORCEINLINE VFloat vload(const float * ptr) { + return vec_ld(ptr) +} + +ICBC_FORCEINLINE VFloat operator+(VFloat a, VFloat b) { + return vec_add(a, b); +} + +ICBC_FORCEINLINE VFloat operator-(VFloat a, VFloat b) { + return vec_sub(a, b); +} + +ICBC_FORCEINLINE VFloat operator*(VFloat a, VFloat b) { + return vec_madd(a, b, vec_splats(-0.0f)); +} + +ICBC_FORCEINLINE VFloat vrcp(VFloat a) { +#if ICBC_USE_RCP + // get the reciprocal estimate + vector float estimate = vec_re( v.vec ); + + // one round of Newton-Rhaphson refinement + vector float diff = vec_nmsub( estimate, v.vec, vec_splats( 1.0f ) ); + return vec_madd(diff, estimate, estimate ); +#else + return vec_div(vec_splats(1),a); +#endif +} + +// a*b+c +ICBC_FORCEINLINE VFloat vmadd(VFloat a, VFloat b, VFloat c) { + return vec_madd(a, b, c); +} + +ICBC_FORCEINLINE VFloat vmsub(VFloat a, VFloat b, VFloat c) { + return vec_msub(a, b, c); // @@ Is this right? +} + +ICBC_FORCEINLINE VFloat vm2sub(VFloat a, VFloat b, VFloat c, VFloat d) { + return vmsub(a, b, c * d); +} + +ICBC_FORCEINLINE VFloat vsaturate(VFloat a) { + return vec_min(vec_max(a, vzero()), vbroadcast(1)); +} + +ICBC_FORCEINLINE VFloat vround01(VFloat a) { + // @@ Assumes a is positive and ~small + return vec_trunc(a + vbroadcast(0.5)); +} + +ICBC_FORCEINLINE VFloat vtruncate(VFloat a) { + return vec_trunc(a); +} + +ICBC_FORCEINLINE VFloat lane_id() { + return (VFloat){ 0, 1, 2, 3 }; +} + +ICBC_FORCEINLINE VMask operator> (VFloat A, VFloat B) { return { vec_cmpgt(A, B) }; } +ICBC_FORCEINLINE VMask operator>=(VFloat A, VFloat B) { return { vec_cmpge(A, B) }; } +ICBC_FORCEINLINE VMask operator< (VFloat A, VFloat B) { return { vec_cmplt(A, B) }; } +ICBC_FORCEINLINE VMask operator<=(VFloat A, VFloat B) { return { vec_cmple(A, B) }; } + +ICBC_FORCEINLINE VMask operator| (VMask A, VMask B) { return { vec_or(A, B) }; } +ICBC_FORCEINLINE VMask operator& (VMask A, VMask B) { return { vec_and(A, B) }; } +ICBC_FORCEINLINE VMask operator^ (VMask A, VMask B) { return { vec_xor(A, B) }; } + +// mask ? b : a +ICBC_FORCEINLINE VFloat vselect(VMask mask, VFloat a, VFloat b) { + return vec_sel(a, b, mask); +} + +ICBC_FORCEINLINE int reduce_min_index(VFloat v) { + + //VFloat vmin = //@@ Horizontal min? + //return vec_cmpeq_idx(v, vmin); + + // @@ Is there a better way to do this reduction? + int min_idx = 0; + float min_value = lane(v, 0); + + for (int i = 1; i < VEC_SIZE; i++) { + float value = lane(v, i); + if (value < min_value) { + min_value = value; + min_idx = i; + } + } + + return min_idx; +} + +ICBC_FORCEINLINE void vtranspose4(VFloat & a, VFloat & b, VFloat & c, VFloat & d) { + VFloat t1 = vec_mergeh(a, c); + VFloat t2 = vec_mergel(a, c); + VFloat t3 = vec_mergeh(b, d); + VFloat t4 = vec_mergel(b, d); + a = vec_mergeh(t1, t3); + b = vec_mergel(t1, t3); + c = vec_mergeh(t2, t4); + d = vec_mergel(t2, t4); +} + +#endif // ICBC_SIMD == * + +#if ICBC_SIMD != ICBC_SCALAR +ICBC_FORCEINLINE VFloat vmadd(VFloat a, float b, VFloat c) { + VFloat vb = vbroadcast(b); + return vmadd(a, vb, c); +} +#endif + +struct VVector3 { + VFloat x; + VFloat y; + VFloat z; +}; + +ICBC_FORCEINLINE VVector3 vbroadcast(Vector3 v) { + VVector3 v8; + + v8.x = vbroadcast(v.x); + v8.y = vbroadcast(v.y); + v8.z = vbroadcast(v.z); + return v8; +} + +ICBC_FORCEINLINE VVector3 vbroadcast(float x, float y, float z) { + VVector3 v8; + v8.x = vbroadcast(x); + v8.y = vbroadcast(y); + v8.z = vbroadcast(z); + return v8; +} + +/*ICBC_FORCEINLINE VVector3 vload(const Vector3 * v) { + // @@ See this for a 8x3 transpose: https://software.intel.com/content/www/us/en/develop/articles/3d-vector-normalization-using-256-bit-intel-advanced-vector-extensions-intel-avx.html +}*/ + +ICBC_FORCEINLINE VVector3 vload(const Vector4 * ptr) { +#if ICBC_SIMD == ICBC_AVX512 + + // @@ AVX512 transpose not implemented. + __m512i vindex = _mm512_set_epi32(4 * 15, 4 * 14, 4 * 13, 4 * 12, 4 * 11, 4 * 10, 4 * 9, 4 * 8, 4 * 7, 4 * 6, 4 * 5, 4 * 4, 4 * 3, 4 * 2, 4 * 1, 0); + + VVector3 v; + v.x = _mm512_i32gather_ps(vindex, &ptr->x, 4); + v.y = _mm512_i32gather_ps(vindex, &ptr->y, 4); + v.z = _mm512_i32gather_ps(vindex, &ptr->z, 4); + return v; + +#else + + VVector3 v; + v.x = vload(&ptr->x + 0 * VEC_SIZE); + v.y = vload(&ptr->x + 1 * VEC_SIZE); + v.z = vload(&ptr->x + 2 * VEC_SIZE); + VFloat tmp = vload(&ptr->x + 3 * VEC_SIZE); + + vtranspose4(v.x, v.y, v.z, tmp); + + return v; +#endif +} + + +ICBC_FORCEINLINE VVector3 operator+(VVector3 a, VVector3 b) { + VVector3 v; + v.x = (a.x + b.x); + v.y = (a.y + b.y); + v.z = (a.z + b.z); + return v; +} + +ICBC_FORCEINLINE VVector3 operator-(VVector3 a, VVector3 b) { + VVector3 v8; + v8.x = (a.x - b.x); + v8.y = (a.y - b.y); + v8.z = (a.z - b.z); + return v8; +} + +ICBC_FORCEINLINE VVector3 operator*(VVector3 a, VVector3 b) { + VVector3 v8; + v8.x = (a.x * b.x); + v8.y = (a.y * b.y); + v8.z = (a.z * b.z); + return v8; +} + +ICBC_FORCEINLINE VVector3 operator*(VVector3 a, VFloat b) { + VVector3 v8; + v8.x = (a.x * b); + v8.y = (a.y * b); + v8.z = (a.z * b); + return v8; +} + +ICBC_FORCEINLINE VVector3 vmadd(VVector3 a, VVector3 b, VVector3 c) { + VVector3 v8; + v8.x = vmadd(a.x, b.x, c.x); + v8.y = vmadd(a.y, b.y, c.y); + v8.z = vmadd(a.z, b.z, c.z); + return v8; +} + +ICBC_FORCEINLINE VVector3 vmadd(VVector3 a, VFloat b, VVector3 c) { + VVector3 v8; + v8.x = vmadd(a.x, b, c.x); + v8.y = vmadd(a.y, b, c.y); + v8.z = vmadd(a.z, b, c.z); + return v8; +} + +#if ICBC_SIMD != ICBC_SCALAR +ICBC_FORCEINLINE VVector3 vmadd(VVector3 a, float b, VVector3 c) { + VVector3 v8; + VFloat vb = vbroadcast(b); + v8.x = vmadd(a.x, vb, c.x); + v8.y = vmadd(a.y, vb, c.y); + v8.z = vmadd(a.z, vb, c.z); + return v8; +} +#endif + +ICBC_FORCEINLINE VVector3 vmsub(VVector3 a, VFloat b, VFloat c) { + VVector3 v8; + v8.x = vmsub(a.x, b, c); + v8.y = vmsub(a.y, b, c); + v8.z = vmsub(a.z, b, c); + return v8; +} + +ICBC_FORCEINLINE VVector3 vmsub(VVector3 a, VFloat b, VVector3 c) { + VVector3 v8; + v8.x = vmsub(a.x, b, c.x); + v8.y = vmsub(a.y, b, c.y); + v8.z = vmsub(a.z, b, c.z); + return v8; +} + +ICBC_FORCEINLINE VVector3 vm2sub(VVector3 a, VFloat b, VVector3 c, VFloat d) { + VVector3 v; + v.x = vm2sub(a.x, b, c.x, d); + v.y = vm2sub(a.y, b, c.y, d); + v.z = vm2sub(a.z, b, c.z, d); + return v; +} + +ICBC_FORCEINLINE VVector3 vm2sub(VVector3 a, VVector3 b, VVector3 c, VFloat d) { + VVector3 v; + v.x = vm2sub(a.x, b.x, c.x, d); + v.y = vm2sub(a.y, b.y, c.y, d); + v.z = vm2sub(a.z, b.z, c.z, d); + return v; +} + +ICBC_FORCEINLINE VVector3 vm2sub(VVector3 a, VVector3 b, VVector3 c, VVector3 d) { + VVector3 v; + v.x = vm2sub(a.x, b.x, c.x, d.x); + v.y = vm2sub(a.y, b.y, c.y, d.y); + v.z = vm2sub(a.z, b.z, c.z, d.z); + return v; +} + +ICBC_FORCEINLINE VFloat vdot(VVector3 a, VVector3 b) { + VFloat r; + r = a.x * b.x + a.y * b.y + a.z * b.z; + return r; +} + +// Length squared. +ICBC_FORCEINLINE VFloat vlen2(VVector3 v) { + return vdot(v, v); +} + + +// mask ? b : a +ICBC_FORCEINLINE VVector3 vselect(VMask mask, VVector3 a, VVector3 b) { + VVector3 r; + r.x = vselect(mask, a.x, b.x); + r.y = vselect(mask, a.y, b.y); + r.z = vselect(mask, a.z, b.z); + return r; +} + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Color conversion functions. + +static const float midpoints5[32] = { + 0.015686f, 0.047059f, 0.078431f, 0.111765f, 0.145098f, 0.176471f, 0.207843f, 0.241176f, 0.274510f, 0.305882f, 0.337255f, 0.370588f, 0.403922f, 0.435294f, 0.466667f, 0.5f, + 0.533333f, 0.564706f, 0.596078f, 0.629412f, 0.662745f, 0.694118f, 0.725490f, 0.758824f, 0.792157f, 0.823529f, 0.854902f, 0.888235f, 0.921569f, 0.952941f, 0.984314f, FLT_MAX +}; + +static const float midpoints6[64] = { + 0.007843f, 0.023529f, 0.039216f, 0.054902f, 0.070588f, 0.086275f, 0.101961f, 0.117647f, 0.133333f, 0.149020f, 0.164706f, 0.180392f, 0.196078f, 0.211765f, 0.227451f, 0.245098f, + 0.262745f, 0.278431f, 0.294118f, 0.309804f, 0.325490f, 0.341176f, 0.356863f, 0.372549f, 0.388235f, 0.403922f, 0.419608f, 0.435294f, 0.450980f, 0.466667f, 0.482353f, 0.500000f, + 0.517647f, 0.533333f, 0.549020f, 0.564706f, 0.580392f, 0.596078f, 0.611765f, 0.627451f, 0.643137f, 0.658824f, 0.674510f, 0.690196f, 0.705882f, 0.721569f, 0.737255f, 0.754902f, + 0.772549f, 0.788235f, 0.803922f, 0.819608f, 0.835294f, 0.850980f, 0.866667f, 0.882353f, 0.898039f, 0.913725f, 0.929412f, 0.945098f, 0.960784f, 0.976471f, 0.992157f, FLT_MAX +}; + +/*void init_tables() { + for (int i = 0; i < 31; i++) { + float f0 = float(((i+0) << 3) | ((i+0) >> 2)) / 255.0f; + float f1 = float(((i+1) << 3) | ((i+1) >> 2)) / 255.0f; + midpoints5[i] = (f0 + f1) * 0.5; + } + midpoints5[31] = FLT_MAX; + + for (int i = 0; i < 63; i++) { + float f0 = float(((i+0) << 2) | ((i+0) >> 4)) / 255.0f; + float f1 = float(((i+1) << 2) | ((i+1) >> 4)) / 255.0f; + midpoints6[i] = (f0 + f1) * 0.5; + } + midpoints6[63] = FLT_MAX; +}*/ + +ICBC_FORCEINLINE VFloat vround5(VFloat x) { + const VFloat rb_scale = vbroadcast(31.0f); + const VFloat rb_inv_scale = vbroadcast(1.0f / 31.0f); + +#if ICBC_PERFECT_ROUND + VFloat q = vtruncate(x * rb_scale); + VFloat mp = vgather(midpoints5, q); + //return (q + (vbroadcast(1.0f) & (x > mp))) * rb_inv_scale; + return (q + vselect(x > mp, vzero(), vbroadcast(1))) * rb_inv_scale; +#else + return vround01(x * rb_scale) * rb_inv_scale; +#endif +} + +ICBC_FORCEINLINE VFloat vround6(VFloat x) { + const VFloat g_scale = vbroadcast(63.0f); + const VFloat g_inv_scale = vbroadcast(1.0f / 63.0f); + +#if ICBC_PERFECT_ROUND + VFloat q = vtruncate(x * g_scale); + VFloat mp = vgather(midpoints6, q); + //return (q + (vbroadcast(1) & (x > mp))) * g_inv_scale; + return (q + vselect(x > mp, vzero(), vbroadcast(1))) * g_inv_scale; +#else + return vround01(x * g_scale) * g_inv_scale; +#endif +} + +ICBC_FORCEINLINE VVector3 vround_ept(VVector3 v) { + VVector3 r; + r.x = vround5(vsaturate(v.x)); + r.y = vround6(vsaturate(v.y)); + r.z = vround5(vsaturate(v.z)); + return r; +} + +static Color16 vector3_to_color16(const Vector3 & v) { + + // Truncate. + uint r = uint(clamp(v.x * 31.0f, 0.0f, 31.0f)); + uint g = uint(clamp(v.y * 63.0f, 0.0f, 63.0f)); + uint b = uint(clamp(v.z * 31.0f, 0.0f, 31.0f)); + + // Round exactly according to 565 bit-expansion. + r += (v.x > midpoints5[r]); + g += (v.y > midpoints6[g]); + b += (v.z > midpoints5[b]); + + Color16 c; + c.u = uint16((r << 11) | (g << 5) | b); + return c; +} + +static Color32 bitexpand_color16_to_color32(Color16 c16) { + Color32 c32; + //c32.b = (c16.b << 3) | (c16.b >> 2); + //c32.g = (c16.g << 2) | (c16.g >> 4); + //c32.r = (c16.r << 3) | (c16.r >> 2); + //c32.a = 0xFF; + + c32.u = ((c16.u << 3) & 0xf8) | ((c16.u << 5) & 0xfc00) | ((c16.u << 8) & 0xf80000); + c32.u |= (c32.u >> 5) & 0x070007; + c32.u |= (c32.u >> 6) & 0x000300; + + return c32; +} + +inline Vector3 color_to_vector3(Color32 c) { + return { c.r / 255.0f, c.g / 255.0f, c.b / 255.0f }; +} + +inline Color32 vector3_to_color32(Vector3 v) { + Color32 color; + color.r = uint8(saturate(v.x) * 255 + 0.5f); + color.g = uint8(saturate(v.y) * 255 + 0.5f); + color.b = uint8(saturate(v.z) * 255 + 0.5f); + color.a = 255; + return color; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Input block processing. + +inline bool is_black(Vector3 c) { + // This large threshold seems to improve compression. This is not forcing these texels to be black, just + // causes them to be ignored during PCA. + // @@ We may want to adjust this based on the quality level, since this increases the number of blocks that try cluster-3 fitting. + //return c.x < midpoints5[0] && c.y < midpoints6[0] && c.z < midpoints5[0]; + //return c.x < 1.0f / 32 && c.y < 1.0f / 32 && c.z < 1.0f / 32; + return c.x < 1.0f / 8 && c.y < 1.0f / 8 && c.z < 1.0f / 8; +} + +// Find similar colors and combine them together. +static int reduce_colors(const Vector4 * input_colors, const float * input_weights, int count, float threshold, Vector3 * colors, float * weights, bool * any_black) +{ +#if 0 + for (int i = 0; i < 16; i++) { + colors[i] = input_colors[i].xyz; + weights[i] = input_weights[i]; + } + return 16; +#else + *any_black = false; + + int n = 0; + for (int i = 0; i < count; i++) + { + Vector3 ci = input_colors[i].xyz; + float wi = input_weights[i]; + + if (wi > 0) { + // Find matching color. + int j; + for (j = 0; j < n; j++) { + if (equal(colors[j], ci, threshold)) { + colors[j] = (colors[j] * weights[j] + ci * wi) / (weights[j] + wi); + weights[j] += wi; + break; + } + } + + // No match found. Add new color. + if (j == n) { + colors[n] = ci; + weights[n] = wi; + n++; + } + + if (is_black(ci)) { + *any_black = true; + } + } + } + + ICBC_ASSERT(n <= count); + + return n; +#endif +} + +static int skip_blacks(const Vector3 * input_colors, const float * input_weights, int count, Vector3 * colors, float * weights) +{ + int n = 0; + for (int i = 0; i < count; i++) + { + Vector3 ci = input_colors[i]; + float wi = input_weights[i]; + + if (is_black(ci)) { + continue; + } + + colors[n] = ci; + weights[n] = wi; + n += 1; + } + + return n; +} + + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// PCA + +static Vector3 computeCentroid(int n, const Vector3 *__restrict points, const float *__restrict weights) +{ + Vector3 centroid = { 0 }; + float total = 0.0f; + + for (int i = 0; i < n; i++) + { + total += weights[i]; + centroid += weights[i] * points[i]; + } + centroid *= (1.0f / total); + + return centroid; +} + +static Vector3 computeCovariance(int n, const Vector3 *__restrict points, const float *__restrict weights, float *__restrict covariance) +{ + // compute the centroid + Vector3 centroid = computeCentroid(n, points, weights); + + // compute covariance matrix + for (int i = 0; i < 6; i++) + { + covariance[i] = 0.0f; + } + + for (int i = 0; i < n; i++) + { + Vector3 a = (points[i] - centroid); // @@ I think weight should be squared, but that seems to increase the error slightly. + Vector3 b = weights[i] * a; + + covariance[0] += a.x * b.x; + covariance[1] += a.x * b.y; + covariance[2] += a.x * b.z; + covariance[3] += a.y * b.y; + covariance[4] += a.y * b.z; + covariance[5] += a.z * b.z; + } + + return centroid; +} + +// @@ We should be able to do something cheaper... +static Vector3 estimatePrincipalComponent(const float * __restrict matrix) +{ + const Vector3 row0 = { matrix[0], matrix[1], matrix[2] }; + const Vector3 row1 = { matrix[1], matrix[3], matrix[4] }; + const Vector3 row2 = { matrix[2], matrix[4], matrix[5] }; + + float r0 = lengthSquared(row0); + float r1 = lengthSquared(row1); + float r2 = lengthSquared(row2); + + if (r0 > r1 && r0 > r2) return row0; + if (r1 > r2) return row1; + return row2; +} + +static inline Vector3 firstEigenVector_PowerMethod(const float *__restrict matrix) +{ + if (matrix[0] == 0 && matrix[3] == 0 && matrix[5] == 0) + { + return {0}; + } + + Vector3 v = estimatePrincipalComponent(matrix); + + const int NUM = 8; + for (int i = 0; i < NUM; i++) + { + float x = v.x * matrix[0] + v.y * matrix[1] + v.z * matrix[2]; + float y = v.x * matrix[1] + v.y * matrix[3] + v.z * matrix[4]; + float z = v.x * matrix[2] + v.y * matrix[4] + v.z * matrix[5]; + + float norm = max(max(x, y), z); + + v = { x, y, z }; + v *= (1.0f / norm); + } + + return v; +} + +static Vector3 computePrincipalComponent_PowerMethod(int n, const Vector3 *__restrict points, const float *__restrict weights) +{ + float matrix[6]; + computeCovariance(n, points, weights, matrix); + + return firstEigenVector_PowerMethod(matrix); +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// SAT + +struct SummedAreaTable { + ICBC_ALIGN_16 float r[16]; + ICBC_ALIGN_16 float g[16]; + ICBC_ALIGN_16 float b[16]; + ICBC_ALIGN_16 float w[16]; +}; + +int compute_sat(const Vector3 * colors, const float * weights, int count, SummedAreaTable * sat) +{ + // I've tried using a lower quality approximation of the principal direction, but the best fit line seems to produce best results. + Vector3 principal = computePrincipalComponent_PowerMethod(count, colors, weights); + + // build the list of values + int order[16]; + float dps[16]; + for (int i = 0; i < count; ++i) + { + order[i] = i; + dps[i] = dot(colors[i], principal); + } + + // stable sort + for (int i = 0; i < count; ++i) + { + for (int j = i; j > 0 && dps[j] < dps[j - 1]; --j) + { + swap(dps[j], dps[j - 1]); + swap(order[j], order[j - 1]); + } + } + + float w = weights[order[0]]; + sat->r[0] = colors[order[0]].x * w; + sat->g[0] = colors[order[0]].y * w; + sat->b[0] = colors[order[0]].z * w; + sat->w[0] = w; + + for (int i = 1; i < count; i++) { + w = weights[order[i]]; + sat->r[i] = sat->r[i - 1] + colors[order[i]].x * w; + sat->g[i] = sat->g[i - 1] + colors[order[i]].y * w; + sat->b[i] = sat->b[i - 1] + colors[order[i]].z * w; + sat->w[i] = sat->w[i - 1] + w; + } + + // Try incremental decimation: + /*if (count > 4) + { + float threshold = 1.0f / 4; + + for (uint i = 1; i < count; ++i) + { + if (sat->r[i] - sat->r[i - 1] < threshold && + sat->g[i] - sat->g[i - 1] < threshold && + sat->b[i] - sat->b[i - 1] < threshold) + { + for (int j = i+1; j < count; j++) { + sat->r[j - 1] = sat->r[j]; + sat->g[j - 1] = sat->g[j]; + sat->b[j - 1] = sat->b[j]; + sat->w[j - 1] = sat->w[j]; + } + count -= 1; + i -= 1; + if (count == 4) break; + } + } + }*/ + + for (int i = count; i < 16; i++) { + sat->r[i] = FLT_MAX; + sat->g[i] = FLT_MAX; + sat->b[i] = FLT_MAX; + sat->w[i] = FLT_MAX; + } + + return count; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Cluster Fit + +struct Combinations { + uint8 c0, c1, c2, pad; +}; + +static ICBC_ALIGN_16 int s_fourClusterTotal[16]; +static ICBC_ALIGN_16 int s_threeClusterTotal[16]; +static ICBC_ALIGN_16 Combinations s_fourCluster[968 + 8]; +static ICBC_ALIGN_16 Combinations s_threeCluster[152 + 8]; + +#if ICBC_USE_NEON_VTL +static uint8 s_neon_vtl_index0_4[4 * 968]; +static uint8 s_neon_vtl_index1_4[4 * 968]; +static uint8 s_neon_vtl_index2_4[4 * 968]; + +static uint8 s_neon_vtl_index0_3[4 * 152]; +static uint8 s_neon_vtl_index1_3[4 * 152]; +#endif + +static void init_cluster_tables() { + + for (int t = 1, i = 0; t <= 16; t++) { + for (int c0 = 0; c0 <= t; c0++) { + for (int c1 = 0; c1 <= t - c0; c1++) { + for (int c2 = 0; c2 <= t - c0 - c1; c2++) { + + // Skip this cluster so that the total is a multiple of 8 + if (c0 == 0 && c1 == 0 && c2 == 0) continue; + + bool found = false; + if (t > 1) { + for (int j = 0; j < s_fourClusterTotal[t-2]; j++) { + if (s_fourCluster[j].c0 == c0 && s_fourCluster[j].c1 == c0+c1 && s_fourCluster[j].c2 == c0+c1+c2) { + found = true; + break; + } + } + } + + if (!found) { + s_fourCluster[i].c0 = uint8(c0); + s_fourCluster[i].c1 = uint8(c0+c1); + s_fourCluster[i].c2 = uint8(c0+c1+c2); + i++; + } + } + } + } + + s_fourClusterTotal[t - 1] = i; + } + + // Replicate last entry. + for (int i = 0; i < 8; i++) { + s_fourCluster[968 + i] = s_fourCluster[968-1]; + } + + for (int t = 1, i = 0; t <= 16; t++) { + for (int c0 = 0; c0 <= t; c0++) { + for (int c1 = 0; c1 <= t - c0; c1++) { + + // Skip this cluster so that the total is a multiple of 8 + if (c0 == 0 && c1 == 0) continue; + + bool found = false; + if (t > 1) { + for (int j = 0; j < s_threeClusterTotal[t - 2]; j++) { + if (s_threeCluster[j].c0 == c0 && s_threeCluster[j].c1 == c0+c1) { + found = true; + break; + } + } + } + + if (!found) { + s_threeCluster[i].c0 = uint8(c0); + s_threeCluster[i].c1 = uint8(c0 + c1); + i++; + } + } + } + + s_threeClusterTotal[t - 1] = i; + } + + // Replicate last entry. + for (int i = 0; i < 8; i++) { + s_threeCluster[152 + i] = s_threeCluster[152 - 1]; + } + +#if ICBC_USE_NEON_VTL + for (int i = 0; i < 968; i++) { + int c0 = (s_fourCluster[i].c0) - 1; + s_neon_vtl_index0_4[4 * i + 0] = uint8(c0 * 4 + 0); + s_neon_vtl_index0_4[4 * i + 1] = uint8(c0 * 4 + 1); + s_neon_vtl_index0_4[4 * i + 2] = uint8(c0 * 4 + 2); + s_neon_vtl_index0_4[4 * i + 3] = uint8(c0 * 4 + 3); + + int c1 = (s_fourCluster[i].c1) - 1; + s_neon_vtl_index1_4[4 * i + 0] = uint8(c1 * 4 + 0); + s_neon_vtl_index1_4[4 * i + 1] = uint8(c1 * 4 + 1); + s_neon_vtl_index1_4[4 * i + 2] = uint8(c1 * 4 + 2); + s_neon_vtl_index1_4[4 * i + 3] = uint8(c1 * 4 + 3); + + int c2 = (s_fourCluster[i].c2) - 1; + s_neon_vtl_index2_4[4 * i + 0] = uint8(c2 * 4 + 0); + s_neon_vtl_index2_4[4 * i + 1] = uint8(c2 * 4 + 1); + s_neon_vtl_index2_4[4 * i + 2] = uint8(c2 * 4 + 2); + s_neon_vtl_index2_4[4 * i + 3] = uint8(c2 * 4 + 3); + } + + for (int i = 0; i < 152; i++) { + int c0 = (s_threeCluster[i].c0) - 1; + s_neon_vtl_index0_3[4 * i + 0] = uint8(c0 * 4 + 0); + s_neon_vtl_index0_3[4 * i + 1] = uint8(c0 * 4 + 1); + s_neon_vtl_index0_3[4 * i + 2] = uint8(c0 * 4 + 2); + s_neon_vtl_index0_3[4 * i + 3] = uint8(c0 * 4 + 3); + + int c1 = (s_threeCluster[i].c1) - 1; + s_neon_vtl_index1_3[4 * i + 0] = uint8(c1 * 4 + 0); + s_neon_vtl_index1_3[4 * i + 1] = uint8(c1 * 4 + 1); + s_neon_vtl_index1_3[4 * i + 2] = uint8(c1 * 4 + 2); + s_neon_vtl_index1_3[4 * i + 3] = uint8(c1 * 4 + 3); + } +#endif +} + + + +static void cluster_fit_three(const SummedAreaTable & sat, int count, Vector3 metric_sqr, Vector3 * start, Vector3 * end) +{ + const float r_sum = sat.r[count-1]; + const float g_sum = sat.g[count-1]; + const float b_sum = sat.b[count-1]; + const float w_sum = sat.w[count-1]; + + VFloat vbesterror = vbroadcast(FLT_MAX); + VVector3 vbeststart = { vzero(), vzero(), vzero() }; + VVector3 vbestend = { vzero(), vzero(), vzero() }; + + // check all possible clusters for this total order + const int total_order_count = s_threeClusterTotal[count - 1]; + + for (int i = 0; i < total_order_count; i += VEC_SIZE) + { + VVector3 x0, x1; + VFloat w0, w1; + +#if ICBC_USE_AVX512_PERMUTE + + auto loadmask = lane_id() < vbroadcast(float(count)); + + // Load sat in one register: + VFloat vrsat = vload(loadmask, sat.r, FLT_MAX); + VFloat vgsat = vload(loadmask, sat.g, FLT_MAX); + VFloat vbsat = vload(loadmask, sat.b, FLT_MAX); + VFloat vwsat = vload(loadmask, sat.w, FLT_MAX); + + // Load 4 uint8 per lane. + VInt packedClusterIndex = vload((int *)&s_threeCluster[i]); + + VInt c0 = (packedClusterIndex & 0xFF) - 1; + VInt c1 = (packedClusterIndex >> 8) - 1; + + x0.x = vpermuteif(c0 >= 0, vrsat, c0); + x0.y = vpermuteif(c0 >= 0, vgsat, c0); + x0.z = vpermuteif(c0 >= 0, vbsat, c0); + w0 = vpermuteif(c0 >= 0, vwsat, c0); + + x1.x = vpermuteif(c1 >= 0, vrsat, c1); + x1.y = vpermuteif(c1 >= 0, vgsat, c1); + x1.z = vpermuteif(c1 >= 0, vbsat, c1); + w1 = vpermuteif(c1 >= 0, vwsat, c1); + +#elif ICBC_USE_AVX2_PERMUTE2 + + // Load 4 uint8 per lane. @@ Ideally I should pack this better and load only 2. + VInt packedClusterIndex = vload((int *)&s_threeCluster[i]); + + VInt c0 = (packedClusterIndex & 0xFF); + VInt c1 = ((packedClusterIndex >> 8)); // No need for & 0xFF + + if (count <= 8) { + // Load sat.r in one register: + VFloat rLo = vload(sat.r); + VFloat gLo = vload(sat.g); + VFloat bLo = vload(sat.b); + VFloat wLo = vload(sat.w); + + x0.x = vpermuteif(c0>0, rLo, c0-1); + x0.y = vpermuteif(c0>0, gLo, c0-1); + x0.z = vpermuteif(c0>0, bLo, c0-1); + w0 = vpermuteif(c0>0, wLo, c0-1); + + x1.x = vpermuteif(c1>0, rLo, c1-1); + x1.y = vpermuteif(c1>0, gLo, c1-1); + x1.z = vpermuteif(c1>0, bLo, c1-1); + w1 = vpermuteif(c1>0, wLo, c1-1); + } + else { + // Load sat.r in two registers: + VFloat rLo = vload(sat.r); VFloat rHi = vload(sat.r + 8); + VFloat gLo = vload(sat.g); VFloat gHi = vload(sat.g + 8); + VFloat bLo = vload(sat.b); VFloat bHi = vload(sat.b + 8); + VFloat wLo = vload(sat.w); VFloat wHi = vload(sat.w + 8); + + x0.x = vpermute2if(c0>0, rLo, rHi, c0-1); + x0.y = vpermute2if(c0>0, gLo, gHi, c0-1); + x0.z = vpermute2if(c0>0, bLo, bHi, c0-1); + w0 = vpermute2if(c0>0, wLo, wHi, c0-1); + + x1.x = vpermute2if(c1>0, rLo, rHi, c1-1); + x1.y = vpermute2if(c1>0, gLo, gHi, c1-1); + x1.z = vpermute2if(c1>0, bLo, bHi, c1-1); + w1 = vpermute2if(c1>0, wLo, wHi, c1-1); + } + +#elif ICBC_USE_NEON_VTL + + uint8x16_t idx0 = (uint8x16_t &)s_neon_vtl_index0_3[4*i]; + uint8x16_t idx1 = (uint8x16_t &)s_neon_vtl_index1_3[4*i]; + + if (count <= 4) { + uint8x16_t rsat1 = vld1q_u8((uint8*)sat.r); + uint8x16_t gsat1 = vld1q_u8((uint8*)sat.g); + uint8x16_t bsat1 = vld1q_u8((uint8*)sat.b); + uint8x16_t wsat1 = vld1q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl1q_u8(rsat1, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl1q_u8(gsat1, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl1q_u8(bsat1, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl1q_u8(wsat1, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl1q_u8(rsat1, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl1q_u8(gsat1, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl1q_u8(bsat1, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl1q_u8(wsat1, idx1)); + } + else if (count <= 8) { + uint8x16x2_t rsat2 = vld2q_u8((uint8*)sat.r); + uint8x16x2_t gsat2 = vld2q_u8((uint8*)sat.g); + uint8x16x2_t bsat2 = vld2q_u8((uint8*)sat.b); + uint8x16x2_t wsat2 = vld2q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl2q_u8(rsat2, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl2q_u8(gsat2, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl2q_u8(bsat2, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl2q_u8(wsat2, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl2q_u8(rsat2, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl2q_u8(gsat2, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl2q_u8(bsat2, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl2q_u8(wsat2, idx1)); + } + else if (count <= 12) { + uint8x16x3_t rsat3 = vld3q_u8((uint8*)sat.r); + uint8x16x3_t gsat3 = vld3q_u8((uint8*)sat.g); + uint8x16x3_t bsat3 = vld3q_u8((uint8*)sat.b); + uint8x16x3_t wsat3 = vld3q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl3q_u8(rsat3, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl3q_u8(gsat3, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl3q_u8(bsat3, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl3q_u8(wsat3, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl3q_u8(rsat3, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl3q_u8(gsat3, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl3q_u8(bsat3, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl3q_u8(wsat3, idx1)); + } + else { + // Load SAT. + uint8x16x4_t rsat4 = vld4q_u8((uint8*)sat.r); + uint8x16x4_t gsat4 = vld4q_u8((uint8*)sat.g); + uint8x16x4_t bsat4 = vld4q_u8((uint8*)sat.b); + uint8x16x4_t wsat4 = vld4q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl4q_u8(rsat4, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl4q_u8(gsat4, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl4q_u8(bsat4, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl4q_u8(wsat4, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl4q_u8(rsat4, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl4q_u8(gsat4, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl4q_u8(bsat4, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl4q_u8(wsat4, idx1)); + } + +#else + + // Scalar path + x0.x = vzero(); x0.y = vzero(); x0.z = vzero(); w0 = vzero(); + x1.x = vzero(); x1.y = vzero(); x1.z = vzero(); w1 = vzero(); + + for (int l = 0; l < VEC_SIZE; l++) { + int c0 = s_threeCluster[i + l].c0 - 1; + if (c0 >= 0) { + lane(x0.x, l) = sat.r[c0]; + lane(x0.y, l) = sat.g[c0]; + lane(x0.z, l) = sat.b[c0]; + lane(w0, l) = sat.w[c0]; + } + + int c1 = s_threeCluster[i + l].c1 - 1; + if (c1 >= 0) { + lane(x1.x, l) = sat.r[c1]; + lane(x1.y, l) = sat.g[c1]; + lane(x1.z, l) = sat.b[c1]; + lane(w1, l) = sat.w[c1]; + } + } + +#endif + + VFloat w2 = vbroadcast(w_sum) - w1; + x1 = x1 - x0; + w1 = w1 - w0; + + VFloat alphabeta_sum = w1 * vbroadcast(0.25f); + VFloat alpha2_sum = w0 + alphabeta_sum; + VFloat beta2_sum = w2 + alphabeta_sum; + VFloat factor = vrcp(vm2sub(alpha2_sum, beta2_sum, alphabeta_sum, alphabeta_sum)); + + VVector3 alphax_sum = x0 + x1 * vbroadcast(0.5f); + VVector3 betax_sum = vbroadcast(r_sum, g_sum, b_sum) - alphax_sum; + + VVector3 a = vm2sub(alphax_sum, beta2_sum, betax_sum, alphabeta_sum) * factor; + VVector3 b = vm2sub(betax_sum, alpha2_sum, alphax_sum, alphabeta_sum) * factor; + + // snap to the grid + a = vround_ept(a); + b = vround_ept(b); + + // compute the error + VVector3 e2 = vm2sub(a, vmsub(b, alphabeta_sum, alphax_sum), b, betax_sum) * vbroadcast(2.0f); + VVector3 e1 = vmadd(a * a, alpha2_sum, vmadd(b * b, beta2_sum, e2)); + + // apply the metric to the error term + VFloat error = vdot(e1, vbroadcast(metric_sqr)); + + + // keep the solution if it wins + auto mask = (error < vbesterror); + + // I could mask the unused lanes here, but instead I set the invalid SAT entries to FLT_MAX. + //mask = (mask & (vbroadcast(total_order_count) >= tid8(i))); // This doesn't seem to help. Is it OK to consider elements out of bounds? + + vbesterror = vselect(mask, vbesterror, error); + vbeststart = vselect(mask, vbeststart, a); + vbestend = vselect(mask, vbestend, b); + } + + int bestindex = reduce_min_index(vbesterror); + + start->x = lane(vbeststart.x, bestindex); + start->y = lane(vbeststart.y, bestindex); + start->z = lane(vbeststart.z, bestindex); + end->x = lane(vbestend.x, bestindex); + end->y = lane(vbestend.y, bestindex); + end->z = lane(vbestend.z, bestindex); +} + + +static void cluster_fit_four(const SummedAreaTable & sat, int count, Vector3 metric_sqr, Vector3 * start, Vector3 * end) +{ + const float r_sum = sat.r[count-1]; + const float g_sum = sat.g[count-1]; + const float b_sum = sat.b[count-1]; + const float w_sum = sat.w[count-1]; + + VFloat vbesterror = vbroadcast(FLT_MAX); + VVector3 vbeststart = { vzero(), vzero(), vzero() }; + VVector3 vbestend = { vzero(), vzero(), vzero() }; + + // check all possible clusters for this total order + const int total_order_count = s_fourClusterTotal[count - 1]; + + for (int i = 0; i < total_order_count; i += VEC_SIZE) + { + VVector3 x0, x1, x2; + VFloat w0, w1, w2; + + /* + // Another approach would be to load and broadcast one color at a time like I do in my old CUDA implementation. + uint akku = 0; + + // Compute alpha & beta for this permutation. + #pragma unroll + for (int i = 0; i < 16; i++) + { + const uint bits = permutation >> (2*i); + + alphax_sum += alphaTable4[bits & 3] * colors[i]; + akku += prods4[bits & 3]; + } + + float alpha2_sum = float(akku >> 16); + float beta2_sum = float((akku >> 8) & 0xff); + float alphabeta_sum = float(akku & 0xff); + float3 betax_sum = 9.0f * color_sum - alphax_sum; + */ + +#if ICBC_USE_AVX512_PERMUTE + + auto loadmask = lane_id() < vbroadcast(float(count)); + + // Load sat in one register: + VFloat vrsat = vload(loadmask, sat.r, FLT_MAX); + VFloat vgsat = vload(loadmask, sat.g, FLT_MAX); + VFloat vbsat = vload(loadmask, sat.b, FLT_MAX); + VFloat vwsat = vload(loadmask, sat.w, FLT_MAX); + + // Load 4 uint8 per lane. + VInt packedClusterIndex = vload((int *)&s_fourCluster[i]); + + VInt c0 = (packedClusterIndex & 0xFF) - 1; + VInt c1 = ((packedClusterIndex >> 8) & 0xFF) - 1; + VInt c2 = ((packedClusterIndex >> 16)) - 1; // @@ No need for & + + x0.x = vpermuteif(c0 >= 0, vrsat, c0); + x0.y = vpermuteif(c0 >= 0, vgsat, c0); + x0.z = vpermuteif(c0 >= 0, vbsat, c0); + w0 = vpermuteif(c0 >= 0, vwsat, c0); + + x1.x = vpermuteif(c1 >= 0, vrsat, c1); + x1.y = vpermuteif(c1 >= 0, vgsat, c1); + x1.z = vpermuteif(c1 >= 0, vbsat, c1); + w1 = vpermuteif(c1 >= 0, vwsat, c1); + + x2.x = vpermuteif(c2 >= 0, vrsat, c2); + x2.y = vpermuteif(c2 >= 0, vgsat, c2); + x2.z = vpermuteif(c2 >= 0, vbsat, c2); + w2 = vpermuteif(c2 >= 0, vwsat, c2); + +#elif ICBC_USE_AVX2_PERMUTE2 + + // Load 4 uint8 per lane. + VInt packedClusterIndex = vload((int *)&s_fourCluster[i]); + + VInt c0 = (packedClusterIndex & 0xFF); + VInt c1 = ((packedClusterIndex >> 8) & 0xFF); + VInt c2 = ((packedClusterIndex >> 16)); // @@ No need for & + + if (count <= 8) { + // Load sat.r in one register: + VFloat rLo = vload(sat.r); + VFloat gLo = vload(sat.g); + VFloat bLo = vload(sat.b); + VFloat wLo = vload(sat.w); + + x0.x = vpermuteif(c0>0, rLo, c0-1); + x0.y = vpermuteif(c0>0, gLo, c0-1); + x0.z = vpermuteif(c0>0, bLo, c0-1); + w0 = vpermuteif(c0>0, wLo, c0-1); + + x1.x = vpermuteif(c1>0, rLo, c1-1); + x1.y = vpermuteif(c1>0, gLo, c1-1); + x1.z = vpermuteif(c1>0, bLo, c1-1); + w1 = vpermuteif(c1>0, wLo, c1-1); + + x2.x = vpermuteif(c2>0, rLo, c2-1); + x2.y = vpermuteif(c2>0, gLo, c2-1); + x2.z = vpermuteif(c2>0, bLo, c2-1); + w2 = vpermuteif(c2>0, wLo, c2-1); + } + else { + // Load sat.r in two registers: + VFloat rLo = vload(sat.r); VFloat rHi = vload(sat.r + 8); + VFloat gLo = vload(sat.g); VFloat gHi = vload(sat.g + 8); + VFloat bLo = vload(sat.b); VFloat bHi = vload(sat.b + 8); + VFloat wLo = vload(sat.w); VFloat wHi = vload(sat.w + 8); + + x0.x = vpermute2if(c0>0, rLo, rHi, c0-1); + x0.y = vpermute2if(c0>0, gLo, gHi, c0-1); + x0.z = vpermute2if(c0>0, bLo, bHi, c0-1); + w0 = vpermute2if(c0>0, wLo, wHi, c0-1); + + x1.x = vpermute2if(c1>0, rLo, rHi, c1-1); + x1.y = vpermute2if(c1>0, gLo, gHi, c1-1); + x1.z = vpermute2if(c1>0, bLo, bHi, c1-1); + w1 = vpermute2if(c1>0, wLo, wHi, c1-1); + + x2.x = vpermute2if(c2>0, rLo, rHi, c2-1); + x2.y = vpermute2if(c2>0, gLo, gHi, c2-1); + x2.z = vpermute2if(c2>0, bLo, bHi, c2-1); + w2 = vpermute2if(c2>0, wLo, wHi, c2-1); + } + +#elif ICBC_USE_NEON_VTL + + uint8x16_t idx0 = (uint8x16_t &)s_neon_vtl_index0_4[4*i]; + uint8x16_t idx1 = (uint8x16_t &)s_neon_vtl_index1_4[4*i]; + uint8x16_t idx2 = (uint8x16_t &)s_neon_vtl_index2_4[4*i]; + + if (count <= 4) { + uint8x16_t rsat1 = vld1q_u8((uint8*)sat.r); + uint8x16_t gsat1 = vld1q_u8((uint8*)sat.g); + uint8x16_t bsat1 = vld1q_u8((uint8*)sat.b); + uint8x16_t wsat1 = vld1q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl1q_u8(rsat1, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl1q_u8(gsat1, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl1q_u8(bsat1, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl1q_u8(wsat1, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl1q_u8(rsat1, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl1q_u8(gsat1, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl1q_u8(bsat1, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl1q_u8(wsat1, idx1)); + + x2.x = vreinterpretq_f32_u8(vqtbl1q_u8(rsat1, idx2)); + x2.y = vreinterpretq_f32_u8(vqtbl1q_u8(gsat1, idx2)); + x2.z = vreinterpretq_f32_u8(vqtbl1q_u8(bsat1, idx2)); + w2 = vreinterpretq_f32_u8(vqtbl1q_u8(wsat1, idx2)); + } + else if (count <= 8) { + uint8x16x2_t rsat2 = vld2q_u8((uint8*)sat.r); + uint8x16x2_t gsat2 = vld2q_u8((uint8*)sat.g); + uint8x16x2_t bsat2 = vld2q_u8((uint8*)sat.b); + uint8x16x2_t wsat2 = vld2q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl2q_u8(rsat2, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl2q_u8(gsat2, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl2q_u8(bsat2, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl2q_u8(wsat2, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl2q_u8(rsat2, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl2q_u8(gsat2, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl2q_u8(bsat2, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl2q_u8(wsat2, idx1)); + + x2.x = vreinterpretq_f32_u8(vqtbl2q_u8(rsat2, idx2)); + x2.y = vreinterpretq_f32_u8(vqtbl2q_u8(gsat2, idx2)); + x2.z = vreinterpretq_f32_u8(vqtbl2q_u8(bsat2, idx2)); + w2 = vreinterpretq_f32_u8(vqtbl2q_u8(wsat2, idx2)); + } + else if (count <= 12) { + uint8x16x3_t rsat3 = vld3q_u8((uint8*)sat.r); + uint8x16x3_t gsat3 = vld3q_u8((uint8*)sat.g); + uint8x16x3_t bsat3 = vld3q_u8((uint8*)sat.b); + uint8x16x3_t wsat3 = vld3q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl3q_u8(rsat3, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl3q_u8(gsat3, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl3q_u8(bsat3, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl3q_u8(wsat3, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl3q_u8(rsat3, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl3q_u8(gsat3, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl3q_u8(bsat3, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl3q_u8(wsat3, idx1)); + + x2.x = vreinterpretq_f32_u8(vqtbl3q_u8(rsat3, idx2)); + x2.y = vreinterpretq_f32_u8(vqtbl3q_u8(gsat3, idx2)); + x2.z = vreinterpretq_f32_u8(vqtbl3q_u8(bsat3, idx2)); + w2 = vreinterpretq_f32_u8(vqtbl3q_u8(wsat3, idx2)); + } + else { + uint8x16x4_t rsat4 = vld4q_u8((uint8*)sat.r); + uint8x16x4_t gsat4 = vld4q_u8((uint8*)sat.g); + uint8x16x4_t bsat4 = vld4q_u8((uint8*)sat.b); + uint8x16x4_t wsat4 = vld4q_u8((uint8*)sat.w); + + x0.x = vreinterpretq_f32_u8(vqtbl4q_u8(rsat4, idx0)); + x0.y = vreinterpretq_f32_u8(vqtbl4q_u8(gsat4, idx0)); + x0.z = vreinterpretq_f32_u8(vqtbl4q_u8(bsat4, idx0)); + w0 = vreinterpretq_f32_u8(vqtbl4q_u8(wsat4, idx0)); + + x1.x = vreinterpretq_f32_u8(vqtbl4q_u8(rsat4, idx1)); + x1.y = vreinterpretq_f32_u8(vqtbl4q_u8(gsat4, idx1)); + x1.z = vreinterpretq_f32_u8(vqtbl4q_u8(bsat4, idx1)); + w1 = vreinterpretq_f32_u8(vqtbl4q_u8(wsat4, idx1)); + + x2.x = vreinterpretq_f32_u8(vqtbl4q_u8(rsat4, idx2)); + x2.y = vreinterpretq_f32_u8(vqtbl4q_u8(gsat4, idx2)); + x2.z = vreinterpretq_f32_u8(vqtbl4q_u8(bsat4, idx2)); + w2 = vreinterpretq_f32_u8(vqtbl4q_u8(wsat4, idx2)); + } + +#else + + // Scalar path + x0.x = vzero(); x0.y = vzero(); x0.z = vzero(); w0 = vzero(); + x1.x = vzero(); x1.y = vzero(); x1.z = vzero(); w1 = vzero(); + x2.x = vzero(); x2.y = vzero(); x2.z = vzero(); w2 = vzero(); + + for (int l = 0; l < VEC_SIZE; l++) { + int c0 = s_fourCluster[i + l].c0 - 1; + if (c0 >= 0) { + lane(x0.x, l) = sat.r[c0]; + lane(x0.y, l) = sat.g[c0]; + lane(x0.z, l) = sat.b[c0]; + lane(w0, l) = sat.w[c0]; + } + + int c1 = s_fourCluster[i + l].c1 - 1; + if (c1 >= 0) { + lane(x1.x, l) = sat.r[c1]; + lane(x1.y, l) = sat.g[c1]; + lane(x1.z, l) = sat.b[c1]; + lane(w1, l) = sat.w[c1]; + } + + int c2 = s_fourCluster[i + l].c2 - 1; + if (c2 >= 0) { + lane(x2.x, l) = sat.r[c2]; + lane(x2.y, l) = sat.g[c2]; + lane(x2.z, l) = sat.b[c2]; + lane(w2, l) = sat.w[c2]; + } + } + +#endif + + VFloat w3 = vbroadcast(w_sum) - w2; + x2 = x2 - x1; + x1 = x1 - x0; + w2 = w2 - w1; + w1 = w1 - w0; + + VFloat alpha2_sum = vmadd(w2, (1.0f / 9.0f), vmadd(w1, (4.0f / 9.0f), w0)); + VFloat beta2_sum = vmadd(w1, (1.0f / 9.0f), vmadd(w2, (4.0f / 9.0f), w3)); + + VFloat alphabeta_sum = (w1 + w2) * vbroadcast(2.0f / 9.0f); + VFloat factor = vrcp(vm2sub(alpha2_sum, beta2_sum, alphabeta_sum, alphabeta_sum)); + + VVector3 alphax_sum = vmadd(x2, (1.0f / 3.0f), vmadd(x1, (2.0f / 3.0f), x0)); + VVector3 betax_sum = vbroadcast(r_sum, g_sum, b_sum) - alphax_sum; + + VVector3 a = vm2sub(alphax_sum, beta2_sum, betax_sum, alphabeta_sum) * factor; + VVector3 b = vm2sub(betax_sum, alpha2_sum, alphax_sum, alphabeta_sum) * factor; + + // snap to the grid + a = vround_ept(a); + b = vround_ept(b); + + // compute the error + VVector3 e2 = vm2sub(a, vmsub(b, alphabeta_sum, alphax_sum), b, betax_sum) * vbroadcast(2.0f); + VVector3 e1 = vmadd(a * a, alpha2_sum, vmadd(b * b, beta2_sum, e2)); + + // apply the metric to the error term + VFloat error = vdot(e1, vbroadcast(metric_sqr)); + + // keep the solution if it wins + auto mask = (error < vbesterror); + + // We could mask the unused lanes here, but instead set the invalid SAT entries to FLT_MAX. + //mask = (mask & (vbroadcast(total_order_count) >= tid8(i))); // This doesn't seem to help. Is it OK to consider elements out of bounds? + + vbesterror = vselect(mask, vbesterror, error); + vbeststart = vselect(mask, vbeststart, a); + vbestend = vselect(mask, vbestend, b); + } + + int bestindex = reduce_min_index(vbesterror); + + start->x = lane(vbeststart.x, bestindex); + start->y = lane(vbeststart.y, bestindex); + start->z = lane(vbeststart.z, bestindex); + end->x = lane(vbestend.x, bestindex); + end->y = lane(vbestend.y, bestindex); + end->z = lane(vbestend.z, bestindex); +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Palette evaluation. + +Decoder s_decoder = Decoder_D3D10; + +// D3D10 +inline void evaluate_palette4_d3d10(Color32 palette[4]) { + palette[2].r = (2 * palette[0].r + palette[1].r) / 3; + palette[2].g = (2 * palette[0].g + palette[1].g) / 3; + palette[2].b = (2 * palette[0].b + palette[1].b) / 3; + palette[2].a = 0xFF; + + palette[3].r = (2 * palette[1].r + palette[0].r) / 3; + palette[3].g = (2 * palette[1].g + palette[0].g) / 3; + palette[3].b = (2 * palette[1].b + palette[0].b) / 3; + palette[3].a = 0xFF; +} +inline void evaluate_palette3_d3d10(Color32 palette[4]) { + palette[2].r = (palette[0].r + palette[1].r) / 2; + palette[2].g = (palette[0].g + palette[1].g) / 2; + palette[2].b = (palette[0].b + palette[1].b) / 2; + palette[2].a = 0xFF; + palette[3].u = 0; +} +static void evaluate_palette_d3d10(Color16 c0, Color16 c1, Color32 palette[4]) { + palette[0] = bitexpand_color16_to_color32(c0); + palette[1] = bitexpand_color16_to_color32(c1); + if (c0.u > c1.u) { + evaluate_palette4_d3d10(palette); + } + else { + evaluate_palette3_d3d10(palette); + } +} + +// NV +inline void evaluate_palette4_nv(Color16 c0, Color16 c1, Color32 palette[4]) { + int gdiff = palette[1].g - palette[0].g; + palette[2].r = uint8(((2 * c0.r + c1.r) * 22) / 8); + palette[2].g = uint8((256 * palette[0].g + gdiff / 4 + 128 + gdiff * 80) / 256); + palette[2].b = uint8(((2 * c0.b + c1.b) * 22) / 8); + palette[2].a = 0xFF; + + palette[3].r = uint8(((2 * c1.r + c0.r) * 22) / 8); + palette[3].g = uint8((256 * palette[1].g - gdiff / 4 + 128 - gdiff * 80) / 256); + palette[3].b = uint8(((2 * c1.b + c0.b) * 22) / 8); + palette[3].a = 0xFF; +} +inline void evaluate_palette3_nv(Color16 c0, Color16 c1, Color32 palette[4]) { + int gdiff = palette[1].g - palette[0].g; + palette[2].r = uint8(((c0.r + c1.r) * 33) / 8); + palette[2].g = uint8((256 * palette[0].g + gdiff / 4 + 128 + gdiff * 128) / 256); + palette[2].b = uint8(((c0.b + c1.b) * 33) / 8); + palette[2].a = 0xFF; + palette[3].u = 0; +} +static void evaluate_palette_nv(Color16 c0, Color16 c1, Color32 palette[4]) { + palette[0] = bitexpand_color16_to_color32(c0); + palette[1] = bitexpand_color16_to_color32(c1); + + if (c0.u > c1.u) { + evaluate_palette4_nv(c0, c1, palette); + } + else { + evaluate_palette3_nv(c0, c1, palette); + } +} + +// AMD +inline void evaluate_palette4_amd(Color32 palette[4]) { + palette[2].r = uint8((43 * palette[0].r + 21 * palette[1].r + 32) >> 6); + palette[2].g = uint8((43 * palette[0].g + 21 * palette[1].g + 32) >> 6); + palette[2].b = uint8((43 * palette[0].b + 21 * palette[1].b + 32) >> 6); + palette[2].a = 0xFF; + + palette[3].r = uint8((43 * palette[1].r + 21 * palette[0].r + 32) >> 6); + palette[3].g = uint8((43 * palette[1].g + 21 * palette[0].g + 32) >> 6); + palette[3].b = uint8((43 * palette[1].b + 21 * palette[0].b + 32) >> 6); + palette[3].a = 0xFF; +} +inline void evaluate_palette3_amd(Color32 palette[4]) { + palette[2].r = uint8((palette[0].r + palette[1].r + 1) / 2); + palette[2].g = uint8((palette[0].g + palette[1].g + 1) / 2); + palette[2].b = uint8((palette[0].b + palette[1].b + 1) / 2); + palette[2].a = 0xFF; + palette[3].u = 0; +} +static void evaluate_palette_amd(Color16 c0, Color16 c1, Color32 palette[4]) { + palette[0] = bitexpand_color16_to_color32(c0); + palette[1] = bitexpand_color16_to_color32(c1); + + if (c0.u > c1.u) { + evaluate_palette4_amd(palette); + } + else { + evaluate_palette3_amd(palette); + } +} + +inline void evaluate_palette(Color16 c0, Color16 c1, Color32 palette[4], Decoder decoder = s_decoder) { + if (decoder == Decoder_D3D10) evaluate_palette_d3d10(c0, c1, palette); + else if (decoder == Decoder_NVIDIA) evaluate_palette_nv(c0, c1, palette); + else if (decoder == Decoder_AMD) evaluate_palette_amd(c0, c1, palette); +} + +static void evaluate_palette(Color16 c0, Color16 c1, Vector3 palette[4]) { + Color32 palette32[4]; + evaluate_palette(c0, c1, palette32); + + for (int i = 0; i < 4; i++) { + palette[i] = color_to_vector3(palette32[i]); + } +} + +static void decode_dxt1(const BlockDXT1 * block, unsigned char rgba_block[16 * 4], Decoder decoder) +{ + Color32 palette[4]; + evaluate_palette(block->col0, block->col1, palette, decoder); + + for (int i = 0; i < 16; i++) { + int index = (block->indices >> (2 * i)) & 3; + Color32 c = palette[index]; + rgba_block[4 * i + 0] = c.r; + rgba_block[4 * i + 1] = c.g; + rgba_block[4 * i + 2] = c.b; + rgba_block[4 * i + 3] = c.a; + } +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Error evaluation. + +// Different ways of estimating the error. + +static float evaluate_mse(const Vector3 & p, const Vector3 & c, const Vector3 & w) { + Vector3 d = (p - c) * w * 255; + return dot(d, d); +} + +static float evaluate_mse(const Color32 & p, const Vector3 & c, const Vector3 & w) { + Vector3 d = (color_to_vector3(p) - c) * w * 255; + return dot(d, d); +} + +static int evaluate_mse(const Color32 & p, const Color32 & c) { + return (square(int(p.r)-c.r) + square(int(p.g)-c.g) + square(int(p.b)-c.b)); +} + +static int evaluate_mse(const Color32 palette[4], const Color32 & c) { + int e0 = evaluate_mse(palette[0], c); + int e1 = evaluate_mse(palette[1], c); + int e2 = evaluate_mse(palette[2], c); + int e3 = evaluate_mse(palette[3], c); + return min(min(e0, e1), min(e2, e3)); +} + +// Returns MSE error in [0-255] range. +static int evaluate_mse(const BlockDXT1 * output, Color32 color, int index) { + Color32 palette[4]; + evaluate_palette(output->col0, output->col1, palette); + + return evaluate_mse(palette[index], color); +} + +// Returns weighted MSE error in [0-255] range. +static float evaluate_palette_error(Color32 palette[4], const Color32 * colors, const float * weights, int count) { + + float total = 0.0f; + for (int i = 0; i < count; i++) { + total += weights[i] * evaluate_mse(palette, colors[i]); + } + + return total; +} + +static float evaluate_palette_error(Color32 palette[4], const Color32 * colors, int count) { + + float total = 0.0f; + for (int i = 0; i < count; i++) { + total += evaluate_mse(palette, colors[i]); + } + + return total; +} + +static float evaluate_mse(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, const BlockDXT1 * output) { + Color32 palette[4]; + evaluate_palette(output->col0, output->col1, palette); + + // evaluate error for each index. + float error = 0.0f; + for (int i = 0; i < 16; i++) { + int index = (output->indices >> (2 * i)) & 3; + error += input_weights[i] * evaluate_mse(palette[index], input_colors[i].xyz, color_weights); + } + return error; +} + +static float evaluate_mse(const Vector4 input_colors[16], const float input_weights[16], const Vector3& color_weights, Vector3 palette[4], uint32 indices) { + + // evaluate error for each index. + float error = 0.0f; + for (int i = 0; i < 16; i++) { + int index = (indices >> (2 * i)) & 3; + error += input_weights[i] * evaluate_mse(palette[index], input_colors[i].xyz, color_weights); + } + return error; +} + +float evaluate_dxt1_error(const uint8 rgba_block[16*4], const BlockDXT1 * block, Decoder decoder) { + Color32 palette[4]; + evaluate_palette(block->col0, block->col1, palette, decoder); + + // evaluate error for each index. + float error = 0.0f; + for (int i = 0; i < 16; i++) { + int index = (block->indices >> (2 * i)) & 3; + Color32 c; + c.r = rgba_block[4 * i + 0]; + c.g = rgba_block[4 * i + 1]; + c.b = rgba_block[4 * i + 2]; + c.a = 255; + error += evaluate_mse(palette[index], c); + } + return error; +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Index selection + +// @@ Can we interleave the two uint16 at once? +inline uint32 interleave_uint16_with_zeros(uint32 input) { + uint32 word = input; + word = (word ^ (word << 8 )) & 0x00ff00ff; + word = (word ^ (word << 4 )) & 0x0f0f0f0f; + word = (word ^ (word << 2 )) & 0x33333333; + word = (word ^ (word << 1 )) & 0x55555555; + return word; +} + +// Interleave the bits. https://lemire.me/blog/2018/01/08/how-fast-can-you-bit-interleave-32-bit-integers/ +ICBC_FORCEINLINE uint32 interleave(uint32 a, uint32 b) { +#if ICBC_BMI2 + return _pdep_u32(a, 0x55555555) | _pdep_u32(b, 0xaaaaaaaa); +#else + return interleave_uint16_with_zeros(a) | (interleave_uint16_with_zeros(b) << 1); +#endif +} + +static uint compute_indices4(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 palette[4]) { + uint indices0 = 0; + uint indices1 = 0; + + VVector3 vw = vbroadcast(color_weights); + VVector3 vp0 = vbroadcast(palette[0]) * vw; + VVector3 vp1 = vbroadcast(palette[1]) * vw; + VVector3 vp2 = vbroadcast(palette[2]) * vw; + VVector3 vp3 = vbroadcast(palette[3]) * vw; + + for (int i = 0; i < 16; i += VEC_SIZE) { + VVector3 vc = vload(&input_colors[i]) * vw; + + VFloat d0 = vlen2(vc - vp0); + VFloat d1 = vlen2(vc - vp1); + VFloat d2 = vlen2(vc - vp2); + VFloat d3 = vlen2(vc - vp3); + + VMask b1 = d1 > d2; + VMask b2 = d0 > d2; + VMask x0 = b1 & b2; + + VMask b0 = d0 > d3; + VMask b3 = d1 > d3; + x0 = x0 | (b0 & b3); + + VMask b4 = d2 > d3; + VMask x1 = b0 & b4; + + indices0 |= mask(x0) << i; + indices1 |= mask(x1) << i; + } + + return interleave(indices1, indices0); +} + +static uint compute_indices3(const Vector4 input_colors[16], const Vector3 & color_weights, bool allow_transparent_black, const Vector3 palette[4]) { + uint indices0 = 0; + uint indices1 = 0; + + VVector3 vw = vbroadcast(color_weights); + VVector3 vp0 = vbroadcast(palette[0]) * vw; + VVector3 vp1 = vbroadcast(palette[1]) * vw; + VVector3 vp2 = vbroadcast(palette[2]) * vw; + + if (allow_transparent_black) { + for (int i = 0; i < 16; i += VEC_SIZE) { + VVector3 vc = vload(&input_colors[i]) * vw; + + VFloat d0 = vlen2(vp0 - vc); + VFloat d1 = vlen2(vp1 - vc); + VFloat d2 = vlen2(vp2 - vc); + VFloat d3 = vdot(vc, vc); + + VMask i1 = (d1 < d2); + VMask i2 = (d2 <= d0) & (d2 <= d1); + VMask i3 = (d3 <= d0) & (d3 <= d1) & (d3 <= d2); + + indices0 |= mask(i2 | i3) << i; + indices1 |= mask(i1 | i3) << i; + } + } + else { + for (int i = 0; i < 16; i += VEC_SIZE) { + VVector3 vc = vload(&input_colors[i]) * vw; + + VFloat d0 = vlen2(vc - vp0); + VFloat d1 = vlen2(vc - vp1); + VFloat d2 = vlen2(vc - vp2); + + VMask i1 = (d1 < d2); + VMask i2 = (d2 <= d0) & (d2 <= d1); + + indices0 |= mask(i2) << i; + indices1 |= mask(i1) << i; + } + } + + return interleave(indices1, indices0); +} + + +static uint compute_indices(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 palette[4]) { +#if 0 + Vector3 p0 = palette[0] * color_weights; + Vector3 p1 = palette[1] * color_weights; + Vector3 p2 = palette[2] * color_weights; + Vector3 p3 = palette[3] * color_weights; + + uint indices = 0; + for (int i = 0; i < 16; i++) { + Vector3 ci = input_colors[i].xyz * color_weights; + float d0 = lengthSquared(p0 - ci); + float d1 = lengthSquared(p1 - ci); + float d2 = lengthSquared(p2 - ci); + float d3 = lengthSquared(p3 - ci); + + uint index; + if (d0 < d1 && d0 < d2 && d0 < d3) index = 0; + else if (d1 < d2 && d1 < d3) index = 1; + else if (d2 < d3) index = 2; + else index = 3; + + indices |= index << (2 * i); + } + + return indices; +#else + uint indices0 = 0; + uint indices1 = 0; + + VVector3 vw = vbroadcast(color_weights); + VVector3 vp0 = vbroadcast(palette[0]) * vw; + VVector3 vp1 = vbroadcast(palette[1]) * vw; + VVector3 vp2 = vbroadcast(palette[2]) * vw; + VVector3 vp3 = vbroadcast(palette[3]) * vw; + + for (int i = 0; i < 16; i += VEC_SIZE) { + VVector3 vc = vload(&input_colors[i]) * vw; + + VFloat d0 = vlen2(vc - vp0); + VFloat d1 = vlen2(vc - vp1); + VFloat d2 = vlen2(vc - vp2); + VFloat d3 = vlen2(vc - vp3); + + //VMask i0 = (d0 < d1) & (d0 < d2) & (d0 < d3); + VMask i1 = (d1 <= d0) & (d1 < d2) & (d1 < d3); + VMask i2 = (d2 <= d0) & (d2 <= d1) & (d2 < d3); + VMask i3 = (d3 <= d0) & (d3 <= d1) & (d3 <= d2); + //VFloat vindex = vselect(i0, vselect(i1, vselect(i2, vbroadcast(3), vbroadcast(2)), vbroadcast(1)), vbroadcast(0)); + + indices0 |= mask(i2 | i3) << i; + indices1 |= mask(i1 | i3) << i; + } + + uint indices = interleave(indices1, indices0); + return indices; +#endif +} + + +static float output_block3(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, bool allow_transparent_black, const Vector3 & v0, const Vector3 & v1, BlockDXT1 * block) +{ + Color16 color0 = vector3_to_color16(v0); + Color16 color1 = vector3_to_color16(v1); + + if (color0.u > color1.u) { + swap(color0, color1); + } + + Vector3 palette[4]; + evaluate_palette(color0, color1, palette); + + block->col0 = color0; + block->col1 = color1; + block->indices = compute_indices3(input_colors, color_weights, allow_transparent_black, palette); + + return evaluate_mse(input_colors, input_weights, color_weights, palette, block->indices); +} + +static float output_block4(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, const Vector3 & v0, const Vector3 & v1, BlockDXT1 * block) +{ + Color16 color0 = vector3_to_color16(v0); + Color16 color1 = vector3_to_color16(v1); + + if (color0.u < color1.u) { + swap(color0, color1); + } + + Vector3 palette[4]; + evaluate_palette(color0, color1, palette); + + block->col0 = color0; + block->col1 = color1; + block->indices = compute_indices4(input_colors, color_weights, palette); + + return evaluate_mse(input_colors, input_weights, color_weights, palette, block->indices); +} + + +// Least squares fitting of color end points for the given indices. @@ Take weights into account. +static bool optimize_end_points4(uint indices, const Vector4 * colors, /*const float * weights,*/ int count, Vector3 * a, Vector3 * b) +{ + float alpha2_sum = 0.0f; + float beta2_sum = 0.0f; + float alphabeta_sum = 0.0f; + Vector3 alphax_sum = { 0,0,0 }; + Vector3 betax_sum = { 0,0,0 }; + + for (int i = 0; i < count; i++) + { + const uint bits = indices >> (2 * i); + + float beta = float(bits & 1); + if (bits & 2) beta = (1 + beta) / 3.0f; + float alpha = 1.0f - beta; + + alpha2_sum += alpha * alpha; + beta2_sum += beta * beta; + alphabeta_sum += alpha * beta; + alphax_sum += alpha * colors[i].xyz; + betax_sum += beta * colors[i].xyz; + } + + float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; + if (equal(denom, 0.0f)) return false; + + float factor = 1.0f / denom; + + *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); + *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); + + return true; +} + +// Least squares optimization with custom factors. +// This allows us passing the standard [1, 0, 2/3 1/3] weights by default, but also use alternative mappings when the number of clusters is not 4. +static bool optimize_end_points4(uint indices, const Vector3 * colors, int count, float factors[4], Vector3 * a, Vector3 * b) +{ + float alpha2_sum = 0.0f; + float beta2_sum = 0.0f; + float alphabeta_sum = 0.0f; + Vector3 alphax_sum = { 0,0,0 }; + Vector3 betax_sum = { 0,0,0 }; + + for (int i = 0; i < count; i++) + { + const uint idx = (indices >> (2 * i)) & 3; + float alpha = factors[idx]; + float beta = 1 - alpha; + + alpha2_sum += alpha * alpha; + beta2_sum += beta * beta; + alphabeta_sum += alpha * beta; + alphax_sum += alpha * colors[i]; + betax_sum += beta * colors[i]; + } + + float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; + if (equal(denom, 0.0f)) return false; + + float factor = 1.0f / denom; + + *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); + *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); + + return true; +} + +static bool optimize_end_points4(uint indices, const Vector3 * colors, int count, Vector3 * a, Vector3 * b) +{ + float factors[4] = { 1, 0, 2.f / 3, 1.f / 3 }; + return optimize_end_points4(indices, colors, count, factors, a, b); +} + + +// Least squares fitting of color end points for the given indices. @@ This does not support black/transparent index. @@ Take weights into account. +static bool optimize_end_points3(uint indices, const Vector3 * colors, /*const float * weights,*/ int count, Vector3 * a, Vector3 * b) +{ + float alpha2_sum = 0.0f; + float beta2_sum = 0.0f; + float alphabeta_sum = 0.0f; + Vector3 alphax_sum = { 0,0,0 }; + Vector3 betax_sum = { 0,0,0 }; + + for (int i = 0; i < count; i++) + { + const uint bits = indices >> (2 * i); + + float beta = float(bits & 1); + if (bits & 2) beta = 0.5f; + float alpha = 1.0f - beta; + + alpha2_sum += alpha * alpha; + beta2_sum += beta * beta; + alphabeta_sum += alpha * beta; + alphax_sum += alpha * colors[i]; + betax_sum += beta * colors[i]; + } + + float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; + if (equal(denom, 0.0f)) return false; + + float factor = 1.0f / denom; + + *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); + *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); + + return true; +} + + +// find minimum and maximum colors based on bounding box in color space +inline static void fit_colors_bbox(const Vector3 * colors, int count, Vector3 * __restrict c0, Vector3 * __restrict c1) +{ + *c0 = { 0,0,0 }; + *c1 = { 1,1,1 }; + + for (int i = 0; i < count; i++) { + *c0 = max(*c0, colors[i]); + *c1 = min(*c1, colors[i]); + } +} + +inline static void select_diagonal(const Vector3 * colors, int count, Vector3 * __restrict c0, Vector3 * __restrict c1) +{ + Vector3 center = (*c0 + *c1) * 0.5f; + + /*Vector3 center = colors[0]; + for (int i = 1; i < count; i++) { + center = center * float(i-1) / i + colors[i] / i; + }*/ + /*Vector3 center = colors[0]; + for (int i = 1; i < count; i++) { + center += colors[i]; + } + center /= count;*/ + + float cov_xz = 0.0f; + float cov_yz = 0.0f; + for (int i = 0; i < count; i++) { + Vector3 t = colors[i] - center; + cov_xz += t.x * t.z; + cov_yz += t.y * t.z; + } + + float x0 = c0->x; + float y0 = c0->y; + float x1 = c1->x; + float y1 = c1->y; + + if (cov_xz < 0) { + swap(x0, x1); + } + if (cov_yz < 0) { + swap(y0, y1); + } + + *c0 = { x0, y0, c0->z }; + *c1 = { x1, y1, c1->z }; +} + +inline static void inset_bbox(Vector3 * __restrict c0, Vector3 * __restrict c1) +{ + float bias = (8.0f / 255.0f) / 16.0f; + Vector3 inset = (*c0 - *c1) / 16.0f - scalar_to_vector3(bias); + *c0 = saturate(*c0 - inset); + *c1 = saturate(*c1 + inset); +} + + + +// Single color lookup tables from: +// https://github.com/nothings/stb/blob/master/stb_dxt.h +static uint8 s_match5[256][2]; +static uint8 s_match6[256][2]; + +static inline int Lerp13(int a, int b) +{ + // replace "/ 3" by "* 0xaaab) >> 17" if your compiler sucks or you really need every ounce of speed. + return (a * 2 + b) / 3; +} + +static void PrepareOptTable5(uint8 * table, Decoder decoder) +{ + uint8 expand[32]; + for (int i = 0; i < 32; i++) expand[i] = uint8((i << 3) | (i >> 2)); + + for (int i = 0; i < 256; i++) { + int bestErr = 256 * 100; + + for (int mn = 0; mn < 32; mn++) { + for (int mx = 0; mx < 32; mx++) { + int mine = expand[mn]; + int maxe = expand[mx]; + + int err; + + int amd_r = (43 * maxe + 21 * mine + 32) >> 6; + int amd_err = abs(amd_r - i); + + int nv_r = ((2 * mx + mn) * 22) / 8; + int nv_err = abs(nv_r - i); + + if (decoder == Decoder_D3D10) { + // DX10 spec says that interpolation must be within 3% of "correct" result, + // add this as error term. (normally we'd expect a random distribution of + // +-1.5% error, but nowhere in the spec does it say that the error has to be + // unbiased - better safe than sorry). + int r = (maxe * 2 + mine) / 3; + err = abs(r - i) * 100 + abs(mx - mn) * 3; + + // Another approach is to consider the worst of AMD and NVIDIA errors. + err = max(amd_err, nv_err); + } + else if (decoder == Decoder_NVIDIA) { + err = nv_err; + } + else /*if (decoder == Decoder_AMD)*/ { + err = amd_err; + } + + if (err < bestErr) { + bestErr = err; + table[i * 2 + 0] = uint8(mx); + table[i * 2 + 1] = uint8(mn); + } + } + } + } +} + +static void PrepareOptTable6(uint8 * table, Decoder decoder) +{ + uint8 expand[64]; + for (int i = 0; i < 64; i++) expand[i] = uint8((i << 2) | (i >> 4)); + + for (int i = 0; i < 256; i++) { + int bestErr = 256 * 100; + + for (int mn = 0; mn < 64; mn++) { + for (int mx = 0; mx < 64; mx++) { + int mine = expand[mn]; + int maxe = expand[mx]; + + int err; + + int amd_g = (43 * maxe + 21 * mine + 32) >> 6; + int amd_err = abs(amd_g - i); + + int nv_g = (256 * mine + (maxe - mine) / 4 + 128 + (maxe - mine) * 80) / 256; + int nv_err = abs(nv_g - i); + + if (decoder == Decoder_D3D10) { + // DX10 spec says that interpolation must be within 3% of "correct" result, + // add this as error term. (normally we'd expect a random distribution of + // +-1.5% error, but nowhere in the spec does it say that the error has to be + // unbiased - better safe than sorry). + int g = (maxe * 2 + mine) / 3; + err = abs(g - i) * 100 + abs(mx - mn) * 3; + + // Another approach is to consider the worst of AMD and NVIDIA errors. + err = max(amd_err, nv_err); + } + else if (decoder == Decoder_NVIDIA) { + err = nv_err; + } + else /*if (decoder == Decoder_AMD)*/ { + err = amd_err; + } + + if (err < bestErr) { + bestErr = err; + table[i * 2 + 0] = uint8(mx); + table[i * 2 + 1] = uint8(mn); + } + } + } + } +} + + +static void init_single_color_tables(Decoder decoder) +{ + // Prepare single color lookup tables. + PrepareOptTable5(&s_match5[0][0], decoder); + PrepareOptTable6(&s_match6[0][0], decoder); +} + +// Single color compressor, based on: +// https://mollyrocket.com/forums/viewtopic.php?t=392 +static void compress_dxt1_single_color_optimal(Color32 c, BlockDXT1 * output) +{ + output->col0.r = s_match5[c.r][0]; + output->col0.g = s_match6[c.g][0]; + output->col0.b = s_match5[c.b][0]; + output->col1.r = s_match5[c.r][1]; + output->col1.g = s_match6[c.g][1]; + output->col1.b = s_match5[c.b][1]; + output->indices = 0xaaaaaaaa; + + if (output->col0.u < output->col1.u) + { + swap(output->col0.u, output->col1.u); + output->indices ^= 0x55555555; + } +} + + +static float compress_dxt1_cluster_fit(const Vector4 input_colors[16], const float input_weights[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, bool try_transparent_black, bool allow_transparent_black, BlockDXT1 * output) +{ + Vector3 metric_sqr = color_weights * color_weights; + + SummedAreaTable sat; + int sat_count = compute_sat(colors, weights, count, &sat); + + Vector3 start, end; + cluster_fit_four(sat, sat_count, metric_sqr, &start, &end); + + float best_error = output_block4(input_colors, input_weights, color_weights, start, end, output); + + if (three_color_mode) { + if (try_transparent_black) { + Vector3 tmp_colors[16]; + float tmp_weights[16]; + int tmp_count = skip_blacks(colors, weights, count, tmp_colors, tmp_weights); + if (!tmp_count) return best_error; + + sat_count = compute_sat(tmp_colors, tmp_weights, tmp_count, &sat); + } + + cluster_fit_three(sat, sat_count, metric_sqr, &start, &end); + + BlockDXT1 three_color_block; + float three_color_error = output_block3(input_colors, input_weights, color_weights, allow_transparent_black, start, end, &three_color_block); + + if (three_color_error < best_error) { + best_error = three_color_error; + *output = three_color_block; + } + } + + return best_error; +} + + +static float refine_endpoints(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, bool three_color_mode, float input_error, BlockDXT1 * output) { + // TODO: + // - Optimize palette evaluation when updating only one channel. + // - try all diagonals. + + // Things that don't help: + // - Alternate endpoint updates. + // - Randomize order. + // - If one direction does not improve, test opposite direction next. + + static const int8 deltas[16][3] = { + {1,0,0}, + {0,1,0}, + {0,0,1}, + + {-1,0,0}, + {0,-1,0}, + {0,0,-1}, + + {1,1,0}, + {1,0,1}, + {0,1,1}, + + {-1,-1,0}, + {-1,0,-1}, + {0,-1,-1}, + + {-1,1,0}, + //{-1,0,1}, + + {1,-1,0}, + {0,-1,1}, + + //{1,0,-1}, + {0,1,-1}, + }; + + float best_error = input_error; + + int lastImprovement = 0; + for (int i = 0; i < 256; i++) { + BlockDXT1 refined = *output; + int8 delta[3] = { deltas[i % 16][0], deltas[i % 16][1], deltas[i % 16][2] }; + + if ((i / 16) & 1) { + refined.col0.r += delta[0]; + refined.col0.g += delta[1]; + refined.col0.b += delta[2]; + } + else { + refined.col1.r += delta[0]; + refined.col1.g += delta[1]; + refined.col1.b += delta[2]; + } + + if (!three_color_mode) { + if (refined.col0.u == refined.col1.u) refined.col1.g += 1; + if (refined.col0.u < refined.col1.u) swap(refined.col0.u, refined.col1.u); + } + + Vector3 palette[4]; + evaluate_palette(output->col0, output->col1, palette); + + refined.indices = compute_indices(input_colors, color_weights, palette); + + float refined_error = evaluate_mse(input_colors, input_weights, color_weights, &refined); + if (refined_error < best_error) { + best_error = refined_error; + *output = refined; + lastImprovement = i; + } + + // Early out if the last 32 steps didn't improve error. + if (i - lastImprovement > 32) break; + } + + return best_error; +} + +struct Options { + float threshold = 0.0f; + bool box_fit = false; + bool least_squares_fit = false; + bool cluster_fit = false; + bool cluster_fit_3 = false; + bool cluster_fit_3_black_only = false; + bool endpoint_refinement = false; +}; + +static Options setup_options(Quality level, bool enable_three_color_mode, bool enable_transparent_black) { + Options opt; + + switch (level) { + case Quality_Level1: // Box fit + least squares fit. + opt.box_fit = true; + opt.least_squares_fit = true; + opt.threshold = 1.0f / 256; + break; + + case Quality_Level2: // Cluster fit 4, threshold = 24. + opt.box_fit = true; + opt.least_squares_fit = true; + opt.cluster_fit = true; + opt.cluster_fit_3_black_only = enable_three_color_mode && enable_transparent_black; + opt.threshold = 1.0f / 24; + break; + + case Quality_Level3: // Cluster fit 4, threshold = 32. + opt.box_fit = true; + opt.cluster_fit = true; + opt.cluster_fit_3_black_only = enable_three_color_mode && enable_transparent_black; + opt.threshold = 1.0f / 32; + break; + + case Quality_Level4: // Cluster fit 3+4, threshold = 48. + opt.cluster_fit = true; + opt.cluster_fit_3_black_only = enable_three_color_mode && enable_transparent_black; + opt.threshold = 1.0f / 48; + break; + + case Quality_Level5: // Cluster fit 3+4, threshold = 64. + opt.cluster_fit = true; + opt.cluster_fit_3_black_only = enable_three_color_mode && enable_transparent_black; + opt.threshold = 1.0f / 64; + break; + + case Quality_Level6: // Cluster fit 3+4, threshold = 96. + opt.cluster_fit = true; + opt.cluster_fit_3_black_only = enable_three_color_mode && enable_transparent_black; + opt.threshold = 1.0f / 96; + break; + + case Quality_Level7: // Cluster fit 3+4, threshold = 128. + opt.cluster_fit = true; + opt.cluster_fit_3_black_only = enable_three_color_mode && enable_transparent_black; + opt.threshold = 1.0f / 128; + break; + + case Quality_Level8: // Cluster fit 3+4, threshold = 256. + opt.cluster_fit = true; + opt.cluster_fit_3 = enable_three_color_mode; + opt.threshold = 1.0f / 256; + break; + + case Quality_Level9: // Cluster fit 3+4, threshold = 256 + Refinement. + opt.cluster_fit = true; + opt.cluster_fit_3 = enable_three_color_mode; + opt.threshold = 1.0f / 256; + opt.endpoint_refinement = true; + break; + } + + return opt; +} + + +static float compress_dxt1(Quality level, const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, bool three_color_mode, bool three_color_black, BlockDXT1 * output) +{ + Options opt = setup_options(level, three_color_mode, three_color_black); + + Vector3 colors[16]; + float weights[16]; + bool any_black = false; + int count; + if (opt.cluster_fit) { + count = reduce_colors(input_colors, input_weights, 16, opt.threshold, colors, weights, &any_black); + } + else { + for (int i = 0; i < 16; i++) { + colors[i] = input_colors[i].xyz; + } + count = 16; + } + + if (count == 0) { + // Output trivial block. + output->col0.u = 0; + output->col1.u = 0; + output->indices = 0; + return 0; + } + + // Cluster fit cannot handle single color blocks, so encode them optimally. + if (count == 1) { + compress_dxt1_single_color_optimal(vector3_to_color32(colors[0]), output); + return evaluate_mse(input_colors, input_weights, color_weights, output); + } + + float error = FLT_MAX; + + // Quick end point selection. + if (opt.box_fit) { + Vector3 c0, c1; + fit_colors_bbox(colors, count, &c0, &c1); + inset_bbox(&c0, &c1); + select_diagonal(colors, count, &c0, &c1); + error = output_block4(input_colors, input_weights, color_weights, c0, c1, output); + + // Refine color for the selected indices. + if (opt.least_squares_fit && optimize_end_points4(output->indices, input_colors, 16, &c0, &c1)) { + BlockDXT1 optimized_block; + float optimized_error = output_block4(input_colors, input_weights, color_weights, c0, c1, &optimized_block); + + if (optimized_error < error) { + error = optimized_error; + *output = optimized_block; + } + } + } + + if (opt.cluster_fit) { + // @@ Use current endpoints as input for initial PCA approximation? + + bool use_three_color_black = any_black && three_color_black; + bool use_three_color_mode = opt.cluster_fit_3 || (use_three_color_black && opt.cluster_fit_3_black_only); + + // Try cluster fit. + BlockDXT1 cluster_fit_output; + float cluster_fit_error = compress_dxt1_cluster_fit(input_colors, input_weights, colors, weights, count, color_weights, use_three_color_mode, use_three_color_black, three_color_black, &cluster_fit_output); + if (cluster_fit_error < error) { + *output = cluster_fit_output; + error = cluster_fit_error; + } + } + + if (opt.endpoint_refinement) { + error = refine_endpoints(input_colors, input_weights, color_weights, three_color_mode, error, output); + } + + return error; +} + + +// Public API + +void init_dxt1(Decoder decoder) { + s_decoder = decoder; + init_single_color_tables(decoder); + init_cluster_tables(); +} + +void decode_dxt1(const void * block, unsigned char rgba_block[16 * 4], Decoder decoder/*=Decoder_D3D10*/) { + decode_dxt1((const BlockDXT1 *)block, rgba_block, decoder); +} + +float evaluate_dxt1_error(const unsigned char rgba_block[16 * 4], const void * dxt_block, Decoder decoder/*=Decoder_D3D10*/) { + return evaluate_dxt1_error(rgba_block, (const BlockDXT1 *)dxt_block, decoder); +} + +float compress_dxt1(Quality level, const float * input_colors, const float * input_weights, const float rgb[3], bool three_color_mode, bool three_color_black, void * output) { + return compress_dxt1(level, (Vector4*)input_colors, input_weights, { rgb[0], rgb[1], rgb[2] }, three_color_mode, three_color_black, (BlockDXT1*)output); +} + +} // icbc + +// // Do not polute preprocessor definitions. +// #undef ICBC_SIMD +// #undef ICBC_ASSERT + +// #undef ICBC_SCALAR +// #undef ICBC_SSE2 +// #undef ICBC_SSE41 +// #undef ICBC_AVX1 +// #undef ICBC_AVX2 +// #undef ICBC_AVX512 +// #undef ICBC_NEON +// #undef ICBC_VMX + +// #undef ICBC_USE_FMA +// #undef ICBC_USE_AVX2_PERMUTE2 +// #undef ICBC_USE_AVX512_PERMUTE +// #undef ICBC_USE_NEON_VTL + +// #undef ICBC_PERFECT_ROUND + +#endif // ICBC_IMPLEMENTATION + +// Version History: +// v1.00 - Initial release. +// v1.01 - Added SPMD code path with AVX support. +// v1.02 - Removed SIMD code path. +// v1.03 - Quality levels. AVX512, Neon, Altivec, vectorized reduction and index selection. +// v1.04 - Automatic compile-time SIMD selection. Specify hw decoder at runtime. More optimizations. +// v1.05 - Bug fixes. Small optimizations. + +// Copyright (c) 2020 Ignacio Castano +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/nvtt/nvtt.h b/src/nvtt/nvtt.h index d86a503a..08200923 100644 --- a/src/nvtt/nvtt.h +++ b/src/nvtt/nvtt.h @@ -49,7 +49,7 @@ # define NVTT_API #endif -#define NVTT_VERSION 20100 +#define NVTT_VERSION 20102 #define NVTT_FORBID_COPY(Class) \ private: \ @@ -463,8 +463,8 @@ namespace nvtt ToneMapper_Lightmap, }; - // Transform the given x,y coordinates. - typedef void WarpFunction(float & x, float & y, float & d); + // Transform the given x,y,z coordinates. + typedef void WarpFunction(float & x, float & y, float & z); // A surface is one level of a 2D or 3D texture. (New in NVTT 2.1) @@ -529,7 +529,9 @@ namespace nvtt NVTT_API void toLinear(int channel, float gamma); NVTT_API void toGamma(int channel, float gamma); NVTT_API void toSrgb(); + NVTT_API void toSrgbFast(); NVTT_API void toLinearFromSrgb(); + NVTT_API void toLinearFromSrgbFast(); NVTT_API void toXenonSrgb(); NVTT_API void transform(const float w0[4], const float w1[4], const float w2[4], const float w3[4], const float offset[4]); NVTT_API void swizzle(int r, int g, int b, int a); @@ -662,6 +664,9 @@ namespace nvtt NVTT_API CubeSurface fastResample(int size, EdgeFixup fixupMethod) const; + // Spherical Harmonics: + NVTT_API void computeLuminanceIrradianceSH3(float sh[9]) const; + NVTT_API void computeIrradianceSH3(int channel, float sh[9]) const; /* NVTT_API void resize(int w, int h, ResizeFilter filter); diff --git a/src/nvtt/nvtt_wrapper.cpp b/src/nvtt/nvtt_wrapper.cpp index 5a212429..fee94834 100644 --- a/src/nvtt/nvtt_wrapper.cpp +++ b/src/nvtt/nvtt_wrapper.cpp @@ -27,9 +27,9 @@ #include "OutputOptions.h" -// An OutputHandler that sets and calls function pointers, rather than -// requiring interfaces to derive from OutputHandler itself -struct HandlerProxy : public nvtt::OutputHandler +// An OutputHandler/ErrorHandler that sets and calls function pointers, rather than +// requiring interfaces to derive from OutputHandler/ErrorHandler itself +struct HandlerProxy : public nvtt::OutputHandler, public nvtt::ErrorHandler { public: @@ -39,6 +39,8 @@ struct HandlerProxy : public nvtt::OutputHandler nvttOutputHandler writeDataHandler; nvttEndImageHandler endImageHandler; + nvttErrorHandler errorHandler; + virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel) { if (beginImageHandler != NULL) @@ -64,6 +66,14 @@ struct HandlerProxy : public nvtt::OutputHandler endImageHandler(); } } + + virtual void error(nvtt::Error e) + { + if (errorHandler != NULL) + { + errorHandler((NvttError)e); + } + } }; @@ -78,9 +88,9 @@ void nvttDestroyInputOptions(NvttInputOptions * inputOptions) delete inputOptions; } -void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d) +void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d, int arraySize) { - inputOptions->setTextureLayout((nvtt::TextureType)type, w, h, d); + inputOptions->setTextureLayout((nvtt::TextureType)type, w, h, d, arraySize); } void nvttResetInputOptionsTextureLayout(NvttInputOptions * inputOptions) @@ -233,12 +243,32 @@ void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoo { outputOptions->setOutputHeader(b != NVTT_False); } -/* + +void nvttSetOutputOptionsContainer(NvttOutputOptions * outputOptions, NvttContainer containerFormat) +{ + outputOptions->setContainer((nvtt::Container)containerFormat); +} + +void nvttSetOutputOptionsSrgbFlag(NvttOutputOptions * outputOptions, NvttBoolean b) +{ + outputOptions->setSrgbFlag(b != NVTT_False); +} + void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler) { - outputOptions->setErrorHandler(errorHandler); + HandlerProxy * handler = (HandlerProxy *)outputOptions->m.wrapperProxy; + + handler->errorHandler = errorHandler; + + if (errorHandler == NULL) + { + outputOptions->setErrorHandler(NULL); + } + else + { + outputOptions->setErrorHandler(handler); + } } -*/ void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler writeDataHandler, nvttEndImageHandler endImageHandler) { @@ -270,6 +300,16 @@ void nvttDestroyCompressor(NvttCompressor * compressor) delete compressor; } +void nvttEnableCudaAcceleration(NvttCompressor * compressor, NvttBoolean b) +{ + compressor->enableCudaAcceleration(b != NVTT_False); +} + +NvttBoolean nvttIsCudaAccelerationEnabled(const NvttCompressor* compressor) +{ + return (NvttBoolean)compressor->isCudaAccelerationEnabled(); +} + NvttBoolean nvttCompress(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions, const NvttOutputOptions * outputOptions) { return (NvttBoolean)compressor->process(*inputOptions, *compressionOptions, *outputOptions); diff --git a/src/nvtt/nvtt_wrapper.h b/src/nvtt/nvtt_wrapper.h index 76fdac64..add4d7a4 100644 --- a/src/nvtt/nvtt_wrapper.h +++ b/src/nvtt/nvtt_wrapper.h @@ -48,7 +48,7 @@ # define NVTT_API #endif -#define NVTT_VERSION 20100 +#define NVTT_VERSION 20102 #ifdef __cplusplus typedef struct nvtt::InputOptions NvttInputOptions; @@ -71,10 +71,10 @@ typedef enum // DX9 formats. NVTT_Format_DXT1, - NVTT_Format_DXT1a, + NVTT_Format_DXT1a, // DXT1 with binary alpha. NVTT_Format_DXT3, NVTT_Format_DXT5, - NVTT_Format_DXT5n, + NVTT_Format_DXT5n, // Compressed HILO: R=1, G=y, B=0, A=x // DX10 formats. NVTT_Format_BC1 = NVTT_Format_DXT1, @@ -84,6 +84,28 @@ typedef enum NVTT_Format_BC3n = NVTT_Format_DXT5n, NVTT_Format_BC4, NVTT_Format_BC5, + + NVTT_Format_DXT1n, // Not supported. + NVTT_Format_CTX1, // Not supported. + + NVTT_Format_BC6, + NVTT_Format_BC7, + + NVTT_Format_BC3_RGBM, + + NVTT_Format_ETC1, + NVTT_Format_ETC2_R, + NVTT_Format_ETC2_RG, + NVTT_Format_ETC2_RGB, + NVTT_Format_ETC2_RGBA, + NVTT_Format_ETC2_RGB_A1, + + NVTT_Format_ETC2_RGBM, + + NVTT_Format_PVR_2BPP_RGB, // Using PVR textools. + NVTT_Format_PVR_4BPP_RGB, + NVTT_Format_PVR_2BPP_RGBA, + NVTT_Format_PVR_4BPP_RGBA, } NvttFormat; /// Quality modes. @@ -108,12 +130,17 @@ typedef enum { NVTT_TextureType_2D, NVTT_TextureType_Cube, + TextureType_3D, + TextureType_Array, } NvttTextureType; /// Input formats. typedef enum { - NVTT_InputFormat_BGRA_8UB, + NVTT_InputFormat_BGRA_8UB, // Normalized [0, 1] 8 bit fixed point. + NVTT_InputFormat_RGBA_16F, // 16 bit floating point. + NVTT_InputFormat_RGBA_32F, // 32 bit floating point. + NVTT_InputFormat_R_32F, // Single channel 32 bit floating point. } NvttInputFormat; /// Mipmap downsampling filters. @@ -131,6 +158,9 @@ typedef enum NVTT_RoundMode_ToNextPowerOfTwo, NVTT_RoundMode_ToNearestPowerOfTwo, NVTT_RoundMode_ToPreviousPowerOfTwo, + NVTT_RoundMode_ToNextMultipleOfFour, // (New in NVTT 2.1) + NVTT_RoundMode_ToNearestMultipleOfFour, // (New in NVTT 2.1) + NVTT_RoundMode_ToPreviousMultipleOfFour, // (New in NVTT 2.1) } NvttRoundMode; /// Alpha mode. @@ -141,18 +171,26 @@ typedef enum NVTT_AlphaMode_Premultiplied, } NvttAlphaMode; +// Error codes. typedef enum { + NVTT_Error_Unknown, NVTT_Error_InvalidInput, - NVTT_Error_UserInterruption, NVTT_Error_UnsupportedFeature, NVTT_Error_CudaError, - NVTT_Error_Unknown, NVTT_Error_FileOpen, NVTT_Error_FileWrite, NVTT_Error_UnsupportedOutputFormat, } NvttError; +// Output container format types. +typedef enum +{ + NVTT_Container_DDS, + NVTT_Container_DDS10, + NVTT_Container_KTX, +} NvttContainer; + typedef enum { NVTT_False, @@ -165,7 +203,7 @@ extern "C" { #endif // Callbacks -//typedef void (* nvttErrorHandler)(NvttError e); +typedef void (* nvttErrorHandler)(NvttError e); typedef void (* nvttBeginImageHandler)(int size, int width, int height, int depth, int face, int miplevel); typedef bool (* nvttOutputHandler)(const void * data, int size); typedef void (* nvttEndImageHandler)(); @@ -175,7 +213,7 @@ typedef void (* nvttEndImageHandler)(); NVTT_API NvttInputOptions * nvttCreateInputOptions(); NVTT_API void nvttDestroyInputOptions(NvttInputOptions * inputOptions); -NVTT_API void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d); +NVTT_API void nvttSetInputOptionsTextureLayout(NvttInputOptions * inputOptions, NvttTextureType type, int w, int h, int d, int arraySize); NVTT_API void nvttResetInputOptionsTextureLayout(NvttInputOptions * inputOptions); NVTT_API NvttBoolean nvttSetInputOptionsMipmapData(NvttInputOptions * inputOptions, const void * data, int w, int h, int d, int face, int mipmap); NVTT_API void nvttSetInputOptionsFormat(NvttInputOptions * inputOptions, NvttInputFormat format); @@ -211,7 +249,9 @@ NVTT_API void nvttDestroyOutputOptions(NvttOutputOptions * outputOptions); NVTT_API void nvttSetOutputOptionsFileName(NvttOutputOptions * outputOptions, const char * fileName); NVTT_API void nvttSetOutputOptionsOutputHeader(NvttOutputOptions * outputOptions, NvttBoolean b); -//NVTT_API void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler); +NVTT_API void nvttSetOutputOptionsContainer(NvttOutputOptions * outputOptions, NvttContainer containerFormat); +NVTT_API void nvttSetOutputOptionsSrgbFlag(NvttOutputOptions * outputOptions, NvttBoolean b); +NVTT_API void nvttSetOutputOptionsErrorHandler(NvttOutputOptions * outputOptions, nvttErrorHandler errorHandler); NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOptions, nvttBeginImageHandler beginImageHandler, nvttOutputHandler outputHandler, nvttEndImageHandler endImageHandler); @@ -219,6 +259,8 @@ NVTT_API void nvttSetOutputOptionsOutputHandler(NvttOutputOptions * outputOption NVTT_API NvttCompressor * nvttCreateCompressor(); NVTT_API void nvttDestroyCompressor(NvttCompressor * compressor); +NVTT_API void nvttEnableCudaAcceleration(NvttCompressor * compressor, NvttBoolean b); +NVTT_API NvttBoolean nvttIsCudaAccelerationEnabled(const NvttCompressor* compressor); NVTT_API NvttBoolean nvttCompress(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions, const NvttOutputOptions * outputOptions); NVTT_API int nvttEstimateSize(const NvttCompressor * compressor, const NvttInputOptions * inputOptions, const NvttCompressionOptions * compressionOptions); diff --git a/src/nvtt/squish/CMakeLists.txt b/src/nvtt/squish/CMakeLists.txt index 832013e1..65a5dd30 100644 --- a/src/nvtt/squish/CMakeLists.txt +++ b/src/nvtt/squish/CMakeLists.txt @@ -1,4 +1,4 @@ -PROJECT(squish) +PROJECT(nvsquish) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) @@ -20,16 +20,4 @@ SET(SQUISH_SRCS simd_sse.h simd_ve.h) -ADD_LIBRARY(squish STATIC ${SQUISH_SRCS}) - -IF(NOT WIN32) - - IF("${CMAKE_CXX_COMPILER}" MATCHES "clang(\\+\\+)?$" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - SET(CMAKE_COMPILER_IS_CLANGXX 1) - ENDIF() - - IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) - SET_TARGET_PROPERTIES(squish PROPERTIES COMPILE_FLAGS -fPIC) - ENDIF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) -ENDIF(NOT WIN32) - +ADD_LIBRARY(nvsquish STATIC ${SQUISH_SRCS}) diff --git a/src/nvtt/squish/simd_ve.h b/src/nvtt/squish/simd_ve.h index 5a11858f..dbffdec2 100644 --- a/src/nvtt/squish/simd_ve.h +++ b/src/nvtt/squish/simd_ve.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Copyright (c) 2006 Simon Brown si@sjbrown.co.uk - Copyright (c) 2016 Raptor Engineering, LLC + Copyright (c) 2016 - 2018 Raptor Engineering, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ #ifndef SQUISH_SIMD_VE_H #define SQUISH_SIMD_VE_H -#ifndef __APPLE_ALTIVEC__ +#if !defined(__APPLE_ALTIVEC__) || defined(__PPC64__) #include #undef bool #endif diff --git a/src/nvtt/tests/CMakeLists.txt b/src/nvtt/tests/CMakeLists.txt index 4a3a6def..8b56d23b 100644 --- a/src/nvtt/tests/CMakeLists.txt +++ b/src/nvtt/tests/CMakeLists.txt @@ -28,6 +28,9 @@ TARGET_LINK_LIBRARIES(cubemaptest nvcore nvmath nvimage nvtt) ADD_EXECUTABLE(nvhdrtest hdrtest.cpp) TARGET_LINK_LIBRARIES(nvhdrtest nvcore nvimage nvtt bc6h nvmath) +#ADD_EXECUTABLE(bc1enc bc1enc.cpp) +#TARGET_LINK_LIBRARIES(bc1enc nvcore nvimage nvmath squish CMP_Core) + INSTALL(TARGETS nvtestsuite nvhdrtest DESTINATION bin) #include_directories("/usr/include/ffmpeg/") diff --git a/src/nvtt/tests/bc1enc.cpp b/src/nvtt/tests/bc1enc.cpp new file mode 100644 index 00000000..51257848 --- /dev/null +++ b/src/nvtt/tests/bc1enc.cpp @@ -0,0 +1,1009 @@ + +#define _CRT_SECURE_NO_WARNINGS +#include + +//#define STBI_ASSERT(x) +#define STB_IMAGE_IMPLEMENTATION +#include "stb_image.h" + +#define STB_IMAGE_WRITE_IMPLEMENTATION +#include "stb_image_write.h" + +#define STB_DXT_IMPLEMENTATION +#include "stb_dxt.h" + +#define RGBCX_IMPLEMENTATION +#include "../extern/rg/rgbcx.h" + +#define ICBC_IMPLEMENTATION +#include "nvtt/icbc.h" + +#define ICETC_IMPLEMENTATION +#include "nvtt/icetc.h" + +//#define GOOFYTC_IMPLEMENTATION +//#include "../extern/goofy_tc.h" + +#include "../extern/rg_etc1_v104/rg_etc1.h" +#include "../extern/rg_etc1_v104/rg_etc1.cpp" + + + +#include "../extern/libsquish-1.15/squish.h" + +#include "../extern/CMP_Core/source/CMP_Core.h" + +#include "nvmath/Vector.inl" +#include "nvmath/Color.h" + +#include "nvcore/Timer.h" +#include "nvcore/Array.inl" + +using namespace nv; + +typedef unsigned char u8; +typedef unsigned int u32; + + +#define TEST_STB 0 +#define TEST_STB_HQ 0 + +#define TEST_GOOFY 0 + +#define TEST_RGBCX_FAST 0 // Level 0-3 +#define TEST_RGBCX_ALL 0 + +#define TEST_ICBC_FAST 1 +#define TEST_ICBC 0 +#define TEST_ICBC_HQ 0 +#define TEST_ICBC_ALL 0 + +#define TEST_IC_ETC 0 +#define TEST_RG_ETC 0 + +#define TEST_SQUISH 1 +#define TEST_SQUISH_HQ 0 + +#define TEST_AMD_CMP 1 + + + + +// Returns mse. +float evaluate_dxt1_mse(uint8 * rgba, uint8 * block, int block_count, icbc::Decoder decoder = icbc::Decoder_D3D10) { + double total = 0.0f; + for (int b = 0; b < block_count; b++) { + total += icbc::evaluate_dxt1_error(rgba, block, decoder); + rgba += 4 * 4 * 4; + block += 8; + } + return float(total / (16 * block_count)); +} + +float evaluate_etc2_mse(uint8 * rgba, uint8 * block, int block_count) { + double total = 0.0f; + for (int b = 0; b < block_count; b++) { + total += icetc::evaluate_etc2_error(rgba, block); + rgba += 4 * 4 * 4; + block += 8; + } + return float(total / (16 * block_count)); +} + + +#define MAKEFOURCC(str) (uint(str[0]) | (uint(str[1]) << 8) | (uint(str[2]) << 16) | (uint(str[3]) << 24 )) + + +bool output_dxt_dds (u32 w, u32 h, const u8* data, const char * filename) { + + const u32 DDSD_CAPS = 0x00000001; + const u32 DDSD_PIXELFORMAT = 0x00001000; + const u32 DDSD_WIDTH = 0x00000004; + const u32 DDSD_HEIGHT = 0x00000002; + const u32 DDSD_LINEARSIZE = 0x00080000; + const u32 DDPF_FOURCC = 0x00000004; + const u32 DDSCAPS_TEXTURE = 0x00001000; + + struct DDS { + u32 fourcc = MAKEFOURCC("DDS "); + u32 size = 124; + u32 flags = DDSD_CAPS|DDSD_PIXELFORMAT|DDSD_WIDTH|DDSD_HEIGHT|DDSD_LINEARSIZE; + u32 height; + u32 width; + u32 pitch; + u32 depth; + u32 mipmapcount; + u32 reserved [11]; + struct { + u32 size = 32; + u32 flags = DDPF_FOURCC; + u32 fourcc = MAKEFOURCC("DXT1"); + u32 bitcount; + u32 rmask; + u32 gmask; + u32 bmask; + u32 amask; + } pf; + struct { + u32 caps1 = DDSCAPS_TEXTURE; + u32 caps2; + u32 caps3; + u32 caps4; + } caps; + u32 notused; + } dds; + static_assert(sizeof(DDS) == 128, "DDS size must be 128"); + + dds.width = w; + dds.height = h; + dds.pitch = 8 * (((w+3)/4) * ((h+3)/4)); // linear size + + FILE * fp = fopen(filename, "wb"); + if (fp == nullptr) return false; + + // Write header: + fwrite(&dds, sizeof(dds), 1, fp); + + // Write dxt data: + fwrite(data, dds.pitch, 1, fp); + + fclose(fp); + + return true; +} + +bool output_etc(u32 bw, u32 bh, const u8* block_data, const char *filename) { + + u8 * rgba_data = (u8 *)malloc(bw * bh * 4); + + for (u32 by = 0; by < bh; by += 4) { + for (u32 bx = 0; bx < bw; bx += 4) { + + u8 rgba_block[64]; + icetc::decompress_etc(block_data, rgba_block); + + block_data += 8; + + for (u32 y = 0; y < 4; y++) { + for (u32 x = 0; x < 4; x++) { + u32 idx = ((by + y) * bw + (bx + x)) * 4; + rgba_data[idx + 0] = rgba_block[4 * (4 * y + x) + 0]; + rgba_data[idx + 1] = rgba_block[4 * (4 * y + x) + 1]; + rgba_data[idx + 2] = rgba_block[4 * (4 * y + x) + 2]; + rgba_data[idx + 3] = rgba_block[4 * (4 * y + x) + 3]; + } + } + } + } + + return stbi_write_png(filename, bw, bh, 4, rgba_data, bw * 4) != 0; +} + + +struct Stats { + const char * compressorName; + Array mseArray; + Array timeArray; +}; + + +bool test_bc1(const char * inputFileName, int index, Stats * stats) { + + int w, h, n; + unsigned char *input_data = stbi_load(inputFileName, &w, &h, &n, 4); + defer { stbi_image_free(input_data); }; + + if (input_data == nullptr) { + printf("Failed to load input image '%s'.\n", inputFileName); + return false; + } + + + int block_count = (w / 4) * (h / 4); + u8 * rgba_block_data = (u8 *)malloc(block_count * 4 * 4 * 4); + defer { free(rgba_block_data); }; + + int bw = 4 * (w / 4); // Round down. + int bh = 4 * (h / 4); + + // Convert to block layout. + for (int y = 0, b = 0; y < bh; y += 4) { + for (int x = 0; x < bw; x += 4, b++) { + for (int yy = 0; yy < 4; yy++) { + for (int xx = 0; xx < 4; xx++) { + if (x + xx < w && y + yy < h) { + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 0] = input_data[((y + yy) * w + x + xx) * 4 + 0]; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 1] = input_data[((y + yy) * w + x + xx) * 4 + 1]; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 2] = input_data[((y + yy) * w + x + xx) * 4 + 2]; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 3] = input_data[((y + yy) * w + x + xx) * 4 + 3]; + } + else { + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 0] = 0; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 1] = 0; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 2] = 0; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 3] = 0; + } + } + } + } + } + + u8 * block_data = (u8 *)malloc(block_count * 8); + + Timer timer; + + // Warmup. + for (int b = 0; b < block_count; b++) { + stb_compress_dxt_block(block_data + b * 8, rgba_block_data + b * 4 * 4 * 4, 0, STB_DXT_NORMAL); + } + +#if _DEBUG + const int repeat_count = 1; +#else + const int repeat_count = 1; // 8 +#endif + + if (TEST_STB) { + memset(block_data, 0, block_count * 8); + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + stb_compress_dxt_block(block_data + b * 8, rgba_block_data + b * 4 * 4 * 4, 0, STB_DXT_NORMAL); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "stb"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "stb_dxt.dds"); + } + } + + if (TEST_STB_HQ) { + memset(block_data, 0, block_count * 8); + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + stb_compress_dxt_block(block_data + b * 8, rgba_block_data + b * 4 * 4 * 4, 0, STB_DXT_HIGHQUAL); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "stb-hq"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "stb_dxt_hq.dds"); + } + } + + if (TEST_GOOFY) { + memset(block_data, 0, block_count * 8); + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + goofy::compressDXT1(block_data, input_data, w, h, w * 4); + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "goofy-dxt"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "goofy_dxt.dds"); + } + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + goofy::compressETC1(block_data, input_data, w, h, w * 4); + } + timer.stop(); + + mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "goofy-etc"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_etc(bw, bh, block_data, "goofy_etc.png"); + } + } + + if (TEST_RGBCX_FAST) { + memset(block_data, 0, block_count * 8); + + rgbcx::init(); + + for (int l = 0; l < 4; l++) { + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + rgbcx::encode_bc1(l, (block_data + b * 8), rgba_block_data + b * 4 * 4 * 4, /*allow_3color=*/true, /*use_transparent_texels_for_black=*/true); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "rgbcx"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "rgbcx.dds"); + } + } + } + + if (TEST_RGBCX_ALL) { + memset(block_data, 0, block_count * 8); + + rgbcx::init(); + + for (int l = 0; l < 19; l++) { + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + rgbcx::encode_bc1(l, (block_data + b * 8), rgba_block_data + b * 4 * 4 * 4, /*allow_3color=*/true, /*use_transparent_texels_for_black=*/true); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "rgbcx"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "rgbcx.dds"); + } + } + } + + bool three_color_mode = true; + bool three_color_black = true; + + if (TEST_ICBC_FAST) { + memset(block_data, 0, block_count * 8); + float color_weights[3] = { 1, 1, 1 }; + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + float input_colors[16*4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4*j+0] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 0] / 255.0f; + input_colors[4*j+1] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 1] / 255.0f; + input_colors[4*j+2] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 2] / 255.0f; + input_colors[4*j+3] = 1.0f; + input_weights[j] = 1.0f; + } + + icbc::compress_dxt1(icbc::Quality_Fast, input_colors, input_weights, color_weights, three_color_mode, three_color_black, (block_data + b * 8)); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "icbc-fast"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "icbc_fast.dds"); + } + } + + if (TEST_ICBC) { + memset(block_data, 0, block_count * 8); + float color_weights[3] = { 1, 1, 1 }; + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + float input_colors[16*4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4*j+0] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 0] / 255.0f; + input_colors[4*j+1] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 1] / 255.0f; + input_colors[4*j+2] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 2] / 255.0f; + input_colors[4*j+3] = 1.0f; + input_weights[j] = 1.0f; + } + + icbc::compress_dxt1(icbc::Quality_Default, input_colors, input_weights, color_weights, three_color_mode, three_color_black, (block_data + b * 8)); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "icbc"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "icbc.dds"); + } + } + + if (TEST_ICBC_HQ) { + memset(block_data, 0, block_count * 8); + float color_weights[3] = { 1, 1, 1 }; + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + float input_colors[16 * 4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4 * j + 0] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 0] / 255.0f; + input_colors[4 * j + 1] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 1] / 255.0f; + input_colors[4 * j + 2] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 2] / 255.0f; + input_colors[4 * j + 3] = 1.0f; + input_weights[j] = 1.0f; + } + + icbc::compress_dxt1(icbc::Quality_Max, input_colors, input_weights, color_weights, three_color_mode, three_color_black, (block_data + b * 8)); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "icbc-hq"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "icbc_hq.dds"); + } + } + + if (TEST_ICBC_ALL) { + memset(block_data, 0, block_count * 8); + float color_weights[3] = { 1, 1, 1 }; + + for (int l = 0; l <= icbc::Quality_Max; l++) { + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + float input_colors[16 * 4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4 * j + 0] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 0] / 255.0f; + input_colors[4 * j + 1] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 1] / 255.0f; + input_colors[4 * j + 2] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 2] / 255.0f; + input_colors[4 * j + 3] = 1.0f; + input_weights[j] = 1.0f; + } + + icbc::compress_dxt1((icbc::Quality)l, input_colors, input_weights, color_weights, true, true, (block_data + b * 8)); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "icbc"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "icbc.dds"); + } + } + } + + if (TEST_IC_ETC) { + memset(block_data, 0, block_count * 8); + float color_weights[3] = { 1, 1, 1 }; + + //int b_stop = (1132 / 4) * (bw / 4) + 1028 / 4; + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + float input_colors[16 * 4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4 * j + 0] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 0] / 255.0f; + input_colors[4 * j + 1] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 1] / 255.0f; + input_colors[4 * j + 2] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 2] / 255.0f; + input_colors[4 * j + 3] = 1.0f; + input_weights[j] = 1.0f; + } + + icetc::compress_etc2(input_colors, input_weights, color_weights, (block_data + b * 8)); + } + } + timer.stop(); + + float mse = evaluate_etc2_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "ic_etc"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_etc(bw, bh, block_data, "ic_etc.png"); + } + } + + if (TEST_RG_ETC) { + memset(block_data, 0, block_count * 8); + float color_weights[3] = { 1, 1, 1 }; + + rg_etc1::etc1_pack_params pack_params; + pack_params.m_quality = rg_etc1::cLowQuality; + //pack_params.m_quality = rg_etc1::cMediumQuality; + //pack_params.m_quality = rg_etc1::cHighQuality; + + //int b_stop = (1132 / 4) * (bw / 4) + 1028 / 4; + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + float input_colors[16 * 4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4 * j + 0] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 0] / 255.0f; + input_colors[4 * j + 1] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 1] / 255.0f; + input_colors[4 * j + 2] = rgba_block_data[b * 4 * 4 * 4 + j * 4 + 2] / 255.0f; + input_colors[4 * j + 3] = 1.0f; + input_weights[j] = 1.0f; + } + + rg_etc1::pack_etc1_block((block_data + b * 8), (const uint*)rgba_block_data + b * 4 * 4, pack_params); + } + } + timer.stop(); + + float mse = evaluate_etc2_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "rg_etc"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_etc(bw, bh, block_data, "rg_etc.png"); + } + } + + if (TEST_SQUISH) { + memset(block_data, 0, block_count * 8); + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + squish::Compress(rgba_block_data + b * 4 * 4 * 4, block_data + b * 8, squish::kDxt1); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "squish"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "squish.dds"); + } + } + + if (TEST_SQUISH_HQ) { + memset(block_data, 0, block_count * 8); + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + squish::Compress(rgba_block_data + b * 4 * 4 * 4, block_data + b * 8, squish::kDxt1 | squish::kColourIterativeClusterFit); + } + } + timer.stop(); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "squish-hq"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "squish_hq.dds"); + } + } + + if (TEST_AMD_CMP) { + memset(block_data, 0, block_count * 8); + + void *options; + CreateOptionsBC1(&options); + SetQualityBC1(options, 1.0); // It seems AMD has only two compressors for 0.0 and 1.0 values. + + timer.start(); + for (int i = 0; i < repeat_count; i++) { + for (int b = 0; b < block_count; b++) { + CompressBlockBC1(rgba_block_data + b * 4 * 4 * 4, 16, block_data + b * 8, options); + } + } + timer.stop(); + + DestroyOptionsBC1(options); + + float mse = evaluate_dxt1_mse(rgba_block_data, block_data, block_count); + + if (stats) { + stats->compressorName = "cmp"; + stats->mseArray[index] = mse; + stats->timeArray[index] = timer.elapsed() / repeat_count; + stats++; + } + else { + output_dxt_dds(bw, bh, block_data, "squish.dds"); + } + } + + return false; +} + + + +bool analyze_bc1(const char * inputFileName) { + + int w, h, n; + unsigned char *input_data = stbi_load(inputFileName, &w, &h, &n, 4); + defer { stbi_image_free(input_data); }; + + if (input_data == nullptr) { + printf("Failed to load input image '%s'.\n", inputFileName); + return false; + } + + int block_count = (w / 4) * (h / 4); + u8 * rgba_block_data = (u8 *)malloc(block_count * 4 * 4 * 4); + defer { free(rgba_block_data); }; + + int bw = 4 * (w / 4); // Round down. + int bh = 4 * (h / 4); + + // Convert to block layout. + for (int y = 0, b = 0; y < bh; y += 4) { + for (int x = 0; x < bw; x += 4, b++) { + for (int yy = 0; yy < 4; yy++) { + for (int xx = 0; xx < 4; xx++) { + if (x + xx < w && y + yy < h) { + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 0] = input_data[((y + yy) * w + x + xx) * 4 + 0]; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 1] = input_data[((y + yy) * w + x + xx) * 4 + 1]; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 2] = input_data[((y + yy) * w + x + xx) * 4 + 2]; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 3] = input_data[((y + yy) * w + x + xx) * 4 + 3]; + } + else { + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 0] = 0; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 1] = 0; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 2] = 0; + rgba_block_data[b * 4 * 4 * 4 + (yy * 4 + xx) * 4 + 3] = 0; + } + } + } + } + } + + u8 * block_data = (u8 *)malloc(block_count * 8); + memset(block_data, 0, block_count * 8); + + Timer timer; + + int stb_better_than_icbc_fast = 0; + int stb_better_than_icbc = 0; + int stb_better_than_icbc_hq = 0; + int squish_better_than_icbc_hq = 0; + + int icbc_hq_wins = 0; + + int this_should_never_happen = 0; + + float color_weights[3] = { 1, 1, 1 }; + + for (int b = 0; b < block_count; b++) { + + uint8 * rgba_block = rgba_block_data + b * 4 * 4 * 4; + uint8 * dxt_block = block_data + b * 8; + + float input_colors[16*4]; + float input_weights[16]; + for (int j = 0; j < 16; j++) { + input_colors[4*j+0] = rgba_block[j * 4 + 0] / 255.0f; + input_colors[4*j+1] = rgba_block[j * 4 + 1] / 255.0f; + input_colors[4*j+2] = rgba_block[j * 4 + 2] / 255.0f; + input_colors[4*j+3] = 255.0f; + input_weights[j] = 1.0f; + } + + // Compare all the different modes on the same block: + + stb_compress_dxt_block(dxt_block, rgba_block, 0, STB_DXT_NORMAL); + float mse_stb = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + stb_compress_dxt_block(dxt_block, rgba_block, 0, STB_DXT_HIGHQUAL); + float mse_stb_hq = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + icbc::compress_dxt1(icbc::Quality_Fast, input_colors, input_weights, color_weights, true, true, dxt_block); + float mse_icbc_fast = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + icbc::compress_dxt1(icbc::Quality_Default, input_colors, input_weights, color_weights, true, true, dxt_block); + float mse_icbc = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + icbc::compress_dxt1(icbc::Quality_Max, input_colors, input_weights, color_weights, true, true, dxt_block); + float mse_icbc_hq = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + squish::Compress(rgba_block, dxt_block, squish::kDxt1); + float mse_squish = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + squish::Compress(rgba_block, dxt_block, squish::kDxt1 | squish::kColourIterativeClusterFit); + float mse_squish_hq = icbc::evaluate_dxt1_error(rgba_block, dxt_block); + + if (mse_stb < mse_icbc_fast) { + stb_better_than_icbc_fast++; + } + if (mse_stb < mse_icbc) { + stb_better_than_icbc++; + } + if (mse_stb < mse_icbc_hq) { + stb_better_than_icbc_hq++; + } + if (mse_icbc_hq < mse_icbc) { + icbc_hq_wins++; + } + if (mse_squish < mse_icbc_hq) { + squish_better_than_icbc_hq++; + } + if (mse_icbc_fast < mse_icbc_hq) { + this_should_never_happen++; + } + } + + return true; +} + + + +static float mse_to_psnr(float mse) { + float rms = sqrtf(mse); + float psnr = rms ? (float)clamp(log10(255.0 / rms) * 20.0, 0.0, 300.0) : 1e+10f; + return psnr; +} + + +const char * image_set[] = { + "testsuite/kodak/kodim01.png", + "testsuite/kodak/kodim02.png", + "testsuite/kodak/kodim03.png", + "testsuite/kodak/kodim04.png", + "testsuite/kodak/kodim05.png", + "testsuite/kodak/kodim06.png", + "testsuite/kodak/kodim07.png", + "testsuite/kodak/kodim08.png", + "testsuite/kodak/kodim09.png", + "testsuite/kodak/kodim10.png", + "testsuite/kodak/kodim11.png", + "testsuite/kodak/kodim12.png", + "testsuite/kodak/kodim13.png", + "testsuite/kodak/kodim14.png", + "testsuite/kodak/kodim15.png", + "testsuite/kodak/kodim16.png", + "testsuite/kodak/kodim17.png", + "testsuite/kodak/kodim18.png", + "testsuite/kodak/kodim19.png", + "testsuite/kodak/kodim20.png", + "testsuite/kodak/kodim21.png", + "testsuite/kodak/kodim22.png", + "testsuite/kodak/kodim23.png", + "testsuite/kodak/kodim24.png", + "testsuite/waterloo/clegg.png", + "testsuite/waterloo/frymire.png", + "testsuite/waterloo/lena.png", + "testsuite/waterloo/monarch.png", + "testsuite/waterloo/peppers.png", + "testsuite/waterloo/sail.png", + "testsuite/waterloo/serrano.png", + "testsuite/waterloo/tulips.png", + //"testsuite/artificial.png", +}; + +const char * roblox_set[] = { + "Roblox/asphalt_side/diffuse.tga", + "Roblox/asphalt_top/diffuse.tga", + "Roblox/basalt/diffuse.tga", + "Roblox/brick/diffuse.tga", + "Roblox/cobblestone_side/diffuse.tga", + "Roblox/cobblestone_top/diffuse.tga", + "Roblox/concrete_side/diffuse.tga", + "Roblox/concrete_top/diffuse.tga", + "Roblox/crackedlava/diffuse.tga", + "Roblox/glacier_bottom/diffuse.tga", + "Roblox/glacier_side/diffuse.tga", + "Roblox/glacier_top/diffuse.tga", + "Roblox/grass_bottom/diffuse.tga", + "Roblox/grass_side/diffuse.tga", + "Roblox/grass_top/diffuse.tga", + "Roblox/ground/diffuse.tga", + "Roblox/ice_side/diffuse.tga", + "Roblox/ice_top/diffuse.tga", + "Roblox/leafygrass_side/diffuse.tga", + "Roblox/leafygrass_top/diffuse.tga", + "Roblox/limestone_side/diffuse.tga", + "Roblox/limestone_top/diffuse.tga", + "Roblox/mud/diffuse.tga", + "Roblox/pavement_side/diffuse.tga", + "Roblox/pavement_top/diffuse.tga", + "Roblox/rock/diffuse.tga", + "Roblox/salt_side/diffuse.tga", + "Roblox/salt_top/diffuse.tga", + "Roblox/sand_side/diffuse.tga", + "Roblox/sand_top/diffuse.tga", + "Roblox/sandstone_bottom/diffuse.tga", + "Roblox/sandstone_side/diffuse.tga", + "Roblox/sandstone_top/diffuse.tga", + "Roblox/slate/diffuse.tga", + "Roblox/snow/diffuse.tga", + "Roblox/woodplanks/diffuse.tga", +}; + + +int main(int argc, char *argv[]) +{ + //const char * inputFileName = "testsuite/artificial.png"; + //const char * inputFileName = "testsuite/kodak/kodim14.png"; + const char * inputFileName = "testsuite/kodak/kodim18.png"; + //const char * inputFileName = "testsuite/kodak/kodim15.png"; + //const char * inputFileName = "testsuite/waterloo/frymire.png"; + //const char * inputFileName = "Roblox/leafygrass_top/diffuse.tga"; + + icbc::init_dxt1(); + icetc::init(); + rgbcx::init(); + rg_etc1::pack_etc1_block_init(); + + //test_bc1(inputFileName, 0, NULL); + //analyze_bc1(inputFileName); + + //const char ** set = roblox_set; + //int count = sizeof(roblox_set) / sizeof(char*); + + const char ** set = image_set; + int count = sizeof(image_set) / sizeof(char*); + + const int MAX_COMPRESSOR_COUNT = 64; + Stats stats[MAX_COMPRESSOR_COUNT]; + + for (int i = 0; i < MAX_COMPRESSOR_COUNT; i++) { + stats[i].compressorName = nullptr; + stats[i].mseArray.resize(count, 0.0f); + stats[i].timeArray.resize(count, 0.0f); + } + + for (int i = 0; i < count; i++) { + printf("\nImage '%s'\n", set[i]); + + test_bc1(set[i], i, stats); + + for (int c = 0; c < MAX_COMPRESSOR_COUNT; c++) { + if (stats[c].compressorName) { + printf("%-16s %f\t%f\t%f\n", stats[c].compressorName, sqrtf(stats[c].mseArray[i]), mse_to_psnr(stats[c].mseArray[i]), stats[c].timeArray[i]); + } + } + } + + // Print stats. + printf("\nAverage Results:\n"); + for (int c = 0; c < MAX_COMPRESSOR_COUNT; c++) { + if (stats[c].compressorName) { + float sum = 0.0f; + for (float it : stats[c].mseArray) { + sum += it; + } + sum /= count; + + float time = 0.0f; + for (float it : stats[c].timeArray) { + time += it; + } + + printf("%-16s %f\t%f\t%f\n", stats[c].compressorName, sqrtf(sum), mse_to_psnr(sum), time); + } + } + + for (int i = 0; i < 16; i++) { + printf("%d, ", icbc::s_fourClusterTotal[i]); + } + printf("\n"); + + for (int i = 0; i < 16; i++) { + printf("%d, ", icbc::s_threeClusterTotal[i]); + } + printf("\n\n"); + + /* + for (int i = 0; i < 968; i++) { + printf("%lld, ", icbc::s_fourClusterHistogram[i]); + } printf("\n\n"); + + for (int i = 0; i < 968; i++) { + printf("%d, ", icbc::s_fourCluster[i].c0); + } printf("\n\n"); + + for (int i = 0; i < 968; i++) { + printf("%d, ", icbc::s_fourCluster[i].c1 - icbc::s_fourCluster[i].c0); + } printf("\n\n"); + + for (int i = 0; i < 968; i++) { + printf("%d, ", icbc::s_fourCluster[i].c2 - icbc::s_fourCluster[i].c1); + } + */ + printf("\n"); + + + /*for (int c = 0; c < MAX_COMPRESSOR_COUNT; c++) { + if (stats[c].compressorName) { + printf("%s:\n", stats[c].compressorName); + for (int i = 0; i < count; i++) { + printf("%f, ", mse_to_psnr(stats[c].mseArray[i])); + } + puts("\n"); + + for (int i = 0; i < count; i++) { + printf("%f, ", stats[c].timeArray[i]); + } + puts("\n"); + } + }*/ + + + return EXIT_SUCCESS; +} diff --git a/src/nvtt/tests/testsuite.cpp b/src/nvtt/tests/testsuite.cpp index 652dcfc0..06ab9d10 100644 --- a/src/nvtt/tests/testsuite.cpp +++ b/src/nvtt/tests/testsuite.cpp @@ -200,6 +200,8 @@ enum Mode { Mode_ETC1_EtcLib, Mode_ETC2_EtcLib, Mode_ETC1_RgEtc, + Mode_ETC1_Intel, + Mode_ETC1_Ericson, Mode_ETC2_RGBM, Mode_PVR, Mode_Count @@ -226,6 +228,8 @@ static const char * s_modeNames[] = { "ETC1-EtcLib", "ETC2-EtcLib", "ETC1-RgEtc", + "ETC1-Intel", + "ETC1-Ericson", "ETC2-RGBM", "PVR", }; @@ -505,6 +509,9 @@ int main(int argc, char *argv[]) nvtt::Context context; context.enableCudaAcceleration(!nocuda); + if (basePath.length() > 0) { + basePath.appendSeparator(); + } basePath.append(set.basePath); FileSystem::changeDirectory(basePath.str()); @@ -666,6 +673,16 @@ int main(int argc, char *argv[]) format = nvtt::Format_ETC1; compressor_name = "rg_etc"; } + else if (mode == Mode_ETC1_Ericson) + { + format = nvtt::Format_ETC1; + compressor_name = "etcpack"; + } + else if (mode == Mode_ETC1_Intel) + { + format = nvtt::Format_ETC1; + compressor_name = "intel"; + } else if (mode == Mode_ETC2_RGBM) { format = nvtt::Format_ETC2_RGBM; diff --git a/src/nvtt/tools/assemble.cpp b/src/nvtt/tools/assemble.cpp index de4ca648..6348255c 100644 --- a/src/nvtt/tools/assemble.cpp +++ b/src/nvtt/tools/assemble.cpp @@ -143,16 +143,16 @@ int main(int argc, char *argv[]) if (i == 0) { - w = images[i].width(); - h = images[i].height(); + w = images[i].width; + h = images[i].height; } - else if (images[i].width() != w || images[i].height() != h) + else if (images[i].width != w || images[i].height != h) { printf("*** error, size of image '%s' does not match\n", files[i].str()); return 1; } - if (images[i].format() == nv::Image::Format_ARGB) + if (images[i].format == nv::Image::Format_ARGB) { hasAlpha = true; } diff --git a/src/nvtt/tools/compress.cpp b/src/nvtt/tools/compress.cpp index 36142f10..1f321104 100644 --- a/src/nvtt/tools/compress.cpp +++ b/src/nvtt/tools/compress.cpp @@ -506,8 +506,8 @@ int main(int argc, char *argv[]) if (nv::strCaseDiff(input.extension(), ".dds") == 0) { // Load surface. - nv::DirectDrawSurface dds(input.str()); - if (!dds.isValid()) + nv::DirectDrawSurface dds; + if (!dds.load(input.str()) || !dds.isValid()) { fprintf(stderr, "The file '%s' is not a valid DDS file.\n", input.str()); return EXIT_FAILURE; @@ -550,9 +550,8 @@ int main(int argc, char *argv[]) { for (uint m = 0; m < mipmapCount; m++) { - dds.mipmap(&mipmap, f, m); // @@ Load as float. - - inputOptions.setMipmapData(mipmap.pixels(), mipmap.width(), mipmap.height(), mipmap.depth(), f, m); + if (imageFromDDS(&mipmap, dds, f, m)) // @@ Load as float. + inputOptions.setMipmapData(mipmap.pixels(), mipmap.width, mipmap.height, mipmap.depth, f, m); } } } @@ -591,8 +590,8 @@ int main(int argc, char *argv[]) return 1; } - inputOptions.setTextureLayout(nvtt::TextureType_2D, image.width(), image.height()); - inputOptions.setMipmapData(image.pixels(), image.width(), image.height()); + inputOptions.setTextureLayout(nvtt::TextureType_2D, image.width, image.height); + inputOptions.setMipmapData(image.pixels(), image.width, image.height); } } diff --git a/src/nvtt/tools/ddsinfo.cpp b/src/nvtt/tools/ddsinfo.cpp index 83a47c6a..d2f1a5ba 100644 --- a/src/nvtt/tools/ddsinfo.cpp +++ b/src/nvtt/tools/ddsinfo.cpp @@ -43,8 +43,8 @@ int main(int argc, char *argv[]) } // Load surface. - nv::DirectDrawSurface dds(argv[1]); - if (!dds.isValid()) + nv::DirectDrawSurface dds; + if (!dds.load(argv[1]) || !dds.isValid()) { printf("The file '%s' is not a valid DDS file.\n", argv[1]); return 1; diff --git a/src/nvtt/tools/decompress.cpp b/src/nvtt/tools/decompress.cpp index a5d592f2..c2a694be 100644 --- a/src/nvtt/tools/decompress.cpp +++ b/src/nvtt/tools/decompress.cpp @@ -166,8 +166,8 @@ int main(int argc, char *argv[]) // Load surface. // !!! DirectDrawSurface API doesn't support float images, so BC6 will be converted to 8-bit on load. // Should use nvtt::Surface instead. - nv::DirectDrawSurface dds(input.str()); - if (!dds.isValid()) + nv::DirectDrawSurface dds; + if (!dds.load(input.str()) || !dds.isValid()) { fprintf(stderr, "The file '%s' is not a valid DDS file.\n", input.str()); return 1; @@ -219,7 +219,8 @@ int main(int argc, char *argv[]) { for (uint m = 0; m < mipmapCount; m++) { - dds.mipmap(&mipmap, f, m); + if (!imageFromDDS(&mipmap, dds, f, m)) + continue; // set output filename, if we are doing faces and/or mipmaps name.copy(output); diff --git a/src/nvtt/tools/imgdiff.cpp b/src/nvtt/tools/imgdiff.cpp index 3dd5eca5..3bbc03f1 100644 --- a/src/nvtt/tools/imgdiff.cpp +++ b/src/nvtt/tools/imgdiff.cpp @@ -290,17 +290,18 @@ int main(int argc, char *argv[]) // key_value = 0.22 // min_luminance = 0.1 -> exposure = 2.2 // max_luminance = 1.0 -> exposure = 0.22 - + + /* float rmse0 = nvtt::rmsToneMappedError(image0, image1, 2.2f); float rmse1 = nvtt::rmsToneMappedError(image0, image1, 1.0f); float rmse2 = nvtt::rmsToneMappedError(image0, image1, 0.22f); printf("RMSE = %.5f %.5f %.5f -> %.5f | %.5f\n", rmse0, rmse1, rmse2, (rmse0 + rmse1 + rmse2)/3, rmse); + */ - - //printf("MSE = %f\n", rmse * rmse); - //printf("RMSE = %f\n", rmse); - //printf("PSNR = %f\n", (rmse == 0) ? 999.0 : 20.0 * log10(255.0 / rmse)); + printf("MSE = %f\n", rmse * rmse); + printf("RMSE = %f\n", rmse); + printf("PSNR = %f\n", (rmse == 0) ? 999.0 : 20.0 * log10(255.0 / rmse)); if (compareNormal) { // @@ Does this assume normal maps are packed or unpacked? diff --git a/src/nvtt/tools/resize.cpp b/src/nvtt/tools/resize.cpp index c563c123..3660ed2f 100644 --- a/src/nvtt/tools/resize.cpp +++ b/src/nvtt/tools/resize.cpp @@ -42,14 +42,14 @@ static bool loadImage(nv::Image & image, const char * fileName) { if (nv::strCaseDiff(nv::Path::extension(fileName), ".dds") == 0) { - nv::DirectDrawSurface dds(fileName); - if (!dds.isValid()) + nv::DirectDrawSurface dds; + if (!dds.load(fileName) || !dds.isValid()) { printf("The file '%s' is not a valid DDS file.\n", fileName); return false; } - dds.mipmap(&image, 0, 0); // get first image + return imageFromDDS(&image, dds, 0, 0); // get first image } else { @@ -59,9 +59,9 @@ static bool loadImage(nv::Image & image, const char * fileName) printf("The file '%s' is not a supported image type.\n", fileName); return false; } + + return true; } - - return true; } @@ -174,10 +174,10 @@ int main(int argc, char *argv[]) fimage.toLinear(0, 3, gamma); #if 1 - nv::AutoPtr fresult(fimage.resize(*filter, uint(image.width() * scale), uint(image.height() * scale), wrapMode)); + nv::AutoPtr fresult(fimage.resize(*filter, uint(image.width * scale), uint(image.height * scale), wrapMode)); nv::AutoPtr result(fresult->createImageGammaCorrect(gamma)); - result->setFormat(nv::Image::Format_ARGB); + result->format = nv::Image::Format_ARGB; nv::StdOutputStream stream(output.str()); nv::ImageIO::save(output.str(), stream, result.ptr()); diff --git a/src/nvtt/tools/thumbnailer.cpp b/src/nvtt/tools/thumbnailer.cpp index b9fb4cfa..03d7b0f6 100644 --- a/src/nvtt/tools/thumbnailer.cpp +++ b/src/nvtt/tools/thumbnailer.cpp @@ -43,14 +43,14 @@ static bool loadImage(nv::Image & image, const char * fileName) { if (nv::strCaseDiff(nv::Path::extension(fileName), ".dds") == 0) { - nv::DirectDrawSurface dds(fileName); - if (!dds.isValid()) + nv::DirectDrawSurface dds; + if (!dds.load(fileName) || !dds.isValid()) { fprintf(stderr, "The file '%s' is not a valid DDS file.\n", fileName); return false; } - dds.mipmap(&image, 0, 0); // get first image + return imageFromDDS(&image, dds, 0, 0); // get first image } else { @@ -60,9 +60,9 @@ static bool loadImage(nv::Image & image, const char * fileName) fprintf(stderr, "The file '%s' is not a supported image type.\n", fileName); return false; } - } - return true; + return true; + } } @@ -119,9 +119,9 @@ int main(int argc, char *argv[]) if (!loadImage(image, input.str())) return 1; nv::StringBuilder widthString; - widthString.number(image.width()); + widthString.number(image.width); nv::StringBuilder heightString; - heightString.number(image.height()); + heightString.number(image.height); nv::Array metaData; metaData.append("Thumb::Image::Width"); @@ -131,26 +131,26 @@ int main(int argc, char *argv[]) metaData.append(NULL); metaData.append(NULL); - if ((image.width() > size) || (image.height() > size)) + if ((image.width > size) || (image.height > size)) { nv::FloatImage fimage(&image); fimage.toLinear(0, 3, gamma); uint thumbW, thumbH; - if (image.width() > image.height()) + if (image.width > image.height) { thumbW = size; - thumbH = uint ((float (image.height()) / float (image.width())) * size); + thumbH = uint ((float (image.height) / float (image.width)) * size); } else { - thumbW = uint ((float (image.width()) / float (image.height())) * size); + thumbW = uint ((float (image.width) / float (image.height)) * size); thumbH = size; } nv::AutoPtr fresult(fimage.resize(nv::BoxFilter(), thumbW, thumbH, nv::FloatImage::WrapMode_Clamp)); nv::AutoPtr result(fresult->createImageGammaCorrect(gamma)); - result->setFormat(nv::Image::Format_ARGB); + result->format = nv::Image::Format_ARGB; nv::StdOutputStream stream(output.str()); nv::ImageIO::save(output.str(), stream, result.ptr(), metaData.buffer());