├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── README.md ├── asset ├── encoder_preset │ ├── ame-12.0 │ │ ├── Hap Alpha-Only.epr │ │ ├── Hap Alpha.epr │ │ ├── Hap Q Alpha.epr │ │ ├── Hap Q.epr │ │ └── Hap.epr │ └── ame-13.0 │ │ ├── Hap Alpha-Only.epr │ │ ├── Hap Alpha.epr │ │ ├── Hap Q Alpha.epr │ │ ├── Hap Q.epr │ │ └── Hap.epr ├── hap-icon.png └── hap-logo.svg ├── codec ├── CMakeLists.txt ├── codec.cpp ├── codec.hpp ├── texture_converter.cpp └── texture_converter.hpp ├── doc └── user_guide │ ├── README.md │ ├── chunk-counts.png │ ├── codec-options.png │ ├── codec-quality.png │ ├── format-option.png │ └── media-encoder-presets.png ├── external ├── hap │ ├── CMakeLists.txt │ ├── hap.c │ └── hap.h ├── snappy │ ├── .appveyor.yml │ ├── .travis.yml │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── COPYING │ ├── NEWS │ ├── README.md │ ├── cmake │ │ ├── SnappyConfig.cmake │ │ └── config.h.in │ ├── format_description.txt │ ├── framing_format.txt │ ├── snappy-c.cc │ ├── snappy-c.h │ ├── snappy-internal.h │ ├── snappy-sinksource.cc │ ├── snappy-sinksource.h │ ├── snappy-stubs-internal.cc │ ├── snappy-stubs-internal.h │ ├── snappy-stubs-public.h.in │ ├── snappy-test.cc │ ├── snappy-test.h │ ├── snappy.cc │ ├── snappy.h │ ├── snappy_unittest.cc │ └── testdata │ │ ├── alice29.txt │ │ ├── asyoulik.txt │ │ ├── baddata1.snappy │ │ ├── baddata2.snappy │ │ ├── baddata3.snappy │ │ ├── fireworks.jpeg │ │ ├── geo.protodata │ │ ├── html │ │ ├── html_x_4 │ │ ├── kppkn.gtb │ │ ├── lcet10.txt │ │ ├── paper-100k.pdf │ │ ├── plrabn12.txt │ │ └── urls.10K ├── squish │ ├── README.md │ ├── squish-source │ │ ├── CMakeLists.txt │ │ ├── ChangeLog │ │ ├── Doxyfile │ │ ├── GNUmakefile │ │ ├── README │ │ ├── alpha.cpp │ │ ├── alpha.h │ │ ├── clusterfit.cpp │ │ ├── clusterfit.h │ │ ├── colourblock.cpp │ │ ├── colourblock.h │ │ ├── colourfit.cpp │ │ ├── colourfit.h │ │ ├── colourset.cpp │ │ ├── colourset.h │ │ ├── config │ │ ├── config.h │ │ ├── extra │ │ │ ├── squishgen.cpp │ │ │ ├── squishpng.cpp │ │ │ └── squishtest.cpp │ │ ├── libSquish.pro │ │ ├── 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 │ │ ├── sources.pro │ │ ├── squish.cpp │ │ ├── squish.h │ │ ├── vs7 │ │ │ ├── squish │ │ │ │ └── squish.vcproj │ │ │ ├── squishpng │ │ │ │ └── squishpng.vcproj │ │ │ └── squishtest │ │ │ │ └── squishtest.vcproj │ │ ├── vs8 │ │ │ ├── squish.sln │ │ │ ├── squish │ │ │ │ └── squish.vcproj │ │ │ ├── squishpng │ │ │ │ └── squishpng.vcproj │ │ │ └── squishtest │ │ │ │ └── squishtest.vcproj │ │ └── vs9 │ │ │ ├── squish.sln │ │ │ ├── squish │ │ │ └── squish.vcproj │ │ │ ├── squishpng │ │ │ └── squishpng.vcproj │ │ │ └── squishtest │ │ │ └── squishtest.vcproj │ ├── squish-windows │ │ ├── squish.vcxproj │ │ └── squish.vcxproj.filters │ └── squish.xcodeproj │ │ └── project.pbxproj └── ycocg │ ├── CMakeLists.txt │ ├── ImageMath.c │ ├── ImageMath.h │ ├── YCoCg.c │ ├── YCoCg.h │ ├── YCoCgDXT.cpp │ └── YCoCgDXT.h ├── installer ├── CodecInstaller.cmake ├── NSIS.template.in ├── ReadMe.txt └── preinstall └── license.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_store 2 | .DS_Store 3 | .vscode 4 | build/ 5 | external/adobe/premiere/ 6 | Release/ 7 | Debug/ 8 | Xcode/ 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/foundation"] 2 | path = external/foundation 3 | url = git@github.com:codec-foundation/adobe-cc.git 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR) 2 | 3 | 4 | # project-wide build settings that MUST BE SET PRIOR TO FIRST 'project' 5 | # ---------------------------- 6 | 7 | # macosx: release on Mojave and Catalina 8 | if(APPLE) 9 | set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") 10 | endif(APPLE) 11 | 12 | 13 | # project 14 | # ---------------------------- 15 | project(CodecPlugin) 16 | 17 | # foundation variables 18 | # ---------------------------- 19 | 20 | set(Foundation_IDENTIFIER_PREFIX org.hapcommunity.HapCodecPlugin) 21 | set(Foundation_CODEC_NAME HAP) 22 | set(Foundation_PRESETS 23 | "${CMAKE_CURRENT_SOURCE_DIR}/asset/encoder_preset/ame-12.0/Hap.epr" 24 | "${CMAKE_CURRENT_SOURCE_DIR}/asset/encoder_preset/ame-12.0/Hap Alpha.epr" 25 | "${CMAKE_CURRENT_SOURCE_DIR}/asset/encoder_preset/ame-12.0/Hap Alpha-Only.epr" 26 | "${CMAKE_CURRENT_SOURCE_DIR}/asset/encoder_preset/ame-12.0/Hap Q.epr" 27 | "${CMAKE_CURRENT_SOURCE_DIR}/asset/encoder_preset/ame-12.0/Hap Q Alpha.epr" 28 | ) 29 | set(Foundation_FILE_IMPORT_FOUR_CC 0x48415000L) # hex for HAP\0, needed as unique importer id so After Effects picks it up as an importer 30 | set(Foundation_CODEC_NAME_WITH_HEX_SIZE_PREFIX "\"\\x07HAP\\0\\0\\0\\0\"") # !!! hack - size must be 0x7 atm, and padded to 7-bytes- we're not using the recommended resource builder step that compiles the correct sizes around this 31 | 32 | # project-wide build settings 33 | # ---------------------------- 34 | 35 | # all platforms: group targets in IDEs 36 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 37 | 38 | if(MSVC) 39 | # add_compile_options(/arch:AVX2) 40 | # may want to use this for specific source files 41 | else() 42 | add_compile_options(-msse4.1) 43 | endif() 44 | 45 | set (CMAKE_CXX_STANDARD 17) 46 | 47 | # foundation interface to be populated 48 | # ---------------------------- 49 | 50 | # - externals needed by codec registration interface 51 | add_subdirectory(external/foundation/external) 52 | # - defines codec registration interface 53 | add_subdirectory(external/foundation/source/codec_registration) 54 | 55 | 56 | # codec-specific external libs 57 | # ---------------------------- 58 | 59 | set(SNAPPY_BUILD_TESTS FALSE) 60 | add_subdirectory(external/snappy) 61 | 62 | add_subdirectory(external/squish/squish-source) 63 | add_subdirectory(external/hap) 64 | add_subdirectory(external/ycocg) 65 | 66 | # codec implementation in its own library 67 | # ---------------------------- 68 | add_subdirectory(codec) 69 | 70 | # foundation plugins 71 | # ---------------------------- 72 | add_subdirectory(external/foundation) 73 | 74 | # codec installer information for foundation 75 | # ---------------------------- 76 | include(installer/CodecInstaller.cmake) 77 | 78 | # foundation installer framework 79 | # *** this must be last according to CPACK usage directions 80 | add_subdirectory(external/foundation/installer) 81 | 82 | # codec-specific components 83 | # must be added *after* CPACK usage in external/foundation/installer above 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](asset/hap-icon.png) 2 | 3 | # Hap Exporter for Adobe CC 4 | 5 | This is the community-supplied Hap and Hap Q exporter plugin for Adobe CC 2019 and Adobe CC 2020. 6 | 7 | HAP is a collection of high-performance codecs optimised for playback of multiple layers of video. 8 | 9 | Exporter plugins are provided for 10 | - Adobe Media Encoder 11 | - Adobe Premiere 12 | - Adobe After Effects 13 | 14 | Please see [license.txt](license.txt) for the licenses of this plugin and the components used to create it. 15 | 16 | ## Getting it 17 | 18 | An installer for the exporter can be downloaded [here](https://github.com/disguise-one/hap-encoder-adobe-cc/releases). 19 | 20 | ## Requirements 21 | 22 | This codec has been tested on Windows 10 and macOS Catalina. 23 | 24 | It has been tested in Adobe CC 2019 and Adobe CC 2020. 25 | 26 | ## Installation 27 | 28 | Run the provided installer. 29 | 30 | ## Usage 31 | 32 | ### Adobe Media Encoder and Adobe Premiere 33 | 34 | After installation, the encoders will be available as the 'HAP Video' format when exporting in Adobe Media Encoder or Adobe Premiere 35 | 36 | ![HAP format](doc/user_guide/format-option.png) 37 | 38 | After choosing the format, codec options may be chosen. 39 | 40 | ![HAP codec options](doc/user_guide/codec-options.png) 41 | 42 | Default presets are supplied and are available in Adobe Media Encoder. 43 | 44 | ![HAP presets](doc/user_guide/media-encoder-presets.png) 45 | 46 | Movies that are encoded with the plugin are exported into .mov files. 47 | 48 | ### Adobe After Effects 49 | 50 | The HAP codecs may be selected by choosing 'Quicktime HAP Format' on an output module. 51 | 52 | ### Choosing the right codec for the job: Hap, Hap Alpha, Hap Q and Hap Q Alpha 53 | 54 | There are four different flavors of HAP to choose from when encoding your clips. 55 | 56 | codec | properties 57 | ----------- | -------------------------------------------------------------------------------- 58 | Hap | lowest data-rate and reasonable image quality 59 | Hap Alpha | same image quality as Hap, and supports an Alpha channel 60 | Hap Q | improved image quality, at the expense of larger file sizes 61 | Hap Q Alpha | improved image quality and an Alpha channel, at the expense of larger file sizes 62 | 63 | ### Codec parameters 64 | For Hap and Hap Alpha codecs render time can be reduced with Quality-Fast option. It uses fast and simple algorithm, but with reduced image quality. 65 | 66 | - Fast suggested for draft renders, last-minute notebook renders, etc... 67 | - Normal is default option for general renders 68 | 69 | ![Hap quality option](doc/user_guide/codec-quality.png) 70 | 71 | An optional specified number of chunks size may be specified to optimize for ultra high resolution video on a particular hardware system. This setting should typically only be used if you are reaching a CPU performance bottleneck during playback. As a general guide, for HD footage or smaller you can set the chunk size to 1 and for 4k or larger footage the number of chunks should never exceed the number of CPU cores on the computer used for playback. 72 | 73 | ![HAP chunk counts](doc/user_guide/chunk-counts.png) 74 | 75 | At present, 'auto' corresponds to choosing 1 chunk per texture; this may change in the future. 76 | 77 | 78 | ## What is HAP 79 | 80 | HAP is a collection of high-performance codecs optimised for playback of multiple layers of video. 81 | 82 | HAP prioritises decode-speed, efficient upload to GPUs and GPU-side decoding to enable the highest amount of video content to be played back at once on modern hardware. 83 | 84 | Please see 85 | 86 | [http://hap.video/](http://hap.video/) 87 | 88 | for details. 89 | 90 | ## Known issues 91 | 92 | Performing multiple parallel exports in Media Encoder may cause the system to become unresponsive, although the operation should eventually complete. 93 | 94 | The plugin does not work in After Effects CC 2018. 95 | 96 | ## Development 97 | 98 | Please see the instructions for the Codec Foundation upon which these plugins are based: 99 | [https://github.com/codec-foundation/adobe-cc] 100 | 101 | ## Credits 102 | 103 | Principal contributors to this plugin are 104 | 105 | - Greg Bakker (gbakker@gmail.com) 106 | - Richard Sykes 107 | - [Tom Butterworth](http://kriss.cx/tom) 108 | - [Nick Zinovenko](https://github.com/exscriber) 109 | 110 | Development of this plugin was sponsored by [disguise](http://disguise.one), makers of the disguise show production software and hardware. 111 | 112 | The Hap codec was developed by Tom Butterworth with the support of [VIDVOX](https://vidvox.net). 113 | 114 | Many thanks to Tom Butterworth, David Lublin, Nick Wilkinson, Ruben Garcia and the disguise QA team for their assistance throughout development of this plugin. 115 | -------------------------------------------------------------------------------- /asset/hap-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/asset/hap-icon.png -------------------------------------------------------------------------------- /asset/hap-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Sketch. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /codec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR) 2 | 3 | project(Codec) 4 | 5 | # this is the one we will install 6 | add_library(Codec 7 | codec.cpp 8 | codec.hpp 9 | texture_converter.cpp 10 | texture_converter.hpp 11 | ) 12 | 13 | target_link_libraries(Codec 14 | CodecRegistration 15 | Hap 16 | snappy 17 | squish 18 | ycocg 19 | ) 20 | 21 | target_include_directories(Codec 22 | PRIVATE 23 | INTERFACE 24 | CodecRegistration 25 | ) 26 | 27 | # hack because squish CMakeLists.txt predates v3.4 28 | # TODO: fix the squish CMakeLists.txt 29 | list(APPEND INCLUDE_DIRS ${squish_SOURCE_DIR}) 30 | include_directories(${INCLUDE_DIRS}) -------------------------------------------------------------------------------- /codec/codec.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // base class for different kinds of Hap encoders 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "codec_registration.hpp" 10 | 11 | #include "texture_converter.hpp" 12 | 13 | // Placeholders for inputs, processing and outputs for encode process 14 | 15 | class HapEncoderJob : public EncoderJob 16 | { 17 | public: 18 | HapEncoderJob( 19 | FrameSize frameSize, 20 | unsigned int count, 21 | HapChunkCounts chunkCounts, 22 | std::array textureFormats, 23 | std::array compressors, 24 | std::array converters, 25 | std::array sizes 26 | ); 27 | ~HapEncoderJob() {} 28 | 29 | private: 30 | virtual void doCopyExternalToLocal( 31 | const uint8_t* data, 32 | size_t stride, 33 | FrameFormat format) override; 34 | virtual void doEncode(EncodeOutput& out) override; 35 | 36 | size_t getMaxEncodedSize() const; 37 | 38 | FrameSize frameSize_; 39 | unsigned int count_; 40 | HapChunkCounts chunkCounts_; 41 | std::array textureFormats_; 42 | std::array compressors_; 43 | std::array converters_; 44 | std::array sizes_; 45 | 46 | std::vector rgbaTopLeftOrigin_; // for squish 47 | 48 | // not all of these are used by all codecs 49 | std::vector ycocg_; // for ycog -> ycog_dxt 50 | std::array, 2> buffers_; // for hap_encode 51 | }; 52 | 53 | // Instantiate once per input frame definition 54 | // 55 | 56 | class HapEncoder : public Encoder 57 | { 58 | public: 59 | HapEncoder(std::unique_ptr& params); 60 | ~HapEncoder(); 61 | 62 | virtual std::unique_ptr create() override; 63 | 64 | private: 65 | static std::array getTextureFormats(Codec4CC subType); 66 | 67 | unsigned int count_; 68 | HapChunkCounts chunkCounts_; 69 | std::array textureFormats_; 70 | std::array compressors_; 71 | std::array, 2> converters_; 72 | std::array sizes_; 73 | }; 74 | -------------------------------------------------------------------------------- /codec/texture_converter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "texture_converter.hpp" 4 | #include "hap.h" 5 | #include "squish.h" 6 | 7 | extern "C" { 8 | #include "YCoCg.h" 9 | } 10 | #include "YCoCgDXT.h" 11 | 12 | static int roundUpToMultipleOf4(int n) 13 | { 14 | return (n + 3) & ~3; 15 | } 16 | 17 | // texture conversion from adobe-preferred to hap_encode required 18 | // these converters all use squish as the final stage 19 | class SquishTextureConverter : public TextureConverter 20 | { 21 | public: 22 | SquishTextureConverter(const FrameSize& frameSize, int squishFlags) 23 | : TextureConverter(frameSize), squishFlags_(squishFlags) 24 | {} 25 | virtual ~SquishTextureConverter() {}; 26 | 27 | private: 28 | size_t size() const override 29 | { 30 | return squish::GetStorageRequirements(frameSize().width, frameSize().height, squishFlags_); 31 | } 32 | 33 | virtual void doConvert( 34 | const uint8_t* in_rgba, 35 | std::vector &ycocg, 36 | std::vector &outputBuffer) override 37 | { 38 | outputBuffer.resize(size()); 39 | 40 | void *blocks = &(outputBuffer[0]); 41 | float *metric = nullptr; 42 | squish::CompressImage(in_rgba, frameSize().width, frameSize().height, blocks, squishFlags_, metric); 43 | } 44 | 45 | int squishFlags_; 46 | }; 47 | 48 | 49 | class TextureConverterToYCoCg_Dxt5 : public TextureConverter 50 | { 51 | public: 52 | TextureConverterToYCoCg_Dxt5(const FrameSize& frameSize) : TextureConverter(frameSize) {} 53 | ~TextureConverterToYCoCg_Dxt5() {} 54 | 55 | size_t size() const override 56 | { 57 | return roundUpToMultipleOf4(frameSize().width) * roundUpToMultipleOf4(frameSize().height); 58 | } 59 | 60 | void doConvert( 61 | const uint8_t* in_rgba, 62 | std::vector &ycocg, 63 | std::vector &outputBuffer) override 64 | { 65 | int rowbytes = frameSize().width * 4; 66 | ycocg.resize(rowbytes * frameSize().height); 67 | 68 | ConvertRGB_ToCoCg_Y8888( 69 | in_rgba, // const uint8_t *src, 70 | &ycocg[0], // uint8_t *dst 71 | frameSize().width, // unsigned long width, 72 | frameSize().height, // unsigned long height, 73 | rowbytes, // size_t src_rowbytes 74 | rowbytes, // size_t dst_rowbytes, 75 | false // int allow_tile 76 | ); 77 | 78 | outputBuffer.resize(size()); 79 | 80 | CompressYCoCgDXT5( 81 | &(ycocg[0]), 82 | &(outputBuffer[0]), 83 | frameSize().width, frameSize().height, 84 | frameSize().width * 4 // stride 85 | ); 86 | } 87 | }; 88 | 89 | 90 | TextureConverter::~TextureConverter() 91 | { 92 | } 93 | 94 | size_t TextureConverter::size() const 95 | { 96 | throw std::runtime_error("unknown texture conversion"); 97 | } 98 | 99 | 100 | std::unique_ptr TextureConverter::create(const FrameSize& frameSize, unsigned int destFormat, SquishEncoderQuality quality) 101 | { 102 | int flag_quality; 103 | switch (quality) 104 | { 105 | case kSquishEncoderFastQuality: 106 | flag_quality = squish::kColourRangeFit; 107 | break; 108 | case kSquishEncoderBestQuality: 109 | flag_quality = squish::kColourIterativeClusterFit; 110 | break; 111 | default: 112 | flag_quality = squish::kColourClusterFit; 113 | break; 114 | } 115 | 116 | switch (destFormat) 117 | { 118 | case HapTextureFormat_RGB_DXT1: 119 | return std::make_unique(frameSize, squish::kDxt1 | flag_quality); 120 | case HapTextureFormat_RGBA_DXT5: 121 | return std::make_unique(frameSize, squish::kDxt5 | flag_quality); 122 | case HapTextureFormat_YCoCg_DXT5: 123 | return std::make_unique(frameSize); 124 | case HapTextureFormat_A_RGTC1: 125 | return std::make_unique(frameSize, squish::kRgtc1A); 126 | default: 127 | throw std::runtime_error("unknown conversion"); 128 | } 129 | } 130 | 131 | 132 | void TextureConverter::convert(const uint8_t* in_rgba, 133 | std::vector &intermediate_ycocg, 134 | std::vector &outputBuffer) 135 | { 136 | doConvert(in_rgba, intermediate_ycocg, outputBuffer); 137 | } 138 | 139 | 140 | void TextureConverter::doConvert( 141 | const uint8_t* in_rgba, 142 | std::vector &intermediate_ycocg, 143 | std::vector &outputBuffer) 144 | { 145 | } -------------------------------------------------------------------------------- /codec/texture_converter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // base class for different kinds of Hap encoders 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "codec_registration.hpp" 10 | 11 | enum SquishEncoderQuality { 12 | kSquishEncoderFastQuality = 0, 13 | kSquishEncoderNormalQuality = 1, 14 | kSquishEncoderBestQuality = 2 15 | }; 16 | 17 | // texture conversion from adobe-preferred to hap_encode required 18 | // these converters all use squish as the final stage 19 | class TextureConverter 20 | { 21 | public: 22 | TextureConverter(const FrameSize& frameSize) 23 | : frameSize_(frameSize) 24 | {} 25 | virtual ~TextureConverter(); 26 | 27 | static std::unique_ptr create(const FrameSize& frameSize, unsigned int destFormat, SquishEncoderQuality quality); 28 | 29 | const FrameSize& frameSize() const { return frameSize_; } 30 | 31 | virtual size_t size() const; // storage required 32 | 33 | void convert(const uint8_t* in_rgba, 34 | std::vector &intermediate_ycocg, 35 | std::vector &outputBuffer); 36 | 37 | private: 38 | virtual void doConvert( 39 | const uint8_t* in_rgba, 40 | std::vector &intermediate_ycocg, 41 | std::vector &outputBuffer)=0; 42 | 43 | FrameSize frameSize_; 44 | }; 45 | -------------------------------------------------------------------------------- /doc/user_guide/README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |
6 | 7 | # Exporter for Adobe CC 2018 8 | 9 | ## Introduction 10 | 11 | This is the community-supplied Hap and Hap Q exporter plugin for Adobe CC 2018. 12 | 13 | HAP is a collection of high-performance codecs optimised for playback of multiple layers of video. 14 | 15 | ## Getting it 16 | 17 | Releases of this plugin are available at 18 | 19 | [https://github.com/disguise-one/hap-encoder-adobe-cc/releases](https://github.com/disguise-one/hap-encoder-adobe-cc/releases) 20 | 21 | ## Requirements 22 | 23 | This codec has been tested on Windows 10, macOS High Sierra and macOS Mojave and supports Core i3 processors and later. 24 | 25 | It has been tested in Adobe Media Encoder CC 2018 12.1.2.69. 26 | 27 | ## Support 28 | 29 | Users can contact happlugin@disguise.one for support. 30 | 31 | ## Installation 32 | 33 | Run the provided installer. 34 | 35 | ## Usage 36 | 37 | After installation, the encoders will be available as the 'HAP Video' format when exporting in Adobe Media Encoder CC 2018 or Adobe Premiere CC 2018. 38 | 39 | ![HAP format](format-option.png) 40 | 41 | After choosing the format, codec options may be chosen. 42 | 43 | ![HAP codec options](codec-options.png) 44 | 45 | Default presets are supplied and are available in Adobe Media Encoder. 46 | 47 | ![HAP presets](media-encoder-presets.png) 48 | 49 | Movies that are encoded with the plugin are exported into .mov files. 50 | 51 | ### Choosing the right codec for the job: Hap, Hap Alpha, Hap Q and Hap Q Alpha 52 | 53 | There are four different flavors of HAP to choose from when encoding your clips. 54 | 55 | 56 | Hap 57 | 58 | : lowest data-rate and reasonable image quality 59 | 60 | Hap Alpha 61 | 62 | : same image quality as Hap, and supports an Alpha channel 63 | 64 | Hap Q 65 | 66 | : improved image quality, at the expense of larger file sizes 67 | 68 | Hap Q Alpha 69 | 70 | : improved image quality and an Alpha channel, at the expense of larger file sizes 71 | 72 | ### Codec parameters 73 | For Hap and Hap Alpha codecs render time can be reduced with Quality-Fast option. It uses fast and simple algorithm, but with reduced image quality. 74 | 75 | - Fast suggested for draft renders, last-minute notebook renders, etc... 76 | - Normal is default option for general renders 77 | 78 | ![Hap quality option](codec-quality.png) 79 | 80 | An optional specified number of chunks size may be specified to optimize for ultra high resolution video on a particular hardware system. This setting should typically only be used if you are reaching a CPU performance bottleneck during playback. As a general guide, for HD footage or smaller you can set the chunk size to 1 and for 4k or larger footage the number of chunks should never exceed the number of CPU cores on the computer used for playback. 81 | 82 | ![HAP chunk counts](chunk-counts.png) 83 | 84 | At present, 'auto' corresponds to choosing 1 chunk per texture; this may change in the future. 85 | 86 | 87 | ## What is HAP 88 | 89 | HAP is a collection of high-performance codecs optimised for playback of multiple layers of video. 90 | 91 | HAP prioritises decode-speed, efficient upload to GPUs and GPU-side decoding to enable the highest amount of video content to be played back at once on modern hardware. 92 | 93 | Please see 94 | 95 | [http://hap.video/](http://hap.video/) 96 | 97 | for details. 98 | 99 | ## Known issues 100 | 101 | Performing multiple parallel exports in Media Encoder may cause the system to become unresponsive, although the operation should eventually complete. 102 | 103 | ## Credits 104 | 105 | Principal authors of this plugin are 106 | 107 | - Greg Bakker (gbakker@gmail.com) 108 | - Richard Sykes 109 | - [Tom Butterworth](http://kriss.cx/tom) 110 | 111 | Development of this plugin was sponsored by [disguise](http://disguise.one), makers of the disguise show production software and hardware. 112 | 113 | The Hap codec was developed by Tom Butterworth with the support of [VIDVOX](https://vidvox.net). 114 | 115 | Many thanks to Tom Butterworth, David Lublin, Nick Wilkinson, Ruben Garcia and the disguise QA team for their assistance throughout development of this plugin. 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /doc/user_guide/chunk-counts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/doc/user_guide/chunk-counts.png -------------------------------------------------------------------------------- /doc/user_guide/codec-options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/doc/user_guide/codec-options.png -------------------------------------------------------------------------------- /doc/user_guide/codec-quality.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/doc/user_guide/codec-quality.png -------------------------------------------------------------------------------- /doc/user_guide/format-option.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/doc/user_guide/format-option.png -------------------------------------------------------------------------------- /doc/user_guide/media-encoder-presets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/doc/user_guide/media-encoder-presets.png -------------------------------------------------------------------------------- /external/hap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR) 2 | project(Hap) 3 | 4 | add_library(Hap STATIC) 5 | 6 | target_sources(Hap 7 | PRIVATE 8 | hap.c 9 | PUBLIC 10 | ${CMAKE_CURRENT_LIST_DIR}/hap.h 11 | ) 12 | 13 | target_link_libraries(Hap 14 | PUBLIC 15 | snappy 16 | ) 17 | 18 | target_include_directories(Hap 19 | PUBLIC 20 | . 21 | ) -------------------------------------------------------------------------------- /external/hap/hap.h: -------------------------------------------------------------------------------- 1 | /* 2 | hap.h 3 | 4 | Copyright (c) 2011-2013, Tom Butterworth and Vidvox LLC. All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef hap_h 29 | #define hap_h 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /* 36 | These match the constants defined by GL_EXT_texture_compression_s3tc and 37 | GL_ARB_texture_compression_rgtc 38 | */ 39 | 40 | enum HapTextureFormat { 41 | HapTextureFormat_RGB_DXT1 = 0x83F0, 42 | HapTextureFormat_RGBA_DXT5 = 0x83F3, 43 | HapTextureFormat_YCoCg_DXT5 = 0x01, 44 | HapTextureFormat_A_RGTC1 = 0x8DBB 45 | }; 46 | 47 | enum HapCompressor { 48 | HapCompressorNone, 49 | HapCompressorSnappy 50 | }; 51 | 52 | enum HapResult { 53 | HapResult_No_Error = 0, 54 | HapResult_Bad_Arguments, 55 | HapResult_Buffer_Too_Small, 56 | HapResult_Bad_Frame, 57 | HapResult_Internal_Error 58 | }; 59 | 60 | /* 61 | See HapDecode for descriptions of these function types. 62 | */ 63 | typedef void (*HapDecodeWorkFunction)(void *p, unsigned int index); 64 | typedef void (*HapDecodeCallback)(HapDecodeWorkFunction function, void *p, unsigned int count, void *info); 65 | 66 | /* 67 | Returns the maximum size of an output buffer for a frame composed of multiple textures. 68 | count is the number of textures 69 | lengths is an array of input texture lengths in bytes 70 | textureFormats is an array of HapTextureFormats 71 | chunkCounts is an array of chunk counts 72 | */ 73 | unsigned long HapMaxEncodedLength(unsigned int count, 74 | unsigned long *lengths, 75 | unsigned int *textureFormats, 76 | unsigned int *chunkCounts); 77 | 78 | /* 79 | Encodes one or multiple textures into one Hap frame, or returns an error. 80 | 81 | Permitted multiple-texture combinations are: 82 | HapTextureFormat_YCoCg_DXT5 + HapTextureFormat_A_RGTC1 83 | 84 | Use HapMaxEncodedLength() to discover the minimal value for outputBufferBytes. 85 | count is the number of textures (1 or 2) 86 | inputBuffers is an array of count pointers to texture data 87 | inputBufferBytes is an array of texture data lengths in bytes 88 | textureFormats is an array of HapTextureFormats 89 | compressors is an array of HapCompressors 90 | chunkCounts is an array of chunk counts to permit multithreaded decoding 91 | outputBuffer is the destination buffer to receive the encoded frame 92 | outputBufferBytes is the destination buffer's length in bytes 93 | outputBufferBytesUsed will be set to the actual encoded length of the frame on return 94 | */ 95 | unsigned int HapEncode(unsigned int count, 96 | const void **inputBuffers, unsigned long *inputBuffersBytes, 97 | unsigned int *textureFormats, 98 | unsigned int *compressors, 99 | unsigned int *chunkCounts, 100 | void *outputBuffer, unsigned long outputBufferBytes, 101 | unsigned long *outputBufferBytesUsed); 102 | 103 | /* 104 | Decodes a texture from inputBuffer which is a Hap frame. 105 | 106 | A frame may contain multiple textures which are to be combined to create the final image. Use HapGetFrameTextureCount() 107 | to discover the number of textures in a frame, and then access each texture by incrementing the index argument to this 108 | function. 109 | 110 | If the frame permits multithreaded decoding, callback will be called once for you to invoke a platform-appropriate 111 | mechanism to assign work to threads, and trigger that work by calling the function passed to your callback the number 112 | of times indicated by the count argument, usually from a number of different threads. This callback must not return 113 | until all the work has been completed. 114 | 115 | void MyHapDecodeCallback(HapDecodeWorkFunction function, void *p, unsigned int count, void *info) 116 | { 117 | int i; 118 | for (i = 0; i < count; i++) { 119 | // Invoke your multithreading mechanism to cause this function to be called 120 | // on a suitable number of threads. 121 | function(p, i); 122 | } 123 | } 124 | info is an argument for your own use to pass context to the callback. 125 | If the frame does not permit multithreaded decoding, callback will not be called. 126 | If outputBufferBytesUsed is not NULL then it will be set to the decoded length of the output buffer. 127 | outputBufferTextureFormat must be non-NULL, and will be set to one of the HapTextureFormat constants. 128 | */ 129 | unsigned int HapDecode(const void *inputBuffer, unsigned long inputBufferBytes, 130 | unsigned int index, 131 | HapDecodeCallback callback, void *info, 132 | void *outputBuffer, unsigned long outputBufferBytes, 133 | unsigned long *outputBufferBytesUsed, 134 | unsigned int *outputBufferTextureFormat); 135 | 136 | /* 137 | If this returns HapResult_No_Error then outputTextureCount is set to the count of textures in the frame. 138 | */ 139 | unsigned int HapGetFrameTextureCount(const void *inputBuffer, unsigned long inputBufferBytes, unsigned int *outputTextureCount); 140 | 141 | /* 142 | On return sets outputBufferTextureFormat to a HapTextureFormat constant describing the format of the texture at index in the frame. 143 | */ 144 | unsigned int HapGetFrameTextureFormat(const void *inputBuffer, unsigned long inputBufferBytes, unsigned int index, unsigned int *outputBufferTextureFormat); 145 | 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /external/snappy/.appveyor.yml: -------------------------------------------------------------------------------- 1 | # Build matrix / environment variables are explained on: 2 | # https://www.appveyor.com/docs/appveyor-yml/ 3 | # This file can be validated on: https://ci.appveyor.com/tools/validate-yaml 4 | 5 | version: "{build}" 6 | 7 | environment: 8 | matrix: 9 | # AppVeyor currently has no custom job name feature. 10 | # http://help.appveyor.com/discussions/questions/1623-can-i-provide-a-friendly-name-for-jobs 11 | - JOB: Visual Studio 2017 12 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 13 | CMAKE_GENERATOR: Visual Studio 15 2017 14 | 15 | platform: 16 | - x86 17 | - x64 18 | 19 | configuration: 20 | - RelWithDebInfo 21 | - Debug 22 | 23 | build: 24 | verbosity: minimal 25 | 26 | build_script: 27 | - git submodule update --init --recursive 28 | - mkdir out 29 | - cd out 30 | - if "%platform%"=="x64" set CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64 31 | - cmake --version 32 | - cmake .. -G "%CMAKE_GENERATOR%" 33 | -DCMAKE_CONFIGURATION_TYPES="%CONFIGURATION%" 34 | - cmake --build . --config %CONFIGURATION% 35 | - cd .. 36 | 37 | test_script: 38 | - out\%CONFIGURATION%\snappy_unittest 39 | -------------------------------------------------------------------------------- /external/snappy/.travis.yml: -------------------------------------------------------------------------------- 1 | # Build matrix / environment variables are explained on: 2 | # http://about.travis-ci.org/docs/user/build-configuration/ 3 | # This file can be validated on: http://lint.travis-ci.org/ 4 | 5 | sudo: false 6 | dist: trusty 7 | language: cpp 8 | 9 | compiler: 10 | - gcc 11 | - clang 12 | os: 13 | - linux 14 | - osx 15 | 16 | env: 17 | - BUILD_TYPE=Debug 18 | - BUILD_TYPE=RelWithDebInfo 19 | 20 | matrix: 21 | allow_failures: 22 | - compiler: clang 23 | env: BUILD_TYPE=RelWithDebInfo 24 | 25 | addons: 26 | apt: 27 | # List of whitelisted in travis packages for ubuntu-trusty can be found here: 28 | # https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-trusty 29 | # List of whitelisted in travis apt-sources: 30 | # https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json 31 | sources: 32 | - ubuntu-toolchain-r-test 33 | - llvm-toolchain-trusty-5.0 34 | packages: 35 | - cmake 36 | - gcc-7 37 | - g++-7 38 | - clang-5.0 39 | 40 | install: 41 | # Travis doesn't have a DSL for installing homebrew packages yet. Status tracked 42 | # in https://github.com/travis-ci/travis-ci/issues/5377 43 | # The Travis VM image for Mac already has a link at /usr/local/include/c++, 44 | # causing Homebrew's gcc@7 installation to error out. This was reported to 45 | # Homebrew maintainers at https://github.com/Homebrew/brew/issues/1742 and 46 | # removing the link emerged as a workaround. 47 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then 48 | brew update; 49 | if [ -L /usr/local/include/c++ ]; then rm /usr/local/include/c++; fi; 50 | brew install gcc@7; 51 | fi 52 | # /usr/bin/gcc is stuck to old versions on both Linux and OSX. 53 | - if [ "$CXX" = "g++" ]; then export CXX="g++-7" CC="gcc-7"; fi 54 | - echo ${CC} 55 | - echo ${CXX} 56 | - ${CXX} --version 57 | - cmake --version 58 | 59 | before_script: 60 | - mkdir -p build && cd build 61 | - cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE 62 | - cmake --build . 63 | - cd .. 64 | 65 | script: 66 | - build/snappy_unittest 67 | -------------------------------------------------------------------------------- /external/snappy/AUTHORS: -------------------------------------------------------------------------------- 1 | opensource@google.com 2 | -------------------------------------------------------------------------------- /external/snappy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(Snappy VERSION 1.1.7 LANGUAGES C CXX) 3 | 4 | # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make 5 | # it prominent in the GUI. 6 | option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF) 7 | 8 | option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON) 9 | 10 | include(TestBigEndian) 11 | test_big_endian(SNAPPY_IS_BIG_ENDIAN) 12 | 13 | include(CheckIncludeFile) 14 | check_include_file("byteswap.h" HAVE_BYTESWAP_H) 15 | check_include_file("stddef.h" HAVE_STDDEF_H) 16 | check_include_file("stdint.h" HAVE_STDINT_H) 17 | check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H) 18 | check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) 19 | check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H) 20 | check_include_file("sys/time.h" HAVE_SYS_TIME_H) 21 | check_include_file("sys/uio.h" HAVE_SYS_UIO_H) 22 | check_include_file("unistd.h" HAVE_UNISTD_H) 23 | check_include_file("windows.h" HAVE_WINDOWS_H) 24 | 25 | include(CheckLibraryExists) 26 | check_library_exists(z zlibVersion "" HAVE_LIBZ) 27 | check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2) 28 | 29 | include(CheckCXXSourceCompiles) 30 | check_cxx_source_compiles( 31 | "int main(void) { return __builtin_expect(0, 1); }" HAVE_BUILTIN_EXPECT) 32 | 33 | check_cxx_source_compiles( 34 | "int main(void) { return __builtin_ctzll(0); }" HAVE_BUILTIN_CTZ) 35 | 36 | include(CheckSymbolExists) 37 | check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP) 38 | check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF) 39 | 40 | find_package(GTest QUIET) 41 | if(GTEST_FOUND) 42 | set(HAVE_GTEST 1) 43 | endif(GTEST_FOUND) 44 | 45 | find_package(Gflags QUIET) 46 | if(GFLAGS_FOUND) 47 | set(HAVE_GFLAGS 1) 48 | endif(GFLAGS_FOUND) 49 | 50 | configure_file( 51 | "${PROJECT_SOURCE_DIR}/cmake/config.h.in" 52 | "${PROJECT_BINARY_DIR}/config.h" 53 | ) 54 | 55 | # We don't want to define HAVE_ macros in public headers. Instead, we use 56 | # CMake's variable substitution with 0/1 variables, which will be seen by the 57 | # preprocessor as constants. 58 | set(HAVE_STDINT_H_01 ${HAVE_STDINT_H}) 59 | set(HAVE_STDDEF_H_01 ${HAVE_STDDEF_H}) 60 | set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H}) 61 | if(NOT HAVE_STDINT_H_01) 62 | set(HAVE_STDINT_H_01 0) 63 | endif(NOT HAVE_STDINT_H_01) 64 | if(NOT HAVE_STDDEF_H_01) 65 | set(HAVE_STDDEF_H_01 0) 66 | endif(NOT HAVE_STDDEF_H_01) 67 | if(NOT HAVE_SYS_UIO_H_01) 68 | set(HAVE_SYS_UIO_H_01 0) 69 | endif(NOT HAVE_SYS_UIO_H_01) 70 | 71 | configure_file( 72 | "${PROJECT_SOURCE_DIR}/snappy-stubs-public.h.in" 73 | "${PROJECT_BINARY_DIR}/snappy-stubs-public.h") 74 | 75 | add_library(snappy "") 76 | target_sources(snappy 77 | PRIVATE 78 | "${PROJECT_SOURCE_DIR}/snappy-internal.h" 79 | "${PROJECT_SOURCE_DIR}/snappy-stubs-internal.h" 80 | "${PROJECT_SOURCE_DIR}/snappy-c.cc" 81 | "${PROJECT_SOURCE_DIR}/snappy-sinksource.cc" 82 | "${PROJECT_SOURCE_DIR}/snappy-stubs-internal.cc" 83 | "${PROJECT_SOURCE_DIR}/snappy.cc" 84 | "${PROJECT_BINARY_DIR}/config.h" 85 | 86 | # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install". 87 | $<$:PUBLIC> 88 | $ 89 | $ 90 | $ 91 | $ 92 | $ 93 | $ 94 | $ 95 | $ 96 | ) 97 | target_include_directories(snappy 98 | PUBLIC 99 | $ 100 | $ 101 | $ 102 | ) 103 | set_target_properties(snappy 104 | PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) 105 | 106 | target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H) 107 | if(BUILD_SHARED_LIBS) 108 | set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) 109 | endif(BUILD_SHARED_LIBS) 110 | 111 | if(SNAPPY_BUILD_TESTS) 112 | enable_testing() 113 | 114 | add_executable(snappy_unittest "") 115 | target_sources(snappy_unittest 116 | PRIVATE 117 | "${PROJECT_SOURCE_DIR}/snappy_unittest.cc" 118 | "${PROJECT_SOURCE_DIR}/snappy-test.cc" 119 | ) 120 | target_compile_definitions(snappy_unittest PRIVATE -DHAVE_CONFIG_H) 121 | target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES}) 122 | 123 | if(HAVE_LIBZ) 124 | target_link_libraries(snappy_unittest z) 125 | endif(HAVE_LIBZ) 126 | if(HAVE_LIBLZO2) 127 | target_link_libraries(snappy_unittest lzo2) 128 | endif(HAVE_LIBLZO2) 129 | 130 | target_include_directories(snappy_unittest 131 | BEFORE PRIVATE 132 | "${PROJECT_SOURCE_DIR}" 133 | "${GTEST_INCLUDE_DIRS}" 134 | "${GFLAGS_INCLUDE_DIRS}" 135 | ) 136 | 137 | add_test( 138 | NAME snappy_unittest 139 | WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 140 | COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest") 141 | endif(SNAPPY_BUILD_TESTS) 142 | 143 | include(GNUInstallDirs) 144 | install(TARGETS snappy 145 | EXPORT SnappyTargets 146 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 147 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 148 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 149 | ) 150 | install( 151 | FILES 152 | "${PROJECT_SOURCE_DIR}/snappy-c.h" 153 | "${PROJECT_SOURCE_DIR}/snappy-sinksource.h" 154 | "${PROJECT_SOURCE_DIR}/snappy.h" 155 | "${PROJECT_BINARY_DIR}/snappy-stubs-public.h" 156 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 157 | ) 158 | 159 | include(CMakePackageConfigHelpers) 160 | write_basic_package_version_file( 161 | "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake" 162 | COMPATIBILITY SameMajorVersion 163 | ) 164 | install( 165 | EXPORT SnappyTargets 166 | NAMESPACE Snappy:: 167 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy" 168 | ) 169 | install( 170 | FILES 171 | "${PROJECT_SOURCE_DIR}/cmake/SnappyConfig.cmake" 172 | "${PROJECT_BINARY_DIR}/SnappyConfigVersion.cmake" 173 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Snappy" 174 | ) 175 | -------------------------------------------------------------------------------- /external/snappy/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | Please make sure that all the automated checks (CLA, AppVeyor, Travis) pass for 26 | your pull requests. Pull requests whose checks fail may be ignored. 27 | -------------------------------------------------------------------------------- /external/snappy/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2011, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | === 31 | 32 | Some of the benchmark data in testdata/ is licensed differently: 33 | 34 | - fireworks.jpeg is Copyright 2013 Steinar H. Gunderson, and 35 | is licensed under the Creative Commons Attribution 3.0 license 36 | (CC-BY-3.0). See https://creativecommons.org/licenses/by/3.0/ 37 | for more information. 38 | 39 | - kppkn.gtb is taken from the Gaviota chess tablebase set, and 40 | is licensed under the MIT License. See 41 | https://sites.google.com/site/gaviotachessengine/Home/endgame-tablebases-1 42 | for more information. 43 | 44 | - paper-100k.pdf is an excerpt (bytes 92160 to 194560) from the paper 45 | “Combinatorial Modeling of Chromatin Features Quantitatively Predicts DNA 46 | Replication Timing in _Drosophila_” by Federico Comoglio and Renato Paro, 47 | which is licensed under the CC-BY license. See 48 | http://www.ploscompbiol.org/static/license for more ifnormation. 49 | 50 | - alice29.txt, asyoulik.txt, plrabn12.txt and lcet10.txt are from Project 51 | Gutenberg. The first three have expired copyrights and are in the public 52 | domain; the latter does not have expired copyright, but is still in the 53 | public domain according to the license information 54 | (http://www.gutenberg.org/ebooks/53). 55 | -------------------------------------------------------------------------------- /external/snappy/NEWS: -------------------------------------------------------------------------------- 1 | Snappy v1.1.7, August 24th 2017: 2 | 3 | * Improved CMake build support for 64-bit Linux distributions. 4 | 5 | * MSVC builds now use MSVC-specific intrinsics that map to clzll. 6 | 7 | * ARM64 (AArch64) builds use the code paths optimized for 64-bit processors. 8 | 9 | Snappy v1.1.6, July 12th 2017: 10 | 11 | This is a re-release of v1.1.5 with proper SONAME / SOVERSION values. 12 | 13 | Snappy v1.1.5, June 28th 2017: 14 | 15 | This release has broken SONAME / SOVERSION values. Users of snappy as a shared 16 | library should avoid 1.1.5 and use 1.1.6 instead. SONAME / SOVERSION errors will 17 | manifest as the dynamic library loader complaining that it cannot find snappy's 18 | shared library file (libsnappy.so / libsnappy.dylib), or that the library it 19 | found does not have the required version. 1.1.6 has the same code as 1.1.5, but 20 | carries build configuration fixes for the issues above. 21 | 22 | * Add CMake build support. The autoconf build support is now deprecated, and 23 | will be removed in the next release. 24 | 25 | * Add AppVeyor configuration, for Windows CI coverage. 26 | 27 | * Small performance improvement on little-endian PowerPC. 28 | 29 | * Small performance improvement on LLVM with position-independent executables. 30 | 31 | * Fix a few issues with various build environments. 32 | 33 | Snappy v1.1.4, January 25th 2017: 34 | 35 | * Fix a 1% performance regression when snappy is used in PIE executables. 36 | 37 | * Improve compression performance by 5%. 38 | 39 | * Improve decompression performance by 20%. 40 | 41 | Snappy v1.1.3, July 6th 2015: 42 | 43 | This is the first release to be done from GitHub, which means that 44 | some minor things like the ChangeLog format has changed (git log 45 | format instead of svn log). 46 | 47 | * Add support for Uncompress() from a Source to a Sink. 48 | 49 | * Various minor changes to improve MSVC support; in particular, 50 | the unit tests now compile and run under MSVC. 51 | 52 | 53 | Snappy v1.1.2, February 28th 2014: 54 | 55 | This is a maintenance release with no changes to the actual library 56 | source code. 57 | 58 | * Stop distributing benchmark data files that have unclear 59 | or unsuitable licensing. 60 | 61 | * Add support for padding chunks in the framing format. 62 | 63 | 64 | Snappy v1.1.1, October 15th 2013: 65 | 66 | * Add support for uncompressing to iovecs (scatter I/O). 67 | The bulk of this patch was contributed by Mohit Aron. 68 | 69 | * Speed up decompression by ~2%; much more so (~13-20%) on 70 | a few benchmarks on given compilers and CPUs. 71 | 72 | * Fix a few issues with MSVC compilation. 73 | 74 | * Support truncated test data in the benchmark. 75 | 76 | 77 | Snappy v1.1.0, January 18th 2013: 78 | 79 | * Snappy now uses 64 kB block size instead of 32 kB. On average, 80 | this means it compresses about 3% denser (more so for some 81 | inputs), at the same or better speeds. 82 | 83 | * libsnappy no longer depends on iostream. 84 | 85 | * Some small performance improvements in compression on x86 86 | (0.5–1%). 87 | 88 | * Various portability fixes for ARM-based platforms, for MSVC, 89 | and for GNU/Hurd. 90 | 91 | 92 | Snappy v1.0.5, February 24th 2012: 93 | 94 | * More speed improvements. Exactly how big will depend on 95 | the architecture: 96 | 97 | - 3–10% faster decompression for the base case (x86-64). 98 | 99 | - ARMv7 and higher can now use unaligned accesses, 100 | and will see about 30% faster decompression and 101 | 20–40% faster compression. 102 | 103 | - 32-bit platforms (ARM and 32-bit x86) will see 2–5% 104 | faster compression. 105 | 106 | These are all cumulative (e.g., ARM gets all three speedups). 107 | 108 | * Fixed an issue where the unit test would crash on system 109 | with less than 256 MB address space available, 110 | e.g. some embedded platforms. 111 | 112 | * Added a framing format description, for use over e.g. HTTP, 113 | or for a command-line compressor. We do not have any 114 | implementations of this at the current point, but there seems 115 | to be enough of a general interest in the topic. 116 | Also make the format description slightly clearer. 117 | 118 | * Remove some compile-time warnings in -Wall 119 | (mostly signed/unsigned comparisons), for easier embedding 120 | into projects that use -Wall -Werror. 121 | 122 | 123 | Snappy v1.0.4, September 15th 2011: 124 | 125 | * Speeded up the decompressor somewhat; typically about 2–8% 126 | for Core i7, in 64-bit mode (comparable for Opteron). 127 | Somewhat more for some tests, almost no gain for others. 128 | 129 | * Make Snappy compile on certain platforms it didn't before 130 | (Solaris with SunPro C++, HP-UX, AIX). 131 | 132 | * Correct some minor errors in the format description. 133 | 134 | 135 | Snappy v1.0.3, June 2nd 2011: 136 | 137 | * Speeded up the decompressor somewhat; about 3-6% for Core 2, 138 | 6-13% for Core i7, and 5-12% for Opteron (all in 64-bit mode). 139 | 140 | * Added compressed format documentation. This text is new, 141 | but an earlier version from Zeev Tarantov was used as reference. 142 | 143 | * Only link snappy_unittest against -lz and other autodetected 144 | libraries, not libsnappy.so (which doesn't need any such dependency). 145 | 146 | * Fixed some display issues in the microbenchmarks, one of which would 147 | frequently make the test crash on GNU/Hurd. 148 | 149 | 150 | Snappy v1.0.2, April 29th 2011: 151 | 152 | * Relicense to a BSD-type license. 153 | 154 | * Added C bindings, contributed by Martin Gieseking. 155 | 156 | * More Win32 fixes, in particular for MSVC. 157 | 158 | * Replace geo.protodata with a newer version. 159 | 160 | * Fix timing inaccuracies in the unit test when comparing Snappy 161 | to other algorithms. 162 | 163 | 164 | Snappy v1.0.1, March 25th 2011: 165 | 166 | This is a maintenance release, mostly containing minor fixes. 167 | There is no new functionality. The most important fixes include: 168 | 169 | * The COPYING file and all licensing headers now correctly state that 170 | Snappy is licensed under the Apache 2.0 license. 171 | 172 | * snappy_unittest should now compile natively under Windows, 173 | as well as on embedded systems with no mmap(). 174 | 175 | * Various autotools nits have been fixed. 176 | 177 | 178 | Snappy v1.0, March 17th 2011: 179 | 180 | * Initial version. 181 | -------------------------------------------------------------------------------- /external/snappy/README.md: -------------------------------------------------------------------------------- 1 | Snappy, a fast compressor/decompressor. 2 | 3 | 4 | Introduction 5 | ============ 6 | 7 | Snappy is a compression/decompression library. It does not aim for maximum 8 | compression, or compatibility with any other compression library; instead, 9 | it aims for very high speeds and reasonable compression. For instance, 10 | compared to the fastest mode of zlib, Snappy is an order of magnitude faster 11 | for most inputs, but the resulting compressed files are anywhere from 20% to 12 | 100% bigger. (For more information, see "Performance", below.) 13 | 14 | Snappy has the following properties: 15 | 16 | * Fast: Compression speeds at 250 MB/sec and beyond, with no assembler code. 17 | See "Performance" below. 18 | * Stable: Over the last few years, Snappy has compressed and decompressed 19 | petabytes of data in Google's production environment. The Snappy bitstream 20 | format is stable and will not change between versions. 21 | * Robust: The Snappy decompressor is designed not to crash in the face of 22 | corrupted or malicious input. 23 | * Free and open source software: Snappy is licensed under a BSD-type license. 24 | For more information, see the included COPYING file. 25 | 26 | Snappy has previously been called "Zippy" in some Google presentations 27 | and the like. 28 | 29 | 30 | Performance 31 | =========== 32 | 33 | Snappy is intended to be fast. On a single core of a Core i7 processor 34 | in 64-bit mode, it compresses at about 250 MB/sec or more and decompresses at 35 | about 500 MB/sec or more. (These numbers are for the slowest inputs in our 36 | benchmark suite; others are much faster.) In our tests, Snappy usually 37 | is faster than algorithms in the same class (e.g. LZO, LZF, QuickLZ, 38 | etc.) while achieving comparable compression ratios. 39 | 40 | Typical compression ratios (based on the benchmark suite) are about 1.5-1.7x 41 | for plain text, about 2-4x for HTML, and of course 1.0x for JPEGs, PNGs and 42 | other already-compressed data. Similar numbers for zlib in its fastest mode 43 | are 2.6-2.8x, 3-7x and 1.0x, respectively. More sophisticated algorithms are 44 | capable of achieving yet higher compression rates, although usually at the 45 | expense of speed. Of course, compression ratio will vary significantly with 46 | the input. 47 | 48 | Although Snappy should be fairly portable, it is primarily optimized 49 | for 64-bit x86-compatible processors, and may run slower in other environments. 50 | In particular: 51 | 52 | - Snappy uses 64-bit operations in several places to process more data at 53 | once than would otherwise be possible. 54 | - Snappy assumes unaligned 32- and 64-bit loads and stores are cheap. 55 | On some platforms, these must be emulated with single-byte loads 56 | and stores, which is much slower. 57 | - Snappy assumes little-endian throughout, and needs to byte-swap data in 58 | several places if running on a big-endian platform. 59 | 60 | Experience has shown that even heavily tuned code can be improved. 61 | Performance optimizations, whether for 64-bit x86 or other platforms, 62 | are of course most welcome; see "Contact", below. 63 | 64 | 65 | Building 66 | ======== 67 | 68 | CMake is supported and autotools will soon be deprecated. 69 | You need CMake 3.4 or above to build: 70 | 71 | mkdir build 72 | cd build && cmake ../ && make 73 | 74 | 75 | Usage 76 | ===== 77 | 78 | Note that Snappy, both the implementation and the main interface, 79 | is written in C++. However, several third-party bindings to other languages 80 | are available; see the home page at http://google.github.io/snappy/ 81 | for more information. Also, if you want to use Snappy from C code, you can 82 | use the included C bindings in snappy-c.h. 83 | 84 | To use Snappy from your own C++ program, include the file "snappy.h" from 85 | your calling file, and link against the compiled library. 86 | 87 | There are many ways to call Snappy, but the simplest possible is 88 | 89 | snappy::Compress(input.data(), input.size(), &output); 90 | 91 | and similarly 92 | 93 | snappy::Uncompress(input.data(), input.size(), &output); 94 | 95 | where "input" and "output" are both instances of std::string. 96 | 97 | There are other interfaces that are more flexible in various ways, including 98 | support for custom (non-array) input sources. See the header file for more 99 | information. 100 | 101 | 102 | Tests and benchmarks 103 | ==================== 104 | 105 | When you compile Snappy, snappy_unittest is compiled in addition to the 106 | library itself. You do not need it to use the compressor from your own library, 107 | but it contains several useful components for Snappy development. 108 | 109 | First of all, it contains unit tests, verifying correctness on your machine in 110 | various scenarios. If you want to change or optimize Snappy, please run the 111 | tests to verify you have not broken anything. Note that if you have the 112 | Google Test library installed, unit test behavior (especially failures) will be 113 | significantly more user-friendly. You can find Google Test at 114 | 115 | http://github.com/google/googletest 116 | 117 | You probably also want the gflags library for handling of command-line flags; 118 | you can find it at 119 | 120 | http://gflags.github.io/gflags/ 121 | 122 | In addition to the unit tests, snappy contains microbenchmarks used to 123 | tune compression and decompression performance. These are automatically run 124 | before the unit tests, but you can disable them using the flag 125 | --run_microbenchmarks=false if you have gflags installed (otherwise you will 126 | need to edit the source). 127 | 128 | Finally, snappy can benchmark Snappy against a few other compression libraries 129 | (zlib, LZO, LZF, and QuickLZ), if they were detected at configure time. 130 | To benchmark using a given file, give the compression algorithm you want to test 131 | Snappy against (e.g. --zlib) and then a list of one or more file names on the 132 | command line. The testdata/ directory contains the files used by the 133 | microbenchmark, which should provide a reasonably balanced starting point for 134 | benchmarking. (Note that baddata[1-3].snappy are not intended as benchmarks; they 135 | are used to verify correctness in the presence of corrupted data in the unit 136 | test.) 137 | 138 | 139 | Contact 140 | ======= 141 | 142 | Snappy is distributed through GitHub. For the latest version, a bug tracker, 143 | and other information, see 144 | 145 | http://google.github.io/snappy/ 146 | 147 | or the repository at 148 | 149 | https://github.com/google/snappy 150 | -------------------------------------------------------------------------------- /external/snappy/cmake/SnappyConfig.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/SnappyTargets.cmake") -------------------------------------------------------------------------------- /external/snappy/cmake/config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_ 2 | #define THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_ 3 | 4 | /* Define to 1 if the compiler supports __builtin_ctz and friends. */ 5 | #cmakedefine HAVE_BUILTIN_CTZ 1 6 | 7 | /* Define to 1 if the compiler supports __builtin_expect. */ 8 | #cmakedefine HAVE_BUILTIN_EXPECT 1 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #cmakedefine HAVE_BYTESWAP_H 1 12 | 13 | /* Define to 1 if you have a definition for mmap() in . */ 14 | #cmakedefine HAVE_FUNC_MMAP 1 15 | 16 | /* Define to 1 if you have a definition for sysconf() in . */ 17 | #cmakedefine HAVE_FUNC_SYSCONF 1 18 | 19 | /* Define to 1 to use the gflags package for command-line parsing. */ 20 | #cmakedefine HAVE_GFLAGS 1 21 | 22 | /* Define to 1 if you have Google Test. */ 23 | #cmakedefine HAVE_GTEST 1 24 | 25 | /* Define to 1 if you have the `lzo2' library (-llzo2). */ 26 | #cmakedefine HAVE_LIBLZO2 1 27 | 28 | /* Define to 1 if you have the `z' library (-lz). */ 29 | #cmakedefine HAVE_LIBZ 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #cmakedefine HAVE_STDDEF_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #cmakedefine HAVE_STDINT_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #cmakedefine HAVE_SYS_ENDIAN_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #cmakedefine HAVE_SYS_MMAN_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #cmakedefine HAVE_SYS_RESOURCE_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #cmakedefine HAVE_SYS_TIME_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #cmakedefine HAVE_SYS_UIO_H 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #cmakedefine HAVE_UNISTD_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #cmakedefine HAVE_WINDOWS_H 1 57 | 58 | /* Define to 1 if your processor stores words with the most significant byte 59 | first (like Motorola and SPARC, unlike Intel and VAX). */ 60 | #cmakedefine SNAPPY_IS_BIG_ENDIAN 1 61 | 62 | #endif // THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_ 63 | -------------------------------------------------------------------------------- /external/snappy/format_description.txt: -------------------------------------------------------------------------------- 1 | Snappy compressed format description 2 | Last revised: 2011-10-05 3 | 4 | 5 | This is not a formal specification, but should suffice to explain most 6 | relevant parts of how the Snappy format works. It is originally based on 7 | text by Zeev Tarantov. 8 | 9 | Snappy is a LZ77-type compressor with a fixed, byte-oriented encoding. 10 | There is no entropy encoder backend nor framing layer -- the latter is 11 | assumed to be handled by other parts of the system. 12 | 13 | This document only describes the format, not how the Snappy compressor nor 14 | decompressor actually works. The correctness of the decompressor should not 15 | depend on implementation details of the compressor, and vice versa. 16 | 17 | 18 | 1. Preamble 19 | 20 | The stream starts with the uncompressed length (up to a maximum of 2^32 - 1), 21 | stored as a little-endian varint. Varints consist of a series of bytes, 22 | where the lower 7 bits are data and the upper bit is set iff there are 23 | more bytes to be read. In other words, an uncompressed length of 64 would 24 | be stored as 0x40, and an uncompressed length of 2097150 (0x1FFFFE) 25 | would be stored as 0xFE 0xFF 0x7F. 26 | 27 | 28 | 2. The compressed stream itself 29 | 30 | There are two types of elements in a Snappy stream: Literals and 31 | copies (backreferences). There is no restriction on the order of elements, 32 | except that the stream naturally cannot start with a copy. (Having 33 | two literals in a row is never optimal from a compression point of 34 | view, but nevertheless fully permitted.) Each element starts with a tag byte, 35 | and the lower two bits of this tag byte signal what type of element will 36 | follow: 37 | 38 | 00: Literal 39 | 01: Copy with 1-byte offset 40 | 10: Copy with 2-byte offset 41 | 11: Copy with 4-byte offset 42 | 43 | The interpretation of the upper six bits are element-dependent. 44 | 45 | 46 | 2.1. Literals (00) 47 | 48 | Literals are uncompressed data stored directly in the byte stream. 49 | The literal length is stored differently depending on the length 50 | of the literal: 51 | 52 | - For literals up to and including 60 bytes in length, the upper 53 | six bits of the tag byte contain (len-1). The literal follows 54 | immediately thereafter in the bytestream. 55 | - For longer literals, the (len-1) value is stored after the tag byte, 56 | little-endian. The upper six bits of the tag byte describe how 57 | many bytes are used for the length; 60, 61, 62 or 63 for 58 | 1-4 bytes, respectively. The literal itself follows after the 59 | length. 60 | 61 | 62 | 2.2. Copies 63 | 64 | Copies are references back into previous decompressed data, telling 65 | the decompressor to reuse data it has previously decoded. 66 | They encode two values: The _offset_, saying how many bytes back 67 | from the current position to read, and the _length_, how many bytes 68 | to copy. Offsets of zero can be encoded, but are not legal; 69 | similarly, it is possible to encode backreferences that would 70 | go past the end of the block (offset > current decompressed position), 71 | which is also nonsensical and thus not allowed. 72 | 73 | As in most LZ77-based compressors, the length can be larger than the offset, 74 | yielding a form of run-length encoding (RLE). For instance, 75 | "xababab" could be encoded as 76 | 77 | 78 | 79 | Note that since the current Snappy compressor works in 32 kB 80 | blocks and does not do matching across blocks, it will never produce 81 | a bitstream with offsets larger than about 32768. However, the 82 | decompressor should not rely on this, as it may change in the future. 83 | 84 | There are several different kinds of copy elements, depending on 85 | the amount of bytes to be copied (length), and how far back the 86 | data to be copied is (offset). 87 | 88 | 89 | 2.2.1. Copy with 1-byte offset (01) 90 | 91 | These elements can encode lengths between [4..11] bytes and offsets 92 | between [0..2047] bytes. (len-4) occupies three bits and is stored 93 | in bits [2..4] of the tag byte. The offset occupies 11 bits, of which the 94 | upper three are stored in the upper three bits ([5..7]) of the tag byte, 95 | and the lower eight are stored in a byte following the tag byte. 96 | 97 | 98 | 2.2.2. Copy with 2-byte offset (10) 99 | 100 | These elements can encode lengths between [1..64] and offsets from 101 | [0..65535]. (len-1) occupies six bits and is stored in the upper 102 | six bits ([2..7]) of the tag byte. The offset is stored as a 103 | little-endian 16-bit integer in the two bytes following the tag byte. 104 | 105 | 106 | 2.2.3. Copy with 4-byte offset (11) 107 | 108 | These are like the copies with 2-byte offsets (see previous subsection), 109 | except that the offset is stored as a 32-bit integer instead of a 110 | 16-bit integer (and thus will occupy four bytes). 111 | -------------------------------------------------------------------------------- /external/snappy/framing_format.txt: -------------------------------------------------------------------------------- 1 | Snappy framing format description 2 | Last revised: 2013-10-25 3 | 4 | This format decribes a framing format for Snappy, allowing compressing to 5 | files or streams that can then more easily be decompressed without having 6 | to hold the entire stream in memory. It also provides data checksums to 7 | help verify integrity. It does not provide metadata checksums, so it does 8 | not protect against e.g. all forms of truncations. 9 | 10 | Implementation of the framing format is optional for Snappy compressors and 11 | decompressor; it is not part of the Snappy core specification. 12 | 13 | 14 | 1. General structure 15 | 16 | The file consists solely of chunks, lying back-to-back with no padding 17 | in between. Each chunk consists first a single byte of chunk identifier, 18 | then a three-byte little-endian length of the chunk in bytes (from 0 to 19 | 16777215, inclusive), and then the data if any. The four bytes of chunk 20 | header is not counted in the data length. 21 | 22 | The different chunk types are listed below. The first chunk must always 23 | be the stream identifier chunk (see section 4.1, below). The stream 24 | ends when the file ends -- there is no explicit end-of-file marker. 25 | 26 | 27 | 2. File type identification 28 | 29 | The following identifiers for this format are recommended where appropriate. 30 | However, note that none have been registered officially, so this is only to 31 | be taken as a guideline. We use "Snappy framed" to distinguish between this 32 | format and raw Snappy data. 33 | 34 | File extension: .sz 35 | MIME type: application/x-snappy-framed 36 | HTTP Content-Encoding: x-snappy-framed 37 | 38 | 39 | 3. Checksum format 40 | 41 | Some chunks have data protected by a checksum (the ones that do will say so 42 | explicitly). The checksums are always masked CRC-32Cs. 43 | 44 | A description of CRC-32C can be found in RFC 3720, section 12.1, with 45 | examples in section B.4. 46 | 47 | Checksums are not stored directly, but masked, as checksumming data and 48 | then its own checksum can be problematic. The masking is the same as used 49 | in Apache Hadoop: Rotate the checksum by 15 bits, then add the constant 50 | 0xa282ead8 (using wraparound as normal for unsigned integers). This is 51 | equivalent to the following C code: 52 | 53 | uint32_t mask_checksum(uint32_t x) { 54 | return ((x >> 15) | (x << 17)) + 0xa282ead8; 55 | } 56 | 57 | Note that the masking is reversible. 58 | 59 | The checksum is always stored as a four bytes long integer, in little-endian. 60 | 61 | 62 | 4. Chunk types 63 | 64 | The currently supported chunk types are described below. The list may 65 | be extended in the future. 66 | 67 | 68 | 4.1. Stream identifier (chunk type 0xff) 69 | 70 | The stream identifier is always the first element in the stream. 71 | It is exactly six bytes long and contains "sNaPpY" in ASCII. This means that 72 | a valid Snappy framed stream always starts with the bytes 73 | 74 | 0xff 0x06 0x00 0x00 0x73 0x4e 0x61 0x50 0x70 0x59 75 | 76 | The stream identifier chunk can come multiple times in the stream besides 77 | the first; if such a chunk shows up, it should simply be ignored, assuming 78 | it has the right length and contents. This allows for easy concatenation of 79 | compressed files without the need for re-framing. 80 | 81 | 82 | 4.2. Compressed data (chunk type 0x00) 83 | 84 | Compressed data chunks contain a normal Snappy compressed bitstream; 85 | see the compressed format specification. The compressed data is preceded by 86 | the CRC-32C (see section 3) of the _uncompressed_ data. 87 | 88 | Note that the data portion of the chunk, i.e., the compressed contents, 89 | can be at most 16777211 bytes (2^24 - 1, minus the checksum). 90 | However, we place an additional restriction that the uncompressed data 91 | in a chunk must be no longer than 65536 bytes. This allows consumers to 92 | easily use small fixed-size buffers. 93 | 94 | 95 | 4.3. Uncompressed data (chunk type 0x01) 96 | 97 | Uncompressed data chunks allow a compressor to send uncompressed, 98 | raw data; this is useful if, for instance, uncompressible or 99 | near-incompressible data is detected, and faster decompression is desired. 100 | 101 | As in the compressed chunks, the data is preceded by its own masked 102 | CRC-32C (see section 3). 103 | 104 | An uncompressed data chunk, like compressed data chunks, should contain 105 | no more than 65536 data bytes, so the maximum legal chunk length with the 106 | checksum is 65540. 107 | 108 | 109 | 4.4. Padding (chunk type 0xfe) 110 | 111 | Padding chunks allow a compressor to increase the size of the data stream 112 | so that it complies with external demands, e.g. that the total number of 113 | bytes is a multiple of some value. 114 | 115 | All bytes of the padding chunk, except the chunk byte itself and the length, 116 | should be zero, but decompressors must not try to interpret or verify the 117 | padding data in any way. 118 | 119 | 120 | 4.5. Reserved unskippable chunks (chunk types 0x02-0x7f) 121 | 122 | These are reserved for future expansion. A decoder that sees such a chunk 123 | should immediately return an error, as it must assume it cannot decode the 124 | stream correctly. 125 | 126 | Future versions of this specification may define meanings for these chunks. 127 | 128 | 129 | 4.6. Reserved skippable chunks (chunk types 0x80-0xfd) 130 | 131 | These are also reserved for future expansion, but unlike the chunks 132 | described in 4.5, a decoder seeing these must skip them and continue 133 | decoding. 134 | 135 | Future versions of this specification may define meanings for these chunks. 136 | -------------------------------------------------------------------------------- /external/snappy/snappy-c.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Martin Gieseking . 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include "snappy.h" 30 | #include "snappy-c.h" 31 | 32 | extern "C" { 33 | 34 | snappy_status snappy_compress(const char* input, 35 | size_t input_length, 36 | char* compressed, 37 | size_t *compressed_length) { 38 | if (*compressed_length < snappy_max_compressed_length(input_length)) { 39 | return SNAPPY_BUFFER_TOO_SMALL; 40 | } 41 | snappy::RawCompress(input, input_length, compressed, compressed_length); 42 | return SNAPPY_OK; 43 | } 44 | 45 | snappy_status snappy_uncompress(const char* compressed, 46 | size_t compressed_length, 47 | char* uncompressed, 48 | size_t* uncompressed_length) { 49 | size_t real_uncompressed_length; 50 | if (!snappy::GetUncompressedLength(compressed, 51 | compressed_length, 52 | &real_uncompressed_length)) { 53 | return SNAPPY_INVALID_INPUT; 54 | } 55 | if (*uncompressed_length < real_uncompressed_length) { 56 | return SNAPPY_BUFFER_TOO_SMALL; 57 | } 58 | if (!snappy::RawUncompress(compressed, compressed_length, uncompressed)) { 59 | return SNAPPY_INVALID_INPUT; 60 | } 61 | *uncompressed_length = real_uncompressed_length; 62 | return SNAPPY_OK; 63 | } 64 | 65 | size_t snappy_max_compressed_length(size_t source_length) { 66 | return snappy::MaxCompressedLength(source_length); 67 | } 68 | 69 | snappy_status snappy_uncompressed_length(const char *compressed, 70 | size_t compressed_length, 71 | size_t *result) { 72 | if (snappy::GetUncompressedLength(compressed, 73 | compressed_length, 74 | result)) { 75 | return SNAPPY_OK; 76 | } else { 77 | return SNAPPY_INVALID_INPUT; 78 | } 79 | } 80 | 81 | snappy_status snappy_validate_compressed_buffer(const char *compressed, 82 | size_t compressed_length) { 83 | if (snappy::IsValidCompressedBuffer(compressed, compressed_length)) { 84 | return SNAPPY_OK; 85 | } else { 86 | return SNAPPY_INVALID_INPUT; 87 | } 88 | } 89 | 90 | } // extern "C" 91 | -------------------------------------------------------------------------------- /external/snappy/snappy-c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Martin Gieseking . 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * * Neither the name of Google Inc. nor the names of its 15 | * contributors may be used to endorse or promote products derived from 16 | * this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * Plain C interface (a wrapper around the C++ implementation). 31 | */ 32 | 33 | #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ 34 | #define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #include 41 | 42 | /* 43 | * Return values; see the documentation for each function to know 44 | * what each can return. 45 | */ 46 | typedef enum { 47 | SNAPPY_OK = 0, 48 | SNAPPY_INVALID_INPUT = 1, 49 | SNAPPY_BUFFER_TOO_SMALL = 2 50 | } snappy_status; 51 | 52 | /* 53 | * Takes the data stored in "input[0..input_length-1]" and stores 54 | * it in the array pointed to by "compressed". 55 | * 56 | * signals the space available in "compressed". 57 | * If it is not at least equal to "snappy_max_compressed_length(input_length)", 58 | * SNAPPY_BUFFER_TOO_SMALL is returned. After successful compression, 59 | * contains the true length of the compressed output, 60 | * and SNAPPY_OK is returned. 61 | * 62 | * Example: 63 | * size_t output_length = snappy_max_compressed_length(input_length); 64 | * char* output = (char*)malloc(output_length); 65 | * if (snappy_compress(input, input_length, output, &output_length) 66 | * == SNAPPY_OK) { 67 | * ... Process(output, output_length) ... 68 | * } 69 | * free(output); 70 | */ 71 | snappy_status snappy_compress(const char* input, 72 | size_t input_length, 73 | char* compressed, 74 | size_t* compressed_length); 75 | 76 | /* 77 | * Given data in "compressed[0..compressed_length-1]" generated by 78 | * calling the snappy_compress routine, this routine stores 79 | * the uncompressed data to 80 | * uncompressed[0..uncompressed_length-1]. 81 | * Returns failure (a value not equal to SNAPPY_OK) if the message 82 | * is corrupted and could not be decrypted. 83 | * 84 | * signals the space available in "uncompressed". 85 | * If it is not at least equal to the value returned by 86 | * snappy_uncompressed_length for this stream, SNAPPY_BUFFER_TOO_SMALL 87 | * is returned. After successful decompression, 88 | * contains the true length of the decompressed output. 89 | * 90 | * Example: 91 | * size_t output_length; 92 | * if (snappy_uncompressed_length(input, input_length, &output_length) 93 | * != SNAPPY_OK) { 94 | * ... fail ... 95 | * } 96 | * char* output = (char*)malloc(output_length); 97 | * if (snappy_uncompress(input, input_length, output, &output_length) 98 | * == SNAPPY_OK) { 99 | * ... Process(output, output_length) ... 100 | * } 101 | * free(output); 102 | */ 103 | snappy_status snappy_uncompress(const char* compressed, 104 | size_t compressed_length, 105 | char* uncompressed, 106 | size_t* uncompressed_length); 107 | 108 | /* 109 | * Returns the maximal size of the compressed representation of 110 | * input data that is "source_length" bytes in length. 111 | */ 112 | size_t snappy_max_compressed_length(size_t source_length); 113 | 114 | /* 115 | * REQUIRES: "compressed[]" was produced by snappy_compress() 116 | * Returns SNAPPY_OK and stores the length of the uncompressed data in 117 | * *result normally. Returns SNAPPY_INVALID_INPUT on parsing error. 118 | * This operation takes O(1) time. 119 | */ 120 | snappy_status snappy_uncompressed_length(const char* compressed, 121 | size_t compressed_length, 122 | size_t* result); 123 | 124 | /* 125 | * Check if the contents of "compressed[]" can be uncompressed successfully. 126 | * Does not return the uncompressed data; if so, returns SNAPPY_OK, 127 | * or if not, returns SNAPPY_INVALID_INPUT. 128 | * Takes time proportional to compressed_length, but is usually at least a 129 | * factor of four faster than actual decompression. 130 | */ 131 | snappy_status snappy_validate_compressed_buffer(const char* compressed, 132 | size_t compressed_length); 133 | 134 | #ifdef __cplusplus 135 | } // extern "C" 136 | #endif 137 | 138 | #endif /* THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_C_H_ */ 139 | -------------------------------------------------------------------------------- /external/snappy/snappy-sinksource.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | 31 | #include "snappy-sinksource.h" 32 | 33 | namespace snappy { 34 | 35 | Source::~Source() { } 36 | 37 | Sink::~Sink() { } 38 | 39 | char* Sink::GetAppendBuffer(size_t length, char* scratch) { 40 | return scratch; 41 | } 42 | 43 | char* Sink::GetAppendBufferVariable( 44 | size_t min_size, size_t desired_size_hint, char* scratch, 45 | size_t scratch_size, size_t* allocated_size) { 46 | *allocated_size = scratch_size; 47 | return scratch; 48 | } 49 | 50 | void Sink::AppendAndTakeOwnership( 51 | char* bytes, size_t n, 52 | void (*deleter)(void*, const char*, size_t), 53 | void *deleter_arg) { 54 | Append(bytes, n); 55 | (*deleter)(deleter_arg, bytes, n); 56 | } 57 | 58 | ByteArraySource::~ByteArraySource() { } 59 | 60 | size_t ByteArraySource::Available() const { return left_; } 61 | 62 | const char* ByteArraySource::Peek(size_t* len) { 63 | *len = left_; 64 | return ptr_; 65 | } 66 | 67 | void ByteArraySource::Skip(size_t n) { 68 | left_ -= n; 69 | ptr_ += n; 70 | } 71 | 72 | UncheckedByteArraySink::~UncheckedByteArraySink() { } 73 | 74 | void UncheckedByteArraySink::Append(const char* data, size_t n) { 75 | // Do no copying if the caller filled in the result of GetAppendBuffer() 76 | if (data != dest_) { 77 | memcpy(dest_, data, n); 78 | } 79 | dest_ += n; 80 | } 81 | 82 | char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) { 83 | return dest_; 84 | } 85 | 86 | void UncheckedByteArraySink::AppendAndTakeOwnership( 87 | char* data, size_t n, 88 | void (*deleter)(void*, const char*, size_t), 89 | void *deleter_arg) { 90 | if (data != dest_) { 91 | memcpy(dest_, data, n); 92 | (*deleter)(deleter_arg, data, n); 93 | } 94 | dest_ += n; 95 | } 96 | 97 | char* UncheckedByteArraySink::GetAppendBufferVariable( 98 | size_t min_size, size_t desired_size_hint, char* scratch, 99 | size_t scratch_size, size_t* allocated_size) { 100 | *allocated_size = desired_size_hint; 101 | return dest_; 102 | } 103 | 104 | } // namespace snappy 105 | -------------------------------------------------------------------------------- /external/snappy/snappy-stubs-internal.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | #include 30 | #include 31 | 32 | #include "snappy-stubs-internal.h" 33 | 34 | namespace snappy { 35 | 36 | void Varint::Append32(string* s, uint32 value) { 37 | char buf[Varint::kMax32]; 38 | const char* p = Varint::Encode32(buf, value); 39 | s->append(buf, p - buf); 40 | } 41 | 42 | } // namespace snappy 43 | -------------------------------------------------------------------------------- /external/snappy/snappy-stubs-public.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All Rights Reserved. 2 | // Author: sesse@google.com (Steinar H. Gunderson) 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Various type stubs for the open-source version of Snappy. 31 | // 32 | // This file cannot include config.h, as it is included from snappy.h, 33 | // which is a public header. Instead, snappy-stubs-public.h is generated by 34 | // from snappy-stubs-public.h.in at configure time. 35 | 36 | #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ 37 | #define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ 38 | 39 | #if ${HAVE_STDINT_H_01} // HAVE_STDINT_H 40 | #include 41 | #endif // HAVE_STDDEF_H 42 | 43 | #if ${HAVE_STDDEF_H_01} // HAVE_STDDEF_H 44 | #include 45 | #endif // HAVE_STDDEF_H 46 | 47 | #if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H 48 | #include 49 | #endif // HAVE_SYS_UIO_H 50 | 51 | #define SNAPPY_MAJOR ${PROJECT_VERSION_MAJOR} 52 | #define SNAPPY_MINOR ${PROJECT_VERSION_MINOR} 53 | #define SNAPPY_PATCHLEVEL ${PROJECT_VERSION_PATCH} 54 | #define SNAPPY_VERSION \ 55 | ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL) 56 | 57 | #include 58 | 59 | namespace snappy { 60 | 61 | #if ${HAVE_STDINT_H_01} // HAVE_STDINT_H 62 | typedef int8_t int8; 63 | typedef uint8_t uint8; 64 | typedef int16_t int16; 65 | typedef uint16_t uint16; 66 | typedef int32_t int32; 67 | typedef uint32_t uint32; 68 | typedef int64_t int64; 69 | typedef uint64_t uint64; 70 | #else 71 | typedef signed char int8; 72 | typedef unsigned char uint8; 73 | typedef short int16; 74 | typedef unsigned short uint16; 75 | typedef int int32; 76 | typedef unsigned int uint32; 77 | typedef long long int64; 78 | typedef unsigned long long uint64; 79 | #endif // HAVE_STDINT_H 80 | 81 | typedef std::string string; 82 | 83 | #if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H 84 | // Windows does not have an iovec type, yet the concept is universally useful. 85 | // It is simple to define it ourselves, so we put it inside our own namespace. 86 | struct iovec { 87 | void* iov_base; 88 | size_t iov_len; 89 | }; 90 | #endif // !HAVE_SYS_UIO_H 91 | 92 | } // namespace snappy 93 | 94 | #endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_ 95 | -------------------------------------------------------------------------------- /external/snappy/testdata/baddata1.snappy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/external/snappy/testdata/baddata1.snappy -------------------------------------------------------------------------------- /external/snappy/testdata/baddata2.snappy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/external/snappy/testdata/baddata2.snappy -------------------------------------------------------------------------------- /external/snappy/testdata/baddata3.snappy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/external/snappy/testdata/baddata3.snappy -------------------------------------------------------------------------------- /external/snappy/testdata/fireworks.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/external/snappy/testdata/fireworks.jpeg -------------------------------------------------------------------------------- /external/snappy/testdata/geo.protodata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/external/snappy/testdata/geo.protodata -------------------------------------------------------------------------------- /external/snappy/testdata/paper-100k.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/disguise-one/hap-encoder-adobe-cc/05e74a89e413b6b1394c17da08310d365440d8c1/external/snappy/testdata/paper-100k.pdf -------------------------------------------------------------------------------- /external/squish/README.md: -------------------------------------------------------------------------------- 1 | This directory contains source for squish and an Xcode project and script to build it. 2 | 3 | Squish is available from http://code.google.com/p/libsquish/ 4 | 5 | This source was acquired at revision 44 thus: 6 | 7 | svn export -r 44 http://libsquish.googlecode.com/svn/trunk squish-source 8 | 9 | On MacOS, the script build-squish.sh is run from within Xcode to build a 32-bit version of the library suitable for use by the Hap codec. A Visual Studio project is used to build on Windows. 10 | 11 | Changes made to the libsquish source for Hap: 12 | 13 | - The test and images directories have been removed 14 | - GNUmakefile has been modified to build a dynamic library (for Hap this only affects the Mac build) 15 | - The generation of 3+clear DXT blocks is supressed as some OpenGL drivers mistreat RGB DXT1 16 | -------------------------------------------------------------------------------- /external/squish/squish-source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # cmake build file for squish 2 | # by Stefan Roettger (stefan@stereofx.org) 3 | # updated by Simon Brown (si@sjbrown.co.uk) 4 | 5 | # features: 6 | # Xcode: builds universal binaries, uses SSE2 on i386 and Altivec on ppc 7 | # Unix and VS: SSE2 support is enabled by default 8 | # use BUILD_SQUISH_WITH_SSE2 and BUILD_SQUISH_WITH_ALTIVEC to override 9 | 10 | PROJECT(squish) 11 | 12 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) 13 | 14 | OPTION(BUILD_SQUISH_WITH_SSE2 "Build with SSE2." ON) 15 | OPTION(BUILD_SQUISH_WITH_ALTIVEC "Build with Altivec." OFF) 16 | 17 | OPTION(BUILD_SHARED_LIBS "Build shared libraries." OFF) 18 | 19 | OPTION(BUILD_SQUISH_EXTRA "Build extra source code." OFF) 20 | 21 | IF (CMAKE_GENERATOR STREQUAL "Xcode") 22 | #!!! ----BEGIN---- 23 | #!!! SET(CMAKE_OSX_ARCHITECTURES "i386;ppc") 24 | SET(CMAKE_OSX_ARCHITECTURES "x86_64") 25 | #!!! ----END---- 26 | ELSE (CMAKE_GENERATOR STREQUAL "Xcode") 27 | #!!! ----BEGIN---- 28 | #!!! previously relied on BUILD_SQUISH_WITH_SSE2=2 being set in non-generated .vcprojs 29 | #!!! IF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) 30 | #!!! ADD_DEFINITIONS(-DSQUISH_USE_SSE=2 -msse2) 31 | #!!! ENDIF (BUILD_SQUISH_WITH_SSE2 AND NOT WIN32) 32 | IF (BUILD_SQUISH_WITH_SSE2) 33 | ADD_DEFINITIONS(-DSQUISH_USE_SSE=2) 34 | IF (NOT WIN32) 35 | ADD_DEFINITIONS(-msse2) 36 | ENDIF (NOT WIN32) 37 | ENDIF (BUILD_SQUISH_WITH_SSE2) 38 | #!!! ----END---- 39 | IF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) 40 | ADD_DEFINITIONS(-DSQUISH_USE_ALTIVEC=1 -maltivec) 41 | ENDIF (BUILD_SQUISH_WITH_ALTIVEC AND NOT WIN32) 42 | ENDIF (CMAKE_GENERATOR STREQUAL "Xcode") 43 | 44 | SET(SQUISH_HDRS 45 | squish.h 46 | ) 47 | 48 | SET(SQUISH_SRCS 49 | alpha.cpp 50 | alpha.h 51 | clusterfit.cpp 52 | clusterfit.h 53 | colourblock.cpp 54 | colourblock.h 55 | colourfit.cpp 56 | colourfit.h 57 | colourset.cpp 58 | colourset.h 59 | maths.cpp 60 | maths.h 61 | rangefit.cpp 62 | rangefit.h 63 | simd.h 64 | simd_float.h 65 | simd_sse.h 66 | simd_ve.h 67 | singlecolourfit.cpp 68 | singlecolourfit.h 69 | singlecolourlookup.inl 70 | squish.cpp 71 | ) 72 | 73 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) 74 | 75 | ADD_LIBRARY(squish ${SQUISH_SRCS} ${SQUISH_HDRS}) 76 | 77 | SET_TARGET_PROPERTIES( 78 | squish PROPERTIES 79 | PUBLIC_HEADER "${SQUISH_HDRS}" 80 | VERSION 0.0 81 | SOVERSION 0.0 82 | DEBUG_POSTFIX "d" 83 | XCODE_ATTRIBUTE_GCC_PREPROCESSOR_DEFINITIONS "$(SQUISH_CPP_$(CURRENT_ARCH))" 84 | XCODE_ATTRIBUTE_OTHER_CFLAGS "$(SQUISH_CFLAGS_$(CURRENT_ARCH))" 85 | XCODE_ATTRIBUTE_SQUISH_CPP_i386 "SQUISH_USE_SSE=2" 86 | XCODE_ATTRIBUTE_SQUISH_CFLAGS_i386 "" 87 | XCODE_ATTRIBUTE_SQUISH_CPP_ppc "SQUISH_USE_ALTIVEC=1" 88 | XCODE_ATTRIBUTE_SQUISH_CFLAGS_ppc "-maltivec" 89 | ) 90 | 91 | IF (BUILD_SQUISH_EXTRA) 92 | SET(SQUISHTEST_SRCS extra/squishtest.cpp) 93 | 94 | ADD_EXECUTABLE(squishtest ${SQUISHTEST_SRCS}) 95 | SET_TARGET_PROPERTIES(squishtest PROPERTIES DEBUG_POSTFIX "d") 96 | TARGET_LINK_LIBRARIES(squishtest squish) 97 | 98 | SET(SQUISHPNG_SRCS extra/squishpng.cpp) 99 | 100 | FIND_PACKAGE(PNG) 101 | 102 | IF (PNG_FOUND) 103 | SET(CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES) 104 | INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR}) 105 | ADD_EXECUTABLE(squishpng ${SQUISHPNG_SRCS}) 106 | SET_TARGET_PROPERTIES(squishpng PROPERTIES DEBUG_POSTFIX "d") 107 | TARGET_LINK_LIBRARIES(squishpng squish ${PNG_LIBRARIES}) 108 | ENDIF (PNG_FOUND) 109 | ENDIF (BUILD_SQUISH_EXTRA) 110 | 111 | INSTALL( 112 | TARGETS squish 113 | LIBRARY DESTINATION lib 114 | ARCHIVE DESTINATION lib 115 | PUBLIC_HEADER DESTINATION include 116 | ) 117 | -------------------------------------------------------------------------------- /external/squish/squish-source/ChangeLog: -------------------------------------------------------------------------------- 1 | 1.10 2 | * Iterative cluster fit is now considered to be a new compression mode 3 | * The core cluster fit is now 4x faster using contributions by Ignacio 4 | Castano from NVIDIA 5 | * The single colour lookup table has been halved by exploiting symmetry 6 | 7 | 1.9 8 | * Added contributed SSE1 truncate implementation 9 | * Changed use of SQUISH_USE_SSE to be 1 for SSE and 2 for SSE2 instructions 10 | * Cluster fit is now iterative to further reduce image error 11 | 12 | 1.8 13 | * Switched from using floor to trunc for much better SSE performance (again) 14 | * Xcode build now expects libpng in /usr/local for extra/squishpng 15 | 16 | 1.7 17 | * Fixed floating-point equality issue in clusterfit sort (x86 affected only) 18 | * Implemented proper SSE(2) floor function for 50% speedup on SSE builds 19 | * The range fit implementation now uses the correct colour metric 20 | 21 | 1.6 22 | * Fixed bug in CompressImage where masked pixels were not skipped over 23 | * DXT3 and DXT5 alpha compression now properly use the mask to ignore pixels 24 | * Fixed major DXT1 bug that can generate unexpected transparent pixels 25 | 26 | 1.5 27 | * Added CompressMasked function to handle incomplete DXT blocks more cleanly 28 | * Added kWeightColourByAlpha flag for better quality images when alpha blending 29 | 30 | 1.4 31 | * Fixed stack overflow in rangefit 32 | 33 | 1.3 34 | * Worked around SSE floor implementation bug, proper fix needed! 35 | * This release has visual studio and makefile builds that work 36 | 37 | 1.2 38 | * Added provably optimal single colour compressor 39 | * Added extra/squishgen.cpp that generates single colour lookup tables 40 | 41 | 1.1 42 | * Fixed a DXT1 colour output bug 43 | * Changed argument order for Decompress function to match Compress 44 | * Added GetStorageRequirements function 45 | * Added CompressImage function 46 | * Added DecompressImage function 47 | * Moved squishtool.cpp to extra/squishpng.cpp 48 | * Added extra/squishtest.cpp 49 | 50 | 1.0 51 | * Initial release 52 | 53 | -------------------------------------------------------------------------------- /external/squish/squish-source/GNUmakefile: -------------------------------------------------------------------------------- 1 | include config 2 | 3 | VER = 1.13 4 | SOVER = 0 5 | 6 | SRC = alpha.cpp clusterfit.cpp colourblock.cpp colourfit.cpp colourset.cpp maths.cpp rangefit.cpp singlecolourfit.cpp squish.cpp 7 | 8 | HDR = alpha.h clusterfit.h colourblock.h colourfit.h colourset.h maths.h rangefit.h singlecolourfit.h squish.h 9 | HDR += config.h simd.h simd_float.h simd_sse.h simd_ve.h singlecolourlookup.inl 10 | 11 | OBJ = $(SRC:%.cpp=%.o) 12 | 13 | ifeq ($(HOSTTYPE),intel-pc) # intel-pc = macos x 14 | USE_SHARED = 0 15 | endif 16 | 17 | ifeq ($(USE_SHARED),1) 18 | SOLIB = libsquish.$(SOVER).dylib 19 | LIB = $(SOLIB) 20 | CPPFLAGS += -fPIC 21 | else 22 | LIB = libsquish.a 23 | endif 24 | 25 | all: $(LIB) 26 | 27 | install: $(LIB) 28 | install squish.h $(INSTALL_DIR)/include 29 | install $(LIB) $(INSTALL_DIR)/lib 30 | 31 | uninstall: 32 | $(RM) $(INSTALL_DIR)/include/squish.h 33 | $(RM) $(INSTALL_DIR)/lib/$(LIB) 34 | 35 | $(LIB): $(OBJ) 36 | ifeq ($(USE_SHARED),1) 37 | $(CXX) -dynamiclib -Wl,-install_name,@rpath/$(SOLIB) -o $@ $(OBJ) 38 | else 39 | $(AR) cr $@ $? 40 | ranlib $@ 41 | endif 42 | 43 | tgz: clean 44 | tar zcf libsquish-$(VER).tgz $(SRC) $(HDR) GNUmakefile config CMakeLists.txt libsquish.pro README ChangeLog Doxyfile 45 | 46 | %.o: %.cpp 47 | $(CXX) $(CPPFLAGS) -I. $(CXXFLAGS) -o $@ -c $< 48 | 49 | clean: 50 | $(RM) $(OBJ) $(LIB) Makefile 51 | -------------------------------------------------------------------------------- /external/squish/squish-source/README: -------------------------------------------------------------------------------- 1 | LICENSE 2 | ------- 3 | 4 | The squish library is distributed under the terms and conditions of the MIT 5 | license. This license is specified at the top of each source file and must be 6 | preserved in its entirety. 7 | 8 | BUILDING AND INSTALLING THE LIBRARY 9 | ----------------------------------- 10 | 11 | If you are using Visual Studio 2003 or above under Windows then load the Visual 12 | Studio 2003 project in the vs7 folder. By default, the library is built using 13 | SSE2 optimisations. To change this either change or remove the SQUISH_USE_SSE=2 14 | from the preprocessor symbols. 15 | 16 | If you are using a Mac then load the Xcode 2.2 project in the distribution. By 17 | default, the library is built using Altivec optimisations. To change this 18 | either change or remove SQUISH_USE_ALTIVEC=1 from the preprocessor symbols. I 19 | guess I'll have to think about changing this for the new Intel Macs that are 20 | rolling out... 21 | 22 | If you are using unix then first edit the config file in the base directory of 23 | the distribution, enabling Altivec or SSE with the USE_ALTIVEC or USE_SSE 24 | variables, and editing the optimisation flags passed to the C++ compiler if 25 | necessary. Then make can be used to build the library, and make install (from 26 | the superuser account) can be used to install (into /usr/local by default). 27 | 28 | REPORTING BUGS OR FEATURE REQUESTS 29 | ---------------------------------- 30 | 31 | Feedback can be sent to Simon Brown (the developer) at si@sjbrown.co.uk 32 | 33 | New releases are announced on the squish library homepage at 34 | http://sjbrown.co.uk/?code=squish 35 | 36 | -------------------------------------------------------------------------------- /external/squish/squish-source/alpha.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_ALPHA_H 27 | #define SQUISH_ALPHA_H 28 | 29 | #include "squish.h" 30 | 31 | namespace squish { 32 | 33 | void CompressAlphaDxt3( u8 const* rgba, int mask, void* block ); 34 | void CompressAlphaDxt5( u8 const* rgba, int mask, void* block ); 35 | 36 | void DecompressAlphaDxt3( u8* rgba, void const* block ); 37 | void DecompressAlphaDxt5( u8* rgba, void const* block ); 38 | 39 | } // namespace squish 40 | 41 | #endif // ndef SQUISH_ALPHA_H 42 | -------------------------------------------------------------------------------- /external/squish/squish-source/clusterfit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | Copyright (c) 2007 Ignacio Castano icastano@nvidia.com 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | -------------------------------------------------------------------------- */ 26 | 27 | #ifndef SQUISH_CLUSTERFIT_H 28 | #define SQUISH_CLUSTERFIT_H 29 | 30 | #include "squish.h" 31 | #include "maths.h" 32 | #include "simd.h" 33 | #include "colourfit.h" 34 | 35 | namespace squish { 36 | 37 | class ClusterFit : public ColourFit 38 | { 39 | public: 40 | ClusterFit( ColourSet const* colours, int flags, float* metric ); 41 | 42 | private: 43 | bool ConstructOrdering( Vec3 const& axis, int iteration ); 44 | 45 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 46 | virtual void Compress3( void* block ); 47 | #endif 48 | virtual void Compress4( void* block ); 49 | 50 | enum { kMaxIterations = 8 }; 51 | 52 | int m_iterationCount; 53 | Vec3 m_principle; 54 | u8 m_order[16*kMaxIterations]; 55 | Vec4 m_points_weights[16]; 56 | Vec4 m_xsum_wsum; 57 | Vec4 m_metric; 58 | Vec4 m_besterror; 59 | }; 60 | 61 | } // namespace squish 62 | 63 | #endif // ndef SQUISH_CLUSTERFIT_H 64 | -------------------------------------------------------------------------------- /external/squish/squish-source/colourblock.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include "colourblock.h" 27 | 28 | namespace squish { 29 | 30 | static int FloatToInt( float a, int limit ) 31 | { 32 | // use ANSI round-to-zero behaviour to get round-to-nearest 33 | int i = ( int )( a + 0.5f ); 34 | 35 | // clamp to the limit 36 | if( i < 0 ) 37 | i = 0; 38 | else if( i > limit ) 39 | i = limit; 40 | 41 | // done 42 | return i; 43 | } 44 | 45 | static int FloatTo565( Vec3::Arg colour ) 46 | { 47 | // get the components in the correct range 48 | int r = FloatToInt( 31.0f*colour.X(), 31 ); 49 | int g = FloatToInt( 63.0f*colour.Y(), 63 ); 50 | int b = FloatToInt( 31.0f*colour.Z(), 31 ); 51 | 52 | // pack into a single value 53 | return ( r << 11 ) | ( g << 5 ) | b; 54 | } 55 | 56 | static void WriteColourBlock( int a, int b, u8* indices, void* block ) 57 | { 58 | // get the block as bytes 59 | u8* bytes = ( u8* )block; 60 | 61 | // write the endpoints 62 | bytes[0] = ( u8 )( a & 0xff ); 63 | bytes[1] = ( u8 )( a >> 8 ); 64 | bytes[2] = ( u8 )( b & 0xff ); 65 | bytes[3] = ( u8 )( b >> 8 ); 66 | 67 | // write the indices 68 | for( int i = 0; i < 4; ++i ) 69 | { 70 | u8 const* ind = indices + 4*i; 71 | bytes[4 + i] = ind[0] | ( ind[1] << 2 ) | ( ind[2] << 4 ) | ( ind[3] << 6 ); 72 | } 73 | } 74 | 75 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 76 | void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ) 77 | { 78 | // get the packed values 79 | int a = FloatTo565( start ); 80 | int b = FloatTo565( end ); 81 | 82 | // remap the indices 83 | u8 remapped[16]; 84 | if( a <= b ) 85 | { 86 | // use the indices directly 87 | for( int i = 0; i < 16; ++i ) 88 | remapped[i] = indices[i]; 89 | } 90 | else 91 | { 92 | // swap a and b 93 | std::swap( a, b ); 94 | for( int i = 0; i < 16; ++i ) 95 | { 96 | if( indices[i] == 0 ) 97 | remapped[i] = 1; 98 | else if( indices[i] == 1 ) 99 | remapped[i] = 0; 100 | else 101 | remapped[i] = indices[i]; 102 | } 103 | } 104 | 105 | // write the block 106 | WriteColourBlock( a, b, remapped, block ); 107 | } 108 | #endif 109 | 110 | void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ) 111 | { 112 | // get the packed values 113 | int a = FloatTo565( start ); 114 | int b = FloatTo565( end ); 115 | 116 | // remap the indices 117 | u8 remapped[16]; 118 | if( a < b ) 119 | { 120 | // swap a and b 121 | std::swap( a, b ); 122 | for( int i = 0; i < 16; ++i ) 123 | remapped[i] = ( indices[i] ^ 0x1 ) & 0x3; 124 | } 125 | else if( a == b ) 126 | { 127 | // use index 0 128 | for( int i = 0; i < 16; ++i ) 129 | remapped[i] = 0; 130 | } 131 | else 132 | { 133 | // use the indices directly 134 | for( int i = 0; i < 16; ++i ) 135 | remapped[i] = indices[i]; 136 | } 137 | 138 | // write the block 139 | WriteColourBlock( a, b, remapped, block ); 140 | } 141 | 142 | static int Unpack565( u8 const* packed, u8* colour ) 143 | { 144 | // build the packed value 145 | int value = ( int )packed[0] | ( ( int )packed[1] << 8 ); 146 | 147 | // get the components in the stored range 148 | u8 red = ( u8 )( ( value >> 11 ) & 0x1f ); 149 | u8 green = ( u8 )( ( value >> 5 ) & 0x3f ); 150 | u8 blue = ( u8 )( value & 0x1f ); 151 | 152 | // scale up to 8 bits 153 | colour[0] = ( red << 3 ) | ( red >> 2 ); 154 | colour[1] = ( green << 2 ) | ( green >> 4 ); 155 | colour[2] = ( blue << 3 ) | ( blue >> 2 ); 156 | colour[3] = 255; 157 | 158 | // return the value 159 | return value; 160 | } 161 | 162 | void DecompressColour( u8* rgba, void const* block, bool isDxt1 ) 163 | { 164 | // get the block bytes 165 | u8 const* bytes = reinterpret_cast< u8 const* >( block ); 166 | 167 | // unpack the endpoints 168 | u8 codes[16]; 169 | int a = Unpack565( bytes, codes ); 170 | int b = Unpack565( bytes + 2, codes + 4 ); 171 | 172 | // generate the midpoints 173 | for( int i = 0; i < 3; ++i ) 174 | { 175 | int c = codes[i]; 176 | int d = codes[4 + i]; 177 | 178 | if( isDxt1 && a <= b ) 179 | { 180 | codes[8 + i] = ( u8 )( ( c + d )/2 ); 181 | codes[12 + i] = 0; 182 | } 183 | else 184 | { 185 | codes[8 + i] = ( u8 )( ( 2*c + d )/3 ); 186 | codes[12 + i] = ( u8 )( ( c + 2*d )/3 ); 187 | } 188 | } 189 | 190 | // fill in alpha for the intermediate values 191 | codes[8 + 3] = 255; 192 | codes[12 + 3] = ( isDxt1 && a <= b ) ? 0 : 255; 193 | 194 | // unpack the indices 195 | u8 indices[16]; 196 | for( int i = 0; i < 4; ++i ) 197 | { 198 | u8* ind = indices + 4*i; 199 | u8 packed = bytes[4 + i]; 200 | 201 | ind[0] = packed & 0x3; 202 | ind[1] = ( packed >> 2 ) & 0x3; 203 | ind[2] = ( packed >> 4 ) & 0x3; 204 | ind[3] = ( packed >> 6 ) & 0x3; 205 | } 206 | 207 | // store out the colours 208 | for( int i = 0; i < 16; ++i ) 209 | { 210 | u8 offset = 4*indices[i]; 211 | for( int j = 0; j < 4; ++j ) 212 | rgba[4*i + j] = codes[offset + j]; 213 | } 214 | } 215 | 216 | } // namespace squish 217 | -------------------------------------------------------------------------------- /external/squish/squish-source/colourblock.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_COLOURBLOCK_H 27 | #define SQUISH_COLOURBLOCK_H 28 | 29 | #include "squish.h" 30 | #include "maths.h" 31 | 32 | namespace squish { 33 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 34 | void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); 35 | #endif 36 | void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); 37 | 38 | void DecompressColour( u8* rgba, void const* block, bool isDxt1 ); 39 | 40 | } // namespace squish 41 | 42 | #endif // ndef SQUISH_COLOURBLOCK_H 43 | -------------------------------------------------------------------------------- /external/squish/squish-source/colourfit.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include "colourfit.h" 27 | #include "colourset.h" 28 | 29 | namespace squish { 30 | 31 | ColourFit::ColourFit( ColourSet const* colours, int flags ) 32 | : m_colours( colours ), 33 | m_flags( flags ) 34 | { 35 | } 36 | 37 | ColourFit::~ColourFit() 38 | { 39 | } 40 | 41 | void ColourFit::Compress( void* block ) 42 | { 43 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 44 | bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 ); 45 | if( isDxt1 ) 46 | { 47 | Compress3( block ); 48 | if( !m_colours->IsTransparent() ) 49 | Compress4( block ); 50 | } 51 | else 52 | #endif 53 | Compress4( block ); 54 | } 55 | 56 | } // namespace squish 57 | -------------------------------------------------------------------------------- /external/squish/squish-source/colourfit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_COLOURFIT_H 27 | #define SQUISH_COLOURFIT_H 28 | 29 | #include "squish.h" 30 | #include "maths.h" 31 | 32 | #include 33 | 34 | namespace squish { 35 | 36 | class ColourSet; 37 | 38 | class ColourFit 39 | { 40 | public: 41 | ColourFit( ColourSet const* colours, int flags ); 42 | virtual ~ColourFit(); 43 | 44 | void Compress( void* block ); 45 | 46 | protected: 47 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 48 | virtual void Compress3( void* block ) = 0; 49 | #endif 50 | virtual void Compress4( void* block ) = 0; 51 | 52 | ColourSet const* m_colours; 53 | int m_flags; 54 | }; 55 | 56 | } // namespace squish 57 | 58 | #endif // ndef SQUISH_COLOURFIT_H 59 | -------------------------------------------------------------------------------- /external/squish/squish-source/colourset.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include "colourset.h" 27 | 28 | namespace squish { 29 | 30 | ColourSet::ColourSet( u8 const* rgba, int mask, int flags ) 31 | : m_count( 0 ), 32 | m_transparent( false ) 33 | { 34 | // check the compression mode for dxt1 35 | bool isDxt1 = ( ( flags & kDxt1 ) != 0 ); 36 | bool weightByAlpha = ( ( flags & kWeightColourByAlpha ) != 0 ); 37 | 38 | // create the minimal set 39 | for( int i = 0; i < 16; ++i ) 40 | { 41 | // check this pixel is enabled 42 | int bit = 1 << i; 43 | if( ( mask & bit ) == 0 ) 44 | { 45 | m_remap[i] = -1; 46 | continue; 47 | } 48 | 49 | // check for transparent pixels when using dxt1 50 | if( isDxt1 && rgba[4*i + 3] < 128 ) 51 | { 52 | m_remap[i] = -1; 53 | m_transparent = true; 54 | continue; 55 | } 56 | 57 | // loop over previous points for a match 58 | for( int j = 0;; ++j ) 59 | { 60 | // allocate a new point 61 | if( j == i ) 62 | { 63 | // normalise coordinates to [0,1] 64 | float x = ( float )rgba[4*i] / 255.0f; 65 | float y = ( float )rgba[4*i + 1] / 255.0f; 66 | float z = ( float )rgba[4*i + 2] / 255.0f; 67 | 68 | // ensure there is always non-zero weight even for zero alpha 69 | float w = ( float )( rgba[4*i + 3] + 1 ) / 256.0f; 70 | 71 | // add the point 72 | m_points[m_count] = Vec3( x, y, z ); 73 | m_weights[m_count] = ( weightByAlpha ? w : 1.0f ); 74 | m_remap[i] = m_count; 75 | 76 | // advance 77 | ++m_count; 78 | break; 79 | } 80 | 81 | // check for a match 82 | int oldbit = 1 << j; 83 | bool match = ( ( mask & oldbit ) != 0 ) 84 | && ( rgba[4*i] == rgba[4*j] ) 85 | && ( rgba[4*i + 1] == rgba[4*j + 1] ) 86 | && ( rgba[4*i + 2] == rgba[4*j + 2] ) 87 | && ( rgba[4*j + 3] >= 128 || !isDxt1 ); 88 | if( match ) 89 | { 90 | // get the index of the match 91 | int index = m_remap[j]; 92 | 93 | // ensure there is always non-zero weight even for zero alpha 94 | float w = ( float )( rgba[4*i + 3] + 1 ) / 256.0f; 95 | 96 | // map to this point and increase the weight 97 | m_weights[index] += ( weightByAlpha ? w : 1.0f ); 98 | m_remap[i] = index; 99 | break; 100 | } 101 | } 102 | } 103 | 104 | // square root the weights 105 | for( int i = 0; i < m_count; ++i ) 106 | m_weights[i] = std::sqrt( m_weights[i] ); 107 | } 108 | 109 | void ColourSet::RemapIndices( u8 const* source, u8* target ) const 110 | { 111 | for( int i = 0; i < 16; ++i ) 112 | { 113 | int j = m_remap[i]; 114 | if( j == -1 ) 115 | target[i] = 3; 116 | else 117 | target[i] = source[j]; 118 | } 119 | } 120 | 121 | } // namespace squish 122 | -------------------------------------------------------------------------------- /external/squish/squish-source/colourset.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_COLOURSET_H 27 | #define SQUISH_COLOURSET_H 28 | 29 | #include "squish.h" 30 | #include "maths.h" 31 | 32 | namespace squish { 33 | 34 | /*! @brief Represents a set of block colours 35 | */ 36 | class ColourSet 37 | { 38 | public: 39 | ColourSet( u8 const* rgba, int mask, int flags ); 40 | 41 | int GetCount() const { return m_count; } 42 | Vec3 const* GetPoints() const { return m_points; } 43 | float const* GetWeights() const { return m_weights; } 44 | bool IsTransparent() const { return m_transparent; } 45 | 46 | void RemapIndices( u8 const* source, u8* target ) const; 47 | 48 | private: 49 | int m_count; 50 | Vec3 m_points[16]; 51 | float m_weights[16]; 52 | int m_remap[16]; 53 | bool m_transparent; 54 | }; 55 | 56 | } // namespace sqish 57 | 58 | #endif // ndef SQUISH_COLOURSET_H 59 | -------------------------------------------------------------------------------- /external/squish/squish-source/config: -------------------------------------------------------------------------------- 1 | # config file used for the GNUmakefile only 2 | 3 | # define to 0 to not build shared library 4 | USE_SHARED ?= 1 5 | 6 | # define to 1 to use Altivec instructions 7 | USE_ALTIVEC ?= 0 8 | 9 | # define to 1 to use SSE2 instructions 10 | USE_SSE ?= 0 11 | 12 | # default flags 13 | CXXFLAGS ?= -O2 -Wall 14 | ifeq ($(USE_ALTIVEC),1) 15 | CPPFLAGS += -DSQUISH_USE_ALTIVEC=1 16 | CXXFLAGS += -maltivec 17 | endif 18 | ifeq ($(USE_SSE),1) 19 | CPPFLAGS += -DSQUISH_USE_SSE=2 20 | CXXFLAGS += -msse 21 | endif 22 | 23 | # where should we install to 24 | INSTALL_DIR ?= /usr/local 25 | -------------------------------------------------------------------------------- /external/squish/squish-source/config.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_CONFIG_H 27 | #define SQUISH_CONFIG_H 28 | 29 | // Set to 1 when building squish to use Altivec instructions. 30 | #ifndef SQUISH_USE_ALTIVEC 31 | #define SQUISH_USE_ALTIVEC 0 32 | #endif 33 | 34 | // Set to 1 or 2 when building squish to use SSE or SSE2 instructions. 35 | #ifndef SQUISH_USE_SSE 36 | #define SQUISH_USE_SSE 0 37 | #endif 38 | 39 | // Internally set SQUISH_USE_SIMD when either Altivec or SSE is available. 40 | #if SQUISH_USE_ALTIVEC && SQUISH_USE_SSE 41 | #error "Cannot enable both Altivec and SSE!" 42 | #endif 43 | #if SQUISH_USE_ALTIVEC || SQUISH_USE_SSE 44 | #define SQUISH_USE_SIMD 1 45 | #else 46 | #define SQUISH_USE_SIMD 0 47 | #endif 48 | 49 | #endif // ndef SQUISH_CONFIG_H 50 | -------------------------------------------------------------------------------- /external/squish/squish-source/extra/squishgen.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include 27 | 28 | struct SourceBlock 29 | { 30 | int start; 31 | int end; 32 | int error; 33 | }; 34 | 35 | struct TargetValue 36 | { 37 | SourceBlock sources[2]; 38 | }; 39 | 40 | static void GenerateData( std::string const& name, int bits, int colours ) 41 | { 42 | TargetValue values[256]; 43 | 44 | // initialise the data 45 | for( int target = 0; target < 256; ++target ) 46 | for( int index = 0; index < colours; ++index ) 47 | values[target].sources[index].error = 255; 48 | 49 | // loop over all possible source points 50 | int count = ( 1 << bits ); 51 | for( int value1 = 0; value1 < count; ++value1 ) 52 | { 53 | for( int value2 = 0; value2 < count; ++value2 ) 54 | { 55 | // compute the 8-bit endpoints 56 | int a = ( value1 << ( 8 - bits ) ) | ( value1 >> ( 2*bits - 8 ) ); 57 | int b = ( value2 << ( 8 - bits ) ) | ( value2 >> ( 2*bits - 8 ) ); 58 | 59 | // fill in the codebook with the these and intermediates 60 | int codes[2]; 61 | codes[0] = a; 62 | if( colours == 3 ) 63 | codes[1] = ( a + b )/2; 64 | else 65 | codes[1] = ( 2*a + b )/3; 66 | 67 | // mark each target point with the endpoints and index needed for it 68 | for( int index = 0; index < 2; ++index ) 69 | { 70 | int target = codes[index]; 71 | 72 | SourceBlock& block = values[target].sources[index]; 73 | if( block.error != 0 ) 74 | { 75 | block.start = value1; 76 | block.end = value2; 77 | block.error = 0; 78 | } 79 | } 80 | } 81 | } 82 | 83 | // iteratively fill in the missing values 84 | for( ;; ) 85 | { 86 | bool stable = true; 87 | for( int index = 0; index < 2; ++index ) 88 | { 89 | for( int target = 0; target < 256; ++target ) 90 | { 91 | if( target != 255 ) 92 | { 93 | SourceBlock& current = values[target].sources[index]; 94 | SourceBlock& next = values[target + 1].sources[index]; 95 | if( current.error > next.error + 1 ) 96 | { 97 | current.start = next.start; 98 | current.end = next.end; 99 | current.error = next.error + 1; 100 | stable = false; 101 | } 102 | } 103 | if( target != 0 ) 104 | { 105 | SourceBlock& current = values[target].sources[index]; 106 | SourceBlock& previous = values[target - 1].sources[index]; 107 | if( current.error > previous.error + 1 ) 108 | { 109 | current.start = previous.start; 110 | current.end = previous.end; 111 | current.error = previous.error + 1; 112 | stable = false; 113 | } 114 | } 115 | } 116 | } 117 | if( stable ) 118 | break; 119 | } 120 | 121 | // debug 122 | std::cout << "\nstatic SingleColourLookup const " << name << "[] = \n{\n"; 123 | for( int i = 0;; ) 124 | { 125 | std::cout << "\t{ { "; 126 | for( int j = 0;; ) 127 | { 128 | SourceBlock const& block = values[i].sources[j]; 129 | if( j < colours ) 130 | std::cout << "{ " << block.start << ", " << block.end << ", " << block.error << " }"; 131 | else 132 | std::cout << "{ 0, 0, 0 }"; 133 | if( ++j == 2 ) 134 | break; 135 | std::cout << ", "; 136 | } 137 | std::cout << " } }"; 138 | if( ++i == 256 ) 139 | break; 140 | std::cout << ",\n"; 141 | } 142 | std::cout << "\n};\n"; 143 | } 144 | 145 | int main() 146 | { 147 | GenerateData( "lookup_5_3", 5, 3 ); 148 | GenerateData( "lookup_6_3", 6, 3 ); 149 | GenerateData( "lookup_5_4", 5, 4 ); 150 | GenerateData( "lookup_6_4", 6, 4 ); 151 | } 152 | -------------------------------------------------------------------------------- /external/squish/squish-source/extra/squishtest.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | /*! @file 27 | 28 | @brief This program tests the error for 1 and 2-colour DXT compression. 29 | 30 | This tests the effectiveness of the DXT compression algorithm for all 31 | possible 1 and 2-colour blocks of pixels. 32 | */ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | using namespace squish; 41 | 42 | double GetColourError( u8 const* a, u8 const* b ) 43 | { 44 | double error = 0.0; 45 | for( int i = 0; i < 16; ++i ) 46 | { 47 | for( int j = 0; j < 3; ++j ) 48 | { 49 | int index = 4*i + j; 50 | int diff = ( int )a[index] - ( int )b[index]; 51 | error += ( double )( diff*diff ); 52 | } 53 | } 54 | return error / 16.0; 55 | } 56 | 57 | void TestOneColour( int flags ) 58 | { 59 | u8 input[4*16]; 60 | u8 output[4*16]; 61 | u8 block[16]; 62 | 63 | double avg = 0.0, min = DBL_MAX, max = -DBL_MAX; 64 | int counter = 0; 65 | 66 | // test all single-channel colours 67 | for( int i = 0; i < 16*4; ++i ) 68 | input[i] = ( ( i % 4 ) == 3 ) ? 255 : 0; 69 | for( int channel = 0; channel < 3; ++channel ) 70 | { 71 | for( int value = 0; value < 255; ++value ) 72 | { 73 | // set the channnel value 74 | for( int i = 0; i < 16; ++i ) 75 | input[4*i + channel] = ( u8 )value; 76 | 77 | // compress and decompress 78 | Compress( input, block, flags ); 79 | Decompress( output, block, flags ); 80 | 81 | // test the results 82 | double rm = GetColourError( input, output ); 83 | double rms = std::sqrt( rm ); 84 | 85 | // accumulate stats 86 | min = std::min( min, rms ); 87 | max = std::max( max, rms ); 88 | avg += rm; 89 | ++counter; 90 | } 91 | 92 | // reset the channel value 93 | for( int i = 0; i < 16; ++i ) 94 | input[4*i + channel] = 0; 95 | } 96 | 97 | // finish stats 98 | avg = std::sqrt( avg/counter ); 99 | 100 | // show stats 101 | std::cout << "one colour error (min, max, avg): " 102 | << min << ", " << max << ", " << avg << std::endl; 103 | } 104 | 105 | void TestOneColourRandom( int flags ) 106 | { 107 | u8 input[4*16]; 108 | u8 output[4*16]; 109 | u8 block[16]; 110 | 111 | double avg = 0.0, min = DBL_MAX, max = -DBL_MAX; 112 | int counter = 0; 113 | 114 | // test all single-channel colours 115 | for( int test = 0; test < 1000; ++test ) 116 | { 117 | // set a constant random colour 118 | for( int channel = 0; channel < 3; ++channel ) 119 | { 120 | u8 value = ( u8 )( rand() & 0xff ); 121 | for( int i = 0; i < 16; ++i ) 122 | input[4*i + channel] = value; 123 | } 124 | for( int i = 0; i < 16; ++i ) 125 | input[4*i + 3] = 255; 126 | 127 | // compress and decompress 128 | Compress( input, block, flags ); 129 | Decompress( output, block, flags ); 130 | 131 | // test the results 132 | double rm = GetColourError( input, output ); 133 | double rms = std::sqrt( rm ); 134 | 135 | // accumulate stats 136 | min = std::min( min, rms ); 137 | max = std::max( max, rms ); 138 | avg += rm; 139 | ++counter; 140 | } 141 | 142 | // finish stats 143 | avg = std::sqrt( avg/counter ); 144 | 145 | // show stats 146 | std::cout << "random one colour error (min, max, avg): " 147 | << min << ", " << max << ", " << avg << std::endl; 148 | } 149 | 150 | void TestTwoColour( int flags ) 151 | { 152 | u8 input[4*16]; 153 | u8 output[4*16]; 154 | u8 block[16]; 155 | 156 | double avg = 0.0, min = DBL_MAX, max = -DBL_MAX; 157 | int counter = 0; 158 | 159 | // test all single-channel colours 160 | for( int i = 0; i < 16*4; ++i ) 161 | input[i] = ( ( i % 4 ) == 3 ) ? 255 : 0; 162 | for( int channel = 0; channel < 3; ++channel ) 163 | { 164 | for( int value1 = 0; value1 < 255; ++value1 ) 165 | { 166 | for( int value2 = value1 + 1; value2 < 255; ++value2 ) 167 | { 168 | // set the channnel value 169 | for( int i = 0; i < 16; ++i ) 170 | input[4*i + channel] = ( u8 )( ( i < 8 ) ? value1 : value2 ); 171 | 172 | // compress and decompress 173 | Compress( input, block, flags ); 174 | Decompress( output, block, flags ); 175 | 176 | // test the results 177 | double rm = GetColourError( input, output ); 178 | double rms = std::sqrt( rm ); 179 | 180 | // accumulate stats 181 | min = std::min( min, rms ); 182 | max = std::max( max, rms ); 183 | avg += rm; 184 | ++counter; 185 | } 186 | } 187 | 188 | // reset the channel value 189 | for( int i = 0; i < 16; ++i ) 190 | input[4*i + channel] = 0; 191 | } 192 | 193 | // finish stats 194 | avg = std::sqrt( avg/counter ); 195 | 196 | // show stats 197 | std::cout << "two colour error (min, max, avg): " 198 | << min << ", " << max << ", " << avg << std::endl; 199 | } 200 | 201 | int main() 202 | { 203 | TestOneColourRandom( kDxt1 | kColourRangeFit ); 204 | TestOneColour( kDxt1 ); 205 | TestTwoColour( kDxt1 ); 206 | } 207 | -------------------------------------------------------------------------------- /external/squish/squish-source/libSquish.pro: -------------------------------------------------------------------------------- 1 | TARGET = squish 2 | TEMPLATE = lib 3 | 4 | include(sources.pro) 5 | 6 | QT -= gui 7 | 8 | CONFIG += staticlib thread 9 | CONFIG += debug_and_release 10 | 11 | CONFIG(debug, debug|release) { 12 | unix:TARGET = $$join(TARGET,,,_debug) 13 | } 14 | 15 | MOC_DIR = mocs 16 | OBJECTS_DIR = objs 17 | RCC_DIR = rccs 18 | UI_DIR = uics 19 | 20 | CONFIG(debug, debug|release) { 21 | unix:MOC_DIR = $$join(MOC_DIR,,,_debug) 22 | unix:OBJECTS_DIR = $$join(OBJECTS_DIR,,,_debug) 23 | unix:RCC_DIR = $$join(RCC_DIR,,,_debug) 24 | unix:UI_DIR = $$join(UI_DIR,,,_debug) 25 | win32:MOC_DIR = $$join(MOC_DIR,,,d) 26 | win32:OBJECTS_DIR = $$join(OBJECTS_DIR,,,d) 27 | win32:RCC_DIR = $$join(RCC_DIR,,,d) 28 | win32:UI_DIR = $$join(UI_DIR,,,d) 29 | } 30 | -------------------------------------------------------------------------------- /external/squish/squish-source/maths.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | /*! @file 27 | 28 | The symmetric eigensystem solver algorithm is from 29 | http://www.geometrictools.com/Documentation/EigenSymmetric3x3.pdf 30 | */ 31 | 32 | #include "maths.h" 33 | #include "simd.h" 34 | #include 35 | 36 | namespace squish { 37 | 38 | Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights ) 39 | { 40 | // compute the centroid 41 | float total = 0.0f; 42 | Vec3 centroid( 0.0f ); 43 | for( int i = 0; i < n; ++i ) 44 | { 45 | total += weights[i]; 46 | centroid += weights[i]*points[i]; 47 | } 48 | if( total > FLT_EPSILON ) 49 | centroid /= total; 50 | 51 | // accumulate the covariance matrix 52 | Sym3x3 covariance( 0.0f ); 53 | for( int i = 0; i < n; ++i ) 54 | { 55 | Vec3 a = points[i] - centroid; 56 | Vec3 b = weights[i]*a; 57 | 58 | covariance[0] += a.X()*b.X(); 59 | covariance[1] += a.X()*b.Y(); 60 | covariance[2] += a.X()*b.Z(); 61 | covariance[3] += a.Y()*b.Y(); 62 | covariance[4] += a.Y()*b.Z(); 63 | covariance[5] += a.Z()*b.Z(); 64 | } 65 | 66 | // return it 67 | return covariance; 68 | } 69 | 70 | #if 0 71 | 72 | static Vec3 GetMultiplicity1Evector( Sym3x3 const& matrix, float evalue ) 73 | { 74 | // compute M 75 | Sym3x3 m; 76 | m[0] = matrix[0] - evalue; 77 | m[1] = matrix[1]; 78 | m[2] = matrix[2]; 79 | m[3] = matrix[3] - evalue; 80 | m[4] = matrix[4]; 81 | m[5] = matrix[5] - evalue; 82 | 83 | // compute U 84 | Sym3x3 u; 85 | u[0] = m[3]*m[5] - m[4]*m[4]; 86 | u[1] = m[2]*m[4] - m[1]*m[5]; 87 | u[2] = m[1]*m[4] - m[2]*m[3]; 88 | u[3] = m[0]*m[5] - m[2]*m[2]; 89 | u[4] = m[1]*m[2] - m[4]*m[0]; 90 | u[5] = m[0]*m[3] - m[1]*m[1]; 91 | 92 | // find the largest component 93 | float mc = std::fabs( u[0] ); 94 | int mi = 0; 95 | for( int i = 1; i < 6; ++i ) 96 | { 97 | float c = std::fabs( u[i] ); 98 | if( c > mc ) 99 | { 100 | mc = c; 101 | mi = i; 102 | } 103 | } 104 | 105 | // pick the column with this component 106 | switch( mi ) 107 | { 108 | case 0: 109 | return Vec3( u[0], u[1], u[2] ); 110 | 111 | case 1: 112 | case 3: 113 | return Vec3( u[1], u[3], u[4] ); 114 | 115 | default: 116 | return Vec3( u[2], u[4], u[5] ); 117 | } 118 | } 119 | 120 | static Vec3 GetMultiplicity2Evector( Sym3x3 const& matrix, float evalue ) 121 | { 122 | // compute M 123 | Sym3x3 m; 124 | m[0] = matrix[0] - evalue; 125 | m[1] = matrix[1]; 126 | m[2] = matrix[2]; 127 | m[3] = matrix[3] - evalue; 128 | m[4] = matrix[4]; 129 | m[5] = matrix[5] - evalue; 130 | 131 | // find the largest component 132 | float mc = std::fabs( m[0] ); 133 | int mi = 0; 134 | for( int i = 1; i < 6; ++i ) 135 | { 136 | float c = std::fabs( m[i] ); 137 | if( c > mc ) 138 | { 139 | mc = c; 140 | mi = i; 141 | } 142 | } 143 | 144 | // pick the first eigenvector based on this index 145 | switch( mi ) 146 | { 147 | case 0: 148 | case 1: 149 | return Vec3( -m[1], m[0], 0.0f ); 150 | 151 | case 2: 152 | return Vec3( m[2], 0.0f, -m[0] ); 153 | 154 | case 3: 155 | case 4: 156 | return Vec3( 0.0f, -m[4], m[3] ); 157 | 158 | default: 159 | return Vec3( 0.0f, -m[5], m[4] ); 160 | } 161 | } 162 | 163 | Vec3 ComputePrincipleComponent( Sym3x3 const& matrix ) 164 | { 165 | // compute the cubic coefficients 166 | float c0 = matrix[0]*matrix[3]*matrix[5] 167 | + 2.0f*matrix[1]*matrix[2]*matrix[4] 168 | - matrix[0]*matrix[4]*matrix[4] 169 | - matrix[3]*matrix[2]*matrix[2] 170 | - matrix[5]*matrix[1]*matrix[1]; 171 | float c1 = matrix[0]*matrix[3] + matrix[0]*matrix[5] + matrix[3]*matrix[5] 172 | - matrix[1]*matrix[1] - matrix[2]*matrix[2] - matrix[4]*matrix[4]; 173 | float c2 = matrix[0] + matrix[3] + matrix[5]; 174 | 175 | // compute the quadratic coefficients 176 | float a = c1 - ( 1.0f/3.0f )*c2*c2; 177 | float b = ( -2.0f/27.0f )*c2*c2*c2 + ( 1.0f/3.0f )*c1*c2 - c0; 178 | 179 | // compute the root count check 180 | float Q = 0.25f*b*b + ( 1.0f/27.0f )*a*a*a; 181 | 182 | // test the multiplicity 183 | if( FLT_EPSILON < Q ) 184 | { 185 | // only one root, which implies we have a multiple of the identity 186 | return Vec3( 1.0f ); 187 | } 188 | else if( Q < -FLT_EPSILON ) 189 | { 190 | // three distinct roots 191 | float theta = std::atan2( std::sqrt( -Q ), -0.5f*b ); 192 | float rho = std::sqrt( 0.25f*b*b - Q ); 193 | 194 | float rt = std::pow( rho, 1.0f/3.0f ); 195 | float ct = std::cos( theta/3.0f ); 196 | float st = std::sin( theta/3.0f ); 197 | 198 | float l1 = ( 1.0f/3.0f )*c2 + 2.0f*rt*ct; 199 | float l2 = ( 1.0f/3.0f )*c2 - rt*( ct + ( float )sqrt( 3.0f )*st ); 200 | float l3 = ( 1.0f/3.0f )*c2 - rt*( ct - ( float )sqrt( 3.0f )*st ); 201 | 202 | // pick the larger 203 | if( std::fabs( l2 ) > std::fabs( l1 ) ) 204 | l1 = l2; 205 | if( std::fabs( l3 ) > std::fabs( l1 ) ) 206 | l1 = l3; 207 | 208 | // get the eigenvector 209 | return GetMultiplicity1Evector( matrix, l1 ); 210 | } 211 | else // if( -FLT_EPSILON <= Q && Q <= FLT_EPSILON ) 212 | { 213 | // two roots 214 | float rt; 215 | if( b < 0.0f ) 216 | rt = -std::pow( -0.5f*b, 1.0f/3.0f ); 217 | else 218 | rt = std::pow( 0.5f*b, 1.0f/3.0f ); 219 | 220 | float l1 = ( 1.0f/3.0f )*c2 + rt; // repeated 221 | float l2 = ( 1.0f/3.0f )*c2 - 2.0f*rt; 222 | 223 | // get the eigenvector 224 | if( std::fabs( l1 ) > std::fabs( l2 ) ) 225 | return GetMultiplicity2Evector( matrix, l1 ); 226 | else 227 | return GetMultiplicity1Evector( matrix, l2 ); 228 | } 229 | } 230 | 231 | #else 232 | 233 | #define POWER_ITERATION_COUNT 8 234 | 235 | Vec3 ComputePrincipleComponent( Sym3x3 const& matrix ) 236 | { 237 | Vec4 const row0( matrix[0], matrix[1], matrix[2], 0.0f ); 238 | Vec4 const row1( matrix[1], matrix[3], matrix[4], 0.0f ); 239 | Vec4 const row2( matrix[2], matrix[4], matrix[5], 0.0f ); 240 | Vec4 v = VEC4_CONST( 1.0f ); 241 | for( int i = 0; i < POWER_ITERATION_COUNT; ++i ) 242 | { 243 | // matrix multiply 244 | Vec4 w = row0*v.SplatX(); 245 | w = MultiplyAdd(row1, v.SplatY(), w); 246 | w = MultiplyAdd(row2, v.SplatZ(), w); 247 | 248 | // get max component from xyz in all channels 249 | Vec4 a = Max(w.SplatX(), Max(w.SplatY(), w.SplatZ())); 250 | 251 | // divide through and advance 252 | v = w*Reciprocal(a); 253 | } 254 | return v.GetVec3(); 255 | } 256 | 257 | #endif 258 | 259 | } // namespace squish 260 | -------------------------------------------------------------------------------- /external/squish/squish-source/maths.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_MATHS_H 27 | #define SQUISH_MATHS_H 28 | 29 | #include 30 | #include 31 | #include "config.h" 32 | 33 | namespace squish { 34 | 35 | class Vec3 36 | { 37 | public: 38 | typedef Vec3 const& Arg; 39 | 40 | Vec3() 41 | { 42 | } 43 | 44 | explicit Vec3( float s ) 45 | { 46 | m_x = s; 47 | m_y = s; 48 | m_z = s; 49 | } 50 | 51 | Vec3( float x, float y, float z ) 52 | { 53 | m_x = x; 54 | m_y = y; 55 | m_z = z; 56 | } 57 | 58 | float X() const { return m_x; } 59 | float Y() const { return m_y; } 60 | float Z() const { return m_z; } 61 | 62 | Vec3 operator-() const 63 | { 64 | return Vec3( -m_x, -m_y, -m_z ); 65 | } 66 | 67 | Vec3& operator+=( Arg v ) 68 | { 69 | m_x += v.m_x; 70 | m_y += v.m_y; 71 | m_z += v.m_z; 72 | return *this; 73 | } 74 | 75 | Vec3& operator-=( Arg v ) 76 | { 77 | m_x -= v.m_x; 78 | m_y -= v.m_y; 79 | m_z -= v.m_z; 80 | return *this; 81 | } 82 | 83 | Vec3& operator*=( Arg v ) 84 | { 85 | m_x *= v.m_x; 86 | m_y *= v.m_y; 87 | m_z *= v.m_z; 88 | return *this; 89 | } 90 | 91 | Vec3& operator*=( float s ) 92 | { 93 | m_x *= s; 94 | m_y *= s; 95 | m_z *= s; 96 | return *this; 97 | } 98 | 99 | Vec3& operator/=( Arg v ) 100 | { 101 | m_x /= v.m_x; 102 | m_y /= v.m_y; 103 | m_z /= v.m_z; 104 | return *this; 105 | } 106 | 107 | Vec3& operator/=( float s ) 108 | { 109 | float t = 1.0f/s; 110 | m_x *= t; 111 | m_y *= t; 112 | m_z *= t; 113 | return *this; 114 | } 115 | 116 | friend Vec3 operator+( Arg left, Arg right ) 117 | { 118 | Vec3 copy( left ); 119 | return copy += right; 120 | } 121 | 122 | friend Vec3 operator-( Arg left, Arg right ) 123 | { 124 | Vec3 copy( left ); 125 | return copy -= right; 126 | } 127 | 128 | friend Vec3 operator*( Arg left, Arg right ) 129 | { 130 | Vec3 copy( left ); 131 | return copy *= right; 132 | } 133 | 134 | friend Vec3 operator*( Arg left, float right ) 135 | { 136 | Vec3 copy( left ); 137 | return copy *= right; 138 | } 139 | 140 | friend Vec3 operator*( float left, Arg right ) 141 | { 142 | Vec3 copy( right ); 143 | return copy *= left; 144 | } 145 | 146 | friend Vec3 operator/( Arg left, Arg right ) 147 | { 148 | Vec3 copy( left ); 149 | return copy /= right; 150 | } 151 | 152 | friend Vec3 operator/( Arg left, float right ) 153 | { 154 | Vec3 copy( left ); 155 | return copy /= right; 156 | } 157 | 158 | friend float Dot( Arg left, Arg right ) 159 | { 160 | return left.m_x*right.m_x + left.m_y*right.m_y + left.m_z*right.m_z; 161 | } 162 | 163 | friend Vec3 Min( Arg left, Arg right ) 164 | { 165 | return Vec3( 166 | std::min( left.m_x, right.m_x ), 167 | std::min( left.m_y, right.m_y ), 168 | std::min( left.m_z, right.m_z ) 169 | ); 170 | } 171 | 172 | friend Vec3 Max( Arg left, Arg right ) 173 | { 174 | return Vec3( 175 | std::max( left.m_x, right.m_x ), 176 | std::max( left.m_y, right.m_y ), 177 | std::max( left.m_z, right.m_z ) 178 | ); 179 | } 180 | 181 | friend Vec3 Truncate( Arg v ) 182 | { 183 | return Vec3( 184 | v.m_x > 0.0f ? std::floor( v.m_x ) : std::ceil( v.m_x ), 185 | v.m_y > 0.0f ? std::floor( v.m_y ) : std::ceil( v.m_y ), 186 | v.m_z > 0.0f ? std::floor( v.m_z ) : std::ceil( v.m_z ) 187 | ); 188 | } 189 | 190 | private: 191 | float m_x; 192 | float m_y; 193 | float m_z; 194 | }; 195 | 196 | inline float LengthSquared( Vec3::Arg v ) 197 | { 198 | return Dot( v, v ); 199 | } 200 | 201 | class Sym3x3 202 | { 203 | public: 204 | Sym3x3() 205 | { 206 | } 207 | 208 | Sym3x3( float s ) 209 | { 210 | for( int i = 0; i < 6; ++i ) 211 | m_x[i] = s; 212 | } 213 | 214 | float operator[]( int index ) const 215 | { 216 | return m_x[index]; 217 | } 218 | 219 | float& operator[]( int index ) 220 | { 221 | return m_x[index]; 222 | } 223 | 224 | private: 225 | float m_x[6]; 226 | }; 227 | 228 | Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weights ); 229 | Vec3 ComputePrincipleComponent( Sym3x3 const& matrix ); 230 | 231 | } // namespace squish 232 | 233 | #endif // ndef SQUISH_MATHS_H 234 | -------------------------------------------------------------------------------- /external/squish/squish-source/rangefit.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include "rangefit.h" 27 | #include "colourset.h" 28 | #include "colourblock.h" 29 | #include 30 | 31 | namespace squish { 32 | 33 | RangeFit::RangeFit( ColourSet const* colours, int flags, float* metric ) 34 | : ColourFit( colours, flags ) 35 | { 36 | // initialise the metric (old perceptual = 0.2126f, 0.7152f, 0.0722f) 37 | if( metric ) 38 | m_metric = Vec3( metric[0], metric[1], metric[2] ); 39 | else 40 | m_metric = Vec3( 1.0f ); 41 | 42 | // initialise the best error 43 | m_besterror = FLT_MAX; 44 | 45 | // cache some values 46 | int const count = m_colours->GetCount(); 47 | Vec3 const* values = m_colours->GetPoints(); 48 | float const* weights = m_colours->GetWeights(); 49 | 50 | // get the covariance matrix 51 | Sym3x3 covariance = ComputeWeightedCovariance( count, values, weights ); 52 | 53 | // compute the principle component 54 | Vec3 principle = ComputePrincipleComponent( covariance ); 55 | 56 | // get the min and max range as the codebook endpoints 57 | Vec3 start( 0.0f ); 58 | Vec3 end( 0.0f ); 59 | if( count > 0 ) 60 | { 61 | float min, max; 62 | 63 | // compute the range 64 | start = end = values[0]; 65 | min = max = Dot( values[0], principle ); 66 | for( int i = 1; i < count; ++i ) 67 | { 68 | float val = Dot( values[i], principle ); 69 | if( val < min ) 70 | { 71 | start = values[i]; 72 | min = val; 73 | } 74 | else if( val > max ) 75 | { 76 | end = values[i]; 77 | max = val; 78 | } 79 | } 80 | } 81 | 82 | // clamp the output to [0, 1] 83 | Vec3 const one( 1.0f ); 84 | Vec3 const zero( 0.0f ); 85 | start = Min( one, Max( zero, start ) ); 86 | end = Min( one, Max( zero, end ) ); 87 | 88 | // clamp to the grid and save 89 | Vec3 const grid( 31.0f, 63.0f, 31.0f ); 90 | Vec3 const gridrcp( 1.0f/31.0f, 1.0f/63.0f, 1.0f/31.0f ); 91 | Vec3 const half( 0.5f ); 92 | m_start = Truncate( grid*start + half )*gridrcp; 93 | m_end = Truncate( grid*end + half )*gridrcp; 94 | } 95 | 96 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 97 | void RangeFit::Compress3( void* block ) 98 | { 99 | // cache some values 100 | int const count = m_colours->GetCount(); 101 | Vec3 const* values = m_colours->GetPoints(); 102 | 103 | // create a codebook 104 | Vec3 codes[3]; 105 | codes[0] = m_start; 106 | codes[1] = m_end; 107 | codes[2] = 0.5f*m_start + 0.5f*m_end; 108 | 109 | // match each point to the closest code 110 | u8 closest[16]; 111 | float error = 0.0f; 112 | for( int i = 0; i < count; ++i ) 113 | { 114 | // find the closest code 115 | float dist = FLT_MAX; 116 | int idx = 0; 117 | for( int j = 0; j < 3; ++j ) 118 | { 119 | float d = LengthSquared( m_metric*( values[i] - codes[j] ) ); 120 | if( d < dist ) 121 | { 122 | dist = d; 123 | idx = j; 124 | } 125 | } 126 | 127 | // save the index 128 | closest[i] = ( u8 )idx; 129 | 130 | // accumulate the error 131 | error += dist; 132 | } 133 | 134 | // save this scheme if it wins 135 | if( error < m_besterror ) 136 | { 137 | // remap the indices 138 | u8 indices[16]; 139 | m_colours->RemapIndices( closest, indices ); 140 | 141 | // save the block 142 | WriteColourBlock3( m_start, m_end, indices, block ); 143 | 144 | // save the error 145 | m_besterror = error; 146 | } 147 | } 148 | #endif 149 | 150 | void RangeFit::Compress4( void* block ) 151 | { 152 | // cache some values 153 | int const count = m_colours->GetCount(); 154 | Vec3 const* values = m_colours->GetPoints(); 155 | 156 | // create a codebook 157 | Vec3 codes[4]; 158 | codes[0] = m_start; 159 | codes[1] = m_end; 160 | codes[2] = ( 2.0f/3.0f )*m_start + ( 1.0f/3.0f )*m_end; 161 | codes[3] = ( 1.0f/3.0f )*m_start + ( 2.0f/3.0f )*m_end; 162 | 163 | // match each point to the closest code 164 | u8 closest[16]; 165 | float error = 0.0f; 166 | for( int i = 0; i < count; ++i ) 167 | { 168 | // find the closest code 169 | float dist = FLT_MAX; 170 | int idx = 0; 171 | for( int j = 0; j < 4; ++j ) 172 | { 173 | float d = LengthSquared( m_metric*( values[i] - codes[j] ) ); 174 | if( d < dist ) 175 | { 176 | dist = d; 177 | idx = j; 178 | } 179 | } 180 | 181 | // save the index 182 | closest[i] = ( u8 )idx; 183 | 184 | // accumulate the error 185 | error += dist; 186 | } 187 | 188 | // save this scheme if it wins 189 | if( error < m_besterror ) 190 | { 191 | // remap the indices 192 | u8 indices[16]; 193 | m_colours->RemapIndices( closest, indices ); 194 | 195 | // save the block 196 | WriteColourBlock4( m_start, m_end, indices, block ); 197 | 198 | // save the error 199 | m_besterror = error; 200 | } 201 | } 202 | 203 | } // namespace squish 204 | -------------------------------------------------------------------------------- /external/squish/squish-source/rangefit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_RANGEFIT_H 27 | #define SQUISH_RANGEFIT_H 28 | 29 | #include "squish.h" 30 | #include "colourfit.h" 31 | #include "maths.h" 32 | 33 | namespace squish { 34 | 35 | class ColourSet; 36 | 37 | class RangeFit : public ColourFit 38 | { 39 | public: 40 | RangeFit( ColourSet const* colours, int flags, float* metric ); 41 | 42 | private: 43 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 44 | virtual void Compress3( void* block ); 45 | #endif 46 | virtual void Compress4( void* block ); 47 | 48 | Vec3 m_metric; 49 | Vec3 m_start; 50 | Vec3 m_end; 51 | float m_besterror; 52 | }; 53 | 54 | } // squish 55 | 56 | #endif // ndef SQUISH_RANGEFIT_H 57 | -------------------------------------------------------------------------------- /external/squish/squish-source/simd.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SIMD_H 27 | #define SQUISH_SIMD_H 28 | 29 | #include "maths.h" 30 | 31 | #if SQUISH_USE_ALTIVEC 32 | #include "simd_ve.h" 33 | #elif SQUISH_USE_SSE 34 | #include "simd_sse.h" 35 | #else 36 | #include "simd_float.h" 37 | #endif 38 | 39 | 40 | #endif // ndef SQUISH_SIMD_H 41 | -------------------------------------------------------------------------------- /external/squish/squish-source/simd_float.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SIMD_FLOAT_H 27 | #define SQUISH_SIMD_FLOAT_H 28 | 29 | #include 30 | 31 | namespace squish { 32 | 33 | #define VEC4_CONST( X ) Vec4( X ) 34 | 35 | class Vec4 36 | { 37 | public: 38 | typedef Vec4 const& Arg; 39 | 40 | Vec4() {} 41 | 42 | explicit Vec4( float s ) 43 | : m_x( s ), 44 | m_y( s ), 45 | m_z( s ), 46 | m_w( s ) 47 | { 48 | } 49 | 50 | Vec4( float x, float y, float z, float w ) 51 | : m_x( x ), 52 | m_y( y ), 53 | m_z( z ), 54 | m_w( w ) 55 | { 56 | } 57 | 58 | Vec3 GetVec3() const 59 | { 60 | return Vec3( m_x, m_y, m_z ); 61 | } 62 | 63 | Vec4 SplatX() const { return Vec4( m_x ); } 64 | Vec4 SplatY() const { return Vec4( m_y ); } 65 | Vec4 SplatZ() const { return Vec4( m_z ); } 66 | Vec4 SplatW() const { return Vec4( m_w ); } 67 | 68 | Vec4& operator+=( Arg v ) 69 | { 70 | m_x += v.m_x; 71 | m_y += v.m_y; 72 | m_z += v.m_z; 73 | m_w += v.m_w; 74 | return *this; 75 | } 76 | 77 | Vec4& operator-=( Arg v ) 78 | { 79 | m_x -= v.m_x; 80 | m_y -= v.m_y; 81 | m_z -= v.m_z; 82 | m_w -= v.m_w; 83 | return *this; 84 | } 85 | 86 | Vec4& operator*=( Arg v ) 87 | { 88 | m_x *= v.m_x; 89 | m_y *= v.m_y; 90 | m_z *= v.m_z; 91 | m_w *= v.m_w; 92 | return *this; 93 | } 94 | 95 | friend Vec4 operator+( Vec4::Arg left, Vec4::Arg right ) 96 | { 97 | Vec4 copy( left ); 98 | return copy += right; 99 | } 100 | 101 | friend Vec4 operator-( Vec4::Arg left, Vec4::Arg right ) 102 | { 103 | Vec4 copy( left ); 104 | return copy -= right; 105 | } 106 | 107 | friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right ) 108 | { 109 | Vec4 copy( left ); 110 | return copy *= right; 111 | } 112 | 113 | //! Returns a*b + c 114 | friend Vec4 MultiplyAdd( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) 115 | { 116 | return a*b + c; 117 | } 118 | 119 | //! Returns -( a*b - c ) 120 | friend Vec4 NegativeMultiplySubtract( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) 121 | { 122 | return c - a*b; 123 | } 124 | 125 | friend Vec4 Reciprocal( Vec4::Arg v ) 126 | { 127 | return Vec4( 128 | 1.0f/v.m_x, 129 | 1.0f/v.m_y, 130 | 1.0f/v.m_z, 131 | 1.0f/v.m_w 132 | ); 133 | } 134 | 135 | friend Vec4 Min( Vec4::Arg left, Vec4::Arg right ) 136 | { 137 | return Vec4( 138 | std::min( left.m_x, right.m_x ), 139 | std::min( left.m_y, right.m_y ), 140 | std::min( left.m_z, right.m_z ), 141 | std::min( left.m_w, right.m_w ) 142 | ); 143 | } 144 | 145 | friend Vec4 Max( Vec4::Arg left, Vec4::Arg right ) 146 | { 147 | return Vec4( 148 | std::max( left.m_x, right.m_x ), 149 | std::max( left.m_y, right.m_y ), 150 | std::max( left.m_z, right.m_z ), 151 | std::max( left.m_w, right.m_w ) 152 | ); 153 | } 154 | 155 | friend Vec4 Truncate( Vec4::Arg v ) 156 | { 157 | return Vec4( 158 | v.m_x > 0.0f ? std::floor( v.m_x ) : std::ceil( v.m_x ), 159 | v.m_y > 0.0f ? std::floor( v.m_y ) : std::ceil( v.m_y ), 160 | v.m_z > 0.0f ? std::floor( v.m_z ) : std::ceil( v.m_z ), 161 | v.m_w > 0.0f ? std::floor( v.m_w ) : std::ceil( v.m_w ) 162 | ); 163 | } 164 | 165 | friend bool CompareAnyLessThan( Vec4::Arg left, Vec4::Arg right ) 166 | { 167 | return left.m_x < right.m_x 168 | || left.m_y < right.m_y 169 | || left.m_z < right.m_z 170 | || left.m_w < right.m_w; 171 | } 172 | 173 | private: 174 | float m_x; 175 | float m_y; 176 | float m_z; 177 | float m_w; 178 | }; 179 | 180 | } // namespace squish 181 | 182 | #endif // ndef SQUISH_SIMD_FLOAT_H 183 | 184 | -------------------------------------------------------------------------------- /external/squish/squish-source/simd_sse.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SIMD_SSE_H 27 | #define SQUISH_SIMD_SSE_H 28 | 29 | #include 30 | #if ( SQUISH_USE_SSE > 1 ) 31 | #include 32 | #endif 33 | 34 | #define SQUISH_SSE_SPLAT( a ) \ 35 | ( ( a ) | ( ( a ) << 2 ) | ( ( a ) << 4 ) | ( ( a ) << 6 ) ) 36 | 37 | #define SQUISH_SSE_SHUF( x, y, z, w ) \ 38 | ( ( x ) | ( ( y ) << 2 ) | ( ( z ) << 4 ) | ( ( w ) << 6 ) ) 39 | 40 | namespace squish { 41 | 42 | #define VEC4_CONST( X ) Vec4( X ) 43 | 44 | class Vec4 45 | { 46 | public: 47 | typedef Vec4 const& Arg; 48 | 49 | Vec4() {} 50 | 51 | explicit Vec4( __m128 v ) : m_v( v ) {} 52 | 53 | Vec4( Vec4 const& arg ) : m_v( arg.m_v ) {} 54 | 55 | Vec4& operator=( Vec4 const& arg ) 56 | { 57 | m_v = arg.m_v; 58 | return *this; 59 | } 60 | 61 | explicit Vec4( float s ) : m_v( _mm_set1_ps( s ) ) {} 62 | 63 | Vec4( float x, float y, float z, float w ) : m_v( _mm_setr_ps( x, y, z, w ) ) {} 64 | 65 | Vec3 GetVec3() const 66 | { 67 | #ifdef __GNUC__ 68 | __attribute__ ((__aligned__ (16))) float c[4]; 69 | #else 70 | __declspec(align(16)) float c[4]; 71 | #endif 72 | _mm_store_ps( c, m_v ); 73 | return Vec3( c[0], c[1], c[2] ); 74 | } 75 | 76 | Vec4 SplatX() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 0 ) ) ); } 77 | Vec4 SplatY() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 1 ) ) ); } 78 | Vec4 SplatZ() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 2 ) ) ); } 79 | Vec4 SplatW() const { return Vec4( _mm_shuffle_ps( m_v, m_v, SQUISH_SSE_SPLAT( 3 ) ) ); } 80 | 81 | Vec4& operator+=( Arg v ) 82 | { 83 | m_v = _mm_add_ps( m_v, v.m_v ); 84 | return *this; 85 | } 86 | 87 | Vec4& operator-=( Arg v ) 88 | { 89 | m_v = _mm_sub_ps( m_v, v.m_v ); 90 | return *this; 91 | } 92 | 93 | Vec4& operator*=( Arg v ) 94 | { 95 | m_v = _mm_mul_ps( m_v, v.m_v ); 96 | return *this; 97 | } 98 | 99 | friend Vec4 operator+( Vec4::Arg left, Vec4::Arg right ) 100 | { 101 | return Vec4( _mm_add_ps( left.m_v, right.m_v ) ); 102 | } 103 | 104 | friend Vec4 operator-( Vec4::Arg left, Vec4::Arg right ) 105 | { 106 | return Vec4( _mm_sub_ps( left.m_v, right.m_v ) ); 107 | } 108 | 109 | friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right ) 110 | { 111 | return Vec4( _mm_mul_ps( left.m_v, right.m_v ) ); 112 | } 113 | 114 | //! Returns a*b + c 115 | friend Vec4 MultiplyAdd( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) 116 | { 117 | return Vec4( _mm_add_ps( _mm_mul_ps( a.m_v, b.m_v ), c.m_v ) ); 118 | } 119 | 120 | //! Returns -( a*b - c ) 121 | friend Vec4 NegativeMultiplySubtract( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) 122 | { 123 | return Vec4( _mm_sub_ps( c.m_v, _mm_mul_ps( a.m_v, b.m_v ) ) ); 124 | } 125 | 126 | friend Vec4 Reciprocal( Vec4::Arg v ) 127 | { 128 | // get the reciprocal estimate 129 | __m128 estimate = _mm_rcp_ps( v.m_v ); 130 | 131 | // one round of Newton-Rhaphson refinement 132 | __m128 diff = _mm_sub_ps( _mm_set1_ps( 1.0f ), _mm_mul_ps( estimate, v.m_v ) ); 133 | return Vec4( _mm_add_ps( _mm_mul_ps( diff, estimate ), estimate ) ); 134 | } 135 | 136 | friend Vec4 Min( Vec4::Arg left, Vec4::Arg right ) 137 | { 138 | return Vec4( _mm_min_ps( left.m_v, right.m_v ) ); 139 | } 140 | 141 | friend Vec4 Max( Vec4::Arg left, Vec4::Arg right ) 142 | { 143 | return Vec4( _mm_max_ps( left.m_v, right.m_v ) ); 144 | } 145 | 146 | friend Vec4 Truncate( Vec4::Arg v ) 147 | { 148 | #if ( SQUISH_USE_SSE == 1 ) 149 | // convert to ints 150 | __m128 input = v.m_v; 151 | __m64 lo = _mm_cvttps_pi32( input ); 152 | __m64 hi = _mm_cvttps_pi32( _mm_movehl_ps( input, input ) ); 153 | 154 | // convert to floats 155 | __m128 part = _mm_movelh_ps( input, _mm_cvtpi32_ps( input, hi ) ); 156 | __m128 truncated = _mm_cvtpi32_ps( part, lo ); 157 | 158 | // clear out the MMX multimedia state to allow FP calls later 159 | _mm_empty(); 160 | return Vec4( truncated ); 161 | #else 162 | // use SSE2 instructions 163 | return Vec4( _mm_cvtepi32_ps( _mm_cvttps_epi32( v.m_v ) ) ); 164 | #endif 165 | } 166 | 167 | friend bool CompareAnyLessThan( Vec4::Arg left, Vec4::Arg right ) 168 | { 169 | __m128 bits = _mm_cmplt_ps( left.m_v, right.m_v ); 170 | int value = _mm_movemask_ps( bits ); 171 | return value != 0; 172 | } 173 | 174 | private: 175 | __m128 m_v; 176 | }; 177 | 178 | } // namespace squish 179 | 180 | #endif // ndef SQUISH_SIMD_SSE_H 181 | -------------------------------------------------------------------------------- /external/squish/squish-source/simd_ve.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SIMD_VE_H 27 | #define SQUISH_SIMD_VE_H 28 | 29 | #include 30 | #undef bool 31 | 32 | namespace squish { 33 | 34 | #define VEC4_CONST( X ) Vec4( ( vector float ){ X } ) 35 | 36 | class Vec4 37 | { 38 | public: 39 | typedef Vec4 Arg; 40 | 41 | Vec4() {} 42 | 43 | explicit Vec4( vector float v ) : m_v( v ) {} 44 | 45 | Vec4( Vec4 const& arg ) : m_v( arg.m_v ) {} 46 | 47 | Vec4& operator=( Vec4 const& arg ) 48 | { 49 | m_v = arg.m_v; 50 | return *this; 51 | } 52 | 53 | explicit Vec4( float s ) 54 | { 55 | union { vector float v; float c[4]; } u; 56 | u.c[0] = s; 57 | u.c[1] = s; 58 | u.c[2] = s; 59 | u.c[3] = s; 60 | m_v = u.v; 61 | } 62 | 63 | Vec4( float x, float y, float z, float w ) 64 | { 65 | union { vector float v; float c[4]; } u; 66 | u.c[0] = x; 67 | u.c[1] = y; 68 | u.c[2] = z; 69 | u.c[3] = w; 70 | m_v = u.v; 71 | } 72 | 73 | Vec3 GetVec3() const 74 | { 75 | union { vector float v; float c[4]; } u; 76 | u.v = m_v; 77 | return Vec3( u.c[0], u.c[1], u.c[2] ); 78 | } 79 | 80 | Vec4 SplatX() const { return Vec4( vec_splat( m_v, 0 ) ); } 81 | Vec4 SplatY() const { return Vec4( vec_splat( m_v, 1 ) ); } 82 | Vec4 SplatZ() const { return Vec4( vec_splat( m_v, 2 ) ); } 83 | Vec4 SplatW() const { return Vec4( vec_splat( m_v, 3 ) ); } 84 | 85 | Vec4& operator+=( Arg v ) 86 | { 87 | m_v = vec_add( m_v, v.m_v ); 88 | return *this; 89 | } 90 | 91 | Vec4& operator-=( Arg v ) 92 | { 93 | m_v = vec_sub( m_v, v.m_v ); 94 | return *this; 95 | } 96 | 97 | Vec4& operator*=( Arg v ) 98 | { 99 | m_v = vec_madd( m_v, v.m_v, ( vector float ){ -0.0f } ); 100 | return *this; 101 | } 102 | 103 | friend Vec4 operator+( Vec4::Arg left, Vec4::Arg right ) 104 | { 105 | return Vec4( vec_add( left.m_v, right.m_v ) ); 106 | } 107 | 108 | friend Vec4 operator-( Vec4::Arg left, Vec4::Arg right ) 109 | { 110 | return Vec4( vec_sub( left.m_v, right.m_v ) ); 111 | } 112 | 113 | friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right ) 114 | { 115 | return Vec4( vec_madd( left.m_v, right.m_v, ( vector float ){ -0.0f } ) ); 116 | } 117 | 118 | //! Returns a*b + c 119 | friend Vec4 MultiplyAdd( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) 120 | { 121 | return Vec4( vec_madd( a.m_v, b.m_v, c.m_v ) ); 122 | } 123 | 124 | //! Returns -( a*b - c ) 125 | friend Vec4 NegativeMultiplySubtract( Vec4::Arg a, Vec4::Arg b, Vec4::Arg c ) 126 | { 127 | return Vec4( vec_nmsub( a.m_v, b.m_v, c.m_v ) ); 128 | } 129 | 130 | friend Vec4 Reciprocal( Vec4::Arg v ) 131 | { 132 | // get the reciprocal estimate 133 | vector float estimate = vec_re( v.m_v ); 134 | 135 | // one round of Newton-Rhaphson refinement 136 | vector float diff = vec_nmsub( estimate, v.m_v, ( vector float ){ 1.0f } ); 137 | return Vec4( vec_madd( diff, estimate, estimate ) ); 138 | } 139 | 140 | friend Vec4 Min( Vec4::Arg left, Vec4::Arg right ) 141 | { 142 | return Vec4( vec_min( left.m_v, right.m_v ) ); 143 | } 144 | 145 | friend Vec4 Max( Vec4::Arg left, Vec4::Arg right ) 146 | { 147 | return Vec4( vec_max( left.m_v, right.m_v ) ); 148 | } 149 | 150 | friend Vec4 Truncate( Vec4::Arg v ) 151 | { 152 | return Vec4( vec_trunc( v.m_v ) ); 153 | } 154 | 155 | friend bool CompareAnyLessThan( Vec4::Arg left, Vec4::Arg right ) 156 | { 157 | return vec_any_lt( left.m_v, right.m_v ) != 0; 158 | } 159 | 160 | private: 161 | vector float m_v; 162 | }; 163 | 164 | } // namespace squish 165 | 166 | #endif // ndef SQUISH_SIMD_VE_H 167 | -------------------------------------------------------------------------------- /external/squish/squish-source/singlecolourfit.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include "singlecolourfit.h" 27 | #include "colourset.h" 28 | #include "colourblock.h" 29 | 30 | namespace squish { 31 | 32 | struct SourceBlock 33 | { 34 | u8 start; 35 | u8 end; 36 | u8 error; 37 | }; 38 | 39 | struct SingleColourLookup 40 | { 41 | SourceBlock sources[2]; 42 | }; 43 | 44 | #include "singlecolourlookup.inl" 45 | 46 | static int FloatToInt( float a, int limit ) 47 | { 48 | // use ANSI round-to-zero behaviour to get round-to-nearest 49 | int i = ( int )( a + 0.5f ); 50 | 51 | // clamp to the limit 52 | if( i < 0 ) 53 | i = 0; 54 | else if( i > limit ) 55 | i = limit; 56 | 57 | // done 58 | return i; 59 | } 60 | 61 | SingleColourFit::SingleColourFit( ColourSet const* colours, int flags ) 62 | : ColourFit( colours, flags ) 63 | { 64 | // grab the single colour 65 | Vec3 const* values = m_colours->GetPoints(); 66 | m_colour[0] = ( u8 )FloatToInt( 255.0f*values->X(), 255 ); 67 | m_colour[1] = ( u8 )FloatToInt( 255.0f*values->Y(), 255 ); 68 | m_colour[2] = ( u8 )FloatToInt( 255.0f*values->Z(), 255 ); 69 | 70 | // initialise the best error 71 | m_besterror = INT_MAX; 72 | } 73 | 74 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 75 | void SingleColourFit::Compress3( void* block ) 76 | { 77 | // build the table of lookups 78 | SingleColourLookup const* const lookups[] = 79 | { 80 | lookup_5_3, 81 | lookup_6_3, 82 | lookup_5_3 83 | }; 84 | 85 | // find the best end-points and index 86 | ComputeEndPoints( lookups ); 87 | 88 | // build the block if we win 89 | if( m_error < m_besterror ) 90 | { 91 | // remap the indices 92 | u8 indices[16]; 93 | m_colours->RemapIndices( &m_index, indices ); 94 | 95 | // save the block 96 | WriteColourBlock3( m_start, m_end, indices, block ); 97 | 98 | // save the error 99 | m_besterror = m_error; 100 | } 101 | } 102 | #endif 103 | 104 | void SingleColourFit::Compress4( void* block ) 105 | { 106 | // build the table of lookups 107 | SingleColourLookup const* const lookups[] = 108 | { 109 | lookup_5_4, 110 | lookup_6_4, 111 | lookup_5_4 112 | }; 113 | 114 | // find the best end-points and index 115 | ComputeEndPoints( lookups ); 116 | 117 | // build the block if we win 118 | if( m_error < m_besterror ) 119 | { 120 | // remap the indices 121 | u8 indices[16]; 122 | m_colours->RemapIndices( &m_index, indices ); 123 | 124 | // save the block 125 | WriteColourBlock4( m_start, m_end, indices, block ); 126 | 127 | // save the error 128 | m_besterror = m_error; 129 | } 130 | } 131 | 132 | void SingleColourFit::ComputeEndPoints( SingleColourLookup const* const* lookups ) 133 | { 134 | // check each index combination (endpoint or intermediate) 135 | m_error = INT_MAX; 136 | for( int index = 0; index < 2; ++index ) 137 | { 138 | // check the error for this codebook index 139 | SourceBlock const* sources[3]; 140 | int error = 0; 141 | for( int channel = 0; channel < 3; ++channel ) 142 | { 143 | // grab the lookup table and index for this channel 144 | SingleColourLookup const* lookup = lookups[channel]; 145 | int target = m_colour[channel]; 146 | 147 | // store a pointer to the source for this channel 148 | sources[channel] = lookup[target].sources + index; 149 | 150 | // accumulate the error 151 | int diff = sources[channel]->error; 152 | error += diff*diff; 153 | } 154 | 155 | // keep it if the error is lower 156 | if( error < m_error ) 157 | { 158 | m_start = Vec3( 159 | ( float )sources[0]->start/31.0f, 160 | ( float )sources[1]->start/63.0f, 161 | ( float )sources[2]->start/31.0f 162 | ); 163 | m_end = Vec3( 164 | ( float )sources[0]->end/31.0f, 165 | ( float )sources[1]->end/63.0f, 166 | ( float )sources[2]->end/31.0f 167 | ); 168 | m_index = ( u8 )( 2*index ); 169 | m_error = error; 170 | } 171 | } 172 | } 173 | 174 | } // namespace squish 175 | -------------------------------------------------------------------------------- /external/squish/squish-source/singlecolourfit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SINGLECOLOURFIT_H 27 | #define SQUISH_SINGLECOLOURFIT_H 28 | 29 | #include "squish.h" 30 | #include "colourfit.h" 31 | 32 | namespace squish { 33 | 34 | class ColourSet; 35 | struct SingleColourLookup; 36 | 37 | class SingleColourFit : public ColourFit 38 | { 39 | public: 40 | SingleColourFit( ColourSet const* colours, int flags ); 41 | 42 | private: 43 | #if defined(HAP_SQUISH_EMIT_3_COLOUR_BLOCKS) 44 | virtual void Compress3( void* block ); 45 | #endif 46 | virtual void Compress4( void* block ); 47 | 48 | void ComputeEndPoints( SingleColourLookup const* const* lookups ); 49 | 50 | u8 m_colour[3]; 51 | Vec3 m_start; 52 | Vec3 m_end; 53 | u8 m_index; 54 | int m_error; 55 | int m_besterror; 56 | }; 57 | 58 | } // namespace squish 59 | 60 | #endif // ndef SQUISH_SINGLECOLOURFIT_H 61 | -------------------------------------------------------------------------------- /external/squish/squish-source/sources.pro: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | squish.h 3 | 4 | SOURCES += \ 5 | alpha.cpp \ 6 | alpha.h \ 7 | clusterfit.cpp \ 8 | clusterfit.h \ 9 | colourblock.cpp \ 10 | colourblock.h \ 11 | colourfit.cpp \ 12 | colourfit.h \ 13 | colourset.cpp \ 14 | colourset.h \ 15 | maths.cpp \ 16 | maths.h \ 17 | rangefit.cpp \ 18 | rangefit.h \ 19 | simd.h \ 20 | simd_float.h \ 21 | simd_sse.h \ 22 | simd_ve.h \ 23 | singlecolourfit.cpp \ 24 | singlecolourfit.h \ 25 | singlecolourlookup.inl \ 26 | squish.cpp 27 | -------------------------------------------------------------------------------- /external/squish/squish-source/vs7/squish/squish.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 34 | 36 | 39 | 41 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 58 | 65 | 80 | 82 | 85 | 87 | 89 | 91 | 93 | 95 | 97 | 99 | 101 | 103 | 104 | 105 | 106 | 107 | 108 | 112 | 114 | 115 | 117 | 118 | 120 | 121 | 123 | 124 | 126 | 127 | 129 | 130 | 132 | 133 | 135 | 136 | 138 | 139 | 140 | 144 | 146 | 147 | 149 | 150 | 152 | 153 | 155 | 156 | 158 | 159 | 161 | 162 | 164 | 165 | 167 | 168 | 170 | 171 | 173 | 174 | 176 | 177 | 179 | 180 | 182 | 183 | 185 | 186 | 188 | 189 | 190 | 194 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /external/squish/squish-source/vs7/squishpng/squishpng.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 33 | 35 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 65 | 71 | 82 | 84 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 112 | 114 | 115 | 116 | 117 | 118 | 119 | 123 | 125 | 126 | 127 | 131 | 132 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /external/squish/squish-source/vs7/squishtest/squishtest.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 33 | 35 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 64 | 70 | 81 | 83 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 112 | 113 | 114 | 115 | 116 | 117 | 121 | 123 | 124 | 125 | 129 | 130 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /external/squish/squish-source/vs8/squish.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 9.00 2 | # Visual Studio 2005 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "squish\squish.vcproj", "{6A8518C3-D81A-4428-BD7F-C37933088AC1}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squishpng", "squishpng\squishpng.vcproj", "{3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}" 6 | ProjectSection(ProjectDependencies) = postProject 7 | {6A8518C3-D81A-4428-BD7F-C37933088AC1} = {6A8518C3-D81A-4428-BD7F-C37933088AC1} 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squishtest", "squishtest\squishtest.vcproj", "{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | {6A8518C3-D81A-4428-BD7F-C37933088AC1} = {6A8518C3-D81A-4428-BD7F-C37933088AC1} 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Win32 = Debug|Win32 18 | Debug|x64 = Debug|x64 19 | Release|Win32 = Release|Win32 20 | Release|x64 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|Win32.Build.0 = Debug|Win32 25 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|x64.ActiveCfg = Debug|x64 26 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|x64.Build.0 = Debug|x64 27 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|Win32.ActiveCfg = Release|Win32 28 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|Win32.Build.0 = Release|Win32 29 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|x64.ActiveCfg = Release|x64 30 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|x64.Build.0 = Release|x64 31 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|Win32.ActiveCfg = Debug|Win32 32 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|Win32.Build.0 = Debug|Win32 33 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|x64.ActiveCfg = Debug|x64 34 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|x64.Build.0 = Debug|x64 35 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|Win32.ActiveCfg = Release|Win32 36 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|Win32.Build.0 = Release|Win32 37 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|x64.ActiveCfg = Release|x64 38 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|x64.Build.0 = Release|x64 39 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|Win32.ActiveCfg = Debug|Win32 40 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|Win32.Build.0 = Debug|Win32 41 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|x64.ActiveCfg = Debug|x64 42 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|x64.Build.0 = Debug|x64 43 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|Win32.ActiveCfg = Release|Win32 44 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|Win32.Build.0 = Release|Win32 45 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x64.ActiveCfg = Release|x64 46 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x64.Build.0 = Release|x64 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /external/squish/squish-source/vs9/squish.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squish", "squish\squish.vcproj", "{6A8518C3-D81A-4428-BD7F-C37933088AC1}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squishpng", "squishpng\squishpng.vcproj", "{3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}" 6 | ProjectSection(ProjectDependencies) = postProject 7 | {6A8518C3-D81A-4428-BD7F-C37933088AC1} = {6A8518C3-D81A-4428-BD7F-C37933088AC1} 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squishtest", "squishtest\squishtest.vcproj", "{77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | {6A8518C3-D81A-4428-BD7F-C37933088AC1} = {6A8518C3-D81A-4428-BD7F-C37933088AC1} 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Win32 = Debug|Win32 18 | Debug|x64 = Debug|x64 19 | Release|Win32 = Release|Win32 20 | Release|x64 = Release|x64 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|Win32.Build.0 = Debug|Win32 25 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|x64.ActiveCfg = Debug|x64 26 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Debug|x64.Build.0 = Debug|x64 27 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|Win32.ActiveCfg = Release|Win32 28 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|Win32.Build.0 = Release|Win32 29 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|x64.ActiveCfg = Release|x64 30 | {6A8518C3-D81A-4428-BD7F-C37933088AC1}.Release|x64.Build.0 = Release|x64 31 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|Win32.ActiveCfg = Debug|Win32 32 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|Win32.Build.0 = Debug|Win32 33 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|x64.ActiveCfg = Debug|x64 34 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Debug|x64.Build.0 = Debug|x64 35 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|Win32.ActiveCfg = Release|Win32 36 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|Win32.Build.0 = Release|Win32 37 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|x64.ActiveCfg = Release|x64 38 | {3BC7CF47-F1C8-4BDA-BE30-92F17B21D2C7}.Release|x64.Build.0 = Release|x64 39 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|Win32.ActiveCfg = Debug|Win32 40 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|Win32.Build.0 = Debug|Win32 41 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|x64.ActiveCfg = Debug|x64 42 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Debug|x64.Build.0 = Debug|x64 43 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|Win32.ActiveCfg = Release|Win32 44 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|Win32.Build.0 = Release|Win32 45 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x64.ActiveCfg = Release|x64 46 | {77A3F26C-A1D6-4535-9E37-7D3DF34E4B4B}.Release|x64.Build.0 = Release|x64 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /external/squish/squish-windows/squish.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | 91 | 92 | Header Files 93 | 94 | 95 | -------------------------------------------------------------------------------- /external/ycocg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR) 2 | project(ycocg) 3 | 4 | add_library(ycocg STATIC) 5 | 6 | target_sources(ycocg 7 | PRIVATE 8 | YCoCg.c 9 | YCoCgDXT.cpp 10 | YCoCgDXT.h 11 | ImageMath.c 12 | ImageMath.h 13 | PUBLIC 14 | ${CMAKE_CURRENT_LIST_DIR}/YCoCg.h 15 | ${CMAKE_CURRENT_LIST_DIR}/YCoCgDXT.h 16 | ) 17 | 18 | target_include_directories(ycocg 19 | PUBLIC 20 | . 21 | ) 22 | 23 | find_library(Accelerate Accelerate) 24 | 25 | target_link_libraries(ycocg 26 | $<$:${Accelerate}> 27 | ) 28 | -------------------------------------------------------------------------------- /external/ycocg/ImageMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | ImageMath.h 3 | Hap Codec 4 | 5 | Copyright (c) 2012-2013, Tom Butterworth and Vidvox LLC. All rights reserved. 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | // Cross-platform image matrix-multiplication 29 | 30 | #ifndef Pxlz_ImageMath_h 31 | #define Pxlz_ImageMath_h 32 | 33 | /* 34 | Avoid a conflict with the QuickTime SDK and MSVC's non-standard stdint.h 35 | */ 36 | #if !defined(_STDINT) && !defined(_STDINT_H) 37 | #include 38 | #endif 39 | #include 40 | 41 | void ImageMath_MatrixMultiply8888(const void *src, 42 | size_t src_bytes_per_row, 43 | void *dst, 44 | size_t dst_bytes_per_row, 45 | unsigned long width, 46 | unsigned long height, 47 | const int16_t matrix[4*4], 48 | int32_t divisor, // Applied after the matrix op 49 | const int16_t *pre_bias, // An array of 4 int16_t or NULL, added before matrix op 50 | const int32_t *post_bias, // An array of 4 int32_t or NULL, added after matrix op 51 | int allow_tile); // if non-zero, operation may be tiled and multithreaded 52 | 53 | void ImageMath_Permute8888(const void *src, 54 | size_t src_bytes_per_row, 55 | void *dst, 56 | size_t dst_bytes_per_row, 57 | unsigned long width, 58 | unsigned long height, 59 | const uint8_t permuteMap[4], // positions are dst channel order, values are src channel order 60 | int allow_tile); // if non-zero, operation may be tiled and multithreaded 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /external/ycocg/YCoCg.h: -------------------------------------------------------------------------------- 1 | /* 2 | YCoCg.h 3 | Hap Codec 4 | 5 | Copyright (c) 2012-2013, Tom Butterworth and Vidvox LLC. All rights reserved. 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef YCoCg_h 29 | #define YCoCg_h 30 | 31 | /* 32 | Avoid a conflict with the QuickTime SDK and MSVC's non-standard stdint.h 33 | */ 34 | #if !defined(_STDINT) && !defined(_STDINT_H) 35 | #include 36 | #endif 37 | #include 38 | 39 | /* 40 | RGB(A) and BGR(A) to and from CoCg(A)Y 41 | */ 42 | void ConvertRGBAToCoCgAY8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 43 | void ConvertCoCgAY8888ToRGBA( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 44 | void ConvertBGRAToCoCgAY8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 45 | void ConvertCoCgAY8888ToBGRA( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 46 | void ConvertBGR_ToCoCg_Y8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 47 | void ConvertCoCg_Y8888ToBGR_( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 48 | void ConvertRGB_ToCoCg_Y8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 49 | void ConvertCoCg_Y8888ToRGB_( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 50 | 51 | /* 52 | RGB(A) and BGR(A) to and from CoYCg(A) 53 | */ 54 | void ConvertRGBAToCoYCgA8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 55 | void ConvertCoYCgA8888ToRGBA( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 56 | void ConvertBGRAToCoYCgA8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 57 | void ConvertCoYCgA8888ToBGRA( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 58 | void ConvertBGR_ToCoYCg_8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 59 | void ConvertCoYCg_8888ToBGR_( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 60 | void ConvertRGB_ToCoYCg_8888( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 61 | void ConvertCoYCg_8888ToRGB_( const uint8_t *src, uint8_t *dst, unsigned long width, unsigned long height, size_t src_rowbytes, size_t dst_rowbytes, int allow_tile ); 62 | #endif 63 | -------------------------------------------------------------------------------- /installer/CodecInstaller.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR) 2 | 3 | set(CPACK_PACKAGE_NAME "HapEncoder") 4 | set(CPACK_PACKAGE_VENDOR "HapCommunity") 5 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HapEncoder - Hap encoding plugin for Adobe CC") 6 | set(CPACK_PACKAGE_VERSION "1.2.0-rc2") 7 | set(CPACK_PACKAGE_VERSION_MAJOR "1") 8 | set(CPACK_PACKAGE_VERSION_MINOR "2") 9 | set(CPACK_PACKAGE_VERSION_PATCH "0-rc2") 10 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "HapEncoderPlugin") 11 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_LIST_DIR}/../license.txt) 12 | set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_LIST_DIR}/ReadMe.txt) 13 | 14 | if (APPLE) 15 | set(CPACK_PREFLIGHT_PLUGIN_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/preinstall") 16 | endif (APPLE) 17 | 18 | # NSIS specific settings 19 | set(CPACK_NSIS_URL_INFO_ABOUT "https://hap.video") 20 | set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) 21 | set(CPACK_NSIS_PACKAGE_NAME "Hap Encoder Plugin for Adobe CC") 22 | set(CPACK_NSIS_HELP_LINK "https://github.com/disguise-one/hap-encoder-adobe-cc") 23 | set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/disguise-one/hap-encoder-adobe-cc/tree/master/doc/user_guide/") 24 | set(CPACK_NSIS_CONTACT "happlugin@disguise.one") 25 | 26 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS 27 | "Delete \\\"$PROGRAMFILES64\\\\Adobe\\\\Common\\\\Plug-ins\\\\7.0\\\\MediaCore\\\\CodecPluginFoundation.prm\\\"" 28 | "\\nDelete \\\"$PROGRAMFILES64\\\\Adobe\\\\Common\\\\Plug-ins\\\\7.0\\\\MediaCore\\\\HapEncoderPlugin.prm\\\"" 29 | ) 30 | 31 | # set(bitmap_path ${CMAKE_CURRENT_LIST_DIR}/../asset/install_image.bmp) 32 | # STRING(REPLACE "/" "\\" bitmap_path ${bitmap_path}) 33 | # set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP ${bitmap_path}) 34 | -------------------------------------------------------------------------------- /installer/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Hap Exporter for Adobe Creative Cloud 2 | 3 | This is the community-supplied Hap and Hap Q exporter plugin for Adobe Creative Cloud. 4 | 5 | Development of this plugin was sponsored by disguise, makers of the disguise show production software and hardware. 6 | 7 | Principal contributors to this plugin are 8 | 9 | - Greg Bakker 10 | - Richard Sykes 11 | - Tom Butterworth 12 | - Nick Zinovenko 13 | 14 | Thanks to Tom Butterworth for creating the Hap codec and Vidvox for supporting that development. 15 | -------------------------------------------------------------------------------- /installer/preinstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | INSTALL_LOCATION="/Library/Application Support/Adobe/Common/Plug-ins/7.0/MediaCore" 6 | 7 | # Delete previous versions which used different names 8 | for PLUGIN in HapEncoderPlugin.bundle CodecPluginFoundation.bundle; do 9 | if [ -d "$INSTALL_LOCATION/$PLUGIN" ]; then 10 | rm -r "$INSTALL_LOCATION/$PLUGIN" 11 | fi 12 | done 13 | 14 | exit 0 15 | --------------------------------------------------------------------------------