Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
90801835
提交
90801835
authored
2月 17, 2015
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7508: reduce vpx memory footprint
上级
0f964b80
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
54 行增加
和
47 行删除
+54
-47
mod_vpx.c
src/mod/codecs/mod_vpx/mod_vpx.c
+54
-47
没有找到文件。
src/mod/codecs/mod_vpx/mod_vpx.c
浏览文件 @
90801835
...
...
@@ -85,7 +85,39 @@ struct vpx_context {
typedef
struct
vpx_context
vpx_context_t
;
static
switch_status_t
init_codec
(
switch_codec_t
*
codec
)
static
switch_status_t
init_decoder
(
switch_codec_t
*
codec
)
{
vpx_context_t
*
context
=
(
vpx_context_t
*
)
codec
->
private_info
;
if
(
context
->
flags
&
SWITCH_CODEC_FLAG_DECODE
&&
!
context
->
decoder_init
)
{
vp8_postproc_cfg_t
ppcfg
;
//if (context->decoder_init) {
// vpx_codec_destroy(&context->decoder);
// context->decoder_init = 0;
//}
if
(
vpx_codec_dec_init
(
&
context
->
decoder
,
decoder_interface
,
NULL
,
VPX_CODEC_USE_POSTPROC
)
!=
VPX_CODEC_OK
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Codec init error: [%d:%s]
\n
"
,
context
->
encoder
.
err
,
context
->
encoder
.
err_detail
);
return
SWITCH_STATUS_FALSE
;
}
context
->
decoder_init
=
1
;
// the types of post processing to be done, should be combination of "vp8_postproc_level"
ppcfg
.
post_proc_flag
=
VP8_DEMACROBLOCK
|
VP8_DEBLOCK
;
// the strength of deblocking, valid range [0, 16]
ppcfg
.
deblocking_level
=
3
;
// Set deblocking settings
vpx_codec_control
(
&
context
->
decoder
,
VP8_SET_POSTPROC
,
&
ppcfg
);
switch_buffer_create_dynamic
(
&
context
->
vpx_packet_buffer
,
512
,
512
,
1024000
);
}
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
init_encoder
(
switch_codec_t
*
codec
)
{
vpx_context_t
*
context
=
(
vpx_context_t
*
)
codec
->
private_info
;
vpx_codec_enc_cfg_t
*
config
=
&
context
->
config
;
...
...
@@ -215,31 +247,6 @@ static switch_status_t init_codec(switch_codec_t *codec)
//vpx_codec_control(&context->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT, 0);
}
if
(
context
->
flags
&
SWITCH_CODEC_FLAG_DECODE
&&
!
context
->
decoder_init
)
{
vp8_postproc_cfg_t
ppcfg
;
//if (context->decoder_init) {
// vpx_codec_destroy(&context->decoder);
// context->decoder_init = 0;
//}
if
(
vpx_codec_dec_init
(
&
context
->
decoder
,
decoder_interface
,
NULL
,
VPX_CODEC_USE_POSTPROC
)
!=
VPX_CODEC_OK
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Codec init error: [%d:%s]
\n
"
,
context
->
encoder
.
err
,
context
->
encoder
.
err_detail
);
return
SWITCH_STATUS_FALSE
;
}
context
->
decoder_init
=
1
;
// the types of post processing to be done, should be combination of "vp8_postproc_level"
ppcfg
.
post_proc_flag
=
VP8_DEMACROBLOCK
|
VP8_DEBLOCK
;
// the strength of deblocking, valid range [0, 16]
ppcfg
.
deblocking_level
=
3
;
// Set deblocking settings
vpx_codec_control
(
&
context
->
decoder
,
VP8_SET_POSTPROC
,
&
ppcfg
);
switch_buffer_create_dynamic
(
&
context
->
vpx_packet_buffer
,
512
,
512
,
1024000
);
}
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -274,9 +281,8 @@ static switch_status_t switch_vpx_init(switch_codec_t *codec, switch_codec_flag_
}
/* start with 4k res cos otherwise you can't reset without re-init the whole codec */
context
->
codec_settings
.
video
.
width
=
3840
;
context
->
codec_settings
.
video
.
height
=
2160
;
init_codec
(
codec
);
context
->
codec_settings
.
video
.
width
=
320
;
context
->
codec_settings
.
video
.
height
=
240
;
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -377,6 +383,19 @@ static switch_status_t consume_partition(vpx_context_t *context, switch_frame_t
}
}
static
void
reset_codec_encoder
(
switch_codec_t
*
codec
)
{
vpx_context_t
*
context
=
(
vpx_context_t
*
)
codec
->
private_info
;
if
(
context
->
encoder_init
)
{
vpx_codec_destroy
(
&
context
->
encoder
);
}
context
->
framesum
=
0
;
context
->
framecount
=
0
;
context
->
encoder_init
=
0
;
init_encoder
(
codec
);
}
static
switch_status_t
switch_vpx_encode
(
switch_codec_t
*
codec
,
switch_frame_t
*
frame
)
{
vpx_context_t
*
context
=
(
vpx_context_t
*
)
codec
->
private_info
;
...
...
@@ -390,17 +409,10 @@ static switch_status_t switch_vpx_encode(switch_codec_t *codec, switch_frame_t *
}
if
(
context
->
need_encoder_reset
!=
0
)
{
vpx_codec_destroy
(
&
context
->
encoder
);
context
->
framesum
=
0
;
context
->
framecount
=
0
;
context
->
encoder_init
=
0
;
init_codec
(
codec
);
reset_codec_encoder
(
codec
);
context
->
need_encoder_reset
=
0
;
}
//d_w and d_h are messed up
//printf("WTF %d %d\n", frame->img->d_w, frame->img->d_h);
if
(
frame
->
img
->
d_h
>
1
)
{
width
=
frame
->
img
->
d_w
;
height
=
frame
->
img
->
d_h
;
...
...
@@ -409,26 +421,23 @@ static switch_status_t switch_vpx_encode(switch_codec_t *codec, switch_frame_t *
height
=
frame
->
img
->
h
;
}
//switch_assert(width > 0 && (width % 4 == 0));
//switch_assert(height > 0 && (height % 4 == 0));
if
(
context
->
config
.
g_w
!=
width
||
context
->
config
.
g_h
!=
height
)
{
context
->
codec_settings
.
video
.
width
=
width
;
context
->
codec_settings
.
video
.
height
=
height
;
init_codec
(
codec
);
reset_codec_encoder
(
codec
);
frame
->
flags
|=
SFF_PICTURE_RESET
;
context
->
need_key_frame
=
1
;
}
if
(
!
context
->
encoder_init
)
{
init_
codec
(
codec
);
init_
encoder
(
codec
);
}
if
(
context
->
change_bandwidth
)
{
context
->
codec_settings
.
video
.
bandwidth
=
context
->
change_bandwidth
;
context
->
change_bandwidth
=
0
;
init_
codec
(
codec
);
init_
encoder
(
codec
);
}
if
(
context
->
need_key_frame
!=
0
)
{
...
...
@@ -546,17 +555,15 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
int
is_keyframe
=
((
*
(
unsigned
char
*
)
frame
->
data
)
&
0x01
)
?
0
:
1
;
if
(
context
->
need_decoder_reset
!=
0
)
{
vpx_codec_destroy
(
&
context
->
decoder
);
context
->
decoder_init
=
0
;
init_
codec
(
codec
);
init_
decoder
(
codec
);
context
->
need_decoder_reset
=
0
;
}
if
(
!
context
->
decoder_init
)
{
init_
codec
(
codec
);
init_
decoder
(
codec
);
}
if
(
!
context
->
decoder_init
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论