Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2bd0ff45
提交
2bd0ff45
authored
3月 02, 2017
作者:
Seven Du
提交者:
Anthony Minessale
3月 03, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10080
上级
a9e2346f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
31 行删除
+28
-31
switch_core_video.h
src/include/switch_core_video.h
+9
-0
switch_core_video.c
src/switch_core_video.c
+19
-31
没有找到文件。
src/include/switch_core_video.h
浏览文件 @
2bd0ff45
...
@@ -80,12 +80,21 @@ typedef struct switch_yuv_color_s {
...
@@ -80,12 +80,21 @@ typedef struct switch_yuv_color_s {
uint8_t
v
;
uint8_t
v
;
}
switch_yuv_color_t
;
}
switch_yuv_color_t
;
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
typedef
struct
switch_rgb_color_s
{
typedef
struct
switch_rgb_color_s
{
uint8_t
a
;
uint8_t
a
;
uint8_t
r
;
uint8_t
r
;
uint8_t
g
;
uint8_t
g
;
uint8_t
b
;
uint8_t
b
;
}
switch_rgb_color_t
;
}
switch_rgb_color_t
;
#else
typedef
struct
switch_rgb_color_s
{
uint8_t
b
;
uint8_t
g
;
uint8_t
r
;
uint8_t
a
;
}
switch_rgb_color_t
;
#endif
typedef
struct
switch_hsl_color_s
{
typedef
struct
switch_hsl_color_s
{
double
h
;
double
h
;
...
...
src/switch_core_video.c
浏览文件 @
2bd0ff45
...
@@ -1081,7 +1081,7 @@ SWITCH_DECLARE(void) switch_chromakey_process(switch_chromakey_t *ck, switch_ima
...
@@ -1081,7 +1081,7 @@ SWITCH_DECLARE(void) switch_chromakey_process(switch_chromakey_t *ck, switch_ima
#ifdef DEBUG_CHROMA
#ifdef DEBUG_CHROMA
other_img_cached
++
;
other_img_cached
++
;
#endif
#endif
*
pixel
=
*
cache_pixel
;
color
->
a
=
cache_color
->
a
;
goto
end
;
goto
end
;
}
}
}
}
...
@@ -1177,7 +1177,7 @@ SWITCH_DECLARE(void) switch_chromakey_process(switch_chromakey_t *ck, switch_ima
...
@@ -1177,7 +1177,7 @@ SWITCH_DECLARE(void) switch_chromakey_process(switch_chromakey_t *ck, switch_ima
#ifdef DEBUG_CHROMA
#ifdef DEBUG_CHROMA
hit_total
++
;
hit_total
++
;
#endif
#endif
*
pixel
=
0
;
color
->
a
=
0
;
}
}
last_pixel
=
pixel
;
last_pixel
=
pixel
;
...
@@ -1230,29 +1230,28 @@ SWITCH_DECLARE(void) switch_chromakey_process(switch_chromakey_t *ck, switch_ima
...
@@ -1230,29 +1230,28 @@ SWITCH_DECLARE(void) switch_chromakey_process(switch_chromakey_t *ck, switch_ima
SWITCH_DECLARE
(
void
)
switch_img_chromakey
(
switch_image_t
*
img
,
switch_rgb_color_t
*
mask
,
int
threshold
)
SWITCH_DECLARE
(
void
)
switch_img_chromakey
(
switch_image_t
*
img
,
switch_rgb_color_t
*
mask
,
int
threshold
)
{
{
uint8
_t
*
pixel
,
*
last_pixel
=
NULL
;
switch_rgb_color
_t
*
pixel
,
*
last_pixel
=
NULL
;
int
last_threshold
=
0
;
int
last_threshold
=
0
;
switch_assert
(
img
);
switch_assert
(
img
);
if
(
img
->
fmt
!=
SWITCH_IMG_FMT_ARGB
)
return
;
if
(
img
->
fmt
!=
SWITCH_IMG_FMT_ARGB
)
return
;
pixel
=
img
->
planes
[
SWITCH_PLANE_PACKED
];
pixel
=
(
switch_rgb_color_t
*
)
img
->
planes
[
SWITCH_PLANE_PACKED
];
for
(;
pixel
<
(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
img
->
d_h
*
4
);
pixel
+=
4
)
{
for
(;
pixel
<
((
switch_rgb_color_t
*
)
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
img
->
d_h
);
pixel
++
)
{
switch_rgb_color_t
*
color
=
(
switch_rgb_color_t
*
)
pixel
;
int
threshold
=
0
;
int
threshold
=
0
;
if
(
last_pixel
&&
(
*
(
uint32_t
*
)
pixel
&
0xFFFFFF
)
==
(
*
(
uint32_t
*
)
last_pixel
&
0xFFFFFF
))
{
if
(
last_pixel
&&
(
*
(
uint32_t
*
)
pixel
&
0xFFFFFF
)
==
(
*
(
uint32_t
*
)
last_pixel
&
0xFFFFFF
))
{
threshold
=
last_threshold
;
threshold
=
last_threshold
;
}
else
{
}
else
{
threshold
=
switch_color_distance
(
color
,
mask
);
threshold
=
switch_color_distance
(
pixel
,
mask
);
}
}
last_threshold
=
threshold
;
last_threshold
=
threshold
;
last_pixel
=
pixel
;
last_pixel
=
pixel
;
if
(
threshold
)
{
if
(
threshold
)
{
*
pixel
=
0
;
pixel
->
a
=
0
;
}
}
}
}
...
@@ -1276,11 +1275,7 @@ static inline void switch_img_draw_pixel(switch_image_t *img, int x, int y, swit
...
@@ -1276,11 +1275,7 @@ static inline void switch_img_draw_pixel(switch_image_t *img, int x, int y, swit
img
->
planes
[
SWITCH_PLANE_V
][
y
/
2
*
img
->
stride
[
SWITCH_PLANE_V
]
+
x
/
2
]
=
yuv
.
v
;
img
->
planes
[
SWITCH_PLANE_V
][
y
/
2
*
img
->
stride
[
SWITCH_PLANE_V
]
+
x
/
2
]
=
yuv
.
v
;
}
}
}
else
if
(
img
->
fmt
==
SWITCH_IMG_FMT_ARGB
)
{
}
else
if
(
img
->
fmt
==
SWITCH_IMG_FMT_ARGB
)
{
uint8_t
*
alpha
=
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
4
*
y
+
x
*
4
;
*
((
switch_rgb_color_t
*
)
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
y
+
x
)
=
*
color
;
*
(
alpha
)
=
color
->
a
;
*
(
alpha
+
1
)
=
color
->
r
;
*
(
alpha
+
2
)
=
color
->
g
;
*
(
alpha
+
3
)
=
color
->
b
;
}
}
#endif
#endif
}
}
...
@@ -1317,10 +1312,7 @@ SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, i
...
@@ -1317,10 +1312,7 @@ SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, i
}
}
}
else
if
(
img
->
fmt
==
SWITCH_IMG_FMT_ARGB
)
{
}
else
if
(
img
->
fmt
==
SWITCH_IMG_FMT_ARGB
)
{
for
(
i
=
0
;
i
<
img
->
d_w
;
i
++
)
{
for
(
i
=
0
;
i
<
img
->
d_w
;
i
++
)
{
*
(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
i
*
4
)
=
color
->
a
;
*
((
switch_rgb_color_t
*
)
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
i
)
=
*
color
;
*
(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
i
*
4
+
1
)
=
color
->
r
;
*
(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
i
*
4
+
2
)
=
color
->
g
;
*
(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
i
*
4
+
3
)
=
color
->
b
;
}
}
for
(
i
=
1
;
i
<
img
->
d_h
;
i
++
)
{
for
(
i
=
1
;
i
<
img
->
d_h
;
i
++
)
{
...
@@ -1354,11 +1346,7 @@ static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_colo
...
@@ -1354,11 +1346,7 @@ static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_colo
switch_img_get_yuv_pixel
(
img
,
&
yuv
,
x
,
y
);
switch_img_get_yuv_pixel
(
img
,
&
yuv
,
x
,
y
);
switch_color_yuv2rgb
(
&
yuv
,
rgb
);
switch_color_yuv2rgb
(
&
yuv
,
rgb
);
}
else
if
(
img
->
fmt
==
SWITCH_IMG_FMT_ARGB
)
{
}
else
if
(
img
->
fmt
==
SWITCH_IMG_FMT_ARGB
)
{
uint8_t
*
a
=
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
4
*
y
+
4
*
x
;
*
rgb
=
*
((
switch_rgb_color_t
*
)
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
img
->
d_w
*
y
+
x
);
rgb
->
a
=
*
a
;
rgb
->
r
=
*
(
++
a
);
rgb
->
g
=
*
(
++
a
);
rgb
->
b
=
*
(
++
a
);
}
}
#endif
#endif
}
}
...
@@ -2088,19 +2076,15 @@ SWITCH_DECLARE(switch_status_t) switch_png_patch_img(switch_png_t *use_png, swit
...
@@ -2088,19 +2076,15 @@ SWITCH_DECLARE(switch_status_t) switch_png_patch_img(switch_png_t *use_png, swit
{
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_rgb_color_t
*
rgb_color
;
switch_rgb_color_t
*
rgb_color
;
uint8_t
alpha
;
int
i
,
j
;
int
i
,
j
;
switch_assert
(
use_png
);
switch_assert
(
use_png
);
for
(
i
=
0
;
i
<
use_png
->
pvt
->
png
.
height
;
i
++
)
{
for
(
i
=
0
;
i
<
use_png
->
pvt
->
png
.
height
;
i
++
)
{
for
(
j
=
0
;
j
<
use_png
->
pvt
->
png
.
width
;
j
++
)
{
for
(
j
=
0
;
j
<
use_png
->
pvt
->
png
.
width
;
j
++
)
{
//alpha = use_png->pvt->buffer[i * use_png->pvt->png.width * 4 + j * 4 + 3];
rgb_color
=
(
switch_rgb_color_t
*
)
use_png
->
pvt
->
buffer
+
i
*
use_png
->
pvt
->
png
.
width
+
j
;
alpha
=
use_png
->
pvt
->
buffer
[
i
*
use_png
->
pvt
->
png
.
width
*
4
+
j
*
4
];
// printf("%d, %d alpha: %d\n", j, i, alpha);
if
(
alpha
)
{
// todo, mux alpha with the underlying pixel
if
(
rgb_color
->
a
)
{
// todo, mux alpha with the underlying pixel
rgb_color
=
(
switch_rgb_color_t
*
)(
use_png
->
pvt
->
buffer
+
i
*
use_png
->
pvt
->
png
.
width
*
4
+
j
*
4
);
switch_img_draw_pixel
(
img
,
x
+
j
,
y
+
i
,
rgb_color
);
switch_img_draw_pixel
(
img
,
x
+
j
,
y
+
i
,
rgb_color
);
}
}
}
}
...
@@ -2149,7 +2133,11 @@ SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name, swit
...
@@ -2149,7 +2133,11 @@ SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name, swit
if
(
img_fmt
==
SWITCH_IMG_FMT_I420
)
{
if
(
img_fmt
==
SWITCH_IMG_FMT_I420
)
{
png
.
format
=
PNG_FORMAT_RGB
;
png
.
format
=
PNG_FORMAT_RGB
;
}
else
if
(
img_fmt
==
SWITCH_IMG_FMT_ARGB
)
{
}
else
if
(
img_fmt
==
SWITCH_IMG_FMT_ARGB
)
{
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
png
.
format
=
PNG_FORMAT_ARGB
;
png
.
format
=
PNG_FORMAT_ARGB
;
#else
png
.
format
=
PNG_FORMAT_BGRA
;
#endif
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unsupported image format: %x
\n
"
,
img_fmt
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unsupported image format: %x
\n
"
,
img_fmt
);
goto
err
;
goto
err
;
...
@@ -2178,7 +2166,7 @@ SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name, swit
...
@@ -2178,7 +2166,7 @@ SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name, swit
img
->
planes
[
SWITCH_PLANE_V
],
img
->
stride
[
SWITCH_PLANE_V
],
img
->
planes
[
SWITCH_PLANE_V
],
img
->
stride
[
SWITCH_PLANE_V
],
png
.
width
,
png
.
height
);
png
.
width
,
png
.
height
);
}
else
if
(
img_fmt
==
SWITCH_IMG_FMT_ARGB
){
}
else
if
(
img_fmt
==
SWITCH_IMG_FMT_ARGB
){
ARGB
ToARGB
(
buffer
,
png
.
width
*
4
,
ARGB
Copy
(
buffer
,
png
.
width
*
4
,
img
->
planes
[
SWITCH_PLANE_PACKED
],
png
.
width
*
4
,
img
->
planes
[
SWITCH_PLANE_PACKED
],
png
.
width
*
4
,
png
.
width
,
png
.
height
);
png
.
width
,
png
.
height
);
}
}
...
@@ -2414,7 +2402,7 @@ SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name, swit
...
@@ -2414,7 +2402,7 @@ SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name, swit
img
->
planes
[
SWITCH_PLANE_V
],
img
->
stride
[
SWITCH_PLANE_V
],
img
->
planes
[
SWITCH_PLANE_V
],
img
->
stride
[
SWITCH_PLANE_V
],
width
,
height
);
width
,
height
);
}
else
if
(
img_fmt
==
SWITCH_IMG_FMT_ARGB
)
{
}
else
if
(
img_fmt
==
SWITCH_IMG_FMT_ARGB
)
{
ARGBToRGBA
(
buffer
,
width
*
4
,
BGRAToARGB
(
buffer
,
width
*
4
,
img
->
planes
[
SWITCH_PLANE_PACKED
],
width
*
4
,
img
->
planes
[
SWITCH_PLANE_PACKED
],
width
*
4
,
width
,
height
);
width
,
height
);
}
}
...
@@ -2745,7 +2733,7 @@ static inline uint32_t switch_img_fmt2fourcc(switch_img_fmt_t fmt)
...
@@ -2745,7 +2733,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_YVYU
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_BGR24
:
fourcc
=
(
uint32_t
)
FOURCC_RAW
;
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_RGB32_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_ARGB
:
fourcc
=
(
uint32_t
)
FOURCC_
BGRA
;
break
;
case
SWITCH_IMG_FMT_ARGB
:
fourcc
=
(
uint32_t
)
FOURCC_
ARGB
;
break
;
case
SWITCH_IMG_FMT_ARGB_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
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_RGB565_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB555_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB555_LE
:
fourcc
=
(
uint32_t
)
FOURCC_ANY
;
break
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论