Merge branch 'working'

pull/290/merge
Sean Barrett 2017-03-03 08:57:49 -08:00
commit eab4930cc4
1 changed files with 22 additions and 5 deletions

View File

@ -1,4 +1,4 @@
// stb_dxt.h - v1.04 - DXT1/DXT5 compressor - public domain
// stb_dxt.h - v1.05 - DXT1/DXT5 compressor - public domain
// original by fabian "ryg" giesen - ported to C by stb
// use '#define STB_DXT_IMPLEMENTATION' before including to create the implementation
//
@ -9,6 +9,7 @@
// and "high quality" using mode.
//
// version history:
// v1.05 - (stb) support bc5/3dc (Arvids Kokins), use extern "C" in C++ (Pavel Krajcevski)
// v1.04 - (ryg) default to no rounding bias for lerped colors (as per S3TC/DX10 spec);
// single color match fix (allow for inexact color interpolation);
// optimal DXT5 index finder; "high quality" mode that runs multiple refinement steps.
@ -29,7 +30,17 @@
#define STB_DXT_DITHER 1 // use dithering. dubious win. never use for normal maps and the like!
#define STB_DXT_HIGHQUAL 2 // high quality mode, does two refinement steps instead of 1. ~30-40% slower.
void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int alpha, int mode);
#ifdef __cplusplus
extern "C" {
#endif
void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src_rgba_four_bytes_per_pixel, int alpha, int mode);
void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two_byte_per_pixel, int mode);
#ifdef __cplusplus
}
#endif
#define STB_COMPRESS_DXT_BLOCK
#ifdef STB_DXT_IMPLEMENTATION
@ -536,7 +547,7 @@ static void stb__CompressColorBlock(unsigned char *dest, unsigned char *block, i
}
// Alpha block compression (this is easy for a change)
static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src,int mode)
static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src, int stride)
{
int i,dist,bias,dist4,dist2,bits,mask;
@ -566,7 +577,7 @@ static void stb__CompressAlphaBlock(unsigned char *dest,unsigned char *src,int m
bits = 0,mask=0;
for (i=0;i<16;i++) {
int a = src[i*4+3]*7 + bias;
int a = src[i*stride]*7 + bias;
int ind,t;
// select index. this is a "linear scale" lerp factor between 0 (val=min) and 7 (val=max).
@ -617,12 +628,18 @@ void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src, int a
}
if (alpha) {
stb__CompressAlphaBlock(dest,(unsigned char*) src,mode);
stb__CompressAlphaBlock(dest,(unsigned char*) src+3, 4);
dest += 8;
}
stb__CompressColorBlock(dest,(unsigned char*) src,mode);
}
void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src)
{
stb__CompressAlphaBlock(dest,(unsigned char*) src,2);
stb__CompressAlphaBlock(dest + 8,(unsigned char*) src+1,2);
}
#endif // STB_DXT_IMPLEMENTATION
#endif // STB_INCLUDE_STB_DXT_H