Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
ed78d389
提交
ed78d389
authored
2月 24, 2016
作者:
Seven Du
提交者:
Michael Jerris
2月 24, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-8867: create conversion function stubs in the core so modules do not need to use libyuv directly
上级
cd2c86b4
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
165 行增加
和
44 行删除
+165
-44
switch_core_video.h
src/include/switch_core_video.h
+24
-1
switch_vpx.h
src/include/switch_vpx.h
+27
-3
mod_cv.cpp
src/mod/applications/mod_cv/mod_cv.cpp
+2
-12
mod_imagick.c
src/mod/formats/mod_imagick/mod_imagick.c
+1
-8
mod_vlc.c
src/mod/formats/mod_vlc/mod_vlc.c
+1
-2
switch_core_video.c
src/switch_core_video.c
+110
-18
没有找到文件。
src/include/switch_core_video.h
浏览文件 @
ed78d389
...
...
@@ -339,7 +339,30 @@ SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width,
SWITCH_DECLARE
(
switch_img_position_t
)
parse_img_position
(
const
char
*
name
);
SWITCH_DECLARE
(
switch_img_fit_t
)
parse_img_fit
(
const
char
*
name
);
SWITCH_DECLARE
(
void
)
switch_img_find_position
(
switch_img_position_t
pos
,
int
sw
,
int
sh
,
int
iw
,
int
ih
,
int
*
xP
,
int
*
yP
);
SWITCH_DECLARE
(
switch_status_t
)
switch_img_convert
(
switch_image_t
*
src
,
switch_convert_fmt_t
fmt
,
void
*
dest
,
switch_size_t
*
size
);
/*!\brief convert img to raw format
*
* dest should be pre-allocated and big enough for the target fmt
*
* \param[in] src The image descriptor
* \param[in] dest The target memory address
* \param[in] size The size of target memory address used for bounds check
* \param[in] fmt The target format
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_img_to_raw
(
switch_image_t
*
src
,
void
*
dest
,
switch_size_t
size
,
switch_img_fmt_t
fmt
);
/*!\brief convert raw memory to switch_img_t
*
* if dest is NULL then a new img is created, user should destroy it later,
* otherwize it will re-used the dest img, and the dest img size must match the src width and height,
* width and height can be 0 in the latter case and it will figure out according to the dest img
*
* \param[in] dest The image descriptor
* \param[in] src The raw data memory address
* \param[in] fmt The raw data format
* \param[in] width The raw data width
* \param[in] height The raw data height
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_img_from_raw
(
switch_image_t
*
dest
,
void
*
src
,
switch_img_fmt_t
fmt
,
int
width
,
int
height
);
SWITCH_DECLARE
(
switch_image_t
*
)
switch_img_write_text_img
(
int
w
,
int
h
,
switch_bool_t
full
,
const
char
*
text
);
SWITCH_DECLARE
(
switch_image_t
*
)
switch_img_read_file
(
const
char
*
file_name
);
...
...
src/include/switch_vpx.h
浏览文件 @
ed78d389
...
...
@@ -59,9 +59,33 @@ SWITCH_BEGIN_EXTERN_C
#define VPX_IMG_FMT_HIGH 0x800
/**< Image uses 16bit framebuffer */
#endif
#define SWITCH_IMG_FMT_HIGH VPX_IMG_FMT_HIGH
#define SWITCH_IMG_FMT_I420 VPX_IMG_FMT_I420
#define SWITCH_IMG_FMT_ARGB VPX_IMG_FMT_ARGB
#define SWITCH_IMG_FMT_NONE VPX_IMG_FMT_NONE
#define SWITCH_IMG_FMT_RGB24 VPX_IMG_FMT_RGB24
#define SWITCH_IMG_FMT_RGB32 VPX_IMG_FMT_RGB32
#define SWITCH_IMG_FMT_RGB565 VPX_IMG_FMT_RGB565
#define SWITCH_IMG_FMT_RGB555 VPX_IMG_FMT_RGB555
#define SWITCH_IMG_FMT_UYVY VPX_IMG_FMT_UYVY
#define SWITCH_IMG_FMT_YUY2 VPX_IMG_FMT_YUY2
#define SWITCH_IMG_FMT_YVYU VPX_IMG_FMT_YVYU
#define SWITCH_IMG_FMT_BGR24 VPX_IMG_FMT_BGR24
#define SWITCH_IMG_FMT_RGB32_LE VPX_IMG_FMT_RGB32_LE
#define SWITCH_IMG_FMT_ARGB VPX_IMG_FMT_ARGB
#define SWITCH_IMG_FMT_ARGB_LE VPX_IMG_FMT_ARGB_LE
#define SWITCH_IMG_FMT_RGB565_LE VPX_IMG_FMT_RGB565_LE
#define SWITCH_IMG_FMT_RGB555_LE VPX_IMG_FMT_RGB555_LE
#define SWITCH_IMG_FMT_YV12 VPX_IMG_FMT_YV12
#define SWITCH_IMG_FMT_I420 VPX_IMG_FMT_I420
#define SWITCH_IMG_FMT_VPXYV12 VPX_IMG_FMT_VPXYV12
#define SWITCH_IMG_FMT_VPXI420 VPX_IMG_FMT_VPXI420
#define SWITCH_IMG_FMT_I422 VPX_IMG_FMT_I422
#define SWITCH_IMG_FMT_I444 VPX_IMG_FMT_I444
#define SWITCH_IMG_FMT_I440 VPX_IMG_FMT_I440
#define SWITCH_IMG_FMT_444A VPX_IMG_FMT_444A
#define SWITCH_IMG_FMT_I42016 VPX_IMG_FMT_I42016
#define SWITCH_IMG_FMT_I42216 VPX_IMG_FMT_I42216
#define SWITCH_IMG_FMT_I44416 VPX_IMG_FMT_I44416
#define SWITCH_IMG_FMT_I44016 VPX_IMG_FMT_I44016
/* experimental */
#define SWITCH_IMG_FMT_GD VPX_IMG_FMT_NONE
typedef
vpx_img_fmt_t
switch_img_fmt_t
;
...
...
src/mod/applications/mod_cv/mod_cv.cpp
浏览文件 @
ed78d389
...
...
@@ -39,7 +39,6 @@ using namespace std;
using
namespace
cv
;
#include <switch.h>
#include <libyuv.h>
#include <cv.h>
#include "cvaux.h"
...
...
@@ -724,12 +723,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
switch_assert
(
context
->
rawImage
->
width
*
3
==
context
->
rawImage
->
widthStep
);
}
libyuv
::
I420ToRGB24
(
frame
->
img
->
planes
[
0
],
frame
->
img
->
stride
[
0
],
frame
->
img
->
planes
[
1
],
frame
->
img
->
stride
[
1
],
frame
->
img
->
planes
[
2
],
frame
->
img
->
stride
[
2
],
(
uint8_t
*
)
context
->
rawImage
->
imageData
,
context
->
rawImage
->
widthStep
,
context
->
rawImage
->
width
,
context
->
rawImage
->
height
);
switch_img_to_raw
(
frame
->
img
,
context
->
rawImage
->
imageData
,
context
->
rawImage
->
widthStep
*
context
->
h
,
SWITCH_IMG_FMT_RGB24
);
detectAndDraw
(
context
);
if
(
context
->
detected
.
simo_count
>
20
)
{
...
...
@@ -824,11 +818,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
}
if
(
context
->
rawImage
&&
(
context
->
debug
||
!
context
->
overlay_count
))
{
libyuv
::
RGB24ToI420
((
uint8_t
*
)
context
->
rawImage
->
imageData
,
context
->
w
*
3
,
frame
->
img
->
planes
[
0
],
frame
->
img
->
stride
[
0
],
frame
->
img
->
planes
[
1
],
frame
->
img
->
stride
[
1
],
frame
->
img
->
planes
[
2
],
frame
->
img
->
stride
[
2
],
context
->
rawImage
->
width
,
context
->
rawImage
->
height
);
switch_img_from_raw
(
frame
->
img
,
(
uint8_t
*
)
context
->
rawImage
->
imageData
,
SWITCH_IMG_FMT_RGB24
,
context
->
rawImage
->
width
,
context
->
rawImage
->
height
);
}
int
abs
=
0
;
...
...
src/mod/formats/mod_imagick/mod_imagick.c
浏览文件 @
ed78d389
...
...
@@ -34,8 +34,6 @@
#include <switch.h>
#include <libyuv.h>
#if defined(__clang__)
/* the imagemagick header files are very badly broken on clang. They really should be fixing this, in the mean time, this dirty hack works */
...
...
@@ -263,12 +261,7 @@ static switch_status_t read_page(pdf_file_context_t *context)
return
SWITCH_STATUS_FALSE
;
}
RAWToI420
(
storage
,
w
*
3
,
context
->
img
->
planes
[
0
],
context
->
img
->
stride
[
0
],
context
->
img
->
planes
[
1
],
context
->
img
->
stride
[
1
],
context
->
img
->
planes
[
2
],
context
->
img
->
stride
[
2
],
context
->
img
->
d_w
,
context
->
img
->
d_h
);
switch_img_from_raw
(
context
->
img
,
storage
,
SWITCH_IMG_FMT_BGR24
,
w
,
h
);
free
(
storage
);
}
else
{
switch_image_t
*
img
=
switch_img_alloc
(
NULL
,
SWITCH_IMG_FMT_ARGB
,
image
->
columns
,
image
->
rows
,
0
);
...
...
src/mod/formats/mod_vlc/mod_vlc.c
浏览文件 @
ed78d389
...
...
@@ -1642,8 +1642,7 @@ int vlc_write_video_imem_get_callback(void *data, const char *cookie, int64_t *
}
*
output
=
context
->
video_frame_buffer
;
*
size
=
0
;
switch_img_convert
(
img
,
SWITCH_CONVERT_FMT_YUYV
,
*
output
,
size
);
switch_img_to_raw
(
img
,
*
output
,
*
size
,
SWITCH_IMG_FMT_YUY2
);
switch_img_free
(
&
img
);
return
0
;
}
...
...
src/switch_core_video.c
浏览文件 @
ed78d389
...
...
@@ -1936,29 +1936,121 @@ SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width,
return
SWITCH_STATUS_FALSE
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_img_convert
(
switch_image_t
*
src
,
switch_convert_fmt_t
fmt
,
void
*
dest
,
switch_size_t
*
size
)
static
inline
uint32_t
switch_img_fmt2fourcc
(
switch_img_fmt_t
fmt
)
{
#ifdef SWITCH_HAVE_YUV
switch_assert
(
src
->
fmt
==
SWITCH_IMG_FMT_I420
);
uint32_t
fourcc
;
switch
(
fmt
)
{
case
SWITCH_IMG_FMT_NONE
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB24
:
fourcc
=
FOURCC_24BG
;
break
;
case
SWITCH_IMG_FMT_RGB32
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB565
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB555
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_UYVY
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_YUY2
:
fourcc
=
FOURCC_YUY2
;
break
;
case
SWITCH_IMG_FMT_YVYU
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_BGR24
:
fourcc
=
FOURCC_RAW
;
break
;
case
SWITCH_IMG_FMT_RGB32_LE
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_ARGB
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_ARGB_LE
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB565_LE
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_RGB555_LE
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_YV12
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I420
:
fourcc
=
FOURCC_I420
;
break
;
case
SWITCH_IMG_FMT_VPXYV12
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_VPXI420
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I422
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I444
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I440
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_444A
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I42016
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I42216
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I44416
:
fourcc
=
FOURCC_ANY
;
break
;
case
SWITCH_IMG_FMT_I44016
:
fourcc
=
FOURCC_ANY
;
break
;
default
:
fourcc
=
FOURCC_ANY
;
}
switch
(
fmt
)
{
case
SWITCH_CONVERT_FMT_YUYV
:
{
switch_size_t
size_in
=
*
size
;
ConvertFromI420
(
src
->
planes
[
0
],
src
->
stride
[
0
],
src
->
planes
[
1
],
src
->
stride
[
1
],
src
->
planes
[
2
],
src
->
stride
[
2
],
dest
,
size_in
,
src
->
d_w
,
src
->
d_h
,
FOURCC_YUY2
);
*
size
=
src
->
d_w
*
src
->
d_h
*
2
;
return
fourcc
;
#else
return
0xFFFFFFFF
;
#endif
}
return
SWITCH_STATUS_SUCCESS
;
}
default
:
abort
();
break
;
SWITCH_DECLARE
(
switch_status_t
)
switch_img_to_raw
(
switch_image_t
*
src
,
void
*
dest
,
switch_size_t
size
,
switch_img_fmt_t
fmt
)
{
#ifdef SWITCH_HAVE_YUV
uint32_t
fourcc
;
int
ret
;
switch_assert
(
src
->
fmt
==
SWITCH_IMG_FMT_I420
);
// todo: support other formats
switch_assert
(
dest
);
fourcc
=
switch_img_fmt2fourcc
(
fmt
);
if
(
fourcc
==
FOURCC_ANY
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"unsupported format: %d
\n
"
,
fmt
);
return
SWITCH_STATUS_FALSE
;
}
ret
=
ConvertFromI420
(
src
->
planes
[
0
],
src
->
stride
[
0
],
src
->
planes
[
1
],
src
->
stride
[
1
],
src
->
planes
[
2
],
src
->
stride
[
2
],
dest
,
size
,
src
->
d_w
,
src
->
d_h
,
fourcc
);
return
ret
==
0
?
SWITCH_STATUS_SUCCESS
:
SWITCH_STATUS_FALSE
;
#else
return
SWITCH_STATUS_FALSE
;
#endif
}
SWITCH_DECLARE
(
switch_status_t
)
switch_img_from_raw
(
switch_image_t
*
dest
,
void
*
src
,
switch_img_fmt_t
fmt
,
int
width
,
int
height
)
{
#ifdef SWITCH_HAVE_YUV
uint32_t
fourcc
;
int
ret
;
fourcc
=
switch_img_fmt2fourcc
(
fmt
);
if
(
fourcc
==
FOURCC_ANY
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"unsupported format: %d
\n
"
,
fmt
);
return
SWITCH_STATUS_FALSE
;
}
if
(
!
dest
&&
width
>
0
&&
height
>
0
)
dest
=
switch_img_alloc
(
NULL
,
SWITCH_IMG_FMT_I420
,
width
,
height
,
1
);
if
(
!
dest
)
return
SWITCH_STATUS_FALSE
;
if
(
width
==
0
||
height
==
0
)
{
width
=
dest
->
d_w
;
height
=
dest
->
d_h
;
}
/*
int ConvertToI420(const uint8* src_frame, size_t src_size,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int crop_x, int crop_y,
int src_width, int src_height,
int crop_width, int crop_height,
enum RotationMode rotation,
uint32 format);
src_size is only used when FOURCC_MJPG which we don't support so always 0
*/
ret
=
ConvertToI420
(
src
,
0
,
dest
->
planes
[
0
],
dest
->
stride
[
0
],
dest
->
planes
[
1
],
dest
->
stride
[
1
],
dest
->
planes
[
2
],
dest
->
stride
[
2
],
0
,
0
,
width
,
height
,
width
,
height
,
0
,
fourcc
);
return
ret
==
0
?
SWITCH_STATUS_SUCCESS
:
SWITCH_STATUS_FALSE
;
#else
return
SWITCH_STATUS_FALSE
;
#endif
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论