Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
18834c6a
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
18834c6a
编写于
10月 17, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some static analysis cleanup
上级
6e6535d5
变更
42
隐藏空白更改
内联
并排
Showing
42 changed file
with
240 addition
and
157 deletion
+240
-157
.gitignore
.gitignore
+1
-0
libobs-d3d11/d3d11-exports.h
libobs-d3d11/d3d11-exports.h
+1
-1
libobs-d3d11/d3d11-shader.cpp
libobs-d3d11/d3d11-shader.cpp
+1
-1
libobs-d3d11/d3d11-subsystem.cpp
libobs-d3d11/d3d11-subsystem.cpp
+1
-1
libobs-opengl/gl-exports.h
libobs-opengl/gl-exports.h
+1
-1
libobs-opengl/gl-shader.c
libobs-opengl/gl-shader.c
+57
-20
libobs-opengl/gl-shaderparser.c
libobs-opengl/gl-shaderparser.c
+5
-3
libobs-opengl/gl-shaderparser.h
libobs-opengl/gl-shaderparser.h
+5
-0
libobs-opengl/gl-subsystem.c
libobs-opengl/gl-subsystem.c
+1
-1
libobs-opengl/gl-subsystem.h
libobs-opengl/gl-subsystem.h
+1
-0
libobs-opengl/gl-zstencil.c
libobs-opengl/gl-zstencil.c
+1
-0
libobs/graphics/effect-parser.c
libobs/graphics/effect-parser.c
+6
-5
libobs/graphics/effect.c
libobs/graphics/effect.c
+22
-5
libobs/graphics/effect.h
libobs/graphics/effect.h
+2
-0
libobs/graphics/graphics-internal.h
libobs/graphics/graphics-internal.h
+1
-1
libobs/graphics/graphics.c
libobs/graphics/graphics.c
+3
-4
libobs/graphics/graphics.h
libobs/graphics/graphics.h
+6
-5
libobs/graphics/math-extra.c
libobs/graphics/math-extra.c
+2
-1
libobs/graphics/quat.c
libobs/graphics/quat.c
+2
-2
libobs/graphics/shader-parser.c
libobs/graphics/shader-parser.c
+4
-4
libobs/graphics/texture-render.c
libobs/graphics/texture-render.c
+6
-5
libobs/graphics/vec3.h
libobs/graphics/vec3.h
+3
-3
libobs/graphics/vec4.h
libobs/graphics/vec4.h
+4
-4
libobs/obs-module.c
libobs/obs-module.c
+5
-5
libobs/obs-scene.c
libobs/obs-scene.c
+3
-3
libobs/obs-source.c
libobs/obs-source.c
+6
-5
libobs/obs-source.h
libobs/obs-source.h
+4
-4
libobs/obs-video.c
libobs/obs-video.c
+12
-6
libobs/obs.h
libobs/obs.h
+3
-3
libobs/util/bmem.c
libobs/util/bmem.c
+17
-6
libobs/util/cf-lexer.c
libobs/util/cf-lexer.c
+14
-9
libobs/util/cf-parser.h
libobs/util/cf-parser.h
+1
-1
libobs/util/config-file.c
libobs/util/config-file.c
+6
-3
libobs/util/darray.h
libobs/util/darray.h
+4
-2
libobs/util/dstr.c
libobs/util/dstr.c
+10
-24
libobs/util/lexer.c
libobs/util/lexer.c
+4
-4
libobs/util/platform-windows.c
libobs/util/platform-windows.c
+0
-4
libobs/util/platform.c
libobs/util/platform.c
+5
-5
libobs/util/platform.h
libobs/util/platform.h
+3
-0
libobs/util/text-lookup.c
libobs/util/text-lookup.c
+3
-2
test/test-input/test-random.c
test/test-input/test-random.c
+2
-2
test/test-input/test-random.h
test/test-input/test-random.h
+2
-2
未找到文件。
.gitignore
浏览文件 @
18834c6a
...
...
@@ -8,6 +8,7 @@ Debug/
x64/
ipch/
.depend
tags
*.swp
*.dat
...
...
libobs-d3d11/d3d11-exports.h
浏览文件 @
18834c6a
...
...
@@ -170,7 +170,7 @@ EXPORT enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer);
EXPORT
void
shader_destroy
(
shader_t
shader
);
EXPORT
int
shader_numparams
(
shader_t
shader
);
EXPORT
sparam_t
shader_getparambyidx
(
shader_t
shader
,
in
t
param
);
EXPORT
sparam_t
shader_getparambyidx
(
shader_t
shader
,
uint32_
t
param
);
EXPORT
sparam_t
shader_getparambyname
(
shader_t
shader
,
const
char
*
name
);
EXPORT
void
shader_getparaminfo
(
shader_t
shader
,
sparam_t
param
,
struct
shader_param_info
*
info
);
...
...
libobs-d3d11/d3d11-shader.cpp
浏览文件 @
18834c6a
...
...
@@ -215,7 +215,7 @@ int shader_numparams(shader_t shader)
return
(
int
)
shader
->
params
.
size
();
}
sparam_t
shader_getparambyidx
(
shader_t
shader
,
in
t
param
)
sparam_t
shader_getparambyidx
(
shader_t
shader
,
uint32_
t
param
)
{
return
&
shader
->
params
[
param
];
}
...
...
libobs-d3d11/d3d11-subsystem.cpp
浏览文件 @
18834c6a
...
...
@@ -232,7 +232,7 @@ ID3D11RasterizerState *gs_device::AddRasterState()
ID3D11RasterizerState
*
state
;
memset
(
&
rd
,
0
,
sizeof
(
rd
));
/* use CCW to convert to
for
a right-handed coordinate system */
/* use CCW to convert to a right-handed coordinate system */
rd
.
FrontCounterClockwise
=
true
;
rd
.
FillMode
=
D3D11_FILL_SOLID
;
rd
.
CullMode
=
ConvertGSCullMode
(
rasterState
.
cullMode
);
...
...
libobs-opengl/gl-exports.h
浏览文件 @
18834c6a
...
...
@@ -164,7 +164,7 @@ EXPORT enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer);
EXPORT
void
shader_destroy
(
shader_t
shader
);
EXPORT
int
shader_numparams
(
shader_t
shader
);
EXPORT
sparam_t
shader_getparambyidx
(
shader_t
shader
,
in
t
param
);
EXPORT
sparam_t
shader_getparambyidx
(
shader_t
shader
,
uint32_
t
param
);
EXPORT
sparam_t
shader_getparambyname
(
shader_t
shader
,
const
char
*
name
);
EXPORT
void
shader_getparaminfo
(
shader_t
shader
,
sparam_t
param
,
struct
shader_param_info
*
info
);
...
...
libobs-opengl/gl-shader.c
浏览文件 @
18834c6a
...
...
@@ -67,6 +67,7 @@ static bool gl_add_param(struct gs_shader *shader, struct shader_var *var,
param
.
array_count
=
var
->
array_count
;
param
.
name
=
bstrdup
(
var
->
name
);
param
.
shader
=
shader
;
param
.
type
=
get_shader_param_type
(
var
->
type
);
if
(
param
.
type
==
SHADER_PARAM_TEXTURE
)
{
...
...
@@ -310,7 +311,7 @@ int shader_numparams(shader_t shader)
return
(
int
)
shader
->
params
.
num
;
}
sparam_t
shader_getparambyidx
(
shader_t
shader
,
in
t
param
)
sparam_t
shader_getparambyidx
(
shader_t
shader
,
uint32_
t
param
)
{
assert
(
param
<
shader
->
params
.
num
);
return
shader
->
params
.
array
+
param
;
...
...
@@ -329,9 +330,22 @@ sparam_t shader_getparambyname(shader_t shader, const char *name)
return
NULL
;
}
static
inline
bool
matching_shader
(
shader_t
shader
,
sparam_t
sparam
)
{
if
(
shader
!=
sparam
->
shader
)
{
blog
(
LOG_ERROR
,
"Shader and shader parameter do not match"
);
return
false
;
}
return
true
;
}
void
shader_getparaminfo
(
shader_t
shader
,
sparam_t
param
,
struct
shader_param_info
*
info
)
{
if
(
!
matching_shader
(
shader
,
param
))
return
;
info
->
type
=
param
->
type
;
info
->
name
=
param
->
name
;
}
...
...
@@ -348,20 +362,26 @@ sparam_t shader_getworldmatrix(shader_t shader)
void
shader_setbool
(
shader_t
shader
,
sparam_t
param
,
bool
val
)
{
glProgramUniform1i
(
shader
->
program
,
param
->
param
,
(
GLint
)
val
);
gl_success
(
"glProgramUniform1i"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniform1i
(
shader
->
program
,
param
->
param
,
(
GLint
)
val
);
gl_success
(
"glProgramUniform1i"
);
}
}
void
shader_setfloat
(
shader_t
shader
,
sparam_t
param
,
float
val
)
{
glProgramUniform1f
(
shader
->
program
,
param
->
param
,
val
);
gl_success
(
"glProgramUniform1f"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniform1f
(
shader
->
program
,
param
->
param
,
val
);
gl_success
(
"glProgramUniform1f"
);
}
}
void
shader_setint
(
shader_t
shader
,
sparam_t
param
,
int
val
)
{
glProgramUniform1i
(
shader
->
program
,
param
->
param
,
val
);
gl_success
(
"glProgramUniform1i"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniform1i
(
shader
->
program
,
param
->
param
,
val
);
gl_success
(
"glProgramUniform1i"
);
}
}
void
shader_setmatrix3
(
shader_t
shader
,
sparam_t
param
,
...
...
@@ -370,48 +390,62 @@ void shader_setmatrix3(shader_t shader, sparam_t param,
struct
matrix4
mat
;
matrix4_from_matrix3
(
&
mat
,
val
);
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
1
,
false
,
mat
.
x
.
ptr
);
gl_success
(
"glProgramUniformMatrix4fv"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
1
,
false
,
mat
.
x
.
ptr
);
gl_success
(
"glProgramUniformMatrix4fv"
);
}
}
void
shader_setmatrix4
(
shader_t
shader
,
sparam_t
param
,
const
struct
matrix4
*
val
)
{
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
1
,
false
,
val
->
x
.
ptr
);
gl_success
(
"glProgramUniformMatrix4fv"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniformMatrix4fv
(
shader
->
program
,
param
->
param
,
1
,
false
,
val
->
x
.
ptr
);
gl_success
(
"glProgramUniformMatrix4fv"
);
}
}
void
shader_setvec2
(
shader_t
shader
,
sparam_t
param
,
const
struct
vec2
*
val
)
{
glProgramUniform2fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform2fv"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniform2fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform2fv"
);
}
}
void
shader_setvec3
(
shader_t
shader
,
sparam_t
param
,
const
struct
vec3
*
val
)
{
glProgramUniform3fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform3fv"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniform3fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform3fv"
);
}
}
void
shader_setvec4
(
shader_t
shader
,
sparam_t
param
,
const
struct
vec4
*
val
)
{
glProgramUniform4fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform4fv"
);
if
(
matching_shader
(
shader
,
param
))
{
glProgramUniform4fv
(
shader
->
program
,
param
->
param
,
1
,
val
->
ptr
);
gl_success
(
"glProgramUniform4fv"
);
}
}
void
shader_settexture
(
shader_t
shader
,
sparam_t
param
,
texture_t
val
)
{
param
->
texture
=
val
;
if
(
matching_shader
(
shader
,
param
))
param
->
texture
=
val
;
}
static
void
shader_setval_data
(
shader_t
shader
,
sparam_t
param
,
const
void
*
val
,
int
count
)
{
if
(
!
matching_shader
(
shader
,
param
))
return
;
if
(
param
->
type
==
SHADER_PARAM_BOOL
||
param
->
type
==
SHADER_PARAM_INT
)
{
glProgramUniform1iv
(
shader
->
program
,
param
->
param
,
count
,
val
);
...
...
@@ -460,6 +494,9 @@ void shader_setval(shader_t shader, sparam_t param, const void *val,
if
(
!
count
)
count
=
1
;
if
(
!
matching_shader
(
shader
,
param
))
return
;
switch
(
param
->
type
)
{
case
SHADER_PARAM_FLOAT
:
expected_size
=
sizeof
(
float
);
break
;
case
SHADER_PARAM_BOOL
:
...
...
libobs-opengl/gl-shaderparser.c
浏览文件 @
18834c6a
...
...
@@ -145,7 +145,9 @@ static void gl_write_storage_var(struct gl_shader_parser *glsp,
if
(
st
)
{
gl_unwrap_storage_struct
(
glsp
,
st
,
var
->
name
,
input
,
prefix
);
}
else
{
struct
gl_parser_attrib
attrib
=
{{
0
}};
struct
gl_parser_attrib
attrib
;
gl_parser_attrib_init
(
&
attrib
);
dstr_cat
(
&
glsp
->
gl_string
,
input
?
"in "
:
"out "
);
if
(
prefix
)
...
...
@@ -286,14 +288,14 @@ static inline bool gl_write_texture_call(struct gl_shader_parser *glsp,
struct
shader_var
*
var
,
const
char
*
call
)
{
struct
cf_parser
*
cfp
=
&
glsp
->
parser
.
cfp
;
size_t
sampler_id
=
-
1
;
size_t
sampler_id
=
(
size_t
)
-
1
;
if
(
!
next_token
(
cfp
))
return
false
;
if
(
!
token_is
(
cfp
,
"("
))
return
false
;
if
(
!
next_token
(
cfp
))
return
false
;
sampler_id
=
sp_getsampler
(
glsp
,
cfp
->
cur_token
);
if
(
sampler_id
==
-
1
)
return
false
;
if
(
sampler_id
==
(
size_t
)
-
1
)
return
false
;
if
(
!
next_token
(
cfp
))
return
false
;
if
(
!
token_is
(
cfp
,
","
))
return
false
;
...
...
libobs-opengl/gl-shaderparser.h
浏览文件 @
18834c6a
...
...
@@ -32,6 +32,11 @@ struct gl_parser_attrib {
bool
input
;
};
static
inline
void
gl_parser_attrib_init
(
struct
gl_parser_attrib
*
attr
)
{
memset
(
attr
,
0
,
sizeof
(
struct
gl_parser_attrib
));
}
static
inline
void
gl_parser_attrib_free
(
struct
gl_parser_attrib
*
attr
)
{
dstr_free
(
&
attr
->
name
);
...
...
libobs-opengl/gl-subsystem.c
浏览文件 @
18834c6a
...
...
@@ -265,7 +265,7 @@ static bool load_sampler_on_textures(device_t device, samplerstate_t ss,
struct
shader_param
*
param
=
shader
->
params
.
array
+
i
;
if
(
param
->
type
==
SHADER_PARAM_TEXTURE
&&
param
->
sampler_id
==
sampler_unit
&&
param
->
sampler_id
==
(
uint32_t
)
sampler_unit
&&
param
->
texture
)
{
if
(
!
gl_active_texture
(
GL_TEXTURE0
+
param
->
texture_id
))
return
false
;
...
...
libobs-opengl/gl-subsystem.h
浏览文件 @
18834c6a
...
...
@@ -279,6 +279,7 @@ struct shader_param {
enum
shader_param_type
type
;
char
*
name
;
shader_t
shader
;
GLint
param
;
GLint
texture_id
;
size_t
sampler_id
;
...
...
libobs-opengl/gl-zstencil.c
浏览文件 @
18834c6a
...
...
@@ -55,6 +55,7 @@ zstencil_t device_create_zstencil(device_t device, uint32_t width,
memset
(
zs
,
0
,
sizeof
(
struct
gs_zstencil_buffer
));
zs
->
format
=
convert_zstencil_format
(
format
);
zs
->
attachment
=
get_attachment
(
format
);
zs
->
device
=
device
;
if
(
!
gl_init_zsbuffer
(
zs
,
width
,
height
))
{
blog
(
LOG_ERROR
,
"device_create_zstencil (GL) failed"
);
...
...
libobs/graphics/effect-parser.c
浏览文件 @
18834c6a
...
...
@@ -676,7 +676,7 @@ static bool ep_parse_param_array(struct effect_parser *ep,
ep
->
cfp
.
cur_token
->
str
.
len
))
return
false
;
param
->
array_count
=
strtol
(
ep
->
cfp
.
cur_token
->
str
.
array
,
NULL
,
10
);
param
->
array_count
=
(
int
)
strtol
(
ep
->
cfp
.
cur_token
->
str
.
array
,
NULL
,
10
);
if
(
next_token_should_be
(
&
ep
->
cfp
,
"]"
,
";"
,
NULL
)
==
PARSE_EOF
)
return
false
;
...
...
@@ -1100,10 +1100,10 @@ static inline void ep_write_func_func_deps(struct effect_parser *ep,
size_t
i
;
for
(
i
=
0
;
i
<
func
->
func_deps
.
num
;
i
++
)
{
const
char
*
name
=
func
->
func_deps
.
array
[
i
];
struct
ep_func
*
func
=
ep_getfunc
(
ep
,
name
);
struct
ep_func
*
func
_dep
=
ep_getfunc
(
ep
,
name
);
if
(
!
func
->
written
)
{
ep_write_func
(
ep
,
shader
,
func
,
used_params
);
if
(
!
func
_dep
->
written
)
{
ep_write_func
(
ep
,
shader
,
func
_dep
,
used_params
);
dstr_cat
(
shader
,
"
\n\n
"
);
}
}
...
...
@@ -1274,6 +1274,7 @@ static void ep_compile_param(struct effect_parser *ep, size_t idx)
param
->
name
=
bstrdup
(
param_in
->
name
);
param
->
section
=
EFFECT_PARAM
;
param
->
effect
=
ep
->
effect
;
da_move
(
param
->
default_val
,
param_in
->
default_val
);
if
(
strcmp
(
param_in
->
type
,
"bool"
)
==
0
)
...
...
@@ -1337,7 +1338,7 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep,
struct
dstr
shader_str
;
struct
dstr
location
;
struct
darray
used_params
;
/* struct dstr */
struct
darray
*
pass_params
;
/* struct pass_shaderparam */
struct
darray
*
pass_params
=
NULL
;
/* struct pass_shaderparam */
shader_t
shader
=
NULL
;
bool
success
=
true
;
...
...
libobs/graphics/effect.c
浏览文件 @
18834c6a
...
...
@@ -43,12 +43,12 @@ technique_t effect_gettechnique(effect_t effect, const char *name)
return
NULL
;
}
in
t
technique_begin
(
technique_t
tech
)
size_
t
technique_begin
(
technique_t
tech
)
{
tech
->
effect
->
cur_technique
=
tech
;
tech
->
effect
->
graphics
->
cur_effect
=
tech
->
effect
;
return
(
int
)
tech
->
passes
.
num
;
return
tech
->
passes
.
num
;
}
void
technique_end
(
technique_t
tech
)
...
...
@@ -156,7 +156,7 @@ bool technique_beginpassbyname(technique_t tech,
for
(
i
=
0
;
i
<
tech
->
passes
.
num
;
i
++
)
{
struct
effect_pass
*
pass
=
tech
->
passes
.
array
+
i
;
if
(
strcmp
(
pass
->
name
,
name
)
==
0
)
{
technique_beginpass
(
tech
,
(
int
)
i
);
technique_beginpass
(
tech
,
i
);
return
true
;
}
}
...
...
@@ -190,9 +190,9 @@ void technique_endpass(technique_t tech)
tech
->
effect
->
cur_pass
=
NULL
;
}
in
t
effect_numparams
(
effect_t
effect
)
size_
t
effect_numparams
(
effect_t
effect
)
{
return
(
int
)
effect
->
params
.
num
;
return
effect
->
params
.
num
;
}
eparam_t
effect_getparambyidx
(
effect_t
effect
,
size_t
param
)
...
...
@@ -220,9 +220,22 @@ eparam_t effect_getparambyname(effect_t effect, const char *name)
return
NULL
;
}
static
inline
bool
matching_effect
(
effect_t
effect
,
eparam_t
param
)
{
if
(
effect
!=
param
->
effect
)
{
blog
(
LOG_ERROR
,
"Effect and effect parameter do not match"
);
return
false
;
}
return
true
;
}
void
effect_getparaminfo
(
effect_t
effect
,
eparam_t
param
,
struct
effect_param_info
*
info
)
{
if
(
!
matching_effect
(
effect
,
param
))
return
;
info
->
name
=
param
->
name
;
info
->
type
=
param
->
type
;
}
...
...
@@ -241,6 +254,10 @@ static inline void effect_setval_inline(effect_t effect, eparam_t param,
const
void
*
data
,
size_t
size
)
{
bool
size_changed
=
param
->
cur_val
.
num
!=
size
;
if
(
!
matching_effect
(
effect
,
param
))
return
;
if
(
size_changed
)
da_resize
(
param
->
cur_val
,
size
);
...
...
libobs/graphics/effect.h
浏览文件 @
18834c6a
...
...
@@ -56,6 +56,8 @@ struct effect_param {
DARRAY
(
uint8_t
)
cur_val
;
DARRAY
(
uint8_t
)
default_val
;
effect_t
effect
;
/*char *full_name;
float scroller_min, scroller_max, scroller_inc, scroller_mul;*/
};
...
...
libobs/graphics/graphics-internal.h
浏览文件 @
18834c6a
...
...
@@ -176,7 +176,7 @@ struct gs_exports {
void
(
*
shader_destroy
)(
shader_t
shader
);
int
(
*
shader_numparams
)(
shader_t
shader
);
sparam_t
(
*
shader_getparambyidx
)(
shader_t
shader
,
in
t
param
);
sparam_t
(
*
shader_getparambyidx
)(
shader_t
shader
,
uint32_
t
param
);
sparam_t
(
*
shader_getparambyname
)(
shader_t
shader
,
const
char
*
name
);
void
(
*
shader_getparaminfo
)(
shader_t
shader
,
sparam_t
param
,
struct
shader_param_info
*
info
);
...
...
libobs/graphics/graphics.c
浏览文件 @
18834c6a
...
...
@@ -472,8 +472,7 @@ void gs_normal3f(float x, float y, float z)
static
inline
bool
validvertsize
(
graphics_t
graphics
,
size_t
num
,
const
char
*
name
)
{
if
(
graphics
->
using_immediate
&&
graphics
->
colors
.
num
==
IMMEDIATE_COUNT
)
{
if
(
graphics
->
using_immediate
&&
num
==
IMMEDIATE_COUNT
)
{
blog
(
LOG_WARNING
,
"%s: tried to use over %u "
"for immediate rendering"
,
name
,
IMMEDIATE_COUNT
);
...
...
@@ -690,7 +689,7 @@ void gs_resetviewport(void)
{
uint32_t
cx
,
cy
;
gs_getsize
(
&
cx
,
&
cy
);
gs_setviewport
(
0
,
0
,
cx
,
cy
);
gs_setviewport
(
0
,
0
,
(
int
)
cx
,
(
int
)
cy
);
}
void
gs_set2dmode
(
void
)
...
...
@@ -1222,7 +1221,7 @@ int shader_numparams(shader_t shader)
return
graphics
->
exports
.
shader_numparams
(
shader
);
}
sparam_t
shader_getparambyidx
(
shader_t
shader
,
in
t
param
)
sparam_t
shader_getparambyidx
(
shader_t
shader
,
uint32_
t
param
)
{
graphics_t
graphics
=
thread_graphics
;
return
graphics
->
exports
.
shader_getparambyidx
(
shader
,
param
);
...
...
libobs/graphics/graphics.h
浏览文件 @
18834c6a
...
...
@@ -293,7 +293,7 @@ enum shader_type {
EXPORT
void
shader_destroy
(
shader_t
shader
);
EXPORT
int
shader_numparams
(
shader_t
shader
);
EXPORT
sparam_t
shader_getparambyidx
(
shader_t
shader
,
in
t
param
);
EXPORT
sparam_t
shader_getparambyidx
(
shader_t
shader
,
uint32_
t
param
);
EXPORT
sparam_t
shader_getparambyname
(
shader_t
shader
,
const
char
*
name
);
EXPORT
void
shader_getparaminfo
(
shader_t
shader
,
sparam_t
param
,
struct
shader_param_info
*
info
);
...
...
@@ -345,14 +345,14 @@ EXPORT void effect_destroy(effect_t effect);
EXPORT
technique_t
effect_gettechnique
(
effect_t
effect
,
const
char
*
name
);
EXPORT
in
t
technique_begin
(
technique_t
technique
);
EXPORT
size_
t
technique_begin
(
technique_t
technique
);
EXPORT
void
technique_end
(
technique_t
technique
);
EXPORT
bool
technique_beginpass
(
technique_t
technique
,
size_t
pass
);
EXPORT
bool
technique_beginpassbyname
(
technique_t
technique
,
const
char
*
name
);
EXPORT
void
technique_endpass
(
technique_t
technique
);
EXPORT
in
t
effect_numparams
(
effect_t
effect
);
EXPORT
size_
t
effect_numparams
(
effect_t
effect
);
EXPORT
eparam_t
effect_getparambyidx
(
effect_t
effect
,
size_t
param
);
EXPORT
eparam_t
effect_getparambyname
(
effect_t
effect
,
const
char
*
name
);
EXPORT
void
effect_getparaminfo
(
effect_t
effect
,
eparam_t
param
,
...
...
@@ -389,7 +389,7 @@ EXPORT void effect_setdefault(effect_t effect, eparam_t param);
EXPORT
texrender_t
texrender_create
(
enum
gs_color_format
format
,
enum
gs_zstencil_format
zsformat
);
EXPORT
void
texrender_destroy
(
texrender_t
texrender
);
EXPORT
bool
texrender_begin
(
texrender_t
texrender
,
int
cx
,
in
t
cy
);
EXPORT
bool
texrender_begin
(
texrender_t
texrender
,
uint32_t
cx
,
uint32_
t
cy
);
EXPORT
void
texrender_end
(
texrender_t
texrender
);
EXPORT
void
texrender_reset
(
texrender_t
texrender
);
EXPORT
texture_t
texrender_gettexture
(
texrender_t
texrender
);
...
...
@@ -681,7 +681,8 @@ static inline uint32_t gs_get_format_bpp(enum gs_color_format format)
case
GS_DXT1
:
return
4
;
case
GS_DXT3
:
return
8
;
case
GS_DXT5
:
return
8
;
default:
return
0
;
default:
case
GS_UNKNOWN
:
return
0
;
}
}
...
...
libobs/graphics/math-extra.c
浏览文件 @
18834c6a
...
...
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include "vec2.h"
#include "vec3.h"
#include "math-defs.h"
#include "math-extra.h"
void
polar_to_cart
(
struct
vec3
*
dst
,
const
struct
vec3
*
v
)
...
...
@@ -70,7 +71,7 @@ float calc_torquef(float val1, float val2, float torque, float min_adjust,
float
dist
;
bool
over
;
if
(
val1
==
val2
)
if
(
close_float
(
val1
,
val2
,
EPSILON
)
)
return
val1
;
dist
=
(
val2
-
val1
)
*
torque
;
...
...
libobs/graphics/quat.c
浏览文件 @
18834c6a
...
...
@@ -55,10 +55,10 @@ void quat_from_axisang(struct quat *dst, const struct axisang *aa)
}
struct
f4x4
{
float
ptr
[
4
][
4
];
float
ptr
[
4
][
4
];
};
void
quat_from_matrix
(
struct
quat
*
dst
,
const
struct
matrix3
*
m
)
void
quat_from_matrix
3
(
struct
quat
*
dst
,
const
struct
matrix3
*
m
)
{
float
tr
=
(
m
->
x
.
x
+
m
->
y
.
y
+
m
->
z
.
z
);
float
inv_half
;
...
...
libobs/graphics/shader-parser.c
浏览文件 @
18834c6a
...
...
@@ -110,7 +110,7 @@ void shader_sampler_convert(struct shader_sampler *ss,
else
if
(
astrcmpi
(
state
,
"AddressW"
)
==
0
)
info
->
address_w
=
get_address_mode
(
value
);
else
if
(
astrcmpi
(
state
,
"MaxAnisotropy"
)
==
0
)
info
->
max_anisotropy
=
strtol
(
value
,
NULL
,
10
);
info
->
max_anisotropy
=
(
int
)
strtol
(
value
,
NULL
,
10
);
/*else if (astrcmpi(state, "BorderColor") == 0)
// TODO */
}
...
...
@@ -319,7 +319,7 @@ static inline int sp_check_for_keyword(struct shader_parser *sp,
}
static
inline
int
sp_parse_func_param
(
struct
shader_parser
*
sp
,
struct
shader_
func
*
func
,
struct
shader_
var
*
var
)
struct
shader_var
*
var
)
{
int
errcode
;
bool
is_uniform
=
false
;
...
...
@@ -380,7 +380,7 @@ static bool sp_parse_func_params(struct shader_parser *sp,
if
(
!
token_is
(
&
sp
->
cfp
,
"("
)
&&
!
token_is
(
&
sp
->
cfp
,
","
))
cf_adderror_syntax_error
(
&
sp
->
cfp
);
errcode
=
sp_parse_func_param
(
sp
,
func
,
&
var
);
errcode
=
sp_parse_func_param
(
sp
,
&
var
);
if
(
errcode
!=
PARSE_SUCCESS
)
{
shader_var_free
(
&
var
);
...
...
@@ -453,7 +453,7 @@ static bool sp_parse_param_array(struct shader_parser *sp,
sp
->
cfp
.
cur_token
->
str
.
len
))
return
false
;
param
->
array_count
=
strtol
(
sp
->
cfp
.
cur_token
->
str
.
array
,
NULL
,
10
);
param
->
array_count
=
(
int
)
strtol
(
sp
->
cfp
.
cur_token
->
str
.
array
,
NULL
,
10
);
if
(
next_token_should_be
(
&
sp
->
cfp
,
"]"
,
";"
,
NULL
)
==
PARSE_EOF
)
return
false
;
...
...
libobs/graphics/texture-render.c
浏览文件 @
18834c6a
...
...
@@ -27,7 +27,7 @@ struct gs_texture_render {
texture_t
target
,
prev_target
;
zstencil_t
zs
,
prev_zs
;
in
t
cx
,
cy
;
uint32_
t
cx
,
cy
;
enum
gs_color_format
format
;
enum
gs_zstencil_format
zsformat
;
...
...
@@ -57,7 +57,8 @@ void texrender_destroy(texrender_t texrender)
}
}
static
bool
texrender_resetbuffer
(
texrender_t
texrender
,
int
cx
,
int
cy
)
static
bool
texrender_resetbuffer
(
texrender_t
texrender
,
uint32_t
cx
,
uint32_t
cy
)
{
texture_destroy
(
texrender
->
target
);
zstencil_destroy
(
texrender
->
zs
);
...
...
@@ -85,14 +86,14 @@ static bool texrender_resetbuffer(texrender_t texrender, int cx, int cy)
return
true
;
}
bool
texrender_begin
(
texrender_t
texrender
,
int
cx
,
in
t
cy
)
bool
texrender_begin
(
texrender_t
texrender
,
uint32_t
cx
,
uint32_
t
cy
)
{
if
(
texrender
->
rendered
)
return
false
;
if
(
cx
==
-
1
)
if
(
cx
==
0
)
cx
=
gs_getwidth
();
if
(
cy
==
-
1
)
if
(
cy
==
0
)
cy
=
gs_getheight
();
assert
(
cx
&&
cy
);
...
...
libobs/graphics/vec3.h
浏览文件 @
18834c6a
...
...
@@ -128,9 +128,9 @@ static inline void vec3_cross(struct vec3 *dst, const struct vec3 *v1,
static
inline
void
vec3_neg
(
struct
vec3
*
dst
,
const
struct
vec3
*
v
)
{
dst
->
x
=
-
dst
->
x
;
dst
->
y
=
-
dst
->
y
;
dst
->
z
=
-
dst
->
z
;
dst
->
x
=
-
v
->
x
;
dst
->
y
=
-
v
->
y
;
dst
->
z
=
-
v
->
z
;
}
static
inline
float
vec3_len
(
const
struct
vec3
*
v
)
...
...
libobs/graphics/vec4.h
浏览文件 @
18834c6a
...
...
@@ -111,10 +111,10 @@ static inline float vec4_dot(const struct vec4 *v1, const struct vec4 *v2)
static
inline
void
vec4_neg
(
struct
vec4
*
dst
,
const
struct
vec4
*
v
)
{
dst
->
x
=
-
dst
->
x
;
dst
->
y
=
-
dst
->
y
;
dst
->
z
=
-
dst
->
z
;
dst
->
w
=
-
dst
->
w
;
dst
->
x
=
-
v
->
x
;
dst
->
y
=
-
v
->
y
;
dst
->
z
=
-
v
->
z
;
dst
->
w
=
-
v
->
w
;
}
static
inline
float
vec4_len
(
const
struct
vec4
*
v
)
...
...
libobs/obs-module.c
浏览文件 @
18834c6a
...
...
@@ -41,7 +41,7 @@ void *load_module_subfunc(void *module, const char *module_name,
return
func_addr
;
}
static
void
module_load_exports
(
struct
obs_
data
*
obs
,
struct
obs_
module
*
mod
,
static
void
module_load_exports
(
struct
obs_module
*
mod
,
struct
darray
*
output_array
,
const
char
*
type
,
const
size_t
data_size
,
void
*
callback_ptr
)
{
...
...
@@ -94,13 +94,13 @@ int obs_load_module(const char *path)
}
mod
.
name
=
bstrdup
(
path
);
module_load_exports
(
obs
,
&
mod
,
&
obs
->
input_types
.
da
,
"inputs"
,
module_load_exports
(
&
mod
,
&
obs
->
input_types
.
da
,
"inputs"
,
sizeof
(
struct
source_info
),
get_source_info
);
module_load_exports
(
obs
,
&
mod
,
&
obs
->
filter_types
.
da
,
"filters"
,
module_load_exports
(
&
mod
,
&
obs
->
filter_types
.
da
,
"filters"
,
sizeof
(
struct
source_info
),
get_source_info
);
module_load_exports
(
obs
,
&
mod
,
&
obs
->
transition_types
.
da
,
"transitions"
,
module_load_exports
(
&
mod
,
&
obs
->
transition_types
.
da
,
"transitions"
,
sizeof
(
struct
source_info
),
get_source_info
);
module_load_exports
(
obs
,
&
mod
,
&
obs
->
output_types
.
da
,
"outputs"
,
module_load_exports
(
&
mod
,
&
obs
->
output_types
.
da
,
"outputs"
,
sizeof
(
struct
output_info
),
get_output_info
);
da_push_back
(
obs
->
modules
,
&
mod
);
...
...
libobs/obs-scene.c
浏览文件 @
18834c6a
...
...
@@ -64,9 +64,9 @@ static void scene_video_render(void *data)
}
}
static
in
t
scene_getsize
(
void
*
data
)
static
uint32_
t
scene_getsize
(
void
*
data
)
{
return
-
1
;
return
0
;
}
static
bool
scene_enum_children
(
void
*
data
,
size_t
idx
,
obs_source_t
*
child
)
...
...
@@ -147,7 +147,7 @@ obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source)
return
item
;
}
void
obs_sceneitem_
remove
(
obs_sceneitem_t
item
)
void
obs_sceneitem_
destroy
(
obs_sceneitem_t
item
)
{
if
(
item
)
{
da_erase_item
(
item
->
parent
->
items
,
item
);
...
...
libobs/obs-source.c
浏览文件 @
18834c6a
...
...
@@ -98,6 +98,7 @@ obs_source_t obs_source_create(enum obs_source_type type, const char *name,
case
SOURCE_INPUT
:
list
=
&
obs
->
input_types
.
da
;
break
;
case
SOURCE_FILTER
:
list
=
&
obs
->
filter_types
.
da
;
break
;
case
SOURCE_TRANSITION
:
list
=
&
obs
->
transition_types
.
da
;
break
;
case
SOURCE_SCENE
:
default:
return
NULL
;
}
...
...
@@ -180,14 +181,14 @@ void obs_source_video_render(obs_source_t source)
}
}
in
t
obs_source_getwidth
(
obs_source_t
source
)
uint32_
t
obs_source_getwidth
(
obs_source_t
source
)
{
if
(
source
->
callbacks
.
getwidth
)
return
source
->
callbacks
.
getwidth
(
source
->
data
);
return
0
;
}
in
t
obs_source_getheight
(
obs_source_t
source
)
uint32_
t
obs_source_getheight
(
obs_source_t
source
)
{
if
(
source
->
callbacks
.
getheight
)
return
source
->
callbacks
.
getheight
(
source
->
data
);
...
...
@@ -225,7 +226,7 @@ obs_source_t obs_filter_gettarget(obs_source_t filter)
void
obs_source_filter_add
(
obs_source_t
source
,
obs_source_t
filter
)
{
if
(
da_find
(
source
->
filters
,
&
filter
,
0
)
!=
-
1
)
{
if
(
da_find
(
source
->
filters
,
&
filter
,
0
)
!=
DARRAY_INVALID
)
{
blog
(
LOG_WARNING
,
"Tried to add a filter that was already "
"present on the source"
);
return
;
...
...
@@ -243,7 +244,7 @@ void obs_source_filter_add(obs_source_t source, obs_source_t filter)
void
obs_source_filter_remove
(
obs_source_t
source
,
obs_source_t
filter
)
{
size_t
idx
=
da_find
(
source
->
filters
,
&
filter
,
0
);
if
(
idx
==
-
1
)
if
(
idx
==
DARRAY_INVALID
)
return
;
if
(
idx
>
0
)
{
...
...
@@ -260,7 +261,7 @@ void obs_source_filter_setorder(obs_source_t source, obs_source_t filter,
{
size_t
idx
=
da_find
(
source
->
filters
,
&
filter
,
0
);
size_t
i
;
if
(
idx
==
-
1
)
if
(
idx
==
DARRAY_INVALID
)
return
;
if
(
movement
==
ORDER_MOVE_UP
)
{
...
...
libobs/obs-source.h
浏览文件 @
18834c6a
...
...
@@ -76,12 +76,12 @@
* + SOURCE_ASYNC: video is sent asynchronously via RAM
*
* ---------------------------------------------------------
*
in
t [name]_getwidth(void *data);
*
uint32_
t [name]_getwidth(void *data);
* Returns the width of a source, or -1 for maximum width. If you render
* video, this is required.
*
* ---------------------------------------------------------
*
in
t [name]_getheight(void *data);
*
uint32_
t [name]_getheight(void *data);
* Returns the height of a source, or -1 for maximum height. If you
* render video, this is required.
*
...
...
@@ -170,8 +170,8 @@ struct source_info {
void
(
*
video_tick
)(
void
*
data
,
float
seconds
);
void
(
*
video_render
)(
void
*
data
);
in
t
(
*
getwidth
)(
void
*
data
);
in
t
(
*
getheight
)(
void
*
data
);
uint32_
t
(
*
getwidth
)(
void
*
data
);
uint32_
t
(
*
getheight
)(
void
*
data
);
size_t
(
*
getparam
)(
void
*
data
,
const
char
*
param
,
void
*
data_out
,
size_t
buf_size
);
...
...
libobs/obs-video.c
浏览文件 @
18834c6a
...
...
@@ -42,17 +42,21 @@ static inline void render_displays(void)
struct
vec4
clear_color
;
vec4_set
(
&
clear_color
,
0
.
3
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
);
gs_ortho
(
0
.
0
f
,
(
float
)
obs
->
output_width
,
0
.
0
f
,
(
float
)
obs
->
output_height
,
-
100
.
0
f
,
100
.
0
f
);
for
(
i
=
0
;
i
<
obs
->
displays
.
num
;
i
++
)
{
uint32_t
cx
,
cy
;
obs_display_t
display
=
obs
->
displays
.
array
[
i
];
gs_load_swapchain
(
display
->
swap
);
cx
=
gs_getwidth
();
cy
=
gs_getheight
();
gs_beginscene
();
gs_setviewport
(
0
,
0
,
gs_getwidth
(),
gs_getheight
());
gs_setviewport
(
0
,
0
,
(
int
)
cx
,
(
int
)
cy
);
gs_ortho
(
0
.
0
f
,
(
float
)
cx
,
0
.
0
f
,
(
float
)
cy
,
-
100
.
0
f
,
100
.
0
f
);
gs_setviewport
(
0
,
0
,
obs
->
output_width
,
obs
->
output_height
);
if
(
display
->
source
)
obs_source_video_render
(
display
->
source
);
...
...
@@ -71,7 +75,10 @@ static inline void render_displays(void)
gs_enable_blending
(
false
);
gs_setcullmode
(
GS_NEITHER
);
gs_setviewport
(
0
,
0
,
gs_getwidth
(),
gs_getheight
());
gs_ortho
(
0
.
0
f
,
(
float
)
obs
->
output_width
,
0
.
0
f
,
(
float
)
obs
->
output_height
,
-
100
.
0
f
,
100
.
0
f
);
gs_setviewport
(
0
,
0
,
obs
->
output_width
,
obs
->
output_height
);
if
(
obs
->
primary_source
)
obs_source_video_render
(
obs
->
primary_source
);
...
...
@@ -113,7 +120,6 @@ static bool swap_frame(uint64_t timestamp)
void
*
obs_video_thread
(
void
*
param
)
{
struct
obs_data
*
obs
=
param
;
uint64_t
last_time
=
0
;
while
(
video_output_wait
(
obs
->
video
))
{
...
...
libobs/obs.h
浏览文件 @
18834c6a
...
...
@@ -182,7 +182,7 @@ EXPORT void obs_source_destroy(obs_source_t source);
* SOURCE_ASYNC if the video is asynchronous.
* SOURCE_AUDIO if it presents/modifies audio (always async)
*/
EXPORT
uint32_t
obs_source_get_o
bs_o
utput_flags
(
obs_source_t
source
);
EXPORT
uint32_t
obs_source_get_output_flags
(
obs_source_t
source
);
/** Specifies whether the source can be configured */
EXPORT
bool
obs_source_hasconfig
(
obs_source_t
source
);
...
...
@@ -194,10 +194,10 @@ EXPORT void obs_source_config(obs_source_t source, void *parent);
EXPORT
void
obs_source_video_render
(
obs_source_t
source
);
/** Gets the width of a source (if it has video) */
EXPORT
in
t
obs_source_getwidth
(
obs_source_t
source
);
EXPORT
uint32_
t
obs_source_getwidth
(
obs_source_t
source
);
/** Gets the height of a source (if it has video) */
EXPORT
in
t
obs_source_getheight
(
obs_source_t
source
);
EXPORT
uint32_
t
obs_source_getheight
(
obs_source_t
source
);
/**
* Gets a custom parameter from the source.
...
...
libobs/util/bmem.c
浏览文件 @
18834c6a
...
...
@@ -33,13 +33,18 @@
*/
#define ALIGNMENT 16
#if defined(_WIN32) && !defined(_WIN64)
#define ALIGNED_MALLOC 1
#elif !defined(__LP64__)
#define ALIGNMENT_HACK 1
#endif
static
void
*
a_malloc
(
size_t
size
)
{
#ifdef
_WIN32
#ifdef
ALIGNED_MALLOC
return
_aligned_malloc
(
size
,
ALIGNMENT
);
#el
se
#el
if ALIGNMENT_HACK
void
*
ptr
=
NULL
;
long
diff
;
...
...
@@ -49,14 +54,16 @@ static void *a_malloc(size_t size)
((
char
*
)
ptr
)[
-
1
]
=
(
char
)
diff
;
return
ptr
;
#else
return
malloc
(
size
);
#endif
}
static
void
*
a_realloc
(
void
*
ptr
,
size_t
size
)
{
#ifdef
_WIN32
#ifdef
ALIGNED_MALLOC
return
_aligned_realloc
(
ptr
,
size
,
ALIGNMENT
);
#el
se
#el
if ALIGNMENT_HACK
long
diff
;
if
(
!
ptr
)
...
...
@@ -66,16 +73,20 @@ static void *a_realloc(void *ptr, size_t size)
if
(
ptr
)
ptr
=
(
char
*
)
ptr
+
diff
;
return
ptr
;
#else
return
realloc
(
ptr
,
size
);
#endif
}
static
void
a_free
(
void
*
ptr
)
{
#ifdef
_WIN32
#ifdef
ALIGNED_MALLOC
_aligned_free
(
ptr
);
#el
se
#el
if ALIGNMENT_HACK
if
(
ptr
)
free
((
char
*
)
ptr
-
((
char
*
)
ptr
)[
-
1
]);
#else
free
(
ptr
);
#endif
}
...
...
libobs/util/cf-lexer.c
浏览文件 @
18834c6a
...
...
@@ -131,7 +131,7 @@ static bool cf_is_token_break(struct base_token *start_token,
break
;
}
default
:
case
BASETOKEN_NONE
:
return
true
;
}
...
...
@@ -196,7 +196,8 @@ static bool cf_lexer_process_comment(struct cf_lexer *lex,
}
}
out_token
->
unmerged_str
.
len
+=
offset
-
out_token
->
unmerged_str
.
array
;
out_token
->
unmerged_str
.
len
+=
(
size_t
)(
offset
-
out_token
->
unmerged_str
.
array
);
out_token
->
type
=
CFTOKEN_SPACETAB
;
lex
->
base_lexer
.
offset
=
offset
;
...
...
@@ -277,7 +278,8 @@ static void cf_lexer_getstrtoken(struct cf_lexer *lex,
}
*
lex
->
write_offset
=
0
;
out_token
->
unmerged_str
.
len
+=
offset
-
out_token
->
unmerged_str
.
array
;
out_token
->
unmerged_str
.
len
+=
(
size_t
)(
offset
-
out_token
->
unmerged_str
.
array
);
out_token
->
type
=
CFTOKEN_STRING
;
lex
->
base_lexer
.
offset
=
offset
;
}
...
...
@@ -316,7 +318,8 @@ static inline enum cf_token_type cf_get_token_type(const struct cf_token *token,
else
return
CFTOKEN_SPACETAB
;
default:
case
BASETOKEN_NONE
:
case
BASETOKEN_OTHER
:
break
;
}
...
...
@@ -370,8 +373,8 @@ static bool cf_lexer_nexttoken(struct cf_lexer *lex, struct cf_token *out_token)
}
if
(
wrote_data
)
{
out_token
->
unmerged_str
.
len
=
lex
->
base_lexer
.
offset
-
out_token
->
unmerged_str
.
array
;
out_token
->
unmerged_str
.
len
=
(
size_t
)(
lex
->
base_lexer
.
offset
-
out_token
->
unmerged_str
.
array
)
;
out_token
->
type
=
cf_get_token_type
(
out_token
,
&
start_token
);
}
...
...
@@ -738,6 +741,8 @@ exit:
return
success
;
}
#define INVALID_INDEX ((size_t)-1)
static
inline
size_t
cf_preprocess_get_def_idx
(
struct
cf_preprocessor
*
pp
,
const
struct
strref
*
def_name
)
{
...
...
@@ -751,14 +756,14 @@ static inline size_t cf_preprocess_get_def_idx(struct cf_preprocessor *pp,
return
i
;
}
return
-
1
;
return
INVALID_INDEX
;
}
static
inline
struct
cf_def
*
cf_preprocess_get_def
(
struct
cf_preprocessor
*
pp
,
const
struct
strref
*
def_name
)
{
size_t
idx
=
cf_preprocess_get_def_idx
(
pp
,
def_name
);
if
(
idx
==
-
1
)
if
(
idx
==
INVALID_INDEX
)
return
NULL
;
return
pp
->
defines
.
array
+
idx
;
...
...
@@ -844,7 +849,7 @@ static inline void cf_preprocess_remove_def_strref(struct cf_preprocessor *pp,
const
struct
strref
*
ref
)
{
size_t
def_idx
=
cf_preprocess_get_def_idx
(
pp
,
ref
);
if
(
def_idx
!=
-
1
)
{
if
(
def_idx
!=
INVALID_INDEX
)
{
struct
cf_def
*
array
=
pp
->
defines
.
array
;
cf_def_free
(
array
+
def_idx
);
da_erase
(
pp
->
defines
,
def_idx
);
...
...
libobs/util/cf-parser.h
浏览文件 @
18834c6a
...
...
@@ -163,7 +163,7 @@ static inline bool go_to_token_type(struct cf_parser *p,
enum
cf_token_type
type
)
{
while
(
p
->
cur_token
->
type
!=
CFTOKEN_NONE
&&
p
->
cur_token
->
type
!=
CFTOKEN_NEWLINE
)
p
->
cur_token
->
type
!=
type
)
p
->
cur_token
++
;
return
p
->
cur_token
->
type
!=
CFTOKEN_NONE
;
...
...
libobs/util/config-file.c
浏览文件 @
18834c6a
...
...
@@ -172,7 +172,8 @@ static void config_parse_section(struct config_section *section,
}
}
static
int
config_parse
(
struct
darray
*
sections
,
const
char
*
file
)
static
int
config_parse
(
struct
darray
*
sections
,
const
char
*
file
,
bool
always_open
)
{
char
*
file_data
;
struct
lexer
lex
;
...
...
@@ -181,6 +182,8 @@ static int config_parse(struct darray *sections, const char *file)
FILE
*
f
;
f
=
os_fopen
(
file
,
"rb"
);
if
(
always_open
&&
!
f
)
f
=
os_fopen
(
file
,
"w+"
);
if
(
!
f
)
return
CONFIG_FILENOTFOUND
;
...
...
@@ -238,7 +241,7 @@ int config_open(config_t *config, const char *file, bool always_open)
*
config
=
bmalloc
(
sizeof
(
struct
config_data
));
memset
(
*
config
,
0
,
sizeof
(
struct
config_data
));
errorcode
=
config_parse
(
&
(
*
config
)
->
sections
,
file
);
errorcode
=
config_parse
(
&
(
*
config
)
->
sections
,
file
,
always_open
);
if
(
errorcode
!=
CONFIG_SUCCESS
)
{
config_close
(
*
config
);
...
...
@@ -253,7 +256,7 @@ int config_open_defaults(config_t config, const char *file)
if
(
!
config
)
return
CONFIG_ERROR
;
return
config_parse
(
&
config
->
defaults
,
file
);
return
config_parse
(
&
config
->
defaults
,
file
,
false
);
}
int
config_save
(
config_t
config
)
...
...
libobs/util/darray.h
浏览文件 @
18834c6a
...
...
@@ -43,6 +43,8 @@ extern "C" {
* See DARRAY macro at the bottom of thhe file for slightly safer usage.
*/
#define DARRAY_INVALID ((size_t)-1)
struct
darray
{
void
*
array
;
size_t
num
;
...
...
@@ -186,7 +188,7 @@ static inline size_t darray_find(const size_t element_size,
return
i
;
}
return
-
1
;
return
DARRAY_INVALID
;
}
static
inline
size_t
darray_push_back
(
const
size_t
element_size
,
...
...
@@ -322,7 +324,7 @@ static inline void darray_erase_item(const size_t element_size,
struct
darray
*
dst
,
const
void
*
item
)
{
size_t
idx
=
darray_find
(
element_size
,
dst
,
item
,
0
);
if
(
idx
!=
(
size_t
)
-
1
)
if
(
idx
!=
DARRAY_INVALID
)
darray_erase
(
element_size
,
dst
,
idx
);
}
...
...
libobs/util/dstr.c
浏览文件 @
18834c6a
...
...
@@ -46,8 +46,8 @@ int astrcmpi(const char *str1, const char *str2)
str2
=
astrblank
;
do
{
char
ch1
=
toupper
(
*
str1
);
char
ch2
=
toupper
(
*
str2
);
char
ch1
=
(
char
)
toupper
(
*
str1
);
char
ch2
=
(
char
)
toupper
(
*
str2
);
if
(
ch1
<
ch2
)
return
-
1
;
...
...
@@ -66,8 +66,8 @@ int wstrcmpi(const wchar_t *str1, const wchar_t *str2)
str2
=
wstrblank
;
do
{
wchar_t
ch1
=
towupper
(
*
str1
);
wchar_t
ch2
=
towupper
(
*
str2
);
wchar_t
ch1
=
(
wchar_t
)
towupper
(
*
str1
);
wchar_t
ch2
=
(
wchar_t
)
towupper
(
*
str2
);
if
(
ch1
<
ch2
)
return
-
1
;
...
...
@@ -132,8 +132,8 @@ int astrcmpi_n(const char *str1, const char *str2, size_t n)
str2
=
astrblank
;
do
{
char
ch1
=
toupper
(
*
str1
);
char
ch2
=
toupper
(
*
str2
);
char
ch1
=
(
char
)
toupper
(
*
str1
);
char
ch2
=
(
char
)
toupper
(
*
str2
);
if
(
ch1
<
ch2
)
return
-
1
;
...
...
@@ -154,8 +154,8 @@ int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n)
str2
=
wstrblank
;
do
{
wchar_t
ch1
=
towupper
(
*
str1
);
wchar_t
ch2
=
towupper
(
*
str2
);
wchar_t
ch1
=
(
wchar_t
)
towupper
(
*
str1
);
wchar_t
ch2
=
(
wchar_t
)
towupper
(
*
str2
);
if
(
ch1
<
ch2
)
return
-
1
;
...
...
@@ -476,7 +476,7 @@ void dstr_replace(struct dstr *str, const char *find,
temp
=
str
->
array
;
if
(
replace_len
<
find_len
)
{
int
count
=
0
;
unsigned
long
count
=
0
;
while
((
temp
=
strstr
(
temp
,
find
))
!=
NULL
)
{
char
*
end
=
temp
+
find_len
;
...
...
@@ -498,7 +498,7 @@ void dstr_replace(struct dstr *str, const char *find,
str
->
len
+=
(
replace_len
-
find_len
)
*
count
;
}
else
if
(
replace_len
>
find_len
)
{
int
count
=
0
;
unsigned
long
count
=
0
;
while
((
temp
=
strstr
(
temp
,
find
))
!=
NULL
)
{
temp
+=
find_len
;
...
...
@@ -595,17 +595,3 @@ void dstr_from_wcs(struct dstr *dst, const wchar_t *wstr)
dstr_free
(
dst
);
}
}
wchar_t
*
dstr_to_utf8
(
const
struct
dstr
*
str
)
{
wchar_t
*
out
=
NULL
;
size_t
len
=
utf8_to_wchar
(
str
->
array
,
str
->
len
,
NULL
,
0
,
0
);
if
(
len
)
{
out
=
bmalloc
((
len
+
1
)
*
sizeof
(
wchar_t
));
utf8_to_wchar
(
str
->
array
,
str
->
len
,
out
,
len
+
1
,
0
);
out
[
len
]
=
0
;
}
return
out
;
}
libobs/util/lexer.c
浏览文件 @
18834c6a
...
...
@@ -67,8 +67,8 @@ int strref_cmpi(const struct strref *str1, const char *str2)
do
{
char
ch1
,
ch2
;
ch1
=
(
i
<
str1
->
len
)
?
toupper
(
str1
->
array
[
i
])
:
0
;
ch2
=
toupper
(
*
str2
);
ch1
=
(
i
<
str1
->
len
)
?
(
char
)
toupper
(
str1
->
array
[
i
])
:
0
;
ch2
=
(
char
)
toupper
(
*
str2
);
if
(
ch1
<
ch2
)
return
-
1
;
...
...
@@ -117,8 +117,8 @@ int strref_cmpi_strref(const struct strref *str1, const struct strref *str2)
do
{
char
ch1
,
ch2
;
ch1
=
(
i
<
str1
->
len
)
?
toupper
(
str1
->
array
[
i
])
:
0
;
ch2
=
(
i
<
str2
->
len
)
?
toupper
(
str2
->
array
[
i
])
:
0
;
ch1
=
(
i
<
str1
->
len
)
?
(
char
)
toupper
(
str1
->
array
[
i
])
:
0
;
ch2
=
(
i
<
str2
->
len
)
?
(
char
)
toupper
(
str2
->
array
[
i
])
:
0
;
if
(
ch1
<
ch2
)
return
-
1
;
...
...
libobs/util/platform-windows.c
浏览文件 @
18834c6a
...
...
@@ -21,8 +21,6 @@
distribution.
******************************************************************************/
#ifdef _WIN32
#include <windows.h>
#include "base.h"
#include "platform.h"
...
...
@@ -165,5 +163,3 @@ BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD reason, LPVOID reserved)
}
#endif
#endif
libobs/util/platform.c
浏览文件 @
18834c6a
...
...
@@ -84,11 +84,11 @@ off_t os_fgetsize(FILE *file)
size_t
os_fread_mbs
(
FILE
*
file
,
char
**
pstr
)
{
off
_t
size
=
0
;
size
_t
size
=
0
;
size_t
len
=
0
;
fseeko
(
file
,
0
,
SEEK_END
);
size
=
ftello
(
file
);
size
=
(
size_t
)
ftello
(
file
);
if
(
size
>
0
)
{
char
*
mbstr
=
bmalloc
(
size
+
1
);
...
...
@@ -107,11 +107,11 @@ size_t os_fread_mbs(FILE *file, char **pstr)
size_t
os_fread_utf8
(
FILE
*
file
,
char
**
pstr
)
{
off
_t
size
=
0
;
size
_t
size
=
0
;
size_t
len
=
0
;
fseeko
(
file
,
0
,
SEEK_END
);
size
=
ftello
(
file
);
size
=
(
size_t
)
ftello
(
file
);
if
(
size
>
0
)
{
char
bom
[
3
];
...
...
@@ -244,7 +244,7 @@ size_t os_wcs_to_mbs(const wchar_t *str, size_t len, char **pstr)
size_t
os_wcs_to_utf8
(
const
wchar_t
*
str
,
size_t
len
,
char
**
pstr
)
{
size_t
in_len
=
wcslen
(
str
);
size_t
in_len
=
(
len
!=
0
)
?
len
:
wcslen
(
str
);
size_t
out_len
=
wchar_to_utf8
(
str
,
in_len
,
NULL
,
0
,
0
);
char
*
dst
=
NULL
;
...
...
libobs/util/platform.h
浏览文件 @
18834c6a
...
...
@@ -48,6 +48,9 @@ EXPORT size_t os_fread_utf8(FILE *file, char **pstr);
EXPORT
char
*
os_quick_read_utf8_file
(
const
char
*
path
);
EXPORT
bool
os_quick_write_utf8_file
(
const
char
*
path
,
const
char
*
str
,
size_t
len
,
bool
marker
);
EXPORT
char
*
os_quick_read_mbs_file
(
const
char
*
path
);
EXPORT
bool
os_quick_write_mbs_file
(
const
char
*
path
,
const
char
*
str
,
size_t
len
);
EXPORT
size_t
os_mbs_to_wcs
(
const
char
*
str
,
size_t
len
,
wchar_t
**
pstr
);
EXPORT
size_t
os_utf8_to_wcs
(
const
char
*
str
,
size_t
len
,
wchar_t
**
pstr
);
...
...
libobs/util/text-lookup.c
浏览文件 @
18834c6a
...
...
@@ -117,7 +117,7 @@ static void lookup_createsubnode(const char *lookup_val,
new
->
leaf
=
leaf
;
dstr_copy
(
&
new
->
str
,
lookup_val
);
darray_push_back
(
sizeof
(
struct
text_node
*
),
&
n
ew
->
subnodes
,
&
new
);
darray_push_back
(
sizeof
(
struct
text_node
*
),
&
n
ode
->
subnodes
,
&
new
);
}
static
void
lookup_splitnode
(
const
char
*
lookup_val
,
size_t
len
,
...
...
@@ -197,7 +197,8 @@ static void lookup_getstringtoken(struct lexer *lex, struct strref *token)
++
temp
;
}
token
->
len
+=
temp
-
lex
->
offset
-
1
;
/* include starting " char */
/* include starting " char */
token
->
len
+=
(
size_t
)(
temp
-
lex
->
offset
-
1
);
lex
->
offset
=
temp
;
}
...
...
test/test-input/test-random.c
浏览文件 @
18834c6a
...
...
@@ -74,12 +74,12 @@ void random_video_render(struct random_tex *rt, obs_source_t filter_target)
technique_end
(
tech
);
}
in
t
random_getwidth
(
struct
random_tex
*
rt
)
uint32_
t
random_getwidth
(
struct
random_tex
*
rt
)
{
return
texture_getwidth
(
rt
->
texture
);
}
in
t
random_getheight
(
struct
random_tex
*
rt
)
uint32_
t
random_getheight
(
struct
random_tex
*
rt
)
{
return
texture_getheight
(
rt
->
texture
);
}
test/test-input/test-random.h
浏览文件 @
18834c6a
...
...
@@ -17,8 +17,8 @@ EXPORT uint32_t random_get_output_flags(struct random_tex *rt);
EXPORT
void
random_video_render
(
struct
random_tex
*
rt
,
obs_source_t
filter_target
);
EXPORT
in
t
random_getwidth
(
struct
random_tex
*
rt
);
EXPORT
in
t
random_getheight
(
struct
random_tex
*
rt
);
EXPORT
uint32_
t
random_getwidth
(
struct
random_tex
*
rt
);
EXPORT
uint32_
t
random_getheight
(
struct
random_tex
*
rt
);
#ifdef __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录