Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>.

For bugs or support contact Binomial: <[email protected]>.

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).
Expand Down
Binary file removed bin/crunch.exe
Binary file not shown.
Binary file removed bin/crunch.pdb
Binary file not shown.
Binary file removed bin/crunch_x64.exe
Binary file not shown.
Binary file removed bin/crunch_x64.pdb
Binary file not shown.
Empty file added build/.gitignore
Empty file.
187 changes: 187 additions & 0 deletions crnlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
2 changes: 1 addition & 1 deletion crnlib/crn_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions crnlib/crn_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace crnlib

template<typename T> 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<typename T> inline T align_up_value(T x, uint alignment)
Expand All @@ -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--;
Expand All @@ -91,7 +91,7 @@ namespace crnlib
val |= val >> 1;
return val + 1;
}

*/
inline uint64 next_pow2(uint64 val)
{
val--;
Expand Down
1 change: 0 additions & 1 deletion crnlib/crnlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8>(values[a]);
}
break;
}

case cCRNFmtDXN_XY:
Expand Down
6 changes: 3 additions & 3 deletions crunch/crunch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("");
}
Expand Down
2 changes: 1 addition & 1 deletion example1/example1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion example2/example2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion example3/example3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
58 changes: 27 additions & 31 deletions inc/crn_decomp.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
//
//------------------------------------------------------------------------------
Loading