diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-04-09 15:02:09 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-04-09 15:03:39 +0200 |
commit | fa2d5b91dc390a11262859e5309351ba58842901 (patch) | |
tree | 46757016a21d4e750f33d9e244bd0828c83188a0 /thirdparty | |
parent | 3fd10ff6f095eb57cb7c293f44e15c34bd09088e (diff) |
squish: Update to upstream version 1.15
Also fix clang-format pre-commit hook to ignore thirdparty files.
Diffstat (limited to 'thirdparty')
-rw-r--r-- | thirdparty/README.md | 2 | ||||
-rw-r--r-- | thirdparty/squish/squish.cpp | 24 | ||||
-rw-r--r-- | thirdparty/squish/squish.h | 9 |
3 files changed, 26 insertions, 9 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md index f35a95df37..8aec75b57d 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -204,7 +204,7 @@ Files extracted from upstream source: ## squish - Upstream: https://sourceforge.net/projects/libsquish -- Version: 1.14 +- Version: 1.15 - License: MIT Files extracted from upstream source: diff --git a/thirdparty/squish/squish.cpp b/thirdparty/squish/squish.cpp index d3cbabbafd..1d22a64ad6 100644 --- a/thirdparty/squish/squish.cpp +++ b/thirdparty/squish/squish.cpp @@ -177,13 +177,17 @@ void CompressImage( u8 const* rgba, int width, int height, int pitch, void* bloc // fix any bad flags flags = FixFlags( flags ); - // initialise the block output - u8* targetBlock = reinterpret_cast< u8* >( blocks ); - int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; - // loop over blocks +#ifdef SQUISH_USE_OPENMP +# pragma omp parallel for +#endif for( int y = 0; y < height; y += 4 ) { + // initialise the block output + u8* targetBlock = reinterpret_cast< u8* >( blocks ); + int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; + targetBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock; + for( int x = 0; x < width; x += 4 ) { // build the 4x4 block of pixels @@ -232,13 +236,17 @@ void DecompressImage( u8* rgba, int width, int height, int pitch, void const* bl // fix any bad flags flags = FixFlags( flags ); - // initialise the block input - u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks ); - int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; - // loop over blocks +#ifdef SQUISH_USE_OPENMP +# pragma omp parallel for +#endif for( int y = 0; y < height; y += 4 ) { + // initialise the block input + u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks ); + int bytesPerBlock = ( ( flags & ( kDxt1 | kBc4 ) ) != 0 ) ? 8 : 16; + sourceBlock += ( (y / 4) * ( (width + 3) / 4) ) * bytesPerBlock; + for( int x = 0; x < width; x += 4 ) { // decompress the block diff --git a/thirdparty/squish/squish.h b/thirdparty/squish/squish.h index 7c46e37ff1..14c9bb59fb 100644 --- a/thirdparty/squish/squish.h +++ b/thirdparty/squish/squish.h @@ -239,6 +239,15 @@ int GetStorageRequirements( int width, int height, int flags ); allows for pixels outside the image to take arbitrary values. The function squish::GetStorageRequirements can be called to compute the amount of memory to allocate for the compressed output. + + Note on compression quality: When compressing textures with + libsquish it is recommended to apply a gamma-correction + beforehand. This will reduce the blockiness in dark areas. The + level of necessary gamma-correction is platform dependent. For + example, a gamma correction with gamma = 0.5 before compression + and gamma = 2.0 after decompression yields good results on the + Windows platform but for other platforms like MacOS X a different + gamma value may be more suitable. */ void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 ); void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 ); |