Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
e1f17c3c
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e1f17c3c
编写于
7月 22, 2017
作者:
F
Fabian Giesen
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'stb_dxt-freestanding' of
https://github.com/h-s-c/stb
into h-s-c-stb_dxt-freestanding
上级
423298e0
50e6be0d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
7 deletion
+25
-7
stb_dxt.h
stb_dxt.h
+25
-7
未找到文件。
stb_dxt.h
浏览文件 @
e1f17c3c
...
...
@@ -19,6 +19,9 @@
// v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom
// v1.00 - (stb) first release
//
// contributors:
// Kevin Schmidt
//
// LICENSE
//
// See end of file for license information.
...
...
@@ -61,8 +64,23 @@ void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two
// #define STB_DXT_USE_ROUNDING_BIAS
#include <stdlib.h>
#if !defined(STBD_ABS) || !defined(STBI_FABS)
#include <math.h>
#include <string.h> // memset
#endif
#ifndef STBD_ABS
#define STBD_ABS(i) abs(i)
#endif
#ifndef STBD_FABS
#define STBD_FABS(x) fabs(x)
#endif
#ifndef STBD_MEMSET
#include <string.h>
#define STBD_MEMSET(x) memset(x)
#endif
static
unsigned
char
stb__Expand5
[
32
];
static
unsigned
char
stb__Expand6
[
64
];
...
...
@@ -127,13 +145,13 @@ static void stb__PrepareOptTable(unsigned char *Table,const unsigned char *expan
for
(
mx
=
0
;
mx
<
size
;
mx
++
)
{
int
mine
=
expand
[
mn
];
int
maxe
=
expand
[
mx
];
int
err
=
abs
(
stb__Lerp13
(
maxe
,
mine
)
-
i
);
int
err
=
STBD_ABS
(
stb__Lerp13
(
maxe
,
mine
)
-
i
);
// DX10 spec says that interpolation must be within 3% of "correct" result,
// add this as error term. (normally we'd expect a random distribution of
// +-1.5% error, but nowhere in the spec does it say that the error has to be
// unbiased - better safe than sorry).
err
+=
abs
(
maxe
-
mine
)
*
3
/
100
;
err
+=
STBD_ABS
(
maxe
-
mine
)
*
3
/
100
;
if
(
err
<
bestErr
)
{
...
...
@@ -165,7 +183,7 @@ static void stb__DitherBlock(unsigned char *dest, unsigned char *block)
for
(
ch
=
0
;
ch
<
3
;
++
ch
)
{
unsigned
char
*
bp
=
block
+
ch
,
*
dp
=
dest
+
ch
;
unsigned
char
*
quant
=
(
ch
==
1
)
?
stb__QuantGTab
+
8
:
stb__QuantRBTab
+
8
;
memset
(
err
,
0
,
sizeof
(
err
));
STBD_MEMSET
(
err
,
0
,
sizeof
(
err
));
for
(
y
=
0
;
y
<
4
;
++
y
)
{
dp
[
0
]
=
quant
[
bp
[
0
]
+
((
3
*
ep2
[
1
]
+
5
*
ep2
[
0
])
>>
4
)];
ep1
[
0
]
=
bp
[
0
]
-
dp
[
0
];
...
...
@@ -349,9 +367,9 @@ static void stb__OptimizeColorsBlock(unsigned char *block, unsigned short *pmax1
vfb
=
b
;
}
magn
=
fabs
(
vfr
);
if
(
fabs
(
vfg
)
>
magn
)
magn
=
fabs
(
vfg
);
if
(
fabs
(
vfb
)
>
magn
)
magn
=
fabs
(
vfb
);
magn
=
STBD_FABS
(
vfr
);
if
(
STBD_FABS
(
vfg
)
>
magn
)
magn
=
STBD_FABS
(
vfg
);
if
(
STBD_FABS
(
vfb
)
>
magn
)
magn
=
STBD_FABS
(
vfb
);
if
(
magn
<
4
.
0
f
)
{
// too small, default to luminance
v_r
=
299
;
// JPEG YCbCr luma coefs, scaled by 1000.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录