Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
065379bf
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,发现更多精彩内容 >>
提交
065379bf
编写于
4月 24, 2014
作者:
P
Palana
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add limited range rendering for rendering YUV non-full range sources
上级
9f43e6c2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
8 deletion
+47
-8
build/data/libobs/default.effect
build/data/libobs/default.effect
+3
-0
libobs/obs-internal.h
libobs/obs-internal.h
+3
-0
libobs/obs-source.c
libobs/obs-source.c
+38
-8
libobs/obs.h
libobs/obs.h
+3
-0
未找到文件。
build/data/libobs/default.effect
浏览文件 @
065379bf
uniform float4x4 ViewProj;
uniform float4x4 color_matrix;
uniform float3 color_range_min;
uniform float3 color_range_max;
uniform texture2d image;
sampler_state def_sampler {
...
...
@@ -29,6 +31,7 @@ float4 PSDrawBare(VertInOut vert_in) : TARGET
float4 PSDrawMatrix(VertInOut vert_in) : TARGET
{
float4 yuv = image.Sample(def_sampler, vert_in.uv);
yuv.xyz = clamp(yuv.xyz, color_range_min, color_range_max);
return saturate(mul(float4(yuv.xyz, 1.0), color_matrix));
}
...
...
libobs/obs-internal.h
浏览文件 @
065379bf
...
...
@@ -269,6 +269,9 @@ struct obs_source {
texture_t
async_texture
;
enum
video_format
async_format
;
float
async_color_matrix
[
16
];
bool
async_full_range
;
float
async_color_range_min
[
3
];
float
async_color_range_max
[
3
];
bool
async_flip
;
DARRAY
(
struct
source_frame
*
)
video_frames
;
pthread_mutex_t
video_mutex
;
...
...
libobs/obs-source.c
浏览文件 @
065379bf
...
...
@@ -625,10 +625,15 @@ static bool update_async_texture(struct obs_source *source,
void
*
ptr
;
uint32_t
linesize
;
source
->
async_format
=
frame
->
format
;
source
->
async_flip
=
frame
->
flip
;
source
->
async_format
=
frame
->
format
;
source
->
async_flip
=
frame
->
flip
;
source
->
async_full_range
=
frame
->
full_range
;
memcpy
(
source
->
async_color_matrix
,
frame
->
color_matrix
,
sizeof
(
frame
->
color_matrix
));
memcpy
(
source
->
async_color_range_min
,
frame
->
color_range_min
,
sizeof
frame
->
color_range_min
);
memcpy
(
source
->
async_color_range_max
,
frame
->
color_range_max
,
sizeof
frame
->
color_range_max
);
if
(
type
==
CONVERT_NONE
)
{
texture_setimage
(
tex
,
frame
->
data
[
0
],
frame
->
linesize
[
0
],
...
...
@@ -661,13 +666,29 @@ static bool update_async_texture(struct obs_source *source,
return
true
;
}
static
float
const
full_range_min
[]
=
{
0
.,
0
.,
0
.};
static
float
const
full_range_max
[]
=
{
1
.,
1
.,
1
.};
static
inline
void
obs_source_draw_texture
(
struct
obs_source
*
source
,
effect_t
effect
,
float
*
color_matrix
)
effect_t
effect
,
float
*
color_matrix
,
float
const
*
color_range_min
,
float
const
*
color_range_max
)
{
texture_t
tex
=
source
->
async_texture
;
eparam_t
param
;
if
(
color_matrix
)
{
size_t
const
size
=
sizeof
(
float
)
*
3
;
if
(
!
color_range_min
)
color_range_min
=
full_range_min
;
if
(
!
color_range_max
)
color_range_max
=
full_range_max
;
param
=
effect_getparambyname
(
effect
,
"color_range_min"
);
effect_setval
(
effect
,
param
,
color_range_min
,
size
);
param
=
effect_getparambyname
(
effect
,
"color_range_max"
);
effect_setval
(
effect
,
param
,
color_range_max
,
size
);
param
=
effect_getparambyname
(
effect
,
"color_matrix"
);
effect_setval
(
effect
,
param
,
color_matrix
,
sizeof
(
float
)
*
16
);
}
...
...
@@ -680,10 +701,11 @@ static inline void obs_source_draw_texture(struct obs_source *source,
static
void
obs_source_draw_async_texture
(
struct
obs_source
*
source
)
{
effect_t
effect
=
gs_geteffect
();
bool
yuv
=
format_is_yuv
(
source
->
async_format
);
const
char
*
type
=
yuv
?
"DrawMatrix"
:
"Draw"
;
bool
def_draw
=
(
!
effect
);
effect_t
effect
=
gs_geteffect
();
bool
yuv
=
format_is_yuv
(
source
->
async_format
);
bool
limited_range
=
yuv
&&
!
source
->
async_full_range
;
const
char
*
type
=
yuv
?
"DrawMatrix"
:
"Draw"
;
bool
def_draw
=
(
!
effect
);
technique_t
tech
;
if
(
def_draw
)
{
...
...
@@ -694,7 +716,9 @@ static void obs_source_draw_async_texture(struct obs_source *source)
}
obs_source_draw_texture
(
source
,
effect
,
yuv
?
source
->
async_color_matrix
:
NULL
);
yuv
?
source
->
async_color_matrix
:
NULL
,
limited_range
?
source
->
async_color_range_min
:
NULL
,
limited_range
?
source
->
async_color_range_max
:
NULL
);
if
(
def_draw
)
{
technique_endpass
(
tech
);
...
...
@@ -947,8 +971,14 @@ static void copy_frame_data(struct source_frame *dst,
const
struct
source_frame
*
src
)
{
dst
->
flip
=
src
->
flip
;
dst
->
full_range
=
src
->
full_range
;
dst
->
timestamp
=
src
->
timestamp
;
memcpy
(
dst
->
color_matrix
,
src
->
color_matrix
,
sizeof
(
float
)
*
16
);
if
(
!
dst
->
full_range
)
{
size_t
const
size
=
sizeof
(
float
)
*
3
;
memcpy
(
dst
->
color_range_min
,
src
->
color_range_min
,
size
);
memcpy
(
dst
->
color_range_max
,
src
->
color_range_max
,
size
);
}
switch
(
dst
->
format
)
{
case
VIDEO_FORMAT_I420
:
...
...
libobs/obs.h
浏览文件 @
065379bf
...
...
@@ -166,6 +166,9 @@ struct source_frame {
enum
video_format
format
;
float
color_matrix
[
16
];
bool
full_range
;
float
color_range_min
[
3
];
float
color_range_max
[
3
];
bool
flip
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录