├── .gitignore
├── CHANGELOG.md
├── README.md
├── bin
├── crunch.exe
├── crunch.pdb
├── crunch_x64.exe
└── crunch_x64.pdb
├── crn.2008.sln
├── crn.workspace
├── crn_examples.2008.sln
├── crn_linux.workspace
├── crnlib
├── Makefile
├── crn_arealist.cpp
├── crn_arealist.h
├── 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_freeimage_image_utils.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_radix_sort.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.cpp
├── 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.2008.vcproj
├── crnlib.cbp
├── crnlib.cpp
├── crnlib_linux.cbp
├── lzham_timer.cpp
├── lzham_timer.h
├── lzham_win32_threading.cpp
├── lzham_win32_threading.h
├── lzma_7zBuf.cpp
├── lzma_7zBuf.h
├── lzma_7zBuf2.cpp
├── lzma_7zCrc.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.cpp
├── 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.cpp
├── lzma_Threads.h
└── lzma_Types.h
├── crunch
├── corpus_gen.cpp
├── corpus_gen.h
├── corpus_test.cpp
├── corpus_test.h
├── crunch.2008.vcproj
├── crunch.cbp
├── crunch.cpp
└── crunch_linux.cbp
├── emscripten
└── crunch_lib.cpp
├── example1
├── example1.2008.vcproj
├── example1.cpp
└── stb_image.h
├── example2
├── example2.2008.vcproj
├── example2.cpp
├── timer.cpp
└── timer.h
├── example3
├── example3.2008.vcproj
├── example3.cpp
└── stb_image.h
├── inc
├── crn_decomp.h
├── crnlib.h
└── dds_defs.h
└── license.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | crnlib/crunch
3 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [0.1.4] - 2012-11-24
4 | ### Added
5 | * KTX file format
6 | * Basic ETC1 support
7 | * Simple makefile
8 |
9 | ### Fixed
10 | * Various DDS format fixes
11 |
12 | ## [0.1.3] - 2012-04-26
13 | ### Added
14 | * Ported to Linux (tested on Ubuntu x86 w/Codeblocks). Note that a few features of the cmd line tool don't work yet (eg. -timestamp)
15 |
16 | [0.1.4]: https://github.com/BinomialLLC/crunch
17 | [0.1.3]: https://github.com/BinomialLLC/crunch
--------------------------------------------------------------------------------
/bin/crunch.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/crunch/ea9b8d8c00c8329791256adafa8cf11e4e7942a2/bin/crunch.exe
--------------------------------------------------------------------------------
/bin/crunch.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/crunch/ea9b8d8c00c8329791256adafa8cf11e4e7942a2/bin/crunch.pdb
--------------------------------------------------------------------------------
/bin/crunch_x64.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/crunch/ea9b8d8c00c8329791256adafa8cf11e4e7942a2/bin/crunch_x64.exe
--------------------------------------------------------------------------------
/bin/crunch_x64.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Unity-Technologies/crunch/ea9b8d8c00c8329791256adafa8cf11e4e7942a2/bin/crunch_x64.pdb
--------------------------------------------------------------------------------
/crn.2008.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crunch", "crunch\crunch.2008.vcproj", "{8F645BA1-B996-49EB-859B-970A671DE05D}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {CF2E70E8-7133-4D96-92C7-68BB406C0664} = {CF2E70E8-7133-4D96-92C7-68BB406C0664}
7 | EndProjectSection
8 | EndProject
9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crnlib", "crnlib\crnlib.2008.vcproj", "{CF2E70E8-7133-4D96-92C7-68BB406C0664}"
10 | EndProject
11 | Global
12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
13 | Debug_DLL|Win32 = Debug_DLL|Win32
14 | Debug_DLL|x64 = Debug_DLL|x64
15 | Debug|Win32 = Debug|Win32
16 | Debug|x64 = Debug|x64
17 | Release_DLL|Win32 = Release_DLL|Win32
18 | Release_DLL|x64 = Release_DLL|x64
19 | Release|Win32 = Release|Win32
20 | Release|x64 = Release|x64
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Debug_DLL|Win32.ActiveCfg = Debug|Win32
24 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Debug_DLL|x64.ActiveCfg = Debug|x64
25 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Debug|Win32.ActiveCfg = Debug|Win32
26 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Debug|Win32.Build.0 = Debug|Win32
27 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Debug|x64.ActiveCfg = Debug|x64
28 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Debug|x64.Build.0 = Debug|x64
29 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Release_DLL|Win32.ActiveCfg = Release|Win32
30 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Release_DLL|x64.ActiveCfg = Release|x64
31 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Release|Win32.ActiveCfg = Release|Win32
32 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Release|Win32.Build.0 = Release|Win32
33 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Release|x64.ActiveCfg = Release|x64
34 | {8F645BA1-B996-49EB-859B-970A671DE05D}.Release|x64.Build.0 = Release|x64
35 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug_DLL|Win32.ActiveCfg = Debug_DLL|Win32
36 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug_DLL|Win32.Build.0 = Debug_DLL|Win32
37 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug_DLL|x64.ActiveCfg = Debug_DLL|x64
38 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug_DLL|x64.Build.0 = Debug_DLL|x64
39 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug|Win32.ActiveCfg = Debug|Win32
40 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug|Win32.Build.0 = Debug|Win32
41 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug|x64.ActiveCfg = Debug|x64
42 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Debug|x64.Build.0 = Debug|x64
43 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release_DLL|Win32.ActiveCfg = Release_DLL|Win32
44 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release_DLL|Win32.Build.0 = Release_DLL|Win32
45 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release_DLL|x64.ActiveCfg = Release_DLL|x64
46 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release_DLL|x64.Build.0 = Release_DLL|x64
47 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release|Win32.ActiveCfg = Release|Win32
48 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release|Win32.Build.0 = Release|Win32
49 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release|x64.ActiveCfg = Release|x64
50 | {CF2E70E8-7133-4D96-92C7-68BB406C0664}.Release|x64.Build.0 = Release|x64
51 | EndGlobalSection
52 | GlobalSection(SolutionProperties) = preSolution
53 | HideSolutionNode = FALSE
54 | EndGlobalSection
55 | EndGlobal
56 |
--------------------------------------------------------------------------------
/crn.workspace:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/crn_examples.2008.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example1", "example1\example1.2008.vcproj", "{8F745B42-F996-49EB-859B-970A671DE05D}"
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example2", "example2\example2.2008.vcproj", "{AF745B42-F996-49EB-859B-970A671DEF5E}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example3", "example3\example3.2008.vcproj", "{AF745B42-E296-46EB-859B-970A671DEF5E}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug_DLL|Win32 = Debug_DLL|Win32
13 | Debug_DLL|x64 = Debug_DLL|x64
14 | Debug|Win32 = Debug|Win32
15 | Debug|x64 = Debug|x64
16 | Release_DLL|Win32 = Release_DLL|Win32
17 | Release_DLL|x64 = Release_DLL|x64
18 | Release|Win32 = Release|Win32
19 | Release|x64 = Release|x64
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug_DLL|Win32.ActiveCfg = Debug_DLL|Win32
23 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug_DLL|Win32.Build.0 = Debug_DLL|Win32
24 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug_DLL|x64.ActiveCfg = Debug_DLL|x64
25 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug_DLL|x64.Build.0 = Debug_DLL|x64
26 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug|Win32.ActiveCfg = Debug|Win32
27 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug|Win32.Build.0 = Debug|Win32
28 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug|x64.ActiveCfg = Debug|x64
29 | {8F745B42-F996-49EB-859B-970A671DE05D}.Debug|x64.Build.0 = Debug|x64
30 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release_DLL|Win32.ActiveCfg = Release_DLL|Win32
31 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release_DLL|Win32.Build.0 = Release_DLL|Win32
32 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release_DLL|x64.ActiveCfg = Release_DLL|x64
33 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release_DLL|x64.Build.0 = Release_DLL|x64
34 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release|Win32.ActiveCfg = Release|Win32
35 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release|Win32.Build.0 = Release|Win32
36 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release|x64.ActiveCfg = Release|x64
37 | {8F745B42-F996-49EB-859B-970A671DE05D}.Release|x64.Build.0 = Release|x64
38 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug_DLL|Win32.ActiveCfg = Debug_DLL|Win32
39 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug_DLL|Win32.Build.0 = Debug_DLL|Win32
40 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug_DLL|x64.ActiveCfg = Debug_DLL|x64
41 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug_DLL|x64.Build.0 = Debug_DLL|x64
42 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug|Win32.ActiveCfg = Debug|Win32
43 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug|Win32.Build.0 = Debug|Win32
44 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug|x64.ActiveCfg = Debug|x64
45 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Debug|x64.Build.0 = Debug|x64
46 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release_DLL|Win32.ActiveCfg = Release_DLL|Win32
47 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release_DLL|Win32.Build.0 = Release_DLL|Win32
48 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release_DLL|x64.ActiveCfg = Release_DLL|x64
49 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release_DLL|x64.Build.0 = Release_DLL|x64
50 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release|Win32.ActiveCfg = Release|Win32
51 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release|Win32.Build.0 = Release|Win32
52 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release|x64.ActiveCfg = Release|x64
53 | {AF745B42-F996-49EB-859B-970A671DEF5E}.Release|x64.Build.0 = Release|x64
54 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug_DLL|Win32.ActiveCfg = Debug_DLL|Win32
55 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug_DLL|Win32.Build.0 = Debug_DLL|Win32
56 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug_DLL|x64.ActiveCfg = Debug_DLL|x64
57 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug_DLL|x64.Build.0 = Debug_DLL|x64
58 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug|Win32.ActiveCfg = Debug|Win32
59 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug|Win32.Build.0 = Debug|Win32
60 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug|x64.ActiveCfg = Debug|x64
61 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Debug|x64.Build.0 = Debug|x64
62 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release_DLL|Win32.ActiveCfg = Release_DLL|Win32
63 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release_DLL|Win32.Build.0 = Release_DLL|Win32
64 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release_DLL|x64.ActiveCfg = Release_DLL|x64
65 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release_DLL|x64.Build.0 = Release_DLL|x64
66 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release|Win32.ActiveCfg = Release|Win32
67 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release|Win32.Build.0 = Release|Win32
68 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release|x64.ActiveCfg = Release|x64
69 | {AF745B42-E296-46EB-859B-970A671DEF5E}.Release|x64.Build.0 = Release|x64
70 | EndGlobalSection
71 | GlobalSection(SolutionProperties) = preSolution
72 | HideSolutionNode = FALSE
73 | EndGlobalSection
74 | EndGlobal
75 |
--------------------------------------------------------------------------------
/crn_linux.workspace:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/crnlib/Makefile:
--------------------------------------------------------------------------------
1 | COMPILE_OPTIONS = -O3 -fomit-frame-pointer -ffast-math -fno-math-errno -g -fno-strict-aliasing -Wall -Wno-unused-value -Wno-unused -march=core2
2 | LINKER_OPTIONS = -lpthread -g
3 |
4 | OBJECTS = \
5 | crn_arealist.o \
6 | crn_assert.o \
7 | crn_checksum.o \
8 | crn_colorized_console.o \
9 | crn_command_line_params.o \
10 | crn_comp.o \
11 | crn_console.o \
12 | crn_core.o \
13 | crn_data_stream.o \
14 | crn_mipmapped_texture.o \
15 | crn_decomp.o \
16 | crn_dxt1.o \
17 | crn_dxt5a.o \
18 | crn_dxt.o \
19 | crn_dxt_endpoint_refiner.o \
20 | crn_dxt_fast.o \
21 | crn_dxt_hc_common.o \
22 | crn_dxt_hc.o \
23 | crn_dxt_image.o \
24 | crn_dynamic_string.o \
25 | crn_file_utils.o \
26 | crn_find_files.o \
27 | crn_hash.o \
28 | crn_hash_map.o \
29 | crn_huffman_codes.o \
30 | crn_image_utils.o \
31 | crnlib.o \
32 | crn_math.o \
33 | crn_mem.o \
34 | crn_pixel_format.o \
35 | crn_platform.o \
36 | crn_prefix_coding.o \
37 | crn_qdxt1.o \
38 | crn_qdxt5.o \
39 | crn_rand.o \
40 | crn_resample_filters.o \
41 | crn_resampler.o \
42 | crn_ryg_dxt.o \
43 | crn_sparse_bit_array.o \
44 | crn_stb_image.o \
45 | crn_strutils.o \
46 | crn_symbol_codec.o \
47 | crn_texture_file_types.o \
48 | crn_threaded_resampler.o \
49 | crn_threading_pthreads.o \
50 | crn_timer.o \
51 | crn_utils.o \
52 | crn_value.o \
53 | crn_vector.o \
54 | crn_zeng.o \
55 | crn_texture_comp.o \
56 | crn_texture_conversion.o \
57 | crn_dds_comp.o \
58 | crn_lzma_codec.o \
59 | crn_ktx_texture.o \
60 | crn_etc.o \
61 | crn_rg_etc1.o \
62 | crn_miniz.o \
63 | crn_jpge.o \
64 | crn_jpgd.o \
65 | lzma_7zBuf2.o \
66 | lzma_7zBuf.o \
67 | lzma_7zCrc.o \
68 | lzma_7zFile.o \
69 | lzma_7zStream.o \
70 | lzma_Alloc.o \
71 | lzma_Bcj2.o \
72 | lzma_Bra86.o \
73 | lzma_Bra.o \
74 | lzma_BraIA64.o \
75 | lzma_LzFind.o \
76 | lzma_LzmaDec.o \
77 | lzma_LzmaEnc.o \
78 | lzma_LzmaLib.o
79 |
80 | all: crunch
81 |
82 | %.o: %.cpp
83 | g++ $< -o $@ -c $(COMPILE_OPTIONS)
84 |
85 | crunch.o: ../crunch/crunch.cpp
86 | g++ $< -o $@ -c -I../inc -I../crnlib $(COMPILE_OPTIONS)
87 |
88 | corpus_gen.o: ../crunch/corpus_gen.cpp
89 | g++ $< -o $@ -c -I../inc -I../crnlib $(COMPILE_OPTIONS)
90 |
91 | corpus_test.o: ../crunch/corpus_test.cpp
92 | g++ $< -o $@ -c -I../inc -I../crnlib $(COMPILE_OPTIONS)
93 |
94 | crunch: $(OBJECTS) crunch.o corpus_gen.o corpus_test.o
95 | g++ $(OBJECTS) crunch.o corpus_gen.o corpus_test.o -o crunch $(LINKER_OPTIONS)
96 |
97 |
--------------------------------------------------------------------------------
/crnlib/crn_arealist.h:
--------------------------------------------------------------------------------
1 | // File: crn_arealist.h - 2D shape algebra
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #pragma once
4 |
5 | namespace crnlib
6 | {
7 | struct Area
8 | {
9 | struct Area *Pprev, *Pnext;
10 |
11 | int x1, y1, x2, y2;
12 |
13 | uint get_width() const { return x2 - x1 + 1; }
14 | uint get_height() const { return y2 - y1 + 1; }
15 | uint get_area() const { return get_width() * get_height(); }
16 | };
17 |
18 | typedef Area * Area_Ptr;
19 |
20 | struct Area_List
21 | {
22 | int total_areas;
23 | int next_free;
24 |
25 | Area *Phead, *Ptail, *Pfree;
26 | };
27 |
28 | typedef Area_List * Area_List_Ptr;
29 |
30 | Area_List * Area_List_init(int max_areas);
31 | void Area_List_deinit(Area_List* Pobj_base);
32 |
33 | void Area_List_print(Area_List *Plist);
34 |
35 | Area_List * Area_List_dup_new(Area_List *Plist,
36 | int x_ofs, int y_ofs);
37 |
38 | uint Area_List_get_num(Area_List* Plist);
39 |
40 | // src and dst area lists must have the same number of total areas.
41 | void Area_List_dup(Area_List *Psrc_list,
42 | Area_List *Pdst_list,
43 | int x_ofs, int y_ofs);
44 |
45 | void Area_List_copy(Area_List *Psrc_list,
46 | Area_List *Pdst_list,
47 | int x_ofs, int y_ofs);
48 |
49 | void Area_List_clear(Area_List *Plist);
50 |
51 | void Area_List_set(Area_List *Plist,
52 | int x1, int y1, int x2, int y2);
53 |
54 | // logical: x and (not y)
55 | void Area_List_remove(Area_List *Plist,
56 | int x1, int y1, int x2, int y2);
57 |
58 | // logical: x or y
59 | void Area_List_insert(Area_List *Plist,
60 | int x1, int y1, int x2, int y2,
61 | bool combine);
62 |
63 | // logical: x and y
64 | void Area_List_intersect_area(Area_List *Plist,
65 | int x1, int y1, int x2, int y2);
66 |
67 | // logical: x and y
68 | void Area_List_intersect_Area_List(Area_List *Pouter_list,
69 | Area_List *Pinner_list,
70 | Area_List *Pdst_list);
71 |
72 | Area_List_Ptr Area_List_create_optimal(Area_List_Ptr Plist);
73 |
74 | } // namespace crnlib
75 |
--------------------------------------------------------------------------------
/crnlib/crn_assert.cpp:
--------------------------------------------------------------------------------
1 | // File: crn_assert.cpp
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #include "crn_core.h"
4 | #if CRNLIB_USE_WIN32_API
5 | #include "crn_winhdr.h"
6 | #endif
7 |
8 | static bool g_fail_exceptions;
9 | static bool g_exit_on_failure = true;
10 |
11 | void crnlib_enable_fail_exceptions(bool enabled)
12 | {
13 | g_fail_exceptions = enabled;
14 | }
15 |
16 | void crnlib_assert(const char* pExp, const char* pFile, unsigned line)
17 | {
18 | char buf[512];
19 |
20 | sprintf_s(buf, sizeof(buf), "%s(%u): Assertion failed: \"%s\"\n", pFile, line, pExp);
21 |
22 | crnlib_output_debug_string(buf);
23 |
24 | fputs(buf, stderr);
25 |
26 | if (crnlib_is_debugger_present())
27 | crnlib_debug_break();
28 | }
29 |
30 | void crnlib_fail(const char* pExp, const char* pFile, unsigned line)
31 | {
32 | char buf[512];
33 |
34 | sprintf_s(buf, sizeof(buf), "%s(%u): Failure: \"%s\"\n", pFile, line, pExp);
35 |
36 | crnlib_output_debug_string(buf);
37 |
38 | fputs(buf, stderr);
39 |
40 | if (crnlib_is_debugger_present())
41 | crnlib_debug_break();
42 |
43 | #if CRNLIB_USE_WIN32_API
44 | if (g_fail_exceptions)
45 | RaiseException(CRNLIB_FAIL_EXCEPTION_CODE, 0, 0, NULL);
46 | else
47 | #endif
48 | if (g_exit_on_failure)
49 | exit(EXIT_FAILURE);
50 | }
51 |
52 | void trace(const char* pFmt, va_list args)
53 | {
54 | if (crnlib_is_debugger_present())
55 | {
56 | char buf[512];
57 | vsprintf_s(buf, sizeof(buf), pFmt, args);
58 |
59 | crnlib_output_debug_string(buf);
60 | }
61 | };
62 |
63 | void trace(const char* pFmt, ...)
64 | {
65 | va_list args;
66 | va_start(args, pFmt);
67 | trace(pFmt, args);
68 | va_end(args);
69 | };
70 |
--------------------------------------------------------------------------------
/crnlib/crn_assert.h:
--------------------------------------------------------------------------------
1 | // File: crn_assert.h
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #pragma once
4 |
5 | const unsigned int CRNLIB_FAIL_EXCEPTION_CODE = 256U;
6 | void crnlib_enable_fail_exceptions(bool enabled);
7 |
8 | void crnlib_assert(const char* pExp, const char* pFile, unsigned line);
9 | void crnlib_fail(const char* pExp, const char* pFile, unsigned line);
10 |
11 | #ifdef NDEBUG
12 | #define CRNLIB_ASSERT(x) ((void)0)
13 | #undef CRNLIB_ASSERTS_ENABLED
14 | #else
15 | #define CRNLIB_ASSERT(_exp) (void)( (!!(_exp)) || (crnlib_assert(#_exp, __FILE__, __LINE__), 0) )
16 | #define CRNLIB_ASSERTS_ENABLED
17 | #endif
18 |
19 | #define CRNLIB_VERIFY(_exp) (void)( (!!(_exp)) || (crnlib_assert(#_exp, __FILE__, __LINE__), 0) )
20 |
21 | #define CRNLIB_FAIL(msg) do { crnlib_fail(#msg, __FILE__, __LINE__); } while(0)
22 |
23 | #define CRNLIB_ASSERT_OPEN_RANGE(x, l, h) CRNLIB_ASSERT((x >= l) && (x < h))
24 | #define CRNLIB_ASSERT_CLOSED_RANGE(x, l, h) CRNLIB_ASSERT((x >= l) && (x <= h))
25 |
26 | void trace(const char* pFmt, va_list args);
27 | void trace(const char* pFmt, ...);
28 |
29 | // Borrowed from boost libraries.
30 | template struct crnlib_assume_failure;
31 | template <> struct crnlib_assume_failure { enum { blah = 1 }; };
32 | template struct crnlib_assume_try { };
33 |
34 | #define CRNLIB_JOINER_FINAL(a, b) a##b
35 | #define CRNLIB_JOINER(a, b) CRNLIB_JOINER_FINAL(a, b)
36 | #define CRNLIB_JOIN(a, b) CRNLIB_JOINER(a, b)
37 | #define CRNLIB_ASSUME(p) typedef crnlib_assume_try < sizeof(crnlib_assume_failure< (bool)(p) > ) > CRNLIB_JOIN(crnlib_assume_typedef, __COUNTER__)
38 |
39 | #ifdef NDEBUG
40 | template inline T crnlib_assert_range(T i, T m)
41 | {
42 | m;
43 | return i;
44 | }
45 | template inline T crnlib_assert_range_incl(T i, T m)
46 | {
47 | m;
48 | return i;
49 | }
50 | #else
51 | template inline T crnlib_assert_range(T i, T m)
52 | {
53 | CRNLIB_ASSERT((i >= 0) && (i < m));
54 | return i;
55 | }
56 | template inline T crnlib_assert_range_incl(T i, T m)
57 | {
58 | CRNLIB_ASSERT((i >= 0) && (i <= m));
59 | return i;
60 | }
61 | #endif
62 |
--------------------------------------------------------------------------------
/crnlib/crn_buffer_stream.h:
--------------------------------------------------------------------------------
1 | // File: crn_buffer_stream.h
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #pragma once
4 | #include "crn_data_stream.h"
5 |
6 | namespace crnlib
7 | {
8 | class buffer_stream : public data_stream
9 | {
10 | public:
11 | buffer_stream() :
12 | data_stream(),
13 | m_pBuf(NULL),
14 | m_size(0),
15 | m_ofs(0)
16 | {
17 | }
18 |
19 | buffer_stream(void* p, uint size) :
20 | data_stream(),
21 | m_pBuf(NULL),
22 | m_size(0),
23 | m_ofs(0)
24 | {
25 | open(p, size);
26 | }
27 |
28 | buffer_stream(const void* p, uint size) :
29 | data_stream(),
30 | m_pBuf(NULL),
31 | m_size(0),
32 | m_ofs(0)
33 | {
34 | open(p, size);
35 | }
36 |
37 | virtual ~buffer_stream()
38 | {
39 | }
40 |
41 | bool open(const void* p, uint size)
42 | {
43 | CRNLIB_ASSERT(p);
44 |
45 | close();
46 |
47 | if ((!p) || (!size))
48 | return false;
49 |
50 | m_opened = true;
51 | m_pBuf = (uint8*)(p);
52 | m_size = size;
53 | m_ofs = 0;
54 | m_attribs = cDataStreamSeekable | cDataStreamReadable;
55 | return true;
56 | }
57 |
58 | bool open(void* p, uint size)
59 | {
60 | CRNLIB_ASSERT(p);
61 |
62 | close();
63 |
64 | if ((!p) || (!size))
65 | return false;
66 |
67 | m_opened = true;
68 | m_pBuf = static_cast(p);
69 | m_size = size;
70 | m_ofs = 0;
71 | m_attribs = cDataStreamSeekable | cDataStreamWritable | cDataStreamReadable;
72 | return true;
73 | }
74 |
75 | virtual bool close()
76 | {
77 | if (m_opened)
78 | {
79 | m_opened = false;
80 | m_pBuf = NULL;
81 | m_size = 0;
82 | m_ofs = 0;
83 | return true;
84 | }
85 |
86 | return false;
87 | }
88 |
89 | const void* get_buf() const { return m_pBuf; }
90 | void* get_buf() { return m_pBuf; }
91 |
92 | virtual const void* get_ptr() const { return m_pBuf; }
93 |
94 | virtual uint read(void* pBuf, uint len)
95 | {
96 | CRNLIB_ASSERT(pBuf && (len <= 0x7FFFFFFF));
97 |
98 | if ((!m_opened) || (!is_readable()) || (!len))
99 | return 0;
100 |
101 | CRNLIB_ASSERT(m_ofs <= m_size);
102 |
103 | uint bytes_left = m_size - m_ofs;
104 |
105 | len = math::minimum(len, bytes_left);
106 |
107 | if (len)
108 | memcpy(pBuf, &m_pBuf[m_ofs], len);
109 |
110 | m_ofs += len;
111 |
112 | return len;
113 | }
114 |
115 | virtual uint write(const void* pBuf, uint len)
116 | {
117 | CRNLIB_ASSERT(pBuf && (len <= 0x7FFFFFFF));
118 |
119 | if ((!m_opened) || (!is_writable()) || (!len))
120 | return 0;
121 |
122 | CRNLIB_ASSERT(m_ofs <= m_size);
123 |
124 | uint bytes_left = m_size - m_ofs;
125 |
126 | len = math::minimum(len, bytes_left);
127 |
128 | if (len)
129 | memcpy(&m_pBuf[m_ofs], pBuf, len);
130 |
131 | m_ofs += len;
132 |
133 | return len;
134 | }
135 |
136 | virtual bool flush()
137 | {
138 | if (!m_opened)
139 | return false;
140 |
141 | return true;
142 | }
143 |
144 | virtual uint64 get_size()
145 | {
146 | if (!m_opened)
147 | return 0;
148 |
149 | return m_size;
150 | }
151 |
152 | virtual uint64 get_remaining()
153 | {
154 | if (!m_opened)
155 | return 0;
156 |
157 | CRNLIB_ASSERT(m_ofs <= m_size);
158 |
159 | return m_size - m_ofs;
160 | }
161 |
162 | virtual uint64 get_ofs()
163 | {
164 | if (!m_opened)
165 | return 0;
166 |
167 | return m_ofs;
168 | }
169 |
170 | virtual bool seek(int64 ofs, bool relative)
171 | {
172 | if ((!m_opened) || (!is_seekable()))
173 | return false;
174 |
175 | int64 new_ofs = relative ? (m_ofs + ofs) : ofs;
176 |
177 | if (new_ofs < 0)
178 | return false;
179 | else if (new_ofs > m_size)
180 | return false;
181 |
182 | m_ofs = static_cast(new_ofs);
183 |
184 | post_seek();
185 |
186 | return true;
187 | }
188 |
189 | private:
190 | uint8* m_pBuf;
191 | uint m_size;
192 | uint m_ofs;
193 | };
194 |
195 | } // namespace crnlib
196 |
197 |
--------------------------------------------------------------------------------
/crnlib/crn_checksum.cpp:
--------------------------------------------------------------------------------
1 | // File: crn_checksum.cpp
2 | #include "crn_core.h"
3 |
4 | namespace crnlib
5 | {
6 | // From the public domain stb.h header.
7 | uint adler32(const void* pBuf, size_t buflen, uint adler32)
8 | {
9 | const uint8* buffer = static_cast(pBuf);
10 |
11 | const unsigned long ADLER_MOD = 65521;
12 | unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
13 | size_t blocklen;
14 | unsigned long i;
15 |
16 | blocklen = buflen % 5552;
17 | while (buflen) {
18 | for (i=0; i + 7 < blocklen; i += 8) {
19 | s1 += buffer[0], s2 += s1;
20 | s1 += buffer[1], s2 += s1;
21 | s1 += buffer[2], s2 += s1;
22 | s1 += buffer[3], s2 += s1;
23 | s1 += buffer[4], s2 += s1;
24 | s1 += buffer[5], s2 += s1;
25 | s1 += buffer[6], s2 += s1;
26 | s1 += buffer[7], s2 += s1;
27 |
28 | buffer += 8;
29 | }
30 |
31 | for (; i < blocklen; ++i)
32 | s1 += *buffer++, s2 += s1;
33 |
34 | s1 %= ADLER_MOD, s2 %= ADLER_MOD;
35 | buflen -= blocklen;
36 | blocklen = 5552;
37 | }
38 | return (s2 << 16) + s1;
39 | }
40 |
41 | uint16 crc16(const void* pBuf, size_t len, uint16 crc)
42 | {
43 | crc = ~crc;
44 |
45 | const uint8* p = reinterpret_cast(pBuf);
46 | while (len)
47 | {
48 | const uint16 q = *p++ ^ (crc >> 8);
49 | crc <<= 8U;
50 | uint16 r = (q >> 4) ^ q;
51 | crc ^= r;
52 | r <<= 5U;
53 | crc ^= r;
54 | r <<= 7U;
55 | crc ^= r;
56 | len--;
57 | }
58 |
59 | return static_cast(~crc);
60 | }
61 |
62 | } // namespace crnlib
63 |
64 |
--------------------------------------------------------------------------------
/crnlib/crn_checksum.h:
--------------------------------------------------------------------------------
1 | // File: crn_checksum.h
2 | #pragma once
3 |
4 | namespace crnlib
5 | {
6 | const uint cInitAdler32 = 1U;
7 | uint adler32(const void* pBuf, size_t buflen, uint adler32 = cInitAdler32);
8 |
9 | // crc16() intended for small buffers - doesn't use an acceleration table.
10 | const uint cInitCRC16 = 0;
11 | uint16 crc16(const void* pBuf, size_t len, uint16 crc = cInitCRC16);
12 |
13 | } // namespace crnlib
14 |
--------------------------------------------------------------------------------
/crnlib/crn_colorized_console.cpp:
--------------------------------------------------------------------------------
1 | // File: crn_colorized_console.cpp
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #include "crn_core.h"
4 | #include "crn_colorized_console.h"
5 | #ifdef CRNLIB_USE_WIN32_API
6 | #include "crn_winhdr.h"
7 | #endif
8 |
9 | namespace crnlib
10 | {
11 | void colorized_console::init()
12 | {
13 | console::init();
14 | console::add_console_output_func(console_output_func, NULL);
15 | }
16 |
17 | void colorized_console::deinit()
18 | {
19 | console::remove_console_output_func(console_output_func);
20 | console::deinit();
21 | }
22 |
23 | void colorized_console::tick()
24 | {
25 | }
26 |
27 | #ifdef CRNLIB_USE_WIN32_API
28 | bool colorized_console::console_output_func(eConsoleMessageType type, const char* pMsg, void* pData)
29 | {
30 | pData;
31 |
32 | if (console::get_output_disabled())
33 | return true;
34 |
35 | HANDLE cons = GetStdHandle(STD_OUTPUT_HANDLE);
36 |
37 | DWORD attr = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
38 | switch (type)
39 | {
40 | case cDebugConsoleMessage: attr = FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
41 | case cMessageConsoleMessage: attr = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
42 | case cWarningConsoleMessage: attr = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; break;
43 | case cErrorConsoleMessage: attr = FOREGROUND_RED | FOREGROUND_INTENSITY; break;
44 | default: break;
45 | }
46 |
47 | if (INVALID_HANDLE_VALUE != cons)
48 | SetConsoleTextAttribute(cons, (WORD)attr);
49 |
50 | if ((console::get_prefixes()) && (console::get_at_beginning_of_line()))
51 | {
52 | switch (type)
53 | {
54 | case cDebugConsoleMessage:
55 | printf("Debug: %s", pMsg);
56 | break;
57 | case cWarningConsoleMessage:
58 | printf("Warning: %s", pMsg);
59 | break;
60 | case cErrorConsoleMessage:
61 | printf("Error: %s", pMsg);
62 | break;
63 | default:
64 | printf("%s", pMsg);
65 | break;
66 | }
67 | }
68 | else
69 | {
70 | printf("%s", pMsg);
71 | }
72 |
73 | if (console::get_crlf())
74 | printf("\n");
75 |
76 | if (INVALID_HANDLE_VALUE != cons)
77 | SetConsoleTextAttribute(cons, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
78 |
79 | return true;
80 | }
81 | #else
82 | bool colorized_console::console_output_func(eConsoleMessageType type, const char* pMsg, void* pData)
83 | {
84 | pData;
85 | if (console::get_output_disabled())
86 | return true;
87 |
88 | if ((console::get_prefixes()) && (console::get_at_beginning_of_line()))
89 | {
90 | switch (type)
91 | {
92 | case cDebugConsoleMessage:
93 | printf("Debug: %s", pMsg);
94 | break;
95 | case cWarningConsoleMessage:
96 | printf("Warning: %s", pMsg);
97 | break;
98 | case cErrorConsoleMessage:
99 | printf("Error: %s", pMsg);
100 | break;
101 | default:
102 | printf("%s", pMsg);
103 | break;
104 | }
105 | }
106 | else
107 | {
108 | printf("%s", pMsg);
109 | }
110 |
111 | if (console::get_crlf())
112 | printf("\n");
113 |
114 | return true;
115 | }
116 | #endif
117 |
118 | } // namespace crnlib
119 |
120 |
--------------------------------------------------------------------------------
/crnlib/crn_colorized_console.h:
--------------------------------------------------------------------------------
1 | // File: crn_colorized_console.h
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #pragma once
4 | #include "crn_console.h"
5 |
6 | namespace crnlib
7 | {
8 | class colorized_console
9 | {
10 | public:
11 | static void init();
12 | static void deinit();
13 | static void tick();
14 |
15 | private:
16 | static bool console_output_func(eConsoleMessageType type, const char* pMsg, void* pData);
17 | };
18 |
19 | } // namespace crnlib
20 |
--------------------------------------------------------------------------------
/crnlib/crn_command_line_params.h:
--------------------------------------------------------------------------------
1 | // File: crn_command_line_params.h
2 | // See Copyright Notice and license at the end of inc/crnlib.h
3 | #pragma once
4 | #include "crn_value.h"
5 | #include