Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
fe74a8c2
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 搜索 >>
提交
fe74a8c2
编写于
11月 08, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
broken attempt at removign STB_VORBIS_CODEBOOK_FLOAT option
上级
bc2219e1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
45 deletion
+18
-45
stb_vorbis.c
stb_vorbis.c
+18
-45
未找到文件。
stb_vorbis.c
浏览文件 @
fe74a8c2
...
...
@@ -493,14 +493,8 @@ enum STBVorbisError
// trade off storage for speed.
//#define STB_VORBIS_DIVIDES_IN_CODEBOOK
// STB_VORBIS_CODEBOOK_SHORTS
// The vorbis file format encodes VQ codebook floats as ax+b where a and
// b are floating point per-codebook constants, and x is a 16-bit int.
// Normally, stb_vorbis decodes them to floats rather than leaving them
// as 16-bit ints and computing ax+b while decoding. This is a speed/space
// tradeoff; you can save space by defining this flag.
#ifndef STB_VORBIS_CODEBOOK_SHORTS
#define STB_VORBIS_CODEBOOK_FLOATS
#ifdef STB_VORBIS_CODEBOOK_SHORTS
#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats"
#endif
// STB_VORBIS_DIVIDE_TABLE
...
...
@@ -607,11 +601,7 @@ typedef signed int int32;
#define FALSE 0
#endif
#ifdef STB_VORBIS_CODEBOOK_FLOATS
typedef
float
codetype
;
#else
typedef
uint16
codetype
;
#endif
// @NOTE
//
...
...
@@ -1703,15 +1693,9 @@ static int codebook_decode_scalar(vorb *f, Codebook *c)
// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
// where we avoid one addition
#ifndef STB_VORBIS_CODEBOOK_FLOATS
#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off] * c->delta_value + c->minimum_value)
#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off] * c->delta_value)
#define CODEBOOK_ELEMENT_BASE(c) (c->minimum_value)
#else
#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off])
#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off])
#define CODEBOOK_ELEMENT_BASE(c) (0)
#endif
#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off] * c->delta_value + c->minimum_value)
#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off] * c->delta_value)
#define CODEBOOK_ELEMENT_BASE(c) (c->minimum_value)
static
int
codebook_decode_start
(
vorb
*
f
,
Codebook
*
c
)
{
...
...
@@ -3860,6 +3844,7 @@ static int start_decoder(vorb *f)
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
if
(
c
->
lookup_type
==
1
)
{
int
len
,
sparse
=
c
->
sparse
;
float
last
=
0
;
// pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
if
(
sparse
)
{
if
(
c
->
sorted_entries
==
0
)
goto
skip
;
...
...
@@ -3873,16 +3858,11 @@ static int start_decoder(vorb *f)
unsigned
int
div
=
1
;
for
(
k
=
0
;
k
<
c
->
dimensions
;
++
k
)
{
int
off
=
(
z
/
div
)
%
c
->
lookup_values
;
#ifndef STB_VORBIS_CODEBOOK_FLOATS
c
->
multiplicands
[
j
*
c
->
dimensions
+
k
]
=
mults
[
off
];
#else
c
->
multiplicands
[
j
*
c
->
dimensions
+
k
]
=
mults
[
off
]
*
c
->
delta_value
+
c
->
minimum_value
;
// in this case (and this case only) we could pre-expand c->sequence_p,
// and throw away the decode logic for it; have to ALSO do
// it in the case below, but it can only be done if
// STB_VORBIS_CODEBOOK_FLOATS
// !STB_VORBIS_DIVIDES_IN_CODEBOOK
#endif
float
val
=
mults
[
off
];
val
=
mults
[
off
]
*
c
->
delta_value
+
c
->
minimum_value
+
last
;
c
->
multiplicands
[
j
*
c
->
dimensions
+
k
]
=
val
;
if
(
c
->
sequence_p
)
last
=
val
;
if
(
k
+
1
<
c
->
dimensions
)
{
if
(
div
>
UINT_MAX
/
(
unsigned
int
)
c
->
lookup_values
)
{
setup_temp_free
(
f
,
mults
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
...
...
@@ -3898,15 +3878,16 @@ static int start_decoder(vorb *f)
else
#endif
{
float
last
=
0
;
CHECK
(
f
);
c
->
multiplicands
=
(
codetype
*
)
setup_malloc
(
f
,
sizeof
(
c
->
multiplicands
[
0
])
*
c
->
lookup_values
);
if
(
c
->
multiplicands
==
NULL
)
{
setup_temp_free
(
f
,
mults
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
return
error
(
f
,
VORBIS_outofmem
);
}
#ifndef STB_VORBIS_CODEBOOK_FLOATS
memcpy
(
c
->
multiplicands
,
mults
,
sizeof
(
c
->
multiplicands
[
0
])
*
c
->
lookup_values
)
;
#else
for
(
j
=
0
;
j
<
(
int
)
c
->
lookup_values
;
++
j
)
c
->
multiplicands
[
j
]
=
mults
[
j
]
*
c
->
delta_value
+
c
->
minimum_value
;
#endif
for
(
j
=
0
;
j
<
(
int
)
c
->
lookup_values
;
++
j
)
{
float
val
=
mults
[
j
]
*
c
->
delta_value
+
c
->
minimum_value
+
last
;
c
->
multiplicands
[
j
]
=
val
;
if
(
c
->
sequence_p
)
last
=
val
;
}
setup_temp_free
(
f
,
mults
,
sizeof
(
mults
[
0
])
*
c
->
lookup_values
);
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
...
...
@@ -3914,14 +3895,6 @@ static int start_decoder(vorb *f)
#endif
CHECK
(
f
);
#ifdef STB_VORBIS_CODEBOOK_FLOATS
if
(
c
->
lookup_type
==
2
&&
c
->
sequence_p
)
{
for
(
j
=
1
;
j
<
(
int
)
(
c
->
sparse
?
c
->
sorted_entries
:
c
->
lookup_values
);
++
j
)
c
->
multiplicands
[
j
]
+=
c
->
multiplicands
[
j
-
1
];
CHECK
(
f
);
c
->
sequence_p
=
0
;
}
#endif
}
CHECK
(
f
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录