diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..55c41944 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +project (crunch) +set( CMAKE_CXX_FLAGS "-Wextra -Wall -fomit-frame-pointer -fexpensive-optimizations -O3 -fexceptions -Wno-unused-value -Wno-unused -fno-strict-aliasing -ffast-math -fno-math-errno " ) + +add_subdirectory (crnlib) + +include_directories(inc) + +add_executable ( crunch + crunch/corpus_gen.cpp + crunch/corpus_gen.h + crunch/corpus_test.cpp + crunch/corpus_test.h + crunch/crunch.cpp +) + +# Link the executable to the crn library. Since the crn library has +# public include directories we will use those link directories when building +# crunch +target_link_libraries (crunch LINK_PUBLIC crn pthread) + +install (TARGETS crunch DESTINATION bin) # installs crunch to /usr/local/bin/crunch diff --git a/README.md b/README.md index ffd72295..248cb2cd 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,10 @@ crunch/crnlib v1.04 - Advanced DXTn texture compression library +Copyright (C) 2010-2017 Richard Geldreich, Jr. and Binomial LLC http://binomial.info -Copyright (C) 2010-2017 Richard Geldreich, Jr. All rights reserved. +For bugs or support contact Binomial . -For bugs or support contact Binomial: . - -Please note that crunch is unsupported software. **Basis** is the new commercial successor -to crunch, which has first-class support for LZ optimized RDO texture compression, much -faster compression, and more GPU formats. More info is on our website -here: http://www.binomial.info/ - -This software uses a modified ZLIB license, which is located in license.txt. This license is the same as zlib -except attribution is required either in the product's documentation or credits. +This software uses the ZLIB license, which is located in license.txt. +http://opensource.org/licenses/Zlib Portions of this software make use of public domain code originally written by Igor Pavlov (LZMA), RYG (crn_ryg_dxt*), and Sean Barrett (stb_image.c). diff --git a/bin/crunch.exe b/bin/crunch.exe deleted file mode 100644 index 07c9ceda..00000000 Binary files a/bin/crunch.exe and /dev/null differ diff --git a/bin/crunch.pdb b/bin/crunch.pdb deleted file mode 100644 index 9aa35c82..00000000 Binary files a/bin/crunch.pdb and /dev/null differ diff --git a/bin/crunch_x64.exe b/bin/crunch_x64.exe deleted file mode 100644 index 6a47d6b7..00000000 Binary files a/bin/crunch_x64.exe and /dev/null differ diff --git a/bin/crunch_x64.pdb b/bin/crunch_x64.pdb deleted file mode 100644 index 1b2c4fc9..00000000 Binary files a/bin/crunch_x64.pdb and /dev/null differ diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/crnlib/CMakeLists.txt b/crnlib/CMakeLists.txt new file mode 100644 index 00000000..4de41277 --- /dev/null +++ b/crnlib/CMakeLists.txt @@ -0,0 +1,187 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +project (crn) +set( CMAKE_CXX_FLAGS "-Wextra -Wall -fomit-frame-pointer -fexpensive-optimizations -O3 -fexceptions -Wno-unused-value -Wno-unused -fno-strict-aliasing -ffast-math -fno-math-errno " ) +add_library (crn + crn_arealist.cpp + crn_assert.cpp + crn_assert.h + crn_atomics.h + crn_buffer_stream.h + crn_cfile_stream.h + crn_checksum.cpp + crn_checksum.h + crn_clusterizer.h + crn_color.h + crn_colorized_console.cpp + crn_colorized_console.h + crn_command_line_params.cpp + crn_command_line_params.h + crn_comp.cpp + crn_comp.h + crn_console.cpp + crn_console.h + crn_core.cpp + crn_core.h + crn_data_stream.cpp + crn_data_stream.h + crn_data_stream_serializer.h + crn_dds_comp.cpp + crn_dds_comp.h + crn_decomp.cpp + crn_dxt.cpp + crn_dxt.h + crn_dxt1.cpp + crn_dxt1.h + crn_dxt5a.cpp + crn_dxt5a.h + crn_dxt_endpoint_refiner.cpp + crn_dxt_endpoint_refiner.h + crn_dxt_fast.cpp + crn_dxt_fast.h + crn_dxt_hc.cpp + crn_dxt_hc.h + crn_dxt_hc_common.cpp + crn_dxt_hc_common.h + crn_dxt_image.cpp + crn_dxt_image.h + crn_dynamic_stream.h + crn_dynamic_string.cpp + crn_dynamic_string.h + crn_etc.cpp + crn_etc.h + crn_file_utils.cpp + crn_file_utils.h + crn_find_files.cpp + crn_find_files.h + crn_hash.cpp + crn_hash.h + crn_hash_map.cpp + crn_hash_map.h + crn_helpers.h + crn_huffman_codes.cpp + crn_huffman_codes.h + crn_image.h + crn_image_utils.cpp + crn_image_utils.h + crn_intersect.h + crn_jpgd.cpp + crn_jpgd.h + crn_jpge.cpp + crn_jpge.h + crn_ktx_texture.cpp + crn_ktx_texture.h + crn_lzma_codec.cpp + crn_lzma_codec.h + crn_math.cpp + crn_math.h + crn_matrix.h + crn_mem.cpp + crn_mem.h + crn_miniz.cpp + crn_miniz.h + crn_mipmapped_texture.cpp + crn_mipmapped_texture.h + crn_packed_uint.h + crn_pixel_format.cpp + crn_pixel_format.h + crn_platform.cpp + crn_platform.h + crn_prefix_coding.cpp + crn_prefix_coding.h + crn_qdxt1.cpp + crn_qdxt1.h + crn_qdxt5.cpp + crn_qdxt5.h + crn_rand.cpp + crn_rand.h + crn_ray.h + crn_rect.h + crn_resample_filters.cpp + crn_resample_filters.h + crn_resampler.cpp + crn_resampler.h + crn_rg_etc1.cpp + crn_rg_etc1.h + crn_ryg_dxt.cpp + crn_ryg_dxt.hpp + crn_ryg_types.hpp + crn_sparse_array.h + crn_sparse_bit_array.cpp + crn_sparse_bit_array.h + crn_stb_image.cpp + crn_strutils.cpp + crn_strutils.h + crn_symbol_codec.cpp + crn_symbol_codec.h + crn_texture_comp.cpp + crn_texture_comp.h + crn_texture_conversion.cpp + crn_texture_conversion.h + crn_texture_file_types.cpp + crn_texture_file_types.h + crn_threaded_clusterizer.h + crn_threaded_resampler.cpp + crn_threaded_resampler.h + crn_threading.h + crn_threading_null.h + crn_threading_pthreads.cpp + crn_threading_pthreads.h + crn_threading_win32.h + crn_timer.cpp + crn_timer.h + crn_traits.h + crn_tree_clusterizer.h + crn_types.h + crn_utils.cpp + crn_utils.h + crn_value.cpp + crn_value.h + crn_vec.h + crn_vec_interval.h + crn_vector.cpp + crn_vector.h + crn_vector2d.h + crn_winhdr.h + crn_zeng.cpp + crn_zeng.h + crnlib.cbp + crnlib.cpp + lzma_7zBuf.cpp + lzma_7zBuf.h + lzma_7zBuf2.cpp + lzma_7zCrc.h + lzma_7zFile.cpp + lzma_7zFile.h + lzma_7zStream.cpp + lzma_7zVersion.h + lzma_Alloc.cpp + lzma_Alloc.h + lzma_Bcj2.cpp + lzma_Bcj2.h + lzma_Bra.cpp + lzma_Bra.h + lzma_Bra86.cpp + lzma_BraIA64.cpp + lzma_CpuArch.h + lzma_LzFind.cpp + lzma_LzFind.h + lzma_LzFindMt.h + lzma_LzHash.h + lzma_LzmaDec.cpp + lzma_LzmaDec.h + lzma_LzmaEnc.cpp + lzma_LzmaEnc.h + lzma_LzmaLib.cpp + lzma_LzmaLib.h + lzma_MyVersion.h + lzma_Threads.h + lzma_Types.h + ../inc/crn_decomp.h + ../inc/crnlib.h + ../inc/dds_defs.h +${SRCS}) + +# Make sure the compiler can find include files for our Hello library +# when other libraries or executables link to Hello +target_include_directories (crn PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/crnlib/crn_core.cpp b/crnlib/crn_core.cpp index 763eab60..8dca8c5b 100644 --- a/crnlib/crn_core.cpp +++ b/crnlib/crn_core.cpp @@ -8,7 +8,7 @@ namespace crnlib { - const char *g_copyright_str = "Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved."; + const char *g_copyright_str = "Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC"; const char *g_sig_str = "C8cfRlaorj0wLtnMSxrBJxTC85rho2L9hUZKHcBL"; } // namespace crnlib diff --git a/crnlib/crn_math.h b/crnlib/crn_math.h index 5b48f8a7..967ce858 100644 --- a/crnlib/crn_math.h +++ b/crnlib/crn_math.h @@ -56,7 +56,7 @@ namespace crnlib template inline T square(T value) { return value * value; } - inline bool is_power_of_2(uint32 x) { return x && ((x & (x - 1U)) == 0U); } + //inline bool is_power_of_2(uint32 x) { return x && ((x & (x - 1U)) == 0U); } inline bool is_power_of_2(uint64 x) { return x && ((x & (x - 1U)) == 0U); } template inline T align_up_value(T x, uint alignment) @@ -80,7 +80,7 @@ namespace crnlib return align_up_value(x, alignment) - x; } - // From "Hackers Delight" +/* // From "Hackers Delight" inline uint32 next_pow2(uint32 val) { val--; @@ -91,7 +91,7 @@ namespace crnlib val |= val >> 1; return val + 1; } - +*/ inline uint64 next_pow2(uint64 val) { val--; diff --git a/crnlib/crnlib.cpp b/crnlib/crnlib.cpp index b5fb42bc..682efad8 100644 --- a/crnlib/crnlib.cpp +++ b/crnlib/crnlib.cpp @@ -405,7 +405,6 @@ bool crn_decompress_block(const void *pSrc_block, crn_uint32 *pDst_pixels_u32, c pDst_pixels[i] = colors[s]; pDst_pixels[i].a = static_cast(values[a]); } - break; } case cCRNFmtDXN_XY: diff --git a/crunch/crunch.cpp b/crunch/crunch.cpp index 58b5456c..57f7e528 100644 --- a/crunch/crunch.cpp +++ b/crunch/crunch.cpp @@ -784,8 +784,8 @@ class crunch } else if (m_params.has_key("relrescale")) { - float w = m_params.get_value_as_float("relrescale", 0, 1, 1, 256, 0); - float h = m_params.get_value_as_float("relrescale", 0, 1, 1, 256, 1); + float w = m_params.get_value_as_float("relrescale", 0, 1, 0, 256, 0); + float h = m_params.get_value_as_float("relrescale", 0, 1, 0, 256, 1); mipmap_params.m_scale_mode = cCRNSMRelative; mipmap_params.m_scale_x = w; @@ -1254,7 +1254,7 @@ static bool check_for_option(int argc, char *argv[], const char *pOption) static void print_title() { console::printf("crunch: Advanced DXTn Texture Compressor - https://github.com/BinomialLLC/crunch"); - console::printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved."); + console::printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC"); console::printf("crnlib version v%u.%02u %s Built %s, %s", CRNLIB_VERSION / 100U, CRNLIB_VERSION % 100U, crnlib_is_x64() ? "x64" : "x86", __DATE__, __TIME__); console::printf(""); } diff --git a/example1/example1.cpp b/example1/example1.cpp index 52ec0396..69d1a89d 100644 --- a/example1/example1.cpp +++ b/example1/example1.cpp @@ -33,7 +33,7 @@ const int cDefaultCRNQualityLevel = 128; static int print_usage() { printf("Description: Simple crnlib API example program.\n"); - printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved.\n"); + printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC\n"); printf("Usage: example1 [mode: i/c/d] [source_file] [options]\n"); printf("\nModes:\n"); printf("c: Compress to .DDS or .CRN using the crn_compress() func. in crnlib.h\n"); diff --git a/example2/example2.cpp b/example2/example2.cpp index d1d6d40d..63c46bac 100644 --- a/example2/example2.cpp +++ b/example2/example2.cpp @@ -24,7 +24,7 @@ using namespace crnlib; static int print_usage() { printf("Description: Transcodes .CRN to .DDS files using crn_decomp.h.\n"); - printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved.\n"); + printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC\n"); printf("Usage: example2 [source_file] [options]\n"); printf("\nOptions:\n"); printf("-out filename - Force output filename.\n"); diff --git a/example3/example3.cpp b/example3/example3.cpp index 6ea8f3ac..0732feb1 100644 --- a/example3/example3.cpp +++ b/example3/example3.cpp @@ -29,7 +29,7 @@ const uint cDXTBlockSize = 4; static int print_usage() { printf("Description: Simple .DDS DXTn block compression using crnlib.\n"); - printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved.\n"); + printf("Copyright (c) 2010-2016 Binomial LLC\n"); printf("Usage: example3 [source_file] [options]\n"); printf("\n"); printf("Note: This simple example is not multithreaded, so it's not going to be\n"); diff --git a/inc/crn_decomp.h b/inc/crn_decomp.h index 2c626af3..680beb1f 100644 --- a/inc/crn_decomp.h +++ b/inc/crn_decomp.h @@ -1,5 +1,5 @@ // File: crn_decomp.h - Fast CRN->DXTc texture transcoder header file library -// Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved. +// Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC // See Copyright Notice and license at the end of this file. // // This single header file contains *all* of the code necessary to unpack .CRN files to raw DXTn bits. @@ -4811,33 +4811,29 @@ namespace crnd #endif // CRND_HEADER_FILE_ONLY - //------------------------------------------------------------------------------ - // - // crunch/crnlib uses a modified ZLIB license. Specifically, it's the same as zlib except that - // public credits for using the library are *required*. - // - // Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved. - // - // This software is provided 'as-is', without any express or implied - // warranty. In no event will the authors be held liable for any damages - // arising from the use of this software. - // - // Permission is granted to anyone to use this software for any purpose, - // including commercial applications, and to alter it and redistribute it - // freely, subject to the following restrictions: - // - // 1. The origin of this software must not be misrepresented; you must not - // claim that you wrote the original software. - // - // 2. If you use this software in a product, this acknowledgment in the product - // documentation or credits is required: - // - // "Crunch Library Copyright (c) 2010-2016 Richard Geldreich, Jr." - // - // 3. Altered source versions must be plainly marked as such, and must not be - // misrepresented as being the original software. - // - // 4. This notice may not be removed or altered from any source distribution. - // - //------------------------------------------------------------------------------ - +//------------------------------------------------------------------------------ +// +// crn_decomp.h uses the ZLIB license: +// http://opensource.org/licenses/Zlib +// +// Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//------------------------------------------------------------------------------ diff --git a/inc/crnlib.h b/inc/crnlib.h index f07142a4..1c3e0782 100644 --- a/inc/crnlib.h +++ b/inc/crnlib.h @@ -1,5 +1,5 @@ // File: crnlib.h - Advanced DXTn texture compression library. -// Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved. +// Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC // See copyright notice and license at the end of this file. // // This header file contains the public crnlib declarations for DXTn, @@ -616,30 +616,27 @@ bool crn_decompress_block(const void *pSrc_block, crn_uint32 *pDst_pixels, crn_f //------------------------------------------------------------------------------ // -// crunch/crnlib uses a modified ZLIB license. Specifically, it's the same as zlib except that -// public credits for using the library are *required*. -// -// Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved. +// crnlib uses the ZLIB license: +// http://opensource.org/licenses/Zlib +// +// Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. -// +// // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: -// +// // 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. -// -// 2. If you use this software in a product, this acknowledgment in the product -// documentation or credits is required: -// -// "Crunch Library Copyright (c) 2010-2016 Richard Geldreich, Jr." -// -// 3. Altered source versions must be plainly marked as such, and must not be +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. -// -// 4. This notice may not be removed or altered from any source distribution. +// +// 3. This notice may not be removed or altered from any source distribution. // //------------------------------------------------------------------------------ diff --git a/license.txt b/license.txt index a24f7629..c6ce4f80 100644 --- a/license.txt +++ b/license.txt @@ -1,7 +1,7 @@ -crunch/crnlib uses a modified ZLIB license. Specifically, it's the same as zlib except that -public credits for using the library are *required*. +crunch/crnlib uses the ZLIB license: +http://opensource.org/licenses/Zlib -Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved. +Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -12,14 +12,11 @@ including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not -claim that you wrote the original software. +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. -2. If you use this software in a product, this acknowledgment in the product -documentation or credits is required: - -"Crunch Library Copyright (c) 2010-2016 Richard Geldreich, Jr." - -3. Altered source versions must be plainly marked as such, and must not be +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -4. This notice may not be removed or altered from any source distribution. +3. This notice may not be removed or altered from any source distribution.