54 Commits

Author SHA1 Message Date
Rich Geldreich 36479bc697 Merge pull request #45 from winterheart/msvc2022
Fix crnlib compilation on MSVC 2022 toolchain
2025-05-24 21:52:23 -04:00
Azamat H. Hackimov 20315fbd1c Fix crnlib compilation on MSVC2022 toolchain 2025-05-24 21:39:18 +03:00
Rich Geldreich 671a0648c8 Merge pull request #25 from griffin2000/master
Avoid ambiguity error on GCC
2020-10-09 00:23:03 -04:00
Rich Geldreich ce2058f457 Update README.md 2020-09-15 14:15:01 -04:00
Rich Geldreich c1115f919d Update README.md
Removing copyright
2020-09-15 14:14:15 -04:00
richgel999 57353fa9ac Removing copyright. This software is now entirely in the public domain. 2020-09-15 14:12:38 -04:00
richgel999 44c8402e24 Correcting crunch's copyright messages. 2019-06-15 00:59:38 -07:00
richgel999 e6e5f0de2b Fixing copyright at end of file 2019-06-15 00:53:09 -07:00
Rich Geldreich fa326be601 Update README.md 2019-06-15 00:45:29 -07:00
richgel999 231d6cef0e Fixing missing break 2019-06-15 00:40:24 -07:00
Rich Geldreich 5bd8d45801 Update README.md 2019-06-15 00:37:40 -07:00
Rich Geldreich 99a01dac7f Update README.md 2019-06-15 00:37:25 -07:00
richgel999 7c54efc80e Correcting crunch's copyright. An IP Release Agreement was never signed by Richard Geldreich, Jr. to release this intellectual property to "Tenacious Software LLC" (a now long defunct Texas LLC), so I am removing this entity from the copyright. The proper crunch library copyright message is "Copyright (c) 2010-2016 Richard Geldreich, Jr. All rights reserved." 2019-06-15 00:35:13 -07:00
Gareth Morgan 3a445a94cd Avoid ambiguity error on GCC 2018-11-12 19:40:08 -05:00
Rich Geldreich ea72a1df7c Updating readme 2018-11-07 23:22:24 -05:00
Rich Geldreich 65d22b25f0 Updating license to require attribution 2018-11-07 23:20:46 -05:00
Rich Geldreich 80c087dbc9 Changing readme 2018-05-14 14:50:22 -07:00
Rich Geldreich 235946f7a1 Updating readme 2017-11-15 15:12:31 -08:00
Rich Geldreich 981166d129 Updating readme 2017-11-15 15:10:55 -08:00
Rich Geldreich c96c88791b Updating readme 2017-11-15 15:06:53 -08:00
Rich Geldreich ea9b8d8c00 Fixing emscripten docs 2017-01-09 14:38:39 -08:00
Rich Geldreich 66892464f6 Merged file 2017-01-09 14:37:37 -08:00
Rich Geldreich a1281e5b2a Improve default documentation
Conflicts:
	README.md
2017-01-09 14:17:29 -08:00
Rich Geldreich 7ae16dda71 clang is also on board (reverted from commit 0c95eb14d6) 2017-01-09 14:12:47 -08:00
Rich Geldreich d64212091e Change data type to match assigned one. (reverted from commit 133a78398f) 2017-01-09 13:57:00 -08:00
Rich Geldreich bf5e9d9c3b Linux fixes 2017-01-09 13:54:05 -08:00
Rich Geldreich 9f20c8c318 Merge pull request #8 from nwnk/master
readme: Update link to Compressonator
2017-01-09 13:44:40 -08:00
Rich Geldreich 0990cc8341 Merge pull request #9 from AnalyticalGraphicsInc/emcc
Compile to Javascript with Emscripten.
2017-01-09 13:42:09 -08:00
Dan Bagnell 1d3fcb59cd Update README with instructions for using Emscripten. 2017-01-09 15:04:52 -05:00
Dan Bagnell 0c22f98142 Rename crn.cpp -> crunch_lib.cpp. 2017-01-09 14:57:52 -05:00
Dan Bagnell a60ed487c5 Update crn.cpp license. 2017-01-09 14:17:31 -05:00
Dan Bagnell 8fbb07dc57 Add functions to export with emscripten. 2017-01-09 14:13:39 -05:00
Adam Jackson 3cae875fda readme: Update link to Compressonator
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-11-15 15:12:47 -05:00
Tomer Barletz e974687ae6 Update with crunch executable. 2016-07-11 18:32:16 -07:00
Tomer Barletz 75632ff47e Fix gcc name-lookup, which requires to use the 'this' qualifier. 2016-07-11 18:31:20 -07:00
Tomer Barletz 133a78398f Change data type to match assigned one. 2016-07-11 18:28:27 -07:00
Tomer Barletz 732cd33239 Fix return types from boolean/false to pointer/NULL. 2016-07-11 15:38:49 -07:00
Tomer Barletz a9653b88e7 Add build support for 64-bit with g++. 2016-07-11 15:37:15 -07:00
Tomer Barletz 001ba71348 Add .gitignore file. 2016-07-11 15:34:36 -07:00
Arvid Gerstmann 0c95eb14d6 clang is also on board 2016-06-29 23:07:41 +02:00
Arvid Gerstmann 1faffa9b1b fixes building 2016-06-29 22:56:37 +02:00
Jake 2ef76b99e5 docs(readme): Update copyright 2016-06-20 11:53:18 +02:00
Jake bf683690a9 Merge remote-tracking branch 'refs/remotes/upstream/master'
Conflicts:
	readme.txt
2016-06-20 11:51:19 +02:00
Rich Geldreich 0aea5beeb2 Fixing copyright 2016-06-16 20:08:40 -07:00
Jake 8f29f0fd75 docs: Add changelog
Moved the version info in top of readme to a changelog. Converted the
version identifiers to more semantic versioning, but it is easy to
change if semantic versioning is not interesting, or my conversion
doesn't make sense.
2016-06-16 09:22:38 +02:00
Jake 9e7a5e80c7 docs(readme): Convert to Markdown
Includes small tweaks to the original text for a nicer look.
2016-06-16 09:20:43 +02:00
Rich Geldreich 97b8233acc Adding URL 2016-06-15 23:25:15 -07:00
Rich Geldreich e647680ef9 Updating github URL 2016-06-15 23:21:39 -07:00
Rich Geldreich eeeeba7e40 Updating license/copyright 2016-06-15 23:03:05 -07:00
Rich Geldreich d2a3948ab9 Updating license/copyright/email contact info 2016-06-15 22:59:25 -07:00
Rich Geldreich dbc9ddb2cd updating readme 2015-11-19 19:34:40 -08:00
Rich Geldreich 6bde5a95b1 checking in new windows execs 2015-11-19 19:14:06 -08:00
Rich Geldreich 0fddd12519 Removing linux/mingw executables 2015-11-19 19:13:44 -08:00
Rich Geldreich 91fbf1fcc4 Fixing integer overflow problem, which can rarely cause serious artifacts. 2015-11-19 18:55:22 -08:00
145 changed files with 657 additions and 578 deletions
+2
View File
@@ -0,0 +1,2 @@
*.o
crnlib/crunch
+17
View File
@@ -0,0 +1,17 @@
# Change Log
## [0.1.4] - 2012-11-24
### Added
* KTX file format
* Basic ETC1 support
* Simple makefile
### Fixed
* Various DDS format fixes
## [0.1.3] - 2012-04-26
### Added
* 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)
[0.1.4]: https://github.com/BinomialLLC/crunch
[0.1.3]: https://github.com/BinomialLLC/crunch
+301 -307
View File
@@ -1,307 +1,301 @@
crunch/crnlib v1.04 - Advanced DXTn texture compression library crunch/crnlib v1.04 - Advanced DXTn texture compression library
Copyright (C) 2010-2012 Rich Geldreich and Tenacious Software LLC
Public Domain - Please see license.txt.
For bugs or support contact Rich Geldreich <richgel99@gmail.com>.
Portions of this software make use of public domain code originally
This software uses the ZLIB license, which is located in license.txt. written by Igor Pavlov (LZMA), RYG (crn_ryg_dxt*), and Sean Barrett (stb_image.c).
http://opensource.org/licenses/Zlib
If you use this software in a product, an acknowledgment in the product
Portions of this software make use of public domain code originally documentation would be highly appreciated but is not required.
written by Igor Pavlov (LZMA), RYG (crn_ryg_dxt*), and Sean Barrett (stb_image.c).
## Overview
If you use this software in a product, an acknowledgment in the product
documentation would be highly appreciated but is not required. crnlib is a lossy texture compression library for developers that ship
content using the DXT1/5/N or 3DC compressed color/normal map/cubemap
New for v1.04 [11/24/12]: KTX file format, basic ETC1 support, DDS format fixes, simple makefile mipmapped texture formats. It was written by the same author as the open
------------------------------------------------ source [LZHAM compression library](http://code.google.com/p/lzham/).
Lots of higher level changes to get crnlib into a state where I can carry it forward to It can compress mipmapped 2D textures, normal maps, and cubemaps to
support other file and texture compression formats. No major codec-level changes. approx. 1-1.25 bits/texel, and normal maps to 1.75-2 bits/texel. The
I've regression tested the codec writing .CRN and RDO .DDS files at various bitrates. actual bitrate depends on the complexity of the texture itself, the
Everything seems OK, but with all the changes I made to support KTX and other formats like ETC1 specified quality factor/target bitrate, and ultimately on the desired
I'm still worried about bugs. quality needed for a particular texture.
New for v1.03 [4/26/12]: crnlib more portable, Linux Port crnlib's differs significantly from other approaches because its
------------------------------------------------ compressed texture data format was carefully designed to be quickly
transcodable directly to DXTn with no intermediate recompression step.
v1.03 has been ported to Linux. It's still a work in progress. A few features The typical (single threaded) transcode to DXTn rate is generally
of the command line tool don't work under Linux yet (such as -timestamp), between 100-250 megatexels/sec. The current library supports PC
but the core functionality (compression/decompression/transcoding) should work (Win32/x64) and Xbox 360. Fast random access to individual mipmap levels
OK. I'm currently testing crnlib/crunch with Codeblocks 10.05 under Ubuntu x86. is supported.
Overview crnlib can also generates standard .DDS files at specified quality
-------- setting, which results in files that are much more compressible by
LZMA/Deflate/etc. compared to files generated by standard DXTn texture
crnlib is a lossy texture compression library for developers that ship tools (see below). This feature allows easy integration into any engine
content using the DXT1/5/N or 3DC compressed color/normal map/cubemap or graphics library that already supports .DDS files.
mipmapped texture formats. It was written by the same author as the open
source LZHAM lossless data compression library: The .CRN file format supports the following core DXTn texture formats:
http://code.google.com/p/lzham/ DXT1 (but not DXT1A), DXT5, DXT5A, and DXN/3DC
It can compress mipmapped 2D textures, normal maps, and cubemaps to It also supports several popular swizzled variants (several are
approx. 1-1.25 bits/texel, and normal maps to 1.75-2 bits/texel. The also supported by AMD's Compressonator):
actual bitrate depends on the complexity of the texture itself, the DXT5_XGBR, DXT5_xGxR, DXT5_AGBR, and DXT5_CCxY (experimental luma-chroma YCoCg).
specified quality factor/target bitrate, and ultimately on the desired
quality needed for a particular texture. ## Recommended Software
crnlib's differs significantly from other approaches because its AMD's [Compressonator tool](https://github.com/GPUOpen-Tools/Compressonator)
compressed texture data format was carefully designed to be quickly is recommended to view the .DDS files created by the crunch tool and the included example projects.
transcodable directly to DXTn with no intermediate recompression step.
The typical (single threaded) transcode to DXTn rate is generally Note: Some of the swizzled DXTn .DDS output formats (such as DXT5_xGBR)
between 100-250 megatexels/sec. The current library supports PC read/written by the crunch tool or examples deviate from the DX9 DDS
(Win32/x64) and Xbox 360. Fast random access to individual mipmap levels standard, so DXSDK tools such as DXTEX.EXE won't load them at all or
is supported. they won't be properly displayed.
crnlib can also generates standard .DDS files at specified quality ## Compression Algorithm Details
setting, which results in files that are much more compressible by
LZMA/Deflate/etc. compared to files generated by standard DXTn texture The compression process employed in creating both .CRN and
tools (see below). This feature allows easy integration into any engine clustered .DDS files utilizes a very high quality, scalable DXTn
or graphics library that already supports .DDS files. endpoint optimizer capable of processing any number of pixels (instead
of the typical hard coded 16), optional adaptive switching between
The .CRN file format supports the following core DXTn texture formats: several macroblock sizes/configurations (currently any combination of
DXT1 (but not DXT1A), DXT5, DXT5A, and DXN/3DC 4x4, 8x4, 4x8, and 8x8 pixel blocks), endpoint clusterization using
top-down cluster analysis, vector quantization (VQ) of the selector
It also supports several popular swizzled variants (several are indices, and several custom algorithms for compressing the resulting
also supported by AMD's Compressonator): endpoint/selector codebooks and macroblock indices. Multiple feedback
DXT5_XGBR, DXT5_xGxR, DXT5_AGBR, and DXT5_CCxY (experimental luma-chroma YCoCg). passes are performed between the clusterization and VQ steps to optimize
quality, and several steps use a brute force refinement approach to improve
Recommended Software quality. The majority of compression steps are multithreaded.
--------------------
The .CRN format currently utilizes canonical Huffman coding for speed
AMD's Compressonator tool is recommended to view the .DDS files created by (similar to Deflate but with much larger tables), but the next major
the crunch tool and the included example projects: version will also utilize adaptive binary arithmetic coding and higher
order context modeling using already developed tech from the my LZHAM
http://developer.amd.com/gpu/compressonator/pages/default.aspx compression library.
Note: Some of the swizzled DXTn .DDS output formats (such as DXT5_xGBR) ## Supported File Formats
read/written by the crunch tool or examples deviate from the DX9 DDS
standard, so DXSDK tools such as DXTEX.EXE won't load them at all or crnlib supports two compressed texture file formats. The first
they won't be properly displayed. format (clustered .DDS) is simple to integrate into an existing project
(typically, no code changes are required), but it doesn't offer the
Compression Algorithm Details highest quality/compression ratio that crnlib is capable of. Integrating
----------------------------- the second, higher quality custom format (.CRN) requires a few
typically straightforward engine modifications to integrate the
The compression process employed in creating both .CRN and .CRN->DXTn transcoder header file library into your tools/engine.
clustered .DDS files utilizes a very high quality, scalable DXTn
endpoint optimizer capable of processing any number of pixels (instead ### .DDS
of the typical hard coded 16), optional adaptive switching between
several macroblock sizes/configurations (currently any combination of crnlib can compress textures to standard DX9-style .DDS files using
4x4, 8x4, 4x8, and 8x8 pixel blocks), endpoint clusterization using clustered DXTn compression, which is a subset of the approach used to
top-down cluster analysis, vector quantization (VQ) of the selector create .CRN files.(For completeness, crnlib also supports vanilla, block
indices, and several custom algorithms for compressing the resulting by block DXTn compression too, but that's not very interesting.)
endpoint/selector codebooks and macroblock indices. Multiple feedback Clustered DXTn compressed .DDS files are much more compressible than
passes are performed between the clusterization and VQ steps to optimize files created by other libraries/tools. Apart from increased
quality, and several steps use a brute force refinement approach to improve compressibility, the .DDS files generated by this process are completely
quality. The majority of compression steps are multithreaded. standard so they should be fairly easy to add to a project with little
to no code changes.
The .CRN format currently utilizes canonical Huffman coding for speed
(similar to Deflate but with much larger tables), but the next major To actually benefit from clustered DXTn .DDS files, your engine needs to
version will also utilize adaptive binary arithmetic coding and higher further losslessly compress the .DDS data generated by crnlib using a
order context modeling using already developed tech from the my LZHAM lossless codec such as zlib, lzo, LZMA, LZHAM, etc. Most likely, your
compression library. engine does this already. (If not, you definitely should because DXTn
compressed textures generally contain a large amount of highly redundant
Supported File Formats data.)
----------------------
Clustered .DDS files are intended to be the simplest/fastest way to
crnlib supports two compressed texture file formats. The first integrate crnlib's tech into a project.
format (clustered .DDS) is simple to integrate into an existing project
(typically, no code changes are required), but it doesn't offer the ### .CRN
highest quality/compression ratio that crnlib is capable of. Integrating
the second, higher quality custom format (.CRN) requires a few The second, better, option is to compress your textures to .CRN files
typically straightforward engine modifications to integrate the using crnlib. To read the resulting .CRN data, you must add the .CRN
.CRN->DXTn transcoder header file library into your tools/engine. transcoder library (located in the included single file, stand-alone
header file library inc/crn_decomp.h) into your application. .CRN files
.DDS provide noticeably higher quality at the same effective bitrate compared
crnlib can compress textures to standard DX9-style .DDS files using to clustered DXTn compressed .DDS files. Also, .CRN files don't require
clustered DXTn compression, which is a subset of the approach used to further lossless compression because they're already highly compressed.
create .CRN files.(For completeness, crnlib also supports vanilla, block
by block DXTn compression too, but that's not very interesting.) .CRN files are a bit more difficult/risky to integrate into a project, but
Clustered DXTn compressed .DDS files are much more compressible than the resulting compression ratio and quality is superior vs. clustered .DDS files.
files created by other libraries/tools. Apart from increased
compressibility, the .DDS files generated by this process are completely ### .KTX
standard so they should be fairly easy to add to a project with little
to no code changes. crnlib and crunch can read/write the .KTX file format in various pixel formats.
Rate distortion optimization (clustered DXTc compression) is not yet supported
To actually benefit from clustered DXTn .DDS files, your engine needs to when writing .KTX files.
further losslessly compress the .DDS data generated by crnlib using a
lossless codec such as zlib, lzo, LZMA, LZHAM, etc. Most likely, your The .KTX file format is just like .DDS, except it's a fairly well specified
engine does this already. (If not, you definitely should because DXTn standard created by the Khronos Group. Unfortunately, almost all of the tools I've
compressed textures generally contain a large amount of highly redundant found that support .KTX are fairly (to very) buggy, or are limited to only a handful
data.) of pixel formats, so there's no guarantee that the .KTX files written by crnlib can
be reliably read by other tools.
Clustered .DDS files are intended to be the simplest/fastest way to
integrate crnlib's tech into a project. ## Building the Examples
.CRN This release contains the source code and projects for three simple
The second, better, option is to compress your textures to .CRN files example projects:
using crnlib. To read the resulting .CRN data, you must add the .CRN
transcoder library (located in the included single file, stand-alone crn_examples.2008.sln is a Visual Studio 2008 (VC9) solution file
header file library inc/crn_decomp.h) into your application. .CRN files containing projects for Win32 and x64. crnlib itself also builds with
provide noticeably higher quality at the same effective bitrate compared VS2005, VS2010, and gcc 4.5.0 (TDM GCC+MinGW). A codeblocks 10.05
to clustered DXTn compressed .DDS files. Also, .CRN files don't require workspace and project file is also included, but compiling crnlib this
further lossless compression because they're already highly compressed. way hasn't been tested much.
.CRN files are a bit more difficult/risky to integrate into a project, but ### example1
the resulting compression ratio and quality is superior vs. clustered .DDS files.
Demonstrates how to use crnlib's high-level C-helper
.KTX compression/decompression/transcoding functions in inc/crnlib.h. It's a
fairly complete example of crnlib's functionality.
crnlib and crunch can read/write the .KTX file format in various pixel formats.
Rate distortion optimization (clustered DXTc compression) is not yet supported ### example2
when writing .KTX files. Shows how to transcodec .CRN files to .DDS using **only**
the functionality in inc/crn_decomp.h. It does not link against against
The .KTX file format is just like .DDS, except it's a fairly well specified crnlib.lib or depend on it in any way. (Note: The complete source code,
standard created by the Khronos Group. Unfortunately, almost all of the tools I've approx. 4800 lines, to the CRN transcoder is included in inc/crn_decomp.h.)
found that support .KTX are fairly (to very) buggy, or are limited to only a handful
of pixel formats, so there's no guarantee that the .KTX files written by crnlib can example2 is intended to show how simple it is to integrate CRN textures
be reliably read by other tools. into your application.
Building the Examples ### example3
--------------------- Shows how to use the regular, low-level DXTn block compressor
functions in inc/crnlib.h. This functionality is included for
This release contains the source code and projects for three simple completeness. (Your engine or toolchain most likely already has its own
example projects: DXTn compressor. crnlib's compressor is typically very competitive or
superior to most available closed and open source CPU-based
crn_examples.2008.sln is a Visual Studio 2008 (VC9) solution file compressors.)
containing projects for Win32 and x64. crnlib itself also builds with
VS2005, VS2010, and gcc 4.5.0 (TDM GCC+MinGW). A codeblocks 10.05 ## Creating Compressed Textures from the Command Line (crunch.exe)
workspace and project file is also included, but compiling crnlib this
way hasn't been tested much. The simplest way to create compressed textures using crnlib is to
integrate the bin\crunch.exe or bin\crunch_x64.exe) command line tool
example1: Demonstrates how to use crnlib's high-level C-helper into your texture build toolchain or export process. It can write DXTn
compression/decompression/transcoding functions in inc/crnlib.h. It's a compressed 2D/cubemap textures to regular DXTn compressed .DDS,
fairly complete example of crnlib's functionality. clustered (or reduced entropy) DXTn compressed .DDS, or .CRN files. It
can also transcode or decompress files to several standard image
example2: Shows how to transcodec .CRN files to .DDS using *only* formats, such as TGA or BMP. Run crunch.exe with no options for help.
the functionality in inc/crn_decomp.h. It does not link against against
crnlib.lib or depend on it in any way. (Note: The complete source code, The .CRN files created by crunch.exe can be efficiently transcoded to
approx. 4800 lines, to the CRN transcoder is included in inc/crn_decomp.h.) DXTn using the included CRN transcoding library, located in full source
form under inc/crn_decomp.h.
example2 is intended to show how simple it is to integrate CRN textures
into your application. Here are a few example crunch.exe command lines:
example3: Shows how to use the regular, low-level DXTn block compressor 1. Compress blah.tga to blah.dds using normal DXT1 compression:
functions in inc/crnlib.h. This functionality is included for * `crunch -file blah.tga -fileformat dds -dxt1`
completeness. (Your engine or toolchain most likely already has its own
DXTn compressor. crnlib's compressor is typically very competitive or 2. Compress blah.tga to blah.dds using clustered DXT1 at an effective bitrate of 1.5 bits/texel, display image statistic:
superior to most available closed and open source CPU-based * `crunch -file blah.tga -fileformat dds -dxt1 -bitrate 1.5 -imagestats`
compressors.)
3. Compress blah.tga to blah.dds using clustered DXT1 at quality level 100 (from [0,255]), with no mipmaps, display LZMA statistics:
Creating Compressed Textures from the Command Line (crunch.exe) * `crunch -file blah.tga -fileformat dds -dxt1 -quality 100 -mipmode none -lzmastats`
---------------------------------------------------------------
3. Compress blah.tga to blah.crn using clustered DXT1 at a bitrate of 1.2 bits/texel, no mipmaps:
The simplest way to create compressed textures using crnlib is to * `crunch -file blah.tga -dxt1 -bitrate 1.2 -mipmode none`
integrate the bin\crunch.exe or bin\crunch_x64.exe) command line tool
into your texture build toolchain or export process. It can write DXTn 4. Decompress blah.dds to a .tga file:
compressed 2D/cubemap textures to regular DXTn compressed .DDS, * `crunch -file blah.dds -fileformat tga`
clustered (or reduced entropy) DXTn compressed .DDS, or .CRN files. It
can also transcode or decompress files to several standard image 5. Transcode blah.crn to a .dds file:
formats, such as TGA or BMP. Run crunch.exe with no options for help. * `crunch -file blah.crn`
The .CRN files created by crunch.exe can be efficiently transcoded to 6. Decompress blah.crn, writing each mipmap level to a separate .tga file:
DXTn using the included CRN transcoding library, located in full source * `crunch -split -file blah.crn -fileformat tga`
form under inc/crn_decomp.h.
crunch.exe can do a lot more, like rescale/crop images before
Here are a few example crunch.exe command lines: compression, convert images from one file format to another, compare
images, process multiple images, etc.
1. Compress blah.tga to blah.dds using normal DXT1 compression:
crunch -file blah.tga -fileformat dds -dxt1 Note: I would have included the full source to crunch.exe, but it still
has some low-level dependencies to crnlib internals which I didn't have
2. Compress blah.tga to blah.dds using clustered DXT1 at an effective bitrate of 1.5 bits/texel, display image statistic: time to address. This version of crunch.exe has some reduced
crunch -file blah.tga -fileformat dds -dxt1 -bitrate 1.5 -imagestats functionality compared to an earlier eval release. For example, XML file
support is not included in this version.
3. Compress blah.tga to blah.dds using clustered DXT1 at quality level 100 (from [0,255]), with no mipmaps, display LZMA statistics:
crunch -file blah.tga -fileformat dds -dxt1 -quality 100 -mipmode none -lzmastats ## Using crnlib
3. Compress blah.tga to blah.crn using clustered DXT1 at a bitrate of 1.2 bits/texel, no mipmaps: The most flexible and powerful way of using crnlib is to integrate the
crunch -file blah.tga -dxt1 -bitrate 1.2 -mipmode none library into your editor/toolchain/etc. and directly supply it your
raw/source texture bits. See the C-style API's and comments in
4. Decompress blah.dds to a .tga file: inc/crnlib.h.
crunch -file blah.dds -fileformat tga
To compress, you basically fill in a few structs in and call one function:
5. Transcode blah.crn to a .dds file:
crunch -file blah.crn ```c
void *crn_compress( const crn_comp_params &comp_params,
6. Decompress blah.crn, writing each mipmap level to a separate .tga file: crn_uint32 &compressed_size,
crunch -split -file blah.crn -fileformat tga crn_uint32 *pActual_quality_level = NULL,
float *pActual_bitrate = NULL);
crunch.exe can do a lot more, like rescale/crop images before ```
compression, convert images from one file format to another, compare
images, process multiple images, etc. Or, if you want crnlib to also generate mipmaps, you call this function:
Note: I would have included the full source to crunch.exe, but it still ```c
has some low-level dependencies to crnlib internals which I didn't have void *crn_compress( const crn_comp_params &comp_params,
time to address. This version of crunch.exe has some reduced const crn_mipmap_params &mip_params,
functionality compared to an earlier eval release. For example, XML file crn_uint32 &compressed_size,
support is not included in this version. crn_uint32 *pActual_quality_level = NULL,
float *pActual_bitrate = NULL);
Using crnlib ```
------------
You can also transcode/uncompress .DDS/.CRN files to raw 32bpp images
The most flexible and powerful way of using crnlib is to integrate the using `crn_decompress_crn_to_dds()` and `crn_decompress_dds_to_images()`.
library into your editor/toolchain/etc. and directly supply it your
raw/source texture bits. See the C-style API's and comments in Internally, crnlib just uses inc/crn_decomp.h to transcode textures to
inc/crnlib.h. DXTn. If you only need to transcode .CRN format files to raw DXTn bits
at runtime (and not compress), you don't actually need to compile or
To compress, you basically fill in a few structs in and call one function: link against crnlib at all. Just include inc/crn_decomp.h, which
contains a completely self-contained CRN transcoder in the "crnd"
void *crn_compress(const crn_comp_params &comp_params, crn_uint32 &compressed_size, crn_uint32 *pActual_quality_level = NULL, float *pActual_bitrate = NULL); namespace. The `crnd_get_texture_info()`, `crnd_unpack_begin()`,
`crnd_unpack_level()`, etc. functions are all you need to efficiently get
Or, if you want crnlib to also generate mipmaps, you call this function: at the raw DXTn bits, which can be directly supplied to whatever API or
GPU you're using. (See example2.)
void *crn_compress(const crn_comp_params &comp_params, const crn_mipmap_params &mip_params, crn_uint32 &compressed_size, crn_uint32 *pActual_quality_level = NULL, float *pActual_bitrate = NULL);
Important note: When compiling under native client, be sure to define
You can also transcode/uncompress .DDS/.CRN files to raw 32bpp images the `PLATFORM_NACL` macro before including the `inc/crn_decomp.h` header file library.
using crn_decompress_crn_to_dds() and crn_decompress_dds_to_images().
## Known Issues/Bugs
Internally, crnlib just uses inc/crn_decomp.h to transcode textures to
DXTn. If you only need to transcode .CRN format files to raw DXTn bits * crnlib currently assumes you'll be further losslessly compressing its
at runtime (and not compress), you don't actually need to compile or output .DDS files using LZMA. However, some engines use weaker codecs
link against crnlib at all. Just include inc/crn_decomp.h, which such as LZO, zlib, or custom codecs, so crnlib's bitrate measurements
contains a completely self-contained CRN transcoder in the "crnd" will be inaccurate. It should be easy to allow the caller to plug-in
namespace. The crnd_get_texture_info(), crnd_unpack_begin(), custom lossless compressors for bitrate measurement.
crnd_unpack_level(), etc. functions are all you need to efficiently get
at the raw DXTn bits, which can be directly supplied to whatever API or * Compressing to a desired bitrate can be time consuming, especially when
GPU you're using. (See example2.) processing large (2k or 4k) images to the .CRN format. There are several
high-level optimizations employed when compressing to clustered DXTn .DDS
Important note: When compiling under native client, be sure to define files using multiple trials, but not so for .CRN.
the PLATFORM_NACL macro before including the inc/crn_decomp.h header file library.
* The .CRN compressor does not currently use 3 color (transparent) DXT1
Known Issues/Bugs blocks at all, only 4 color blocks. So it doesn't support DXT1A
----------------- transparency, and its output quality suffers a little due to this
limitation. (Note that the clustered DXTn compressor used when
* crnlib currently assumes you'll be further losslessly compressing its writing clustered .DDS files does *not* have this limitation.)
output .DDS files using LZMA. However, some engines use weaker codecs
such as LZO, zlib, or custom codecs, so crnlib's bitrate measurements * Clustered DXT5/DXT5A compressor is able to group DXT5A blocks into
will be inaccurate. It should be easy to allow the caller to plug-in clusters only if they use absolute (black/white) selector indices. This
custom lossless compressors for bitrate measurement. hurts performance at very low bitrates, because too many bits are
effectively given to alpha.
* Compressing to a desired bitrate can be time consuming, especially when
processing large (2k or 4k) images to the .CRN format. There are several * DXT3 is not supported when writing .CRN or clustered DXTn DDS files.
high-level optimizations employed when compressing to clustered DXTn .DDS (DXT3 is supported by crnlib's when compressing to regular DXTn DDS
files using multiple trials, but not so for .CRN. files.) You'll get DXT5 files if you request DXT3. However, DXT3 is
supported by the regular DXTn block compressor. (DXT3's 4bpp fixed alpha
* The .CRN compressor does not currently use 3 color (transparent) DXT1 sucks verses DXT5 alpha blocks, so I don't see this as a bug deal.)
blocks at all, only 4 color blocks. So it doesn't support DXT1A
transparency, and its output quality suffers a little due to this * The DXT5_CCXY format uses a simple YCoCg encoding that is workable but
limitation. (Note that the clustered DXTn compressor used when hasn't been tuned for max. quality yet.
writing clustered .DDS files does *not* have this limitation.)
* Clustered (or rate distortion optimized) DXTc compression is only
* Clustered DXT5/DXT5A compressor is able to group DXT5A blocks into supported when writing to .DDS, not .KTX. Also, only plain block by block
clusters only if they use absolute (black/white) selector indices. This compression is supported when writing to ETC1, and .CRN does not support ETC1.
hurts performance at very low bitrates, because too many bits are
effectively given to alpha. ## Compile to Javascript with Emscripten
* DXT3 is not supported when writing .CRN or clustered DXTn DDS files. Download and install Emscripten:
(DXT3 is supported by crnlib's when compressing to regular DXTn DDS http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
files.) You'll get DXT5 files if you request DXT3. However, DXT3 is
supported by the regular DXTn block compressor. (DXT3's 4bpp fixed alpha From the root directory, run:
sucks verses DXT5 alpha blocks, so I don't see this as a bug deal.) ```c
emcc -O3 emscripten/crn.cpp -I./inc -s EXPORTED_FUNCTIONS="['_malloc', '_free', '_crn_get_width', '_crn_get_height', '_crn_get_levels', '_crn_get_dxt_format', '_crn_get_bytes_per_block', '_crn_get_uncompressed_size', '_crn_decompress']" -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 0 -o crunch.js
* The DXT5_CCXY format uses a simple YCoCg encoding that is workable but ```
hasn't been tuned for max. quality yet.
* Clustered (or rate distortion optimized) DXTc compression is only
supported when writing to .DDS, not .KTX. Also, only plain block by block
compression is supported when writing to ETC1, and .CRN does not support ETC1.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_arealist.cpp - 2D shape algebra (currently unused) // File: crn_arealist.cpp - 2D shape algebra (currently unused)
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
// Ported from the PowerView DOS image viewer, a product I wrote back in 1993. Not currently used in the open source release of crnlib. // Ported from the PowerView DOS image viewer, a product I wrote back in 1993. Not currently used in the open source release of crnlib.
#include "crn_core.h" #include "crn_core.h"
#include "crn_arealist.h" #include "crn_arealist.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_arealist.h - 2D shape algebra // File: crn_arealist.h - 2D shape algebra
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_assert.cpp // File: crn_assert.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#if CRNLIB_USE_WIN32_API #if CRNLIB_USE_WIN32_API
#include "crn_winhdr.h" #include "crn_winhdr.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_assert.h // File: crn_assert.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
const unsigned int CRNLIB_FAIL_EXCEPTION_CODE = 256U; const unsigned int CRNLIB_FAIL_EXCEPTION_CODE = 256U;
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_buffer_stream.h // File: crn_buffer_stream.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_data_stream.h" #include "crn_data_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_cfile_stream.h // File: crn_cfile_stream.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_data_stream.h" #include "crn_data_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_clusterizer.h // File: crn_clusterizer.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_matrix.h" #include "crn_matrix.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_color.h // File: crn_color.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_core.h" #include "crn_core.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_colorized_console.cpp // File: crn_colorized_console.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_colorized_console.h" #include "crn_colorized_console.h"
#ifdef CRNLIB_USE_WIN32_API #ifdef CRNLIB_USE_WIN32_API
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_colorized_console.h // File: crn_colorized_console.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_console.h" #include "crn_console.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_command_line_params.cpp // File: crn_command_line_params.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_command_line_params.h" #include "crn_command_line_params.h"
#include "crn_console.h" #include "crn_console.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_command_line_params.h // File: crn_command_line_params.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_value.h" #include "crn_value.h"
#include <map> #include <map>
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_comp.cpp // File: crn_comp.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_console.h" #include "crn_console.h"
#include "crn_comp.h" #include "crn_comp.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_comp.h // File: crn_comp.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#define CRND_HEADER_FILE_ONLY #define CRND_HEADER_FILE_ONLY
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_console.cpp // File: crn_console.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_console.h" #include "crn_console.h"
#include "crn_data_stream.h" #include "crn_data_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_console.h // File: crn_console.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dynamic_string.h" #include "crn_dynamic_string.h"
+2 -2
View File
@@ -1,5 +1,5 @@
// File: crn_core.cpp // File: crn_core.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#if CRNLIB_USE_WIN32_API #if CRNLIB_USE_WIN32_API
@@ -8,7 +8,7 @@
namespace crnlib namespace crnlib
{ {
const char *g_copyright_str = "Copyright (c) 2010-2012 Rich Geldreich and Tenacious Software LLC"; const char *g_copyright_str = "This is Public Domain Software, please see license.txt.";
const char *g_sig_str = "C8cfRlaorj0wLtnMSxrBJxTC85rho2L9hUZKHcBL"; const char *g_sig_str = "C8cfRlaorj0wLtnMSxrBJxTC85rho2L9hUZKHcBL";
} // namespace crnlib } // namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_core.h // File: crn_core.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#if defined(WIN32) && defined(_MSC_VER) #if defined(WIN32) && defined(_MSC_VER)
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_data_stream.cpp // File: crn_data_stream.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_data_stream.h" #include "crn_data_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_data_stream.h // File: crn_data_stream.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: data_stream_serializer.h // File: data_stream_serializer.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_data_stream.h" #include "crn_data_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dds_comp.cpp // File: crn_dds_comp.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dds_comp.h" #include "crn_dds_comp.h"
#include "crn_dynamic_stream.h" #include "crn_dynamic_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_comp.h // File: crn_comp.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_comp.h" #include "crn_comp.h"
#include "crn_mipmapped_texture.h" #include "crn_mipmapped_texture.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_decomp.cpp // File: crn_decomp.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
// Include the single-file header library with no defines, which brings in the full CRN decompressor. // Include the single-file header library with no defines, which brings in the full CRN decompressor.
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt.cpp // File: crn_dxt.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt.h" #include "crn_dxt.h"
#include "crn_dxt1.h" #include "crn_dxt1.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt.h // File: crn_dxt.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "../inc/crnlib.h" #include "../inc/crnlib.h"
#include "crn_color.h" #include "crn_color.h"
+15 -15
View File
@@ -1,5 +1,5 @@
// File: crn_dxt1.cpp // File: crn_dxt1.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
// //
// Notes: // Notes:
// This class is not optimized for performance on small blocks, unlike typical DXT1 compressors. It's optimized for scalability and quality: // This class is not optimized for performance on small blocks, unlike typical DXT1 compressors. It's optimized for scalability and quality:
@@ -112,9 +112,9 @@ namespace crnlib
uint weight = m_unique_colors[i].m_weight; uint weight = m_unique_colors[i].m_weight;
total_weight += weight; total_weight += weight;
tot_r += m_unique_colors[i].m_color.r * weight; tot_r += m_unique_colors[i].m_color.r * static_cast<uint64>(weight);
tot_g += m_unique_colors[i].m_color.g * weight; tot_g += m_unique_colors[i].m_color.g * static_cast<uint64>(weight);
tot_b += m_unique_colors[i].m_color.b * weight; tot_b += m_unique_colors[i].m_color.b * static_cast<uint64>(weight);
} }
const uint half_total_weight = total_weight >> 1; const uint half_total_weight = total_weight >> 1;
@@ -494,7 +494,7 @@ namespace crnlib
ll[2] = (ll[0]*2+ll[1])/3; ll[2] = (ll[0]*2+ll[1])/3;
ll[3] = (ll[0]+ll[1]*2)/3; ll[3] = (ll[0]+ll[1]*2)/3;
uint error_to_beat = 0; uint64 error_to_beat = 0;
uint min_color_weight = 0; uint min_color_weight = 0;
uint max_color_weight = 0; uint max_color_weight = 0;
for (uint i = 0; i < m_unique_colors.size(); i++) for (uint i = 0; i < m_unique_colors.size(); i++)
@@ -503,7 +503,7 @@ namespace crnlib
uint w = m_unique_colors[i].m_weight; uint w = m_unique_colors[i].m_weight;
int delta = ll[m_best_solution.m_selectors[i]] - c; int delta = ll[m_best_solution.m_selectors[i]] - c;
error_to_beat += (int)w * (delta * delta); error_to_beat += static_cast<int64>(w) * (delta * delta);
if (c == min_color[comp_index]) if (c == min_color[comp_index])
min_color_weight += w; min_color_weight += w;
@@ -561,11 +561,11 @@ namespace crnlib
tl[2] = (tl[0]*2+tl[1])/3; tl[2] = (tl[0]*2+tl[1])/3;
tl[3] = (tl[0]+tl[1]*2)/3; tl[3] = (tl[0]+tl[1]*2)/3;
uint trial_error = 0; uint64 trial_error = 0;
for (uint i = 0; i < m_unique_colors.size(); i++) for (uint i = 0; i < m_unique_colors.size(); i++)
{ {
int delta = tl[m_best_solution.m_selectors[i]] - m_unique_colors[i].m_color[comp_index]; int delta = tl[m_best_solution.m_selectors[i]] - m_unique_colors[i].m_color[comp_index];
trial_error += m_unique_colors[i].m_weight * (delta * delta); trial_error += static_cast<int64>(m_unique_colors[i].m_weight) * (delta * delta);
if (trial_error >= error_to_beat) if (trial_error >= error_to_beat)
break; break;
} }
@@ -599,7 +599,7 @@ namespace crnlib
for (uint i = 0; i < m_unique_colors.size(); i++) for (uint i = 0; i < m_unique_colors.size(); i++)
{ {
int delta = tl[m_best_solution.m_selectors[i]] - m_unique_colors[i].m_color[comp_index]; int delta = tl[m_best_solution.m_selectors[i]] - m_unique_colors[i].m_color[comp_index];
error_to_beat += m_unique_colors[i].m_weight * (delta * delta); error_to_beat += static_cast<int64>(m_unique_colors[i].m_weight) * (delta * delta);
} }
} // better } // better
@@ -1582,7 +1582,7 @@ namespace crnlib
err = color_distance(true, c, colors[3], false); err = color_distance(true, c, colors[3], false);
if (err < best_error) { best_error = err; best_color_index = 3; } if (err < best_error) { best_error = err; best_color_index = 3; }
trial_error += best_error * m_unique_colors[unique_color_index].m_weight; trial_error += best_error * static_cast<uint64>(m_unique_colors[unique_color_index].m_weight);
if (trial_error >= solution.m_error) if (trial_error >= solution.m_error)
break; break;
@@ -1607,7 +1607,7 @@ namespace crnlib
err = color_distance(false, c, colors[3], false); err = color_distance(false, c, colors[3], false);
if (err < best_error) { best_error = err; best_color_index = 3; } if (err < best_error) { best_error = err; best_color_index = 3; }
trial_error += best_error * m_unique_colors[unique_color_index].m_weight; trial_error += best_error * static_cast<uint64>(m_unique_colors[unique_color_index].m_weight);
if (trial_error >= solution.m_error) if (trial_error >= solution.m_error)
break; break;
@@ -1634,7 +1634,7 @@ namespace crnlib
err = color_distance(true, c, colors[2], false); err = color_distance(true, c, colors[2], false);
if (err < best_error) { best_error = err; best_color_index = 2; } if (err < best_error) { best_error = err; best_color_index = 2; }
trial_error += best_error * m_unique_colors[unique_color_index].m_weight; trial_error += best_error * static_cast<uint64>(m_unique_colors[unique_color_index].m_weight);
if (trial_error >= solution.m_error) if (trial_error >= solution.m_error)
break; break;
@@ -1656,7 +1656,7 @@ namespace crnlib
err = color_distance(false, c, colors[2], false); err = color_distance(false, c, colors[2], false);
if (err < best_error) { best_error = err; best_color_index = 2; } if (err < best_error) { best_error = err; best_color_index = 2; }
trial_error += best_error * m_unique_colors[unique_color_index].m_weight; trial_error += best_error * static_cast<uint64>(m_unique_colors[unique_color_index].m_weight);
if (trial_error >= solution.m_error) if (trial_error >= solution.m_error)
break; break;
@@ -1781,7 +1781,7 @@ namespace crnlib
uint best_error = color_distance(m_perceptual, c, colors[best_color_index], false); uint best_error = color_distance(m_perceptual, c, colors[best_color_index], false);
trial_error += best_error * m_unique_colors[unique_color_index].m_weight; trial_error += best_error * static_cast<uint64>(m_unique_colors[unique_color_index].m_weight);
if (trial_error >= solution.m_error) if (trial_error >= solution.m_error)
break; break;
@@ -1814,7 +1814,7 @@ namespace crnlib
uint best_error = color_distance(m_perceptual, c, colors[best_color_index], false); uint best_error = color_distance(m_perceptual, c, colors[best_color_index], false);
trial_error += best_error * m_unique_colors[unique_color_index].m_weight; trial_error += best_error * static_cast<uint64>(m_unique_colors[unique_color_index].m_weight);
if (trial_error >= solution.m_error) if (trial_error >= solution.m_error)
break; break;
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt1.h // File: crn_dxt1.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt.h" #include "crn_dxt.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt5a.cpp // File: crn_dxt5a.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt5a.h" #include "crn_dxt5a.h"
#include "crn_ryg_dxt.hpp" #include "crn_ryg_dxt.hpp"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt5a.h // File: crn_dxt5a.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt.h" #include "crn_dxt.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_endpoint_refiner.cpp // File: crn_dxt_endpoint_refiner.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt_endpoint_refiner.h" #include "crn_dxt_endpoint_refiner.h"
#include "crn_dxt1.h" #include "crn_dxt1.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_endpoint_refiner.h // File: crn_dxt_endpoint_refiner.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt.h" #include "crn_dxt.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_fast.cpp // File: crn_dxt_fast.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
// Parts of this module are derived from RYG's excellent public domain DXTx compressor. // Parts of this module are derived from RYG's excellent public domain DXTx compressor.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt_fast.h" #include "crn_dxt_fast.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_fast.h // File: crn_dxt_fast.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_color.h" #include "crn_color.h"
#include "crn_dxt.h" #include "crn_dxt.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_hc.cpp // File: crn_dxt_hc.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt_hc.h" #include "crn_dxt_hc.h"
#include "crn_image_utils.h" #include "crn_image_utils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_hc.h // File: crn_dxt_hc.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt1.h" #include "crn_dxt1.h"
#include "crn_dxt5a.h" #include "crn_dxt5a.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_hc_common.cpp // File: crn_dxt_hc_common.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt_hc_common.h" #include "crn_dxt_hc_common.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_hc_common.h // File: crn_dxt_hc_common.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_image.cpp // File: crn_dxt_image.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_dxt_image.h" #include "crn_dxt_image.h"
#if CRNLIB_SUPPORT_SQUISH #if CRNLIB_SUPPORT_SQUISH
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dxt_image.h // File: crn_dxt_image.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt1.h" #include "crn_dxt1.h"
#include "crn_dxt5a.h" #include "crn_dxt5a.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dynamic_stream.h // File: crn_dynamic_stream.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_data_stream.h" #include "crn_data_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dynamic_string.cpp // File: crn_dynamic_string.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_strutils.h" #include "crn_strutils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dynamic_string.h // File: crn_dynamic_string.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_etc.cpp // File: crn_etc.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_etc.h" #include "crn_etc.h"
#include "crn_radix_sort.h" #include "crn_radix_sort.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_etc.h // File: crn_etc.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "../inc/crnlib.h" #include "../inc/crnlib.h"
#include "crn_dxt.h" #include "crn_dxt.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_file_utils.cpp // File: crn_file_utils.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_file_utils.h" #include "crn_file_utils.h"
#include "crn_strutils.h" #include "crn_strutils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_file_utils.h // File: crn_file_utils.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_win32_find_files.cpp // File: crn_win32_find_files.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_find_files.h" #include "crn_find_files.h"
#include "crn_file_utils.h" #include "crn_file_utils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_win32_find_files.h // File: crn_win32_find_files.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_freeimage_image_utils.h // File: crn_freeimage_image_utils.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
// Note: This header file requires FreeImage/FreeImagePlus. // Note: This header file requires FreeImage/FreeImagePlus.
#include "crn_image_utils.h" #include "crn_image_utils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_hash.h // File: crn_hash.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_hash_map.cpp // File: crn_hash_map.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_hash_map.h" #include "crn_hash_map.h"
#include "crn_rand.h" #include "crn_rand.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_hash_map.h // File: crn_hash_map.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
// //
// Notes: // Notes:
// stl-like hash map/hash set, with predictable performance across platforms/compilers/C run times/etc. // stl-like hash map/hash set, with predictable performance across platforms/compilers/C run times/etc.
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_helpers.h // File: crn_helpers.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#define CRNLIB_NO_COPY_OR_ASSIGNMENT_OP(c) c(const c&); c& operator= (const c&); #define CRNLIB_NO_COPY_OR_ASSIGNMENT_OP(c) c(const c&); c& operator= (const c&);
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_huffman_codes.cpp // File: crn_huffman_codes.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_huffman_codes.h" #include "crn_huffman_codes.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_huffman_codes.h // File: crn_huffman_codes.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_image.h // File: crn_image.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_color.h" #include "crn_color.h"
#include "crn_vec.h" #include "crn_vec.h"
+2 -2
View File
@@ -1,5 +1,5 @@
// File: crn_image_utils.cpp // File: crn_image_utils.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_image_utils.h" #include "crn_image_utils.h"
#include "crn_console.h" #include "crn_console.h"
@@ -1305,7 +1305,7 @@ namespace crnlib
*pActualComps = 0; *pActualComps = 0;
if ((req_comps < 1) || (req_comps > 4)) if ((req_comps < 1) || (req_comps > 4))
return false; return NULL;
mipmapped_texture tex; mipmapped_texture tex;
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_image_utils.h // File: crn_image_utils.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_image.h" #include "crn_image.h"
#include "crn_data_stream_serializer.h" #include "crn_data_stream_serializer.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_intersect.h // File: crn_intersect.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_ray.h" #include "crn_ray.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_lzma_codec.cpp // File: crn_lzma_codec.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_lzma_codec.h" #include "crn_lzma_codec.h"
#include "crn_strutils.h" #include "crn_strutils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_lzma_codec.h // File: crn_lzma_codec.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_packed_uint.h" #include "crn_packed_uint.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_math.cpp // File: crn_math.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_math.h // File: crn_math.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#if defined(_M_IX86) && defined(_MSC_VER) #if defined(_M_IX86) && defined(_MSC_VER)
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_matrix.h // File: crn_matrix.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_vec.h" #include "crn_vec.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_mem.cpp // File: crn_mem.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_console.h" #include "crn_console.h"
#include "../inc/crnlib.h" #include "../inc/crnlib.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_mem.h // File: crn_mem.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#ifndef CRNLIB_MIN_ALLOC_ALIGNMENT #ifndef CRNLIB_MIN_ALLOC_ALIGNMENT
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_dds_texture.cpp - Actually supports both .DDS and .KTX. Probably will rename this eventually. // File: crn_dds_texture.cpp - Actually supports both .DDS and .KTX. Probably will rename this eventually.
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_mipmapped_texture.h" #include "crn_mipmapped_texture.h"
#include "crn_cfile_stream.h" #include "crn_cfile_stream.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_mipmapped_texture.h // File: crn_mipmapped_texture.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt_image.h" #include "crn_dxt_image.h"
#include "../inc/dds_defs.h" #include "../inc/dds_defs.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_packed_uint // File: crn_packed_uint
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_pixel_format.cpp // File: crn_pixel_format.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_pixel_format.h" #include "crn_pixel_format.h"
#include "crn_image.h" #include "crn_image.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_pixel_format.h // File: crn_pixel_format.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt.h" #include "crn_dxt.h"
#include "../inc/crnlib.h" #include "../inc/crnlib.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_platform.cpp // File: crn_platform.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#if CRNLIB_USE_WIN32_API #if CRNLIB_USE_WIN32_API
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_platform.h // File: crn_platform.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
bool crnlib_is_debugger_present(void); bool crnlib_is_debugger_present(void);
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_prefix_coding.cpp // File: crn_prefix_coding.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_prefix_coding.h" #include "crn_prefix_coding.h"
//#include "rand.h" //#include "rand.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_prefix_coding.h // File: crn_prefix_coding.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_qdxt.cpp // File: crn_qdxt.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_qdxt1.h" #include "crn_qdxt1.h"
#include "crn_dxt1.h" #include "crn_dxt1.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_qdxt1.h // File: crn_qdxt1.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_dxt.h" #include "crn_dxt.h"
#include "crn_hash_map.h" #include "crn_hash_map.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_qdxt5.cpp // File: crn_qdxt5.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_qdxt5.h" #include "crn_qdxt5.h"
#include "crn_dxt5a.h" #include "crn_dxt5a.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_qdxt5.h // File: crn_qdxt5.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_hash_map.h" #include "crn_hash_map.h"
#include "crn_clusterizer.h" #include "crn_clusterizer.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_radix_sort.h // File: crn_radix_sort.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_rand.cpp // File: crn_rand.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
// See: // See:
// http://www.ciphersbyritter.com/NEWS4/RANDC.HTM // http://www.ciphersbyritter.com/NEWS4/RANDC.HTM
// http://burtleburtle.net/bob/rand/smallprng.html // http://burtleburtle.net/bob/rand/smallprng.html
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_rand.h // File: crn_rand.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_ray.h // File: crn_ray.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_vec.h" #include "crn_vec.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_rect.h // File: crn_rect.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_vec.h" #include "crn_vec.h"
#include "crn_hash.h" #include "crn_hash.h"
+1 -27
View File
@@ -1,5 +1,5 @@
// File: rg_etc1.h - Fast, high quality ETC1 block packer/unpacker - Rich Geldreich <richgel99@gmail.com> // File: rg_etc1.h - Fast, high quality ETC1 block packer/unpacker - Rich Geldreich <richgel99@gmail.com>
// Please see ZLIB license at the end of this file. // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib { namespace crnlib {
@@ -52,29 +52,3 @@ namespace rg_etc1
} // namespace crnlib } // namespace crnlib
//------------------------------------------------------------------------------
//
// rg_etc1 uses the ZLIB license:
// http://opensource.org/licenses/Zlib
//
// Copyright (c) 2012 Rich Geldreich
//
// 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.
//
//------------------------------------------------------------------------------
+7 -7
View File
@@ -1,5 +1,5 @@
// File: crn_sparse_array.h // File: crn_sparse_array.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
@@ -355,7 +355,7 @@ namespace crnlib
inline T* alloc_group(bool nofail = false) inline T* alloc_group(bool nofail = false)
{ {
T* p = static_cast<T*>(alloc_space(N * sizeof(T))); T* p = static_cast<T*>(sparse_array_traits<T, Log2N>::alloc_space(N * sizeof(T)));
if (!p) if (!p)
{ {
@@ -365,7 +365,7 @@ namespace crnlib
CRNLIB_FAIL("Out of memory"); CRNLIB_FAIL("Out of memory");
} }
construct_group(p); sparse_array_traits<T, Log2N>::construct_group(p);
m_num_active_groups++; m_num_active_groups++;
@@ -379,20 +379,20 @@ namespace crnlib
CRNLIB_ASSERT(m_num_active_groups); CRNLIB_ASSERT(m_num_active_groups);
m_num_active_groups--; m_num_active_groups--;
destruct_group(p); sparse_array_traits<T, Log2N>::destruct_group(p);
free_space(p); sparse_array_traits<T, Log2N>::free_space(p);
} }
} }
inline void init_default() inline void init_default()
{ {
construct_element(reinterpret_cast<T*>(m_default)); sparse_array_traits<T, Log2N>::construct_element(reinterpret_cast<T*>(m_default));
} }
inline void deinit_default() inline void deinit_default()
{ {
destruct_element(reinterpret_cast<T*>(m_default)); sparse_array_traits<T, Log2N>::destruct_element(reinterpret_cast<T*>(m_default));
} }
}; };
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_sparse_bit_array.h // File: crn_sparse_bit_array.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_sparse_bit_array.h" #include "crn_sparse_bit_array.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_sparse_bit_array.h // File: crn_sparse_bit_array.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
namespace crnlib namespace crnlib
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_strutils.cpp // File: crn_strutils.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_strutils.h" #include "crn_strutils.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_strutils.h // File: crn_strutils.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#ifdef WIN32 #ifdef WIN32
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_symbol_codec.cpp // File: crn_symbol_codec.cpp
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#include "crn_core.h" #include "crn_core.h"
#include "crn_symbol_codec.h" #include "crn_symbol_codec.h"
#include "crn_huffman_codes.h" #include "crn_huffman_codes.h"
+1 -1
View File
@@ -1,5 +1,5 @@
// File: crn_symbol_codec.h // File: crn_symbol_codec.h
// See Copyright Notice and license at the end of inc/crnlib.h // This software is in the public domain. Please see license.txt.
#pragma once #pragma once
#include "crn_prefix_coding.h" #include "crn_prefix_coding.h"

Some files were not shown because too many files have changed in this diff Show More