Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
87766a23
提交
87766a23
authored
3月 12, 2015
作者:
Seven Du
提交者:
Michael Jerris
5月 28, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7508: add vp9 key frame detection and some packet sanity check
上级
4a6e9fd4
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
8 行删除
+24
-8
mod_vpx.c
src/mod/codecs/mod_vpx/mod_vpx.c
+24
-8
没有找到文件。
src/mod/codecs/mod_vpx/mod_vpx.c
浏览文件 @
87766a23
...
@@ -41,6 +41,10 @@
...
@@ -41,6 +41,10 @@
#define SLICE_SIZE SWITCH_DEFAULT_VIDEO_SIZE
#define SLICE_SIZE SWITCH_DEFAULT_VIDEO_SIZE
#define KEY_FRAME_MIN_FREQ 1000000
#define KEY_FRAME_MIN_FREQ 1000000
#define IS_VP8_KEY_FRAME(byte) (((byte) & 0x01) ^ 0x01)
#define IS_VP9_KEY_FRAME(byte) ((byte) & 0x01)
#define IS_VP9_START_PKT(byte) ((byte) & 0x02)
SWITCH_MODULE_LOAD_FUNCTION
(
mod_vpx_load
);
SWITCH_MODULE_LOAD_FUNCTION
(
mod_vpx_load
);
SWITCH_MODULE_DEFINITION
(
mod_vpx
,
mod_vpx_load
,
NULL
,
NULL
);
SWITCH_MODULE_DEFINITION
(
mod_vpx
,
mod_vpx_load
,
NULL
,
NULL
);
...
@@ -329,13 +333,10 @@ static switch_status_t switch_vpx_init(switch_codec_t *codec, switch_codec_flag_
...
@@ -329,13 +333,10 @@ static switch_status_t switch_vpx_init(switch_codec_t *codec, switch_codec_flag_
context
->
codec_settings
=
*
codec_settings
;
context
->
codec_settings
=
*
codec_settings
;
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"%s
\n
"
,
codec
->
implementation
->
iananame
);
if
(
!
strcmp
(
codec
->
implementation
->
iananame
,
"VP9"
))
{
if
(
!
strcmp
(
codec
->
implementation
->
iananame
,
"VP9"
))
{
context
->
is_vp9
=
1
;
context
->
is_vp9
=
1
;
context
->
encoder_interface
=
vpx_codec_vp9_cx
();
context
->
encoder_interface
=
vpx_codec_vp9_cx
();
context
->
decoder_interface
=
vpx_codec_vp9_dx
();
context
->
decoder_interface
=
vpx_codec_vp9_dx
();
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"is vp9
\n
"
);
}
else
{
}
else
{
context
->
encoder_interface
=
vpx_codec_vp8_cx
();
context
->
encoder_interface
=
vpx_codec_vp8_cx
();
context
->
decoder_interface
=
vpx_codec_vp8_dx
();
context
->
decoder_interface
=
vpx_codec_vp8_dx
();
...
@@ -687,7 +688,7 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
...
@@ -687,7 +688,7 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
}
}
if
(
S
&&
(
PID
==
0
))
{
if
(
S
&&
(
PID
==
0
))
{
int
is_keyframe
=
((
*
data
)
&
0x01
)
?
0
:
1
;
int
is_keyframe
=
IS_VP8_KEY_FRAME
(
*
data
)
;
if
(
is_keyframe
&&
context
->
got_key_frame
<=
0
)
{
if
(
is_keyframe
&&
context
->
got_key_frame
<=
0
)
{
context
->
got_key_frame
=
1
;
context
->
got_key_frame
=
1
;
...
@@ -709,8 +710,8 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
...
@@ -709,8 +710,8 @@ static switch_status_t buffer_vp8_packets(vpx_context_t *context, switch_frame_t
static
switch_status_t
buffer_vp9_packets
(
vpx_context_t
*
context
,
switch_frame_t
*
frame
)
static
switch_status_t
buffer_vp9_packets
(
vpx_context_t
*
context
,
switch_frame_t
*
frame
)
{
{
uint8_t
*
data
=
frame
->
data
;
uint8_t
*
data
=
(
uint8_t
*
)
frame
->
data
;
uint8_t
*
vp9
;
uint8_t
*
vp9
=
(
uint8_t
*
)
frame
->
data
;
int
len
=
0
;
int
len
=
0
;
if
(
!
frame
)
{
if
(
!
frame
)
{
...
@@ -718,6 +719,17 @@ static switch_status_t buffer_vp9_packets(vpx_context_t *context, switch_frame_t
...
@@ -718,6 +719,17 @@ static switch_status_t buffer_vp9_packets(vpx_context_t *context, switch_frame_t
return
SWITCH_STATUS_RESTART
;
return
SWITCH_STATUS_RESTART
;
}
}
if
(
switch_buffer_inuse
(
context
->
vpx_packet_buffer
))
{
// middle packet
if
(
IS_VP9_START_PKT
(
*
vp9
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"got invalid vp9 packet, packet loss? resetting buffer
\n
"
);
switch_buffer_zero
(
context
->
vpx_packet_buffer
);
}
}
else
{
// start packet
if
(
!
IS_VP9_START_PKT
(
*
vp9
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"got invalid vp9 packet, packet loss? waiting for a start packet
\n
"
);
}
}
vp9
=
data
+
1
;
vp9
=
data
+
1
;
len
=
frame
->
datalen
-
(
vp9
-
data
);
len
=
frame
->
datalen
-
(
vp9
-
data
);
...
@@ -734,9 +746,13 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
...
@@ -734,9 +746,13 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
switch_size_t
len
;
switch_size_t
len
;
vpx_codec_ctx_t
*
decoder
=
NULL
;
vpx_codec_ctx_t
*
decoder
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
int
is_keyframe
=
((
*
(
unsigned
char
*
)
frame
->
data
)
&
0x01
)
?
0
:
1
;
int
is_keyframe
=
0
;
if
(
context
->
is_vp9
)
is_keyframe
=
1
;
// don't know how to get it yet
if
(
context
->
is_vp9
)
{
is_keyframe
=
IS_VP9_KEY_FRAME
(
*
(
unsigned
char
*
)
frame
->
data
);
}
else
{
// vp8
is_keyframe
=
IS_VP8_KEY_FRAME
(
*
(
unsigned
char
*
)
frame
->
data
);
}
if
(
context
->
need_decoder_reset
!=
0
)
{
if
(
context
->
need_decoder_reset
!=
0
)
{
vpx_codec_destroy
(
&
context
->
decoder
);
vpx_codec_destroy
(
&
context
->
decoder
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论