Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
f31393d3
提交
f31393d3
authored
2月 16, 2017
作者:
Seven Du
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10050 add chromakey
上级
91866404
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
44 行增加
和
2 行删除
+44
-2
switch_core_video.h
src/include/switch_core_video.h
+5
-1
switch_core_video.c
src/switch_core_video.c
+39
-1
没有找到文件。
src/include/switch_core_video.h
浏览文件 @
f31393d3
...
...
@@ -387,7 +387,11 @@ SWITCH_DECLARE(switch_status_t) switch_I420_copy(const uint8_t* src_y, int src_s
SWITCH_DECLARE
(
switch_status_t
)
switch_I420_copy2
(
uint8_t
*
src_planes
[],
int
src_stride
[],
uint8_t
*
dst_planes
[],
int
dst_stride
[],
int
width
,
int
height
);
/** @} */
/*!\brief chromakey an img, img must be RGBA and return modified img */
SWITCH_DECLARE
(
void
)
switch_img_chromakey
(
switch_image_t
*
img
,
switch_rgb_color_t
*
mask
,
int
threshold
);
SWITCH_END_EXTERN_C
#endif
...
...
src/switch_core_video.c
浏览文件 @
f31393d3
...
...
@@ -73,6 +73,13 @@ static inline void switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_colo
static
inline
void
switch_color_yuv2rgb
(
switch_yuv_color_t
*
yuv
,
switch_rgb_color_t
*
rgb
);
#endif
/*!\brief compute distance between two colors
*
* \param[in] c1 RGB color1
* \param[in] c2 RGB color2
*/
static
inline
int
switch_color_distance
(
switch_rgb_color_t
*
c1
,
switch_rgb_color_t
*
c2
);
/*!\brief Draw a pixel on an image
*
* \param[in] img Image descriptor
...
...
@@ -527,6 +534,27 @@ SWITCH_DECLARE(switch_image_t *) switch_img_copy_rect(switch_image_t *img, uint3
#endif
}
SWITCH_DECLARE
(
void
)
switch_img_chromakey
(
switch_image_t
*
img
,
switch_rgb_color_t
*
mask
,
int
threshold
)
{
uint8_t
*
pixel
;
switch_assert
(
img
);
if
(
img
->
fmt
!=
SWITCH_IMG_FMT_ARGB
)
return
;
pixel
=
img
->
planes
[
SWITCH_PLANE_PACKED
];
for
(;
pixel
<
(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
img
->
d_h
*
4
);
pixel
+=
4
)
{
switch_rgb_color_t
*
color
=
(
switch_rgb_color_t
*
)
pixel
;
int
distance
=
switch_color_distance
(
color
,
mask
);
if
(
distance
<=
threshold
)
{
*
pixel
=
0
;
}
}
return
;
}
static
inline
void
switch_img_draw_pixel
(
switch_image_t
*
img
,
int
x
,
int
y
,
switch_rgb_color_t
*
color
)
{
#ifdef SWITCH_HAVE_YUV
...
...
@@ -767,6 +795,16 @@ static inline void switch_color_rgb2yuv(switch_rgb_color_t *rgb, switch_yuv_colo
}
#endif
static
inline
int
switch_color_distance
(
switch_rgb_color_t
*
c1
,
switch_rgb_color_t
*
c2
)
{
int
rmean
=
(
c1
->
r
+
c2
->
r
)
/
2
;
int
r
=
c1
->
r
-
c2
->
r
;
int
g
=
c1
->
g
-
c2
->
g
;
int
b
=
c1
->
b
-
c2
->
b
;
return
sqrt
((((
512
+
rmean
)
*
r
*
r
)
>>
8
)
+
4
*
g
*
g
+
(((
767
-
rmean
)
*
b
*
b
)
>>
8
));
}
#define CLAMP(val) MAX(0, MIN(val, 255))
#ifdef SWITCH_HAVE_YUV
...
...
@@ -2008,7 +2046,7 @@ static inline uint32_t switch_img_fmt2fourcc(switch_img_fmt_t fmt)
case
SWITCH_IMG_FMT_YVYU
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_BGR24
:
fourcc
=
(
uint32_t
)
FOURCC_RAW
;
break
;
case
SWITCH_IMG_FMT_RGB32_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_ARGB
:
fourcc
=
(
uint32_t
)
FOURCC_
ANY
;
break
;
case
SWITCH_IMG_FMT_ARGB
:
fourcc
=
(
uint32_t
)
FOURCC_
BGRA
;
break
;
case
SWITCH_IMG_FMT_ARGB_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB565_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB555_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论