Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
f68f1968
提交
f68f1968
authored
5月 12, 2015
作者:
Seven Du
提交者:
Michael Jerris
5月 28, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7506 refactor to use rgb color for pixel
上级
d10cb874
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
28 行删除
+21
-28
switch_core_video.h
src/include/switch_core_video.h
+2
-2
switch_core_video.c
src/switch_core_video.c
+19
-26
没有找到文件。
src/include/switch_core_video.h
浏览文件 @
f68f1968
...
...
@@ -256,9 +256,9 @@ SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, i
* \param[in] img Image descriptor
* \param[in] x leftmost pos
* \param[in] y topmost pos
* \param[in] color
YUV
color
* \param[in] color
RGB
color
*/
SWITCH_DECLARE
(
void
)
switch_img_draw_pixel
(
switch_image_t
*
img
,
int
x
,
int
y
,
switch_
yuv
_color_t
*
color
);
SWITCH_DECLARE
(
void
)
switch_img_draw_pixel
(
switch_image_t
*
img
,
int
x
,
int
y
,
switch_
rgb
_color_t
*
color
);
/*!\brief Set RGB color with a string
*
...
...
src/switch_core_video.c
浏览文件 @
f68f1968
...
...
@@ -134,7 +134,6 @@ SWITCH_DECLARE(void) switch_img_patch(switch_image_t *IMG, switch_image_t *img,
int
j
;
uint8_t
alpha
;
switch_rgb_color_t
*
rgb_color
;
switch_yuv_color_t
yuv_color
;
for
(
i
=
0
;
i
<
max_h
;
i
++
)
{
for
(
j
=
0
;
j
<
max_w
;
j
++
)
{
...
...
@@ -143,8 +142,7 @@ SWITCH_DECLARE(void) switch_img_patch(switch_image_t *IMG, switch_image_t *img,
if
(
alpha
>
127
)
{
// todo: mux alpha with the underlying pixel ?
rgb_color
=
(
switch_rgb_color_t
*
)(
img
->
planes
[
SWITCH_PLANE_PACKED
]
+
i
*
img
->
stride
[
SWITCH_PLANE_PACKED
]
+
j
*
4
+
1
);
switch_color_rgb2yuv
(
rgb_color
,
&
yuv_color
);
switch_img_draw_pixel
(
IMG
,
x
+
j
,
y
+
i
,
&
yuv_color
);
switch_img_draw_pixel
(
IMG
,
x
+
j
,
y
+
i
,
rgb_color
);
}
}
}
...
...
@@ -291,15 +289,19 @@ SWITCH_DECLARE(switch_image_t *) switch_img_copy_rect(switch_image_t *img, uint3
return
new_img
;
}
SWITCH_DECLARE
(
void
)
switch_img_draw_pixel
(
switch_image_t
*
img
,
int
x
,
int
y
,
switch_
yuv
_color_t
*
color
)
SWITCH_DECLARE
(
void
)
switch_img_draw_pixel
(
switch_image_t
*
img
,
int
x
,
int
y
,
switch_
rgb
_color_t
*
color
)
{
switch_yuv_color_t
yuv
;
if
(
img
->
fmt
!=
SWITCH_IMG_FMT_I420
||
x
<
0
||
y
<
0
||
x
>=
img
->
d_w
||
y
>=
img
->
d_h
)
return
;
img
->
planes
[
SWITCH_PLANE_Y
][
y
*
img
->
stride
[
SWITCH_PLANE_Y
]
+
x
]
=
color
->
y
;
switch_color_rgb2yuv
(
color
,
&
yuv
);
img
->
planes
[
SWITCH_PLANE_Y
][
y
*
img
->
stride
[
SWITCH_PLANE_Y
]
+
x
]
=
yuv
.
y
;
if
(((
x
&
0x1
)
==
0
)
&&
((
y
&
0x1
)
==
0
))
{
// only draw on even position
img
->
planes
[
SWITCH_PLANE_U
][
y
/
2
*
img
->
stride
[
SWITCH_PLANE_U
]
+
x
/
2
]
=
color
->
u
;
img
->
planes
[
SWITCH_PLANE_V
][
y
/
2
*
img
->
stride
[
SWITCH_PLANE_V
]
+
x
/
2
]
=
color
->
v
;
img
->
planes
[
SWITCH_PLANE_U
][
y
/
2
*
img
->
stride
[
SWITCH_PLANE_U
]
+
x
/
2
]
=
yuv
.
u
;
img
->
planes
[
SWITCH_PLANE_V
][
y
/
2
*
img
->
stride
[
SWITCH_PLANE_V
]
+
x
/
2
]
=
yuv
.
v
;
}
}
...
...
@@ -365,7 +367,6 @@ SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img
{
int
i
,
j
,
len
,
max_h
;
switch_rgb_color_t
RGB
,
rgb
,
c
;
switch_yuv_color_t
yuv
;
int
xoff
=
0
,
yoff
=
0
;
switch_assert
(
IMG
->
fmt
==
SWITCH_IMG_FMT_I420
);
...
...
@@ -396,8 +397,7 @@ SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img
c
.
g
=
((
RGB
.
g
*
(
255
-
alpha
))
>>
8
)
+
((
rgb
.
g
*
alpha
)
>>
8
);
c
.
b
=
((
RGB
.
b
*
(
255
-
alpha
))
>>
8
)
+
((
rgb
.
b
*
alpha
)
>>
8
);
switch_color_rgb2yuv
(
&
c
,
&
yuv
);
switch_img_draw_pixel
(
IMG
,
x
+
j
,
i
,
&
yuv
);
switch_img_draw_pixel
(
IMG
,
x
+
j
,
i
,
&
c
);
}
}
}
...
...
@@ -537,24 +537,23 @@ struct switch_img_txt_handle_s {
switch_image_t
*
img
;
switch_memory_pool_t
*
pool
;
int
free_pool
;
switch_
yuv
_color_t
gradient_table
[
MAX_GRADIENT
];
switch_
rgb
_color_t
gradient_table
[
MAX_GRADIENT
];
switch_bool_t
use_bgcolor
;
};
static
void
init_gradient_table
(
switch_img_txt_handle_t
*
handle
)
{
int
i
;
switch_rgb_color_t
color
;
switch_rgb_color_t
*
color
;
switch_rgb_color_t
*
c1
=
&
handle
->
bgcolor
;
switch_rgb_color_t
*
c2
=
&
handle
->
color
;
for
(
i
=
0
;
i
<
MAX_GRADIENT
;
i
++
)
{
color
.
r
=
c1
->
r
+
(
c2
->
r
-
c1
->
r
)
*
i
/
MAX_GRADIENT
;
color
.
g
=
c1
->
g
+
(
c2
->
g
-
c1
->
g
)
*
i
/
MAX_GRADIENT
;
color
.
b
=
c1
->
b
+
(
c2
->
b
-
c1
->
b
)
*
i
/
MAX_GRADIENT
;
switch_color_rgb2yuv
(
&
color
,
&
handle
->
gradient_table
[
i
]);
color
=
&
handle
->
gradient_table
[
i
];
color
->
r
=
c1
->
r
+
(
c2
->
r
-
c1
->
r
)
*
i
/
MAX_GRADIENT
;
color
->
g
=
c1
->
g
+
(
c2
->
g
-
c1
->
g
)
*
i
/
MAX_GRADIENT
;
color
->
b
=
c1
->
b
+
(
c2
->
b
-
c1
->
b
)
*
i
/
MAX_GRADIENT
;
}
}
...
...
@@ -649,7 +648,6 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT
FT_Int
i
,
j
,
p
,
q
;
FT_Int
x_max
=
x
+
bitmap
->
width
;
FT_Int
y_max
=
y
+
bitmap
->
rows
;
switch_yuv_color_t
yuv_color
;
if
(
bitmap
->
width
==
0
)
return
;
...
...
@@ -659,8 +657,6 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT
case
FT_PIXEL_MODE_NONE
:
case
FT_PIXEL_MODE_MONO
:
{
switch_color_rgb2yuv
(
&
handle
->
color
,
&
yuv_color
);
for
(
j
=
y
,
q
=
0
;
j
<
y_max
;
j
++
,
q
++
)
{
for
(
i
=
x
,
p
=
0
;
i
<
x_max
;
i
++
,
p
++
)
{
uint8_t
byte
;
...
...
@@ -670,7 +666,7 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT
byte
=
bitmap
->
buffer
[(
q
*
linesize
+
p
)
/
8
];
if
((
byte
>>
(
7
-
(
p
%
8
)))
&
0x1
)
{
switch_img_draw_pixel
(
img
,
i
,
j
,
&
yuv_
color
);
switch_img_draw_pixel
(
img
,
i
,
j
,
&
handle
->
color
);
}
}
}
...
...
@@ -700,8 +696,7 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT
c
.
g
=
((
rgb_color
.
g
*
(
255
-
gradient
))
>>
8
)
+
((
handle
->
color
.
g
*
gradient
)
>>
8
);
c
.
b
=
((
rgb_color
.
b
*
(
255
-
gradient
))
>>
8
)
+
((
handle
->
color
.
b
*
gradient
)
>>
8
);
switch_color_rgb2yuv
(
&
c
,
&
yuv_color
);
switch_img_draw_pixel
(
img
,
i
,
j
,
&
yuv_color
);
switch_img_draw_pixel
(
img
,
i
,
j
,
&
c
);
}
}
}
...
...
@@ -1047,7 +1042,6 @@ SWITCH_DECLARE(switch_status_t) switch_png_patch_img(switch_png_t *use_png, swit
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_rgb_color_t
*
rgb_color
;
switch_yuv_color_t
yuv_color
;
uint8_t
alpha
;
int
i
,
j
;
...
...
@@ -1062,8 +1056,7 @@ SWITCH_DECLARE(switch_status_t) switch_png_patch_img(switch_png_t *use_png, swit
if
(
alpha
)
{
// 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);
rgb_color
=
(
switch_rgb_color_t
*
)(
use_png
->
pvt
->
buffer
+
i
*
use_png
->
pvt
->
png
.
width
*
4
+
j
*
4
+
1
);
switch_color_rgb2yuv
(
rgb_color
,
&
yuv_color
);
switch_img_draw_pixel
(
img
,
x
+
j
,
y
+
i
,
&
yuv_color
);
switch_img_draw_pixel
(
img
,
x
+
j
,
y
+
i
,
rgb_color
);
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论